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
5
5
6
6
language : generic
7
7
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
14
10
15
11
script : ./test-build.sh $NODE_VERSION $VARIANT
16
12
Original file line number Diff line number Diff line change @@ -249,3 +249,54 @@ function sort_versions() {
249
249
250
250
echo " ${sorted[@]} "
251
251
}
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}"
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 @@ -3,12 +3,8 @@ sudo: false
3
3
4
4
language: generic
5
5
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
12
8
13
9
script: ./test-build.sh $NODE_VERSION $VARIANT
14
10
You can’t perform that action at this time.
0 commit comments