File tree Expand file tree Collapse file tree 4 files changed +56
-29
lines changed Expand file tree Collapse file tree 4 files changed +56
-29
lines changed Original file line number Diff line number Diff line change @@ -5,12 +5,8 @@ sudo: false
55
66language : generic
77
8- services :
9- - docker
10- addons :
11- apt :
12- packages :
13- - docker-ce
8+ before_install :
9+ - source functions.sh && images_updated $TRAVIS_COMMIT_RANGE || tests_updated $TRAVIS_COMMIT_RANGE || travis_terminate
1410
1511script : ./test-build.sh $NODE_VERSION $VARIANT
1612
Original file line number Diff line number Diff line change @@ -249,3 +249,54 @@ function sort_versions() {
249249
250250 echo " ${sorted[@]} "
251251}
252+
253+ function commit_range() {
254+ local commit_id_end=${1}
255+ shift
256+ local commit_id_start=${1}
257+
258+ if [ -z " ${commit_id_start} " ]; then
259+ if [ -z " ${commit_id_end} " ]; then
260+ echo " HEAD~1..HEAD"
261+ elif [[ " ${commit_id_end} " =~ .. ]]; then
262+ echo " ${commit_id_end} "
263+ else
264+ echo " ${commit_id_end} ~1..${commit_id_end} "
265+ fi
266+ else
267+ echo " ${commit_id_end} ..${commit_id_start} "
268+ fi
269+ }
270+
271+ function images_updated() {
272+ local commit_range
273+ local versions
274+ local images_changed
275+
276+ commit_range=" $( commit_range " $@ " ) "
277+
278+ IFS=' ' read -ra versions <<< " $(
279+ IFS=','
280+ get_versions
281+ )"
282+ images_changed=$( git diff --name-only " ${commit_range} " " ${versions[@]} " )
283+
284+ if [ -z " ${images_changed} " ]; then
285+ return 1
286+ fi
287+ return 0
288+ }
289+
290+ function tests_updated() {
291+ local commit_range
292+ local test_changed
293+
294+ commit_range=" $( commit_range " $@ " ) "
295+
296+ test_changed=$( git diff --name-only " ${commit_range} " test* )
297+
298+ if [ -z " ${test_changed} " ]; then
299+ return 1
300+ fi
301+ return 0
302+ }
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 @@ -3,12 +3,8 @@ sudo: false
33
44language: generic
55
6- services:
7- - docker
8- addons:
9- apt:
10- packages:
11- - docker-ce
6+ before_install:
7+ - source functions.sh && images_updated $TRAVIS_COMMIT_RANGE || tests_updated $TRAVIS_COMMIT_RANGE || travis_terminate
128
139script: ./test-build.sh $NODE_VERSION $VARIANT
1410
You can’t perform that action at this time.
0 commit comments