4545// 'python3 jenkins/generate.py'
4646// Note: This timestamp is here to ensure that updates to the Jenkinsfile are
4747// always rebased on main before merging:
48- // Generated at 2022-05-20T18:06:10.772162
48+ // Generated at 2022-05-20T13:19:17.945668
4949
5050import org.jenkinsci.plugins.pipeline.modeldefinition.Utils
5151// NOTE: these lines are scanned by docker/dev_common.sh. Please update the regex as needed. -->
@@ -86,6 +86,20 @@ docker_build = 'docker/build.sh'
8686max_time = 180
8787rebuild_docker_images = false
8888
89+ // skips builds from branch indexing; sourced from https://www.jvt.me/posts/2020/02/23/jenkins-multibranch-skip-branch-index/
90+ // execute this before anything else, including requesting any time on an agent
91+ if (currentBuild. getBuildCauses(). toString(). contains(' BranchIndexingCause' )) {
92+ print " INFO: Build skipped due to trigger being Branch Indexing"
93+ currentBuild. result = ' ABORTED' // optional, gives a better hint to the user that it's been skipped, rather than the default which shows it's successful
94+ return
95+ }
96+
97+ // Filenames for stashing between build and test steps
98+ s3_prefix = " tvm-jenkins-artifacts-prod/tvm/${ env.BRANCH_NAME} /${ env.BUILD_NUMBER} "
99+
100+ // General note: Jenkins has limits on the size of a method (or top level code)
101+ // that are pretty strict, so most usage of groovy methods in these templates
102+ // are purely to satisfy the JVM
89103def per_exec_ws (folder ) {
90104 return " workspace/exec_${ env.EXECUTOR_NUMBER} /" + folder
91105}
@@ -183,146 +197,52 @@ def should_skip_ci(pr_number) {
183197 return git_skip_ci_code == 0
184198}
185199
186- // skips builds from branch indexing; sourced from https://www.jvt.me/posts/2020/02/23/jenkins-multibranch-skip-branch-index/
187- // execute this before anything else, including requesting any time on an agent
188- if (currentBuild. getBuildCauses(). toString(). contains(' BranchIndexingCause' )) {
189- print " INFO: Build skipped due to trigger being Branch Indexing"
190- currentBuild. result = ' ABORTED' // optional, gives a better hint to the user that it's been skipped, rather than the default which shows it's successful
191- return
192- }
193-
194- cancel_previous_build()
195-
196- def lint () {
197- stage(' Lint' ) {
198- parallel(
199- ' Lint 1 of 2' : {
200+ def prepare () {
201+ stage(' Prepare' ) {
200202 node(' CPU-SMALL' ) {
201- ws(" workspace/exec_${ env.EXECUTOR_NUMBER} /tvm/lint " ) {
203+ ws(" workspace/exec_${ env.EXECUTOR_NUMBER} /tvm/prepare " ) {
202204 init_git()
203- timeout(time : max_time, unit : ' MINUTES' ) {
204- withEnv([
205- ' TVM_NUM_SHARDS=2' ,
206- ' TVM_SHARD_INDEX=0' ], {
207- ci_arm = params. ci_arm_param ?: ci_arm
208- ci_cpu = params. ci_cpu_param ?: ci_cpu
209- ci_gpu = params. ci_gpu_param ?: ci_gpu
210- ci_hexagon = params. ci_hexagon_param ?: ci_hexagon
211- ci_i386 = params. ci_i386_param ?: ci_i386
212- ci_lint = params. ci_lint_param ?: ci_lint
213- ci_qemu = params. ci_qemu_param ?: ci_qemu
214- ci_wasm = params. ci_wasm_param ?: ci_wasm
215-
216- sh (script : """
217- echo "Docker images being used in this build:"
218- echo " ci_arm = ${ ci_arm} "
219- echo " ci_cpu = ${ ci_cpu} "
220- echo " ci_gpu = ${ ci_gpu} "
221- echo " ci_hexagon = ${ ci_hexagon} "
222- echo " ci_i386 = ${ ci_i386} "
223- echo " ci_lint = ${ ci_lint} "
224- echo " ci_qemu = ${ ci_qemu} "
225- echo " ci_wasm = ${ ci_wasm} "
226- """ , label : ' Docker image names' )
227-
228- is_docs_only_build = sh (
229- returnStatus : true ,
230- script : ' ./tests/scripts/git_change_docs.sh' ,
231- label : ' Check for docs only changes' ,
232- )
233- skip_ci = should_skip_ci(env. CHANGE_ID )
234- skip_slow_tests = should_skip_slow_tests(env. CHANGE_ID )
235- rebuild_docker_images = sh (
236- returnStatus : true ,
237- script : ' ./tests/scripts/git_change_docker.sh' ,
238- label : ' Check for any docker changes' ,
239- )
240- if (skip_ci) {
241- // Don't rebuild when skipping CI
242- rebuild_docker_images = false
243- }
244- if (rebuild_docker_images) {
245- // Exit before linting so we can use the newly created Docker images
246- // to run the lint
247- return
248- }
249- sh (
250- script : " ${ docker_run} ${ ci_lint} ./tests/scripts/task_lint.sh" ,
251- label : ' Run lint' ,
252- )
253- })
254- }
255- }
256- }
257- },
258- ' Lint 2 of 2' : {
259- node(' CPU-SMALL' ) {
260- ws(" workspace/exec_${ env.EXECUTOR_NUMBER} /tvm/lint" ) {
261- init_git()
262- timeout(time : max_time, unit : ' MINUTES' ) {
263- withEnv([
264- ' TVM_NUM_SHARDS=2' ,
265- ' TVM_SHARD_INDEX=1' ], {
266- ci_arm = params. ci_arm_param ?: ci_arm
267- ci_cpu = params. ci_cpu_param ?: ci_cpu
268- ci_gpu = params. ci_gpu_param ?: ci_gpu
269- ci_hexagon = params. ci_hexagon_param ?: ci_hexagon
270- ci_i386 = params. ci_i386_param ?: ci_i386
271- ci_lint = params. ci_lint_param ?: ci_lint
272- ci_qemu = params. ci_qemu_param ?: ci_qemu
273- ci_wasm = params. ci_wasm_param ?: ci_wasm
274-
275- sh (script : """
276- echo "Docker images being used in this build:"
277- echo " ci_arm = ${ ci_arm} "
278- echo " ci_cpu = ${ ci_cpu} "
279- echo " ci_gpu = ${ ci_gpu} "
280- echo " ci_hexagon = ${ ci_hexagon} "
281- echo " ci_i386 = ${ ci_i386} "
282- echo " ci_lint = ${ ci_lint} "
283- echo " ci_qemu = ${ ci_qemu} "
284- echo " ci_wasm = ${ ci_wasm} "
285- """ , label : ' Docker image names' )
286-
287- is_docs_only_build = sh (
288- returnStatus : true ,
289- script : ' ./tests/scripts/git_change_docs.sh' ,
290- label : ' Check for docs only changes' ,
291- )
292- skip_ci = should_skip_ci(env. CHANGE_ID )
293- skip_slow_tests = should_skip_slow_tests(env. CHANGE_ID )
294- rebuild_docker_images = sh (
295- returnStatus : true ,
296- script : ' ./tests/scripts/git_change_docker.sh' ,
297- label : ' Check for any docker changes' ,
298- )
299- if (skip_ci) {
300- // Don't rebuild when skipping CI
301- rebuild_docker_images = false
302- }
303- if (rebuild_docker_images) {
304- // Exit before linting so we can use the newly created Docker images
305- // to run the lint
306- return
307- }
308- sh (
309- script : " ${ docker_run} ${ ci_lint} ./tests/scripts/task_lint.sh" ,
310- label : ' Run lint' ,
311- )
312- })
205+ ci_arm = params. ci_arm_param ?: ci_arm
206+ ci_cpu = params. ci_cpu_param ?: ci_cpu
207+ ci_gpu = params. ci_gpu_param ?: ci_gpu
208+ ci_hexagon = params. ci_hexagon_param ?: ci_hexagon
209+ ci_i386 = params. ci_i386_param ?: ci_i386
210+ ci_lint = params. ci_lint_param ?: ci_lint
211+ ci_qemu = params. ci_qemu_param ?: ci_qemu
212+ ci_wasm = params. ci_wasm_param ?: ci_wasm
213+
214+ sh (script : """
215+ echo "Docker images being used in this build:"
216+ echo " ci_arm = ${ ci_arm} "
217+ echo " ci_cpu = ${ ci_cpu} "
218+ echo " ci_gpu = ${ ci_gpu} "
219+ echo " ci_hexagon = ${ ci_hexagon} "
220+ echo " ci_i386 = ${ ci_i386} "
221+ echo " ci_lint = ${ ci_lint} "
222+ echo " ci_qemu = ${ ci_qemu} "
223+ echo " ci_wasm = ${ ci_wasm} "
224+ """ , label : ' Docker image names' )
225+
226+ is_docs_only_build = sh (
227+ returnStatus : true ,
228+ script : ' ./tests/scripts/git_change_docs.sh' ,
229+ label : ' Check for docs only changes' ,
230+ )
231+ skip_ci = should_skip_ci(env. CHANGE_ID )
232+ skip_slow_tests = should_skip_slow_tests(env. CHANGE_ID )
233+ rebuild_docker_images = sh (
234+ returnStatus : true ,
235+ script : ' ./tests/scripts/should_rebuild_docker.py' ,
236+ label : ' Check for any docker changes' ,
237+ )
238+ if (skip_ci) {
239+ // Don't rebuild when skipping CI
240+ rebuild_docker_images = false
313241 }
314242 }
315243 }
316- },
317- )
318- }
244+ }
319245}
320-
321- // [note: method size]
322- // This has to be extracted into a method due to JVM limitations on the size of
323- // a method (so the code can't all be inlined)
324- lint()
325-
326246def build_image (image_name ) {
327247 hash = sh(
328248 returnStdout : true ,
@@ -378,7 +298,7 @@ def build_image(image_name) {
378298 )
379299}
380300
381- if (rebuild_docker_images ) {
301+ def build_docker_images ( ) {
382302 stage(' Docker Image Build' ) {
383303 // TODO in a follow up PR: Find ecr tag and use in subsequent builds
384304 parallel ' ci-lint' : {
@@ -481,11 +401,46 @@ def make(docker_type, path, make_flag) {
481401 }
482402 }
483403}
484-
485- // Filenames for stashing between build and test steps
486- s3_prefix = " tvm-jenkins-artifacts-prod/tvm/${ env.BRANCH_NAME} /${ env.BUILD_NUMBER} "
487-
488-
404+ def lint () {
405+ stage(' Lint' ) {
406+ parallel(
407+ ' Lint 1 of 2' : {
408+ node(' CPU-SMALL' ) {
409+ ws(" workspace/exec_${ env.EXECUTOR_NUMBER} /tvm/lint" ) {
410+ init_git()
411+ timeout(time : max_time, unit : ' MINUTES' ) {
412+ withEnv([
413+ ' TVM_NUM_SHARDS=2' ,
414+ ' TVM_SHARD_INDEX=0' ], {
415+ sh (
416+ script : " ${ docker_run} ${ ci_lint} ./tests/scripts/task_lint.sh" ,
417+ label : ' Run lint' ,
418+ )
419+ })
420+ }
421+ }
422+ }
423+ },
424+ ' Lint 2 of 2' : {
425+ node(' CPU-SMALL' ) {
426+ ws(" workspace/exec_${ env.EXECUTOR_NUMBER} /tvm/lint" ) {
427+ init_git()
428+ timeout(time : max_time, unit : ' MINUTES' ) {
429+ withEnv([
430+ ' TVM_NUM_SHARDS=2' ,
431+ ' TVM_SHARD_INDEX=1' ], {
432+ sh (
433+ script : " ${ docker_run} ${ ci_lint} ./tests/scripts/task_lint.sh" ,
434+ label : ' Run lint' ,
435+ )
436+ })
437+ }
438+ }
439+ }
440+ },
441+ )
442+ }
443+ }
489444def ci_setup (image ) {
490445 sh (
491446 script : " ${ docker_run} ${ image} ./tests/scripts/task_ci_setup.sh" ,
@@ -529,7 +484,6 @@ def add_microtvm_permissions() {
529484 )
530485}
531486
532-
533487def build () {
534488stage(' Build' ) {
535489 environment {
@@ -771,10 +725,6 @@ stage('Build') {
771725 )
772726}
773727}
774-
775- // [note: method size]
776- build()
777-
778728def test () {
779729stage(' Test' ) {
780730 environment {
@@ -1845,10 +1795,6 @@ stage('Test') {
18451795 )
18461796}
18471797}
1848-
1849- // [note: method size]
1850- test()
1851-
18521798/*
18531799stage('Build packages') {
18541800 parallel 'conda CPU': {
@@ -1907,11 +1853,13 @@ def deploy_docs() {
19071853 }
19081854}
19091855
1910- stage(' Deploy' ) {
1911- if (env. BRANCH_NAME == ' main' && env. DOCS_DEPLOY_ENABLED == ' yes' ) {
1912- node(' CPU' ) {
1913- ws(" workspace/exec_${ env.EXECUTOR_NUMBER} /tvm/deploy-docs" ) {
1914- sh(
1856+
1857+ def deploy () {
1858+ stage(' Deploy' ) {
1859+ if (env. BRANCH_NAME == ' main' && env. DOCS_DEPLOY_ENABLED == ' yes' ) {
1860+ node(' CPU' ) {
1861+ ws(" workspace/exec_${ env.EXECUTOR_NUMBER} /tvm/deploy-docs" ) {
1862+ sh(
19151863 script : """
19161864 set -eux
19171865 aws s3 cp --no-progress s3://${ s3_prefix} /docs/docs.tgz docs.tgz
@@ -1920,8 +1868,26 @@ stage('Deploy') {
19201868 label : ' Download artifacts from S3' ,
19211869 )
19221870
1923- deploy_docs()
1871+ deploy_docs()
1872+ }
19241873 }
19251874 }
19261875 }
19271876}
1877+
1878+
1879+ cancel_previous_build()
1880+
1881+ prepare()
1882+
1883+ if (rebuild_docker_images) {
1884+ build_docker_images()
1885+ }
1886+
1887+ lint()
1888+
1889+ build()
1890+
1891+ test()
1892+
1893+ deploy()
0 commit comments