File tree Expand file tree Collapse file tree 4 files changed +58
-17
lines changed Expand file tree Collapse file tree 4 files changed +58
-17
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,9 @@ addons:
1212 packages :
1313 - docker-ce
1414
15+ before_install :
16+ - source functions.sh && images_updated $TRAVIS_COMMIT_RANGE || tests_updated $TRAVIS_COMMIT_RANGE || travis_terminate
17+
1518script : ./test-build.sh $NODE_VERSION $VARIANT
1619
1720stages :
Original file line number Diff line number Diff line change @@ -239,3 +239,54 @@ function sort_versions() {
239239
240240 echo " ${sorted[@]} "
241241}
242+
243+ function commit_range() {
244+ local commit_id_end=${1}
245+ shift
246+ local commit_id_start=${1}
247+
248+ if [ -z " ${commit_id_start} " ]; then
249+ if [ -z " ${commit_id_end} " ]; then
250+ echo " HEAD~1..HEAD"
251+ elif [[ " ${commit_id_end} " =~ .. ]]; then
252+ echo " ${commit_id_end} "
253+ else
254+ echo " ${commit_id_end} ~1..${commit_id_end} "
255+ fi
256+ else
257+ echo " ${commit_id_end} ..${commit_id_start} "
258+ fi
259+ }
260+
261+ function images_updated() {
262+ local commit_range
263+ local versions
264+ local images_changed
265+
266+ commit_range=" $( commit_range " $@ " ) "
267+
268+ IFS=' ' read -ra versions <<< " $(
269+ IFS=','
270+ get_versions
271+ )"
272+ images_changed=$( git diff --name-only " ${commit_range} " " ${versions[@]} " )
273+
274+ if [ -z " ${images_changed} " ]; then
275+ return 1
276+ fi
277+ return 0
278+ }
279+
280+ function tests_updated() {
281+ local commit_range
282+ local test_changed
283+
284+ commit_range=" $( commit_range " $@ " ) "
285+
286+ test_changed=$( git diff --name-only " ${commit_range} " test* )
287+
288+ if [ -z " ${test_changed} " ]; then
289+ return 1
290+ fi
291+ return 0
292+ }
Original file line number Diff line number Diff line change @@ -31,22 +31,6 @@ UPSTREAM_SLUG="docker-library/${REPO_NAME}"
3131DOCKER_SLUG=" nodejs/docker-node"
3232gitpath=" ../${REPO_NAME} "
3333
34- function updated() {
35- local versions
36- local images_changed
37-
38- IFS=' ' read -ra versions <<< " $(
39- IFS=','
40- get_versions
41- )"
42- images_changed=$( git diff --name-only " ${COMMIT_ID} " .." ${COMMIT_ID} " ~1 " ${versions[@]} " )
43-
44- if [ -z " ${images_changed} " ]; then
45- return 1
46- fi
47- return 0
48- }
49-
5034function auth_header() {
5135 echo " Authorization: token ${GITHUB_API_TOKEN} "
5236}
@@ -104,7 +88,7 @@ function comment_payload() {
10488 }"
10589}
10690
107- if updated ; then
91+ if images_updated " ${COMMIT_ID} " ; then
10892
10993 permission_check
11094
Original file line number Diff line number Diff line change @@ -10,6 +10,9 @@ addons:
1010 packages:
1111 - docker-ce
1212
13+ before_install:
14+ - source functions.sh && images_updated $TRAVIS_COMMIT_RANGE || tests_updated $TRAVIS_COMMIT_RANGE || travis_terminate
15+
1316script: ./test-build.sh $NODE_VERSION $VARIANT
1417
1518stages:
You can’t perform that action at this time.
0 commit comments