Skip to content

Commit 7447608

Browse files
committed
Implement [skip ci] for Jenkins
GitHub Actions already respects this ([link](https://github.blog/changelog/2021-02-08-github-actions-skip-pull-request-and-push-workflows-with-skip-ci/)), this implements it for Jenkins as well. When `[skip ci]` is in the commit message of the head commit, the only things that will run are the sanity check + lint, so CI should be much quicker if someone manually sets this. This is useful for PRs that need to get landed quickly and the outcome is pretty well known, such as reverts.
1 parent cdca84a commit 7447608

File tree

2 files changed

+70
-30
lines changed

2 files changed

+70
-30
lines changed

Jenkinsfile

Lines changed: 38 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,10 @@ stage('Sanity Check') {
158158
./tests/scripts/git_change_docs.sh
159159
'''
160160
)
161+
skip_ci = sh (returnStatus: true, script: '''
162+
./tests/scripts/git_skip_ci.sh
163+
'''
164+
)
161165
sh "${docker_run} ${ci_lint} ./tests/scripts/task_lint.sh"
162166
}
163167
}
@@ -206,20 +210,22 @@ def unpack_lib(name, libs) {
206210

207211
stage('Build') {
208212
parallel 'BUILD: GPU': {
209-
node('GPUBUILD') {
210-
ws(per_exec_ws('tvm/build-gpu')) {
211-
init_git()
212-
sh "${docker_run} ${ci_gpu} ./tests/scripts/task_config_build_gpu.sh"
213-
make(ci_gpu, 'build', '-j2')
214-
pack_lib('gpu', tvm_multilib)
215-
// compiler test
216-
sh "${docker_run} ${ci_gpu} ./tests/scripts/task_config_build_gpu_other.sh"
217-
make(ci_gpu, 'build2', '-j2')
213+
if (skip_ci != 1) {
214+
node('GPUBUILD') {
215+
ws(per_exec_ws('tvm/build-gpu')) {
216+
init_git()
217+
sh "${docker_run} ${ci_gpu} ./tests/scripts/task_config_build_gpu.sh"
218+
make(ci_gpu, 'build', '-j2')
219+
pack_lib('gpu', tvm_multilib)
220+
// compiler test
221+
sh "${docker_run} ${ci_gpu} ./tests/scripts/task_config_build_gpu_other.sh"
222+
make(ci_gpu, 'build2', '-j2')
223+
}
218224
}
219225
}
220226
},
221227
'BUILD: CPU': {
222-
if (is_docs_only_build != 1) {
228+
if (skip_ci != 1 && is_docs_only_build != 1) {
223229
node('CPU') {
224230
ws(per_exec_ws('tvm/build-cpu')) {
225231
init_git()
@@ -243,7 +249,7 @@ stage('Build') {
243249
}
244250
},
245251
'BUILD: WASM': {
246-
if (is_docs_only_build != 1) {
252+
if (skip_ci != 1 && is_docs_only_build != 1) {
247253
node('CPU') {
248254
ws(per_exec_ws('tvm/build-wasm')) {
249255
init_git()
@@ -260,7 +266,7 @@ stage('Build') {
260266
}
261267
},
262268
'BUILD : i386': {
263-
if ( is_docs_only_build != 1) {
269+
if (skip_ci != 1 && is_docs_only_build != 1) {
264270
node('CPU') {
265271
ws(per_exec_ws('tvm/build-i386')) {
266272
init_git()
@@ -274,7 +280,7 @@ stage('Build') {
274280
}
275281
},
276282
'BUILD : arm': {
277-
if (is_docs_only_build != 1) {
283+
if (skip_ci != 1 && is_docs_only_build != 1) {
278284
node('ARM') {
279285
ws(per_exec_ws('tvm/build-arm')) {
280286
init_git()
@@ -288,7 +294,7 @@ stage('Build') {
288294
}
289295
},
290296
'BUILD: QEMU': {
291-
if (is_docs_only_build != 1) {
297+
if (skip_ci != 1 && is_docs_only_build != 1) {
292298
node('CPU') {
293299
ws(per_exec_ws('tvm/build-qemu')) {
294300
init_git()
@@ -309,7 +315,7 @@ stage('Build') {
309315

310316
stage('Unit Test') {
311317
parallel 'python3: GPU': {
312-
if (is_docs_only_build != 1) {
318+
if (skip_ci != 1 && is_docs_only_build != 1) {
313319
node('TensorCore') {
314320
ws(per_exec_ws('tvm/ut-python-gpu')) {
315321
init_git()
@@ -328,7 +334,7 @@ stage('Unit Test') {
328334
}
329335
},
330336
'python3: CPU': {
331-
if (is_docs_only_build != 1) {
337+
if (skip_ci != 1 && is_docs_only_build != 1) {
332338
node('CPU') {
333339
ws(per_exec_ws("tvm/ut-python-cpu")) {
334340
init_git()
@@ -345,7 +351,7 @@ stage('Unit Test') {
345351
}
346352
},
347353
'python3: i386': {
348-
if (is_docs_only_build != 1) {
354+
if (skip_ci != 1 && is_docs_only_build != 1) {
349355
node('CPU') {
350356
ws(per_exec_ws('tvm/ut-python-i386')) {
351357
init_git()
@@ -364,7 +370,7 @@ stage('Unit Test') {
364370
}
365371
},
366372
'python3: arm': {
367-
if (is_docs_only_build != 1) {
373+
if (skip_ci != 1 && is_docs_only_build != 1) {
368374
node('ARM') {
369375
ws(per_exec_ws('tvm/ut-python-arm')) {
370376
init_git()
@@ -383,7 +389,7 @@ stage('Unit Test') {
383389
}
384390
},
385391
'java: GPU': {
386-
if (is_docs_only_build != 1 ) {
392+
if (skip_ci != 1 && is_docs_only_build != 1 ) {
387393
node('GPU') {
388394
ws(per_exec_ws('tvm/ut-java')) {
389395
init_git()
@@ -402,7 +408,7 @@ stage('Unit Test') {
402408

403409
stage('Integration Test') {
404410
parallel 'topi: GPU': {
405-
if (is_docs_only_build != 1) {
411+
if (skip_ci != 1 && is_docs_only_build != 1) {
406412
node('GPU') {
407413
ws(per_exec_ws('tvm/topi-python-gpu')) {
408414
init_git()
@@ -419,7 +425,7 @@ stage('Integration Test') {
419425
}
420426
},
421427
'frontend: GPU': {
422-
if (is_docs_only_build != 1) {
428+
if (skip_ci != 1 && is_docs_only_build != 1) {
423429
node('GPU') {
424430
ws(per_exec_ws('tvm/frontend-python-gpu')) {
425431
init_git()
@@ -436,7 +442,7 @@ stage('Integration Test') {
436442
}
437443
},
438444
'frontend: CPU': {
439-
if (is_docs_only_build != 1) {
445+
if (skip_ci != 1 && is_docs_only_build != 1) {
440446
node('CPU') {
441447
ws(per_exec_ws('tvm/frontend-python-cpu')) {
442448
init_git()
@@ -453,15 +459,17 @@ stage('Integration Test') {
453459
}
454460
},
455461
'docs: GPU': {
456-
node('TensorCore') {
457-
ws(per_exec_ws('tvm/docs-python-gpu')) {
458-
init_git()
459-
unpack_lib('gpu', tvm_multilib)
460-
timeout(time: max_time, unit: 'MINUTES') {
461-
sh "${docker_run} ${ci_gpu} ./tests/scripts/task_ci_setup.sh"
462-
sh "${docker_run} ${ci_gpu} ./tests/scripts/task_python_docs.sh"
462+
if (skip_ci != 1) {
463+
node('TensorCore') {
464+
ws(per_exec_ws('tvm/docs-python-gpu')) {
465+
init_git()
466+
unpack_lib('gpu', tvm_multilib)
467+
timeout(time: max_time, unit: 'MINUTES') {
468+
sh "${docker_run} ${ci_gpu} ./tests/scripts/task_ci_setup.sh"
469+
sh "${docker_run} ${ci_gpu} ./tests/scripts/task_python_docs.sh"
470+
}
471+
pack_lib('mydocs', 'docs.tgz')
463472
}
464-
pack_lib('mydocs', 'docs.tgz')
465473
}
466474
}
467475
}

tests/scripts/git_skip_ci.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/usr/bin/env bash
2+
3+
# Licensed to the Apache Software Foundation (ASF) under one
4+
# or more contributor license agreements. See the NOTICE file
5+
# distributed with this work for additional information
6+
# regarding copyright ownership. The ASF licenses this file
7+
# to you under the Apache License, Version 2.0 (the
8+
# "License"); you may not use this file except in compliance
9+
# with the License. You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing,
14+
# software distributed under the License is distributed on an
15+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
# KIND, either express or implied. See the License for the
17+
# specific language governing permissions and limitations
18+
# under the License.
19+
20+
set -eux
21+
22+
# This implements the skip commands found here:
23+
# https://github.blog/changelog/2021-02-08-github-actions-skip-pull-request-and-push-workflows-with-skip-ci/
24+
25+
# The script will return 1 if any of these are found in the HEAD commit message
26+
# headline
27+
28+
if git log --format='%s' HEAD~1..HEAD | grep -q -E '([skip ci])|([ci skip])|([no ci])|([skip actions])|([actions skip])'; then
29+
exit 1
30+
else
31+
exit 0
32+
fi

0 commit comments

Comments
 (0)