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:
12
12
packages :
13
13
- docker-ce
14
14
15
+ before_install :
16
+ - source functions.sh && images_updated $TRAVIS_COMMIT_RANGE || tests_updated $TRAVIS_COMMIT_RANGE || travis_terminate
17
+
15
18
script : ./test-build.sh $NODE_VERSION $VARIANT
16
19
17
20
stages :
Original file line number Diff line number Diff line change @@ -239,3 +239,54 @@ function sort_versions() {
239
239
240
240
echo " ${sorted[@]} "
241
241
}
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}"
31
31
DOCKER_SLUG=" nodejs/docker-node"
32
32
gitpath=" ../${REPO_NAME} "
33
33
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
-
50
34
function auth_header() {
51
35
echo " Authorization: token ${GITHUB_API_TOKEN} "
52
36
}
@@ -104,7 +88,7 @@ function comment_payload() {
104
88
}"
105
89
}
106
90
107
- if updated ; then
91
+ if images_updated " ${COMMIT_ID} " ; then
108
92
109
93
permission_check
110
94
Original file line number Diff line number Diff line change @@ -10,6 +10,9 @@ addons:
10
10
packages:
11
11
- docker-ce
12
12
13
+ before_install:
14
+ - source functions.sh && images_updated $TRAVIS_COMMIT_RANGE || tests_updated $TRAVIS_COMMIT_RANGE || travis_terminate
15
+
13
16
script: ./test-build.sh $NODE_VERSION $VARIANT
14
17
15
18
stages:
You can’t perform that action at this time.
0 commit comments