Skip to content

Commit

Permalink
Implement [skip ci] for Jenkins
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
driazati committed Nov 23, 2021
1 parent 44fae01 commit 46b956c
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 30 deletions.
68 changes: 38 additions & 30 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,10 @@ stage('Sanity Check') {
./tests/scripts/git_change_docs.sh
'''
)
skip_ci = sh (returnStatus: true, script: '''
./tests/scripts/git_skip_ci.sh
'''
)
sh "${docker_run} ${ci_lint} ./tests/scripts/task_lint.sh"
}
}
Expand Down Expand Up @@ -206,20 +210,22 @@ def unpack_lib(name, libs) {

stage('Build') {
parallel 'BUILD: GPU': {
node('GPUBUILD') {
ws(per_exec_ws('tvm/build-gpu')) {
init_git()
sh "${docker_run} ${ci_gpu} ./tests/scripts/task_config_build_gpu.sh"
make(ci_gpu, 'build', '-j2')
pack_lib('gpu', tvm_multilib)
// compiler test
sh "${docker_run} ${ci_gpu} ./tests/scripts/task_config_build_gpu_other.sh"
make(ci_gpu, 'build2', '-j2')
if (skip_ci != 1) {
node('GPUBUILD') {
ws(per_exec_ws('tvm/build-gpu')) {
init_git()
sh "${docker_run} ${ci_gpu} ./tests/scripts/task_config_build_gpu.sh"
make(ci_gpu, 'build', '-j2')
pack_lib('gpu', tvm_multilib)
// compiler test
sh "${docker_run} ${ci_gpu} ./tests/scripts/task_config_build_gpu_other.sh"
make(ci_gpu, 'build2', '-j2')
}
}
}
},
'BUILD: CPU': {
if (is_docs_only_build != 1) {
if (skip_ci != 1 && is_docs_only_build != 1) {
node('CPU') {
ws(per_exec_ws('tvm/build-cpu')) {
init_git()
Expand All @@ -243,7 +249,7 @@ stage('Build') {
}
},
'BUILD: WASM': {
if (is_docs_only_build != 1) {
if (skip_ci != 1 && is_docs_only_build != 1) {
node('CPU') {
ws(per_exec_ws('tvm/build-wasm')) {
init_git()
Expand All @@ -260,7 +266,7 @@ stage('Build') {
}
},
'BUILD : i386': {
if ( is_docs_only_build != 1) {
if (skip_ci != 1 && is_docs_only_build != 1) {
node('CPU') {
ws(per_exec_ws('tvm/build-i386')) {
init_git()
Expand All @@ -274,7 +280,7 @@ stage('Build') {
}
},
'BUILD : arm': {
if (is_docs_only_build != 1) {
if (skip_ci != 1 && is_docs_only_build != 1) {
node('ARM') {
ws(per_exec_ws('tvm/build-arm')) {
init_git()
Expand All @@ -288,7 +294,7 @@ stage('Build') {
}
},
'BUILD: QEMU': {
if (is_docs_only_build != 1) {
if (skip_ci != 1 && is_docs_only_build != 1) {
node('CPU') {
ws(per_exec_ws('tvm/build-qemu')) {
init_git()
Expand All @@ -309,7 +315,7 @@ stage('Build') {

stage('Unit Test') {
parallel 'python3: GPU': {
if (is_docs_only_build != 1) {
if (skip_ci != 1 && is_docs_only_build != 1) {
node('TensorCore') {
ws(per_exec_ws('tvm/ut-python-gpu')) {
init_git()
Expand All @@ -328,7 +334,7 @@ stage('Unit Test') {
}
},
'python3: CPU': {
if (is_docs_only_build != 1) {
if (skip_ci != 1 && is_docs_only_build != 1) {
node('CPU') {
ws(per_exec_ws("tvm/ut-python-cpu")) {
init_git()
Expand All @@ -345,7 +351,7 @@ stage('Unit Test') {
}
},
'python3: i386': {
if (is_docs_only_build != 1) {
if (skip_ci != 1 && is_docs_only_build != 1) {
node('CPU') {
ws(per_exec_ws('tvm/ut-python-i386')) {
init_git()
Expand All @@ -364,7 +370,7 @@ stage('Unit Test') {
}
},
'python3: arm': {
if (is_docs_only_build != 1) {
if (skip_ci != 1 && is_docs_only_build != 1) {
node('ARM') {
ws(per_exec_ws('tvm/ut-python-arm')) {
init_git()
Expand All @@ -383,7 +389,7 @@ stage('Unit Test') {
}
},
'java: GPU': {
if (is_docs_only_build != 1 ) {
if (skip_ci != 1 && is_docs_only_build != 1 ) {
node('GPU') {
ws(per_exec_ws('tvm/ut-java')) {
init_git()
Expand All @@ -402,7 +408,7 @@ stage('Unit Test') {

stage('Integration Test') {
parallel 'topi: GPU': {
if (is_docs_only_build != 1) {
if (skip_ci != 1 && is_docs_only_build != 1) {
node('GPU') {
ws(per_exec_ws('tvm/topi-python-gpu')) {
init_git()
Expand All @@ -419,7 +425,7 @@ stage('Integration Test') {
}
},
'frontend: GPU': {
if (is_docs_only_build != 1) {
if (skip_ci != 1 && is_docs_only_build != 1) {
node('GPU') {
ws(per_exec_ws('tvm/frontend-python-gpu')) {
init_git()
Expand All @@ -436,7 +442,7 @@ stage('Integration Test') {
}
},
'frontend: CPU': {
if (is_docs_only_build != 1) {
if (skip_ci != 1 && is_docs_only_build != 1) {
node('CPU') {
ws(per_exec_ws('tvm/frontend-python-cpu')) {
init_git()
Expand All @@ -453,15 +459,17 @@ stage('Integration Test') {
}
},
'docs: GPU': {
node('TensorCore') {
ws(per_exec_ws('tvm/docs-python-gpu')) {
init_git()
unpack_lib('gpu', tvm_multilib)
timeout(time: max_time, unit: 'MINUTES') {
sh "${docker_run} ${ci_gpu} ./tests/scripts/task_ci_setup.sh"
sh "${docker_run} ${ci_gpu} ./tests/scripts/task_python_docs.sh"
if (skip_ci != 1) {
node('TensorCore') {
ws(per_exec_ws('tvm/docs-python-gpu')) {
init_git()
unpack_lib('gpu', tvm_multilib)
timeout(time: max_time, unit: 'MINUTES') {
sh "${docker_run} ${ci_gpu} ./tests/scripts/task_ci_setup.sh"
sh "${docker_run} ${ci_gpu} ./tests/scripts/task_python_docs.sh"
}
pack_lib('mydocs', 'docs.tgz')
}
pack_lib('mydocs', 'docs.tgz')
}
}
}
Expand Down
40 changes: 40 additions & 0 deletions tests/scripts/git_skip_ci.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/usr/bin/env bash

# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

set -eux

# This implements the skip commands found here:
# https://github.blog/changelog/2021-02-08-github-actions-skip-pull-request-and-push-workflows-with-skip-ci/

# The script will return 1 if any of these are found in the HEAD commit message
# headline

if git log --format='%s' HEAD~1..HEAD | grep --quiet \
--regexp='\[skip ci\]' \
--regexp='\[ci skip\]' \
--regexp='\[no ci\]' \
--regexp='\[skip actions\]' \
--regexp='\[actions skip\]'; then
# last commit message subject matched one of the tags, exit with 1 to
# tell Jenkins to skip subsequent jobs
exit 1
else
# no match in message, don't skip anything
exit 0
fi

0 comments on commit 46b956c

Please sign in to comment.