forked from apache/tvm
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Jenkinsfile
executable file
·4753 lines (4506 loc) · 174 KB
/
Jenkinsfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!groovy
// -*- mode: groovy -*-
// 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.
// Jenkins pipeline
// See documents at https://jenkins.io/doc/book/pipeline/jenkinsfile/
// Docker env used for testing
// Different image may have different version tag
// because some of them are more stable than anoter.
//
// Docker images are maintained by PMC, cached in dockerhub
// and remains relatively stable over the time.
// Flow for upgrading docker env(need commiter)
//
// - Send PR to upgrade build script in the repo
// - Build the new docker image
// - Tag the docker image with a new version and push to a binary cache.
// - Update the version in the Jenkinsfile, send a PR
// - Fix any issues wrt to the new image version in the PR
// - Merge the PR and now we are in new version
// - Tag the new version as the lates
// - Periodically cleanup the old versions on local workers
//
// ============================= IMPORTANT NOTE =============================
// This file is generated by 'jenkins/generate.py'. Do not edit this file directly!
// Make edits to 'jenkins/Jenkinsfile.j2' and regenerate this with
// 'python3 jenkins/generate.py'
// Note: This timestamp is here to ensure that updates to the Jenkinsfile are
// always rebased on main before merging:
// Generated at 2022-10-19T13:44:32.119961
import org.jenkinsci.plugins.pipeline.modeldefinition.Utils
// NOTE: these lines are scanned by docker/dev_common.sh. Please update the regex as needed. -->
ci_lint = 'tlcpack/ci-lint:20221025-182121-e41d0ed6e'
ci_gpu = 'tlcpack/ci-gpu:20221025-182121-e41d0ed6e'
ci_cpu = 'tlcpack/ci-cpu:20221025-182121-e41d0ed6e'
ci_minimal = 'tlcpack/ci-minimal:20221025-182121-e41d0ed6e'
ci_wasm = 'tlcpack/ci-wasm:20221025-182121-e41d0ed6e'
ci_i386 = 'tlcpack/ci-i386:20221025-182121-e41d0ed6e'
ci_cortexm = 'tlcpack/ci-cortexm:20221025-182121-e41d0ed6e'
ci_arm = 'tlcpack/ci-arm:20221025-182121-e41d0ed6e'
ci_hexagon = 'tlcpack/ci-hexagon:20221025-182121-e41d0ed6e'
ci_riscv = 'tlcpack/ci-riscv:20221025-182121-e41d0ed6e'
// <--- End of regex-scanned config.
// Parameters to allow overriding (in Jenkins UI), the images
// to be used by a given build. When provided, they take precedence
// over default values above.
properties([
parameters([
string(name: 'ci_arm_param', defaultValue: ''),
string(name: 'ci_cortexm_param', defaultValue: ''),
string(name: 'ci_cpu_param', defaultValue: ''),
string(name: 'ci_gpu_param', defaultValue: ''),
string(name: 'ci_hexagon_param', defaultValue: ''),
string(name: 'ci_i386_param', defaultValue: ''),
string(name: 'ci_lint_param', defaultValue: ''),
string(name: 'ci_minimal_param', defaultValue: ''),
string(name: 'ci_riscv_param', defaultValue: ''),
string(name: 'ci_wasm_param', defaultValue: ''),
])
])
// Placeholders for newly built Docker image names (if rebuild_docker_images
// is used)
built_ci_arm = null;
built_ci_cortexm = null;
built_ci_cpu = null;
built_ci_gpu = null;
built_ci_hexagon = null;
built_ci_i386 = null;
built_ci_lint = null;
built_ci_minimal = null;
built_ci_riscv = null;
built_ci_wasm = null;
// Global variable assigned during Sanity Check that holds the sha1 which should be
// merged into the PR in all branches.
upstream_revision = null
// command to start a docker container
docker_run = 'docker/bash.sh --env CI --env TVM_SHARD_INDEX --env TVM_NUM_SHARDS --env RUN_DISPLAY_URL --env PLATFORM --env SKIP_SLOW_TESTS --env TEST_STEP_NAME'
docker_build = 'docker/build.sh'
// timeout in minutes
max_time = 180
rebuild_docker_images = false
// Filenames for stashing between build and test steps
s3_prefix = "tvm-jenkins-artifacts-prod/tvm/${env.BRANCH_NAME}/${env.BUILD_NUMBER}"
// General note: Jenkins has limits on the size of a method (or top level code)
// that are pretty strict, so most usage of groovy methods in these templates
// are purely to satisfy the JVM
def per_exec_ws(folder) {
return "workspace/exec_${env.EXECUTOR_NUMBER}/" + folder
}
// initialize source codes
def init_git() {
retry(5) {
checkout scm
}
// Add more info about job node
sh (
script: './tests/scripts/task_show_node_info.sh',
label: 'Show executor node info',
)
// Determine merge commit to use for all stages
sh (
script: 'git fetch origin main',
label: 'Fetch upstream',
)
if (upstream_revision == null) {
upstream_revision = sh(
script: 'git log -1 FETCH_HEAD --format=\'%H\'',
label: 'Determine upstream revision',
returnStdout: true,
).trim()
}
sh (
script: "git -c user.name=TVM-Jenkins -c [email protected] merge ${upstream_revision}",
label: 'Merge to origin/main'
)
sh(
script: """
set -eux
. ci/scripts/retry.sh
retry 3 timeout 5m git submodule update --init -f --jobs 0
""",
label: 'Update git submodules',
)
checkout_trusted_files()
}
def docker_init(image) {
// Clear out all Docker images that aren't going to be used
sh(
script: """
set -eux
docker image ls --all
IMAGES=\$(docker image ls --all --format '{{.Repository}}:{{.Tag}} {{.ID}}')
echo -e "Found images:\\n\$IMAGES"
echo "\$IMAGES" | { grep -vE '${image}' || test \$? = 1; } | { xargs docker rmi || test \$? = 123; }
docker image ls --all
""",
label: 'Clean old Docker images',
)
if (image.contains("amazonaws.com")) {
// If this string is in the image name it's from ECR and needs to be pulled
// with the right credentials
ecr_pull(image)
} else {
sh(
script: """
set -eux
. ci/scripts/retry.sh
retry 5 docker pull ${image}
""",
label: 'Pull docker image',
)
}
}
def should_skip_slow_tests(pr_number) {
withCredentials([string(
credentialsId: 'tvm-bot-jenkins-reader',
variable: 'GITHUB_TOKEN',
)]) {
// Exit code of 1 means run slow tests, exit code of 0 means skip slow tests
result = sh (
returnStatus: true,
script: "./ci/scripts/should_run_slow_tests.py --pr '${pr_number}'",
label: 'Check if CI should run slow tests',
)
}
return result == 0
}
def cancel_previous_build() {
// cancel previous build if it is not on main.
if (env.BRANCH_NAME != 'main') {
def buildNumber = env.BUILD_NUMBER as int
// Milestone API allows us to cancel previous build
// with the same milestone number
if (buildNumber > 1) milestone(buildNumber - 1)
milestone(buildNumber)
}
}
def checkout_trusted_files() {
// trust everything from branch builds
if (env.BRANCH_NAME == null || !env.BRANCH_NAME.startsWith('PR-')) {
return;
}
// trust peoople listed in CONTRIBUTING.md
grep_code = sh(
returnStatus: true,
script: "git show '${upstream_revision}:CONTRIBUTORS.md' | grep '@${env.CHANGE_AUTHOR}'",
label: 'Check if change is from a contributor',
)
if (grep_code == 1) {
// Any scripts that run on the bare host and not inside a Docker container
// (especially those that access secrets) should be checked out here so
// only trusted versions are used in CI
sh(
script: "git checkout ${upstream_revision} ci/scripts/.",
label: 'Check out trusted files',
)
}
}
def should_skip_ci(pr_number) {
if (env.BRANCH_NAME == null || !env.BRANCH_NAME.startsWith('PR-')) {
// never skip CI on build sourced from a branch
return false
}
glob_skip_ci_code = sh (
returnStatus: true,
script: "./ci/scripts/git_skip_ci_globs.py",
label: 'Check if CI should be skipped due to changed files',
)
if (glob_skip_ci_code == 0) {
return true
}
withCredentials([string(
credentialsId: 'tvm-bot-jenkins-reader',
variable: 'GITHUB_TOKEN',
)]) {
// Exit code of 1 means run full CI (or the script had an error, so run
// full CI just in case). Exit code of 0 means skip CI.
git_skip_ci_code = sh (
returnStatus: true,
script: "./ci/scripts/git_skip_ci.py --pr '${pr_number}'",
label: 'Check if CI should be skipped',
)
}
return git_skip_ci_code == 0
}
def check_pr(pr_number) {
if (env.BRANCH_NAME == null || !env.BRANCH_NAME.startsWith('PR-')) {
// never skip CI on build sourced from a branch
return false
}
withCredentials([string(
credentialsId: 'tvm-bot-jenkins-reader',
variable: 'GITHUB_TOKEN',
)]) {
sh (
script: "python3 ci/scripts/check_pr.py --pr ${pr_number}",
label: 'Check PR title and body',
)
}
}
def prepare() {
stage('Prepare') {
node('CPU-SMALL') {
ws("workspace/exec_${env.EXECUTOR_NUMBER}/tvm/prepare") {
init_git()
check_pr(env.CHANGE_ID)
if (env.DETERMINE_DOCKER_IMAGES == 'yes') {
sh(
script: "./ci/scripts/determine_docker_images.py ci_arm=${ci_arm} ci_cortexm=${ci_cortexm} ci_cpu=${ci_cpu} ci_gpu=${ci_gpu} ci_hexagon=${ci_hexagon} ci_i386=${ci_i386} ci_lint=${ci_lint} ci_minimal=${ci_minimal} ci_riscv=${ci_riscv} ci_wasm=${ci_wasm} ",
label: 'Decide whether to use tlcpack or tlcpackstaging for Docker images',
)
// Pull image names from the results of should_rebuild_docker.py
ci_arm = sh(
script: "cat .docker-image-names/ci_arm",
label: "Find docker image name for ci_arm",
returnStdout: true,
).trim()
ci_cortexm = sh(
script: "cat .docker-image-names/ci_cortexm",
label: "Find docker image name for ci_cortexm",
returnStdout: true,
).trim()
ci_cpu = sh(
script: "cat .docker-image-names/ci_cpu",
label: "Find docker image name for ci_cpu",
returnStdout: true,
).trim()
ci_gpu = sh(
script: "cat .docker-image-names/ci_gpu",
label: "Find docker image name for ci_gpu",
returnStdout: true,
).trim()
ci_hexagon = sh(
script: "cat .docker-image-names/ci_hexagon",
label: "Find docker image name for ci_hexagon",
returnStdout: true,
).trim()
ci_i386 = sh(
script: "cat .docker-image-names/ci_i386",
label: "Find docker image name for ci_i386",
returnStdout: true,
).trim()
ci_lint = sh(
script: "cat .docker-image-names/ci_lint",
label: "Find docker image name for ci_lint",
returnStdout: true,
).trim()
ci_minimal = sh(
script: "cat .docker-image-names/ci_minimal",
label: "Find docker image name for ci_minimal",
returnStdout: true,
).trim()
ci_riscv = sh(
script: "cat .docker-image-names/ci_riscv",
label: "Find docker image name for ci_riscv",
returnStdout: true,
).trim()
ci_wasm = sh(
script: "cat .docker-image-names/ci_wasm",
label: "Find docker image name for ci_wasm",
returnStdout: true,
).trim()
}
ci_arm = params.ci_arm_param ?: ci_arm
ci_cortexm = params.ci_cortexm_param ?: ci_cortexm
ci_cpu = params.ci_cpu_param ?: ci_cpu
ci_gpu = params.ci_gpu_param ?: ci_gpu
ci_hexagon = params.ci_hexagon_param ?: ci_hexagon
ci_i386 = params.ci_i386_param ?: ci_i386
ci_lint = params.ci_lint_param ?: ci_lint
ci_minimal = params.ci_minimal_param ?: ci_minimal
ci_riscv = params.ci_riscv_param ?: ci_riscv
ci_wasm = params.ci_wasm_param ?: ci_wasm
sh (script: """
echo "Docker images being used in this build:"
echo " ci_arm = ${ci_arm}"
echo " ci_cortexm = ${ci_cortexm}"
echo " ci_cpu = ${ci_cpu}"
echo " ci_gpu = ${ci_gpu}"
echo " ci_hexagon = ${ci_hexagon}"
echo " ci_i386 = ${ci_i386}"
echo " ci_lint = ${ci_lint}"
echo " ci_minimal = ${ci_minimal}"
echo " ci_riscv = ${ci_riscv}"
echo " ci_wasm = ${ci_wasm}"
""", label: 'Docker image names')
is_docs_only_build = sh (
returnStatus: true,
script: './ci/scripts/git_change_docs.sh',
label: 'Check for docs only changes',
)
skip_ci = should_skip_ci(env.CHANGE_ID)
skip_slow_tests = should_skip_slow_tests(env.CHANGE_ID)
rebuild_docker_images = sh (
returnStatus: true,
script: './ci/scripts/git_change_docker.sh',
label: 'Check for any docker changes',
)
if (skip_ci) {
// Don't rebuild when skipping CI
rebuild_docker_images = false
}
}
}
}
}
def ecr_push(full_name) {
aws_account_id = sh(
returnStdout: true,
script: 'aws sts get-caller-identity | grep Account | cut -f4 -d\\"',
label: 'Get AWS ID'
).trim()
def ecr_name = "${aws_account_id}.dkr.ecr.us-west-2.amazonaws.com/${full_name}"
try {
withEnv([
"AWS_ACCOUNT_ID=${aws_account_id}",
'AWS_DEFAULT_REGION=us-west-2',
"AWS_ECR_REPO=${aws_account_id}.dkr.ecr.us-west-2.amazonaws.com"]) {
sh(
script: '''
set -eux
aws ecr get-login-password --region $AWS_DEFAULT_REGION | docker login --username AWS --password-stdin $AWS_ECR_REPO
''',
label: 'Log in to ECR'
)
sh(
script: """
set -x
. ci/scripts/retry.sh
docker tag ${full_name} \$AWS_ECR_REPO/${full_name}
retry 5 docker push \$AWS_ECR_REPO/${full_name}
""",
label: 'Upload image to ECR'
)
}
} finally {
withEnv([
"AWS_ACCOUNT_ID=${aws_account_id}",
'AWS_DEFAULT_REGION=us-west-2',
"AWS_ECR_REPO=${aws_account_id}.dkr.ecr.us-west-2.amazonaws.com"]) {
sh(
script: 'docker logout $AWS_ECR_REPO',
label: 'Clean up login credentials'
)
}
}
return ecr_name
}
def ecr_pull(full_name) {
aws_account_id = sh(
returnStdout: true,
script: 'aws sts get-caller-identity | grep Account | cut -f4 -d\\"',
label: 'Get AWS ID'
).trim()
try {
withEnv([
"AWS_ACCOUNT_ID=${aws_account_id}",
'AWS_DEFAULT_REGION=us-west-2',
"AWS_ECR_REPO=${aws_account_id}.dkr.ecr.us-west-2.amazonaws.com"]) {
sh(
script: '''
set -eux
aws ecr get-login-password --region $AWS_DEFAULT_REGION | docker login --username AWS --password-stdin $AWS_ECR_REPO
''',
label: 'Log in to ECR'
)
sh(
script: """
set -eux
. ci/scripts/retry.sh
retry 5 docker pull ${full_name}
""",
label: 'Pull image from ECR'
)
}
} finally {
withEnv([
"AWS_ACCOUNT_ID=${aws_account_id}",
'AWS_DEFAULT_REGION=us-west-2',
"AWS_ECR_REPO=${aws_account_id}.dkr.ecr.us-west-2.amazonaws.com"]) {
sh(
script: 'docker logout $AWS_ECR_REPO',
label: 'Clean up login credentials'
)
}
}
}
def build_image(image_name) {
hash = sh(
returnStdout: true,
script: 'git log -1 --format=\'%h\''
).trim()
def full_name = "${image_name}:${env.BRANCH_NAME}-${hash}-${env.BUILD_NUMBER}"
sh(
script: "${docker_build} ${image_name} --spec ${full_name}",
label: 'Build docker image'
)
return ecr_push(full_name)
}
def build_docker_images() {
stage('Docker Image Build') {
parallel(
'ci_arm': {
node('ARM') {
timeout(time: max_time, unit: 'MINUTES') {
init_git()
// We're purposefully not setting the built image here since they
// are not yet being uploaded to tlcpack
// ci_arm = build_image('ci_arm')
built_ci_arm = build_image('ci_arm');
}
}
},
'ci_cortexm': {
node('CPU') {
timeout(time: max_time, unit: 'MINUTES') {
init_git()
// We're purposefully not setting the built image here since they
// are not yet being uploaded to tlcpack
// ci_cortexm = build_image('ci_cortexm')
built_ci_cortexm = build_image('ci_cortexm');
}
}
},
'ci_cpu': {
node('CPU') {
timeout(time: max_time, unit: 'MINUTES') {
init_git()
// We're purposefully not setting the built image here since they
// are not yet being uploaded to tlcpack
// ci_cpu = build_image('ci_cpu')
built_ci_cpu = build_image('ci_cpu');
}
}
},
'ci_gpu': {
node('CPU') {
timeout(time: max_time, unit: 'MINUTES') {
init_git()
// We're purposefully not setting the built image here since they
// are not yet being uploaded to tlcpack
// ci_gpu = build_image('ci_gpu')
built_ci_gpu = build_image('ci_gpu');
}
}
},
'ci_hexagon': {
node('CPU') {
timeout(time: max_time, unit: 'MINUTES') {
init_git()
// We're purposefully not setting the built image here since they
// are not yet being uploaded to tlcpack
// ci_hexagon = build_image('ci_hexagon')
built_ci_hexagon = build_image('ci_hexagon');
}
}
},
'ci_i386': {
node('CPU') {
timeout(time: max_time, unit: 'MINUTES') {
init_git()
// We're purposefully not setting the built image here since they
// are not yet being uploaded to tlcpack
// ci_i386 = build_image('ci_i386')
built_ci_i386 = build_image('ci_i386');
}
}
},
'ci_lint': {
node('CPU') {
timeout(time: max_time, unit: 'MINUTES') {
init_git()
// We're purposefully not setting the built image here since they
// are not yet being uploaded to tlcpack
// ci_lint = build_image('ci_lint')
built_ci_lint = build_image('ci_lint');
}
}
},
'ci_minimal': {
node('CPU') {
timeout(time: max_time, unit: 'MINUTES') {
init_git()
// We're purposefully not setting the built image here since they
// are not yet being uploaded to tlcpack
// ci_minimal = build_image('ci_minimal')
built_ci_minimal = build_image('ci_minimal');
}
}
},
'ci_riscv': {
node('CPU') {
timeout(time: max_time, unit: 'MINUTES') {
init_git()
// We're purposefully not setting the built image here since they
// are not yet being uploaded to tlcpack
// ci_riscv = build_image('ci_riscv')
built_ci_riscv = build_image('ci_riscv');
}
}
},
'ci_wasm': {
node('CPU') {
timeout(time: max_time, unit: 'MINUTES') {
init_git()
// We're purposefully not setting the built image here since they
// are not yet being uploaded to tlcpack
// ci_wasm = build_image('ci_wasm')
built_ci_wasm = build_image('ci_wasm');
}
}
},
)
}
}
def lint() {
stage('Lint') {
parallel(
'Lint 1 of 2': {
node('CPU-SMALL') {
ws("workspace/exec_${env.EXECUTOR_NUMBER}/tvm/lint") {
init_git()
docker_init(ci_lint)
timeout(time: max_time, unit: 'MINUTES') {
withEnv([
'TVM_NUM_SHARDS=2',
'TEST_STEP_NAME=Lint',
'TVM_SHARD_INDEX=0',
"SKIP_SLOW_TESTS=${skip_slow_tests}"], {
sh (
script: "${docker_run} ${ci_lint} ./tests/scripts/task_lint.sh",
label: 'Run lint',
)
})
}
}
}
},
'Lint 2 of 2': {
node('CPU-SMALL') {
ws("workspace/exec_${env.EXECUTOR_NUMBER}/tvm/lint") {
init_git()
docker_init(ci_lint)
timeout(time: max_time, unit: 'MINUTES') {
withEnv([
'TVM_NUM_SHARDS=2',
'TEST_STEP_NAME=Lint',
'TVM_SHARD_INDEX=1',
"SKIP_SLOW_TESTS=${skip_slow_tests}"], {
sh (
script: "${docker_run} ${ci_lint} ./tests/scripts/task_lint.sh",
label: 'Run lint',
)
})
}
}
}
},
)
}
}
def ci_setup(image) {
sh (
script: "${docker_run} ${image} ./tests/scripts/task_ci_setup.sh",
label: 'Set up CI environment',
)
}
def python_unittest(image) {
sh (
script: "${docker_run} ${image} ./tests/scripts/task_python_unittest.sh",
label: 'Run Python unit tests',
)
}
def fsim_test(image) {
sh (
script: "${docker_run} ${image} ./tests/scripts/task_python_vta_fsim.sh",
label: 'Run VTA tests in FSIM',
)
}
def cmake_build(image, path, make_flag) {
sh (
script: "${docker_run} --env CI_NUM_EXECUTORS ${image} ./tests/scripts/task_build.py --sccache-bucket tvm-sccache-prod",
label: 'Run cmake build',
)
}
def cpp_unittest(image) {
sh (
script: "${docker_run} --env CI_NUM_EXECUTORS ${image} ./tests/scripts/task_cpp_unittest.sh",
label: 'Build and run C++ tests',
)
}
def add_microtvm_permissions() {
sh(
script: 'find build/microtvm_template_projects -type f | grep qemu-hack | xargs chmod +x',
label: 'Add execute permissions for microTVM files',
)
}
def add_hexagon_permissions() {
sh(
script: 'find build/hexagon_api_output -type f | xargs chmod +x',
label: 'Add execute permissions for hexagon files',
)
}
// Run make. First try to do an incremental make from a previous workspace in hope to
// accelerate the compilation. If something is wrong, clean the workspace and then
// build from scratch.
def make(docker_type, path, make_flag) {
timeout(time: max_time, unit: 'MINUTES') {
try {
cmake_build(docker_type, path, make_flag)
} catch (hudson.AbortException ae) {
// script exited due to user abort, directly throw instead of retry
if (ae.getMessage().contains('script returned exit code 143')) {
throw ae
}
echo 'Incremental compilation failed. Fall back to build from scratch'
sh (
script: "${docker_run} ${docker_type} ./tests/scripts/task_clean.sh ${path}",
label: 'Clear old cmake workspace',
)
cmake_build(docker_type, path, make_flag)
}
}
}
def build() {
stage('Build') {
environment {
SKIP_SLOW_TESTS = "${skip_slow_tests}"
}
parallel(
'BUILD: GPU': {
if (!skip_ci) {
node('CPU-SMALL') {
ws("workspace/exec_${env.EXECUTOR_NUMBER}/tvm/build-gpu") {
init_git()
docker_init(ci_gpu)
timeout(time: max_time, unit: 'MINUTES') {
sh "${docker_run} --no-gpu ${ci_gpu} ./tests/scripts/task_config_build_gpu.sh build"
make("${ci_gpu} --no-gpu", 'build', '-j2')
sh(
script: """
set -eux
. ci/scripts/retry.sh
md5sum build/libtvm.so
retry 3 aws s3 cp --no-progress build/libtvm.so s3://${s3_prefix}/gpu/build/libtvm.so
md5sum build/libvta_fsim.so
retry 3 aws s3 cp --no-progress build/libvta_fsim.so s3://${s3_prefix}/gpu/build/libvta_fsim.so
md5sum build/libtvm_runtime.so
retry 3 aws s3 cp --no-progress build/libtvm_runtime.so s3://${s3_prefix}/gpu/build/libtvm_runtime.so
md5sum build/config.cmake
retry 3 aws s3 cp --no-progress build/config.cmake s3://${s3_prefix}/gpu/build/config.cmake
retry 3 aws s3 cp --no-progress build/microtvm_template_projects s3://${s3_prefix}/gpu/build/microtvm_template_projects --recursive
""",
label: 'Upload artifacts to S3',
)
// compiler test
sh "${docker_run} --no-gpu ${ci_gpu} ./tests/scripts/task_config_build_gpu_other.sh build2"
make("${ci_gpu} --no-gpu", 'build2', '-j2')
sh(
script: """
set -eux
. ci/scripts/retry.sh
md5sum build/libtvm.so
retry 3 aws s3 cp --no-progress build/libtvm.so s3://${s3_prefix}/gpu2/build/libtvm.so
md5sum build/libvta_fsim.so
retry 3 aws s3 cp --no-progress build/libvta_fsim.so s3://${s3_prefix}/gpu2/build/libvta_fsim.so
md5sum build/libtvm_runtime.so
retry 3 aws s3 cp --no-progress build/libtvm_runtime.so s3://${s3_prefix}/gpu2/build/libtvm_runtime.so
md5sum build/config.cmake
retry 3 aws s3 cp --no-progress build/config.cmake s3://${s3_prefix}/gpu2/build/config.cmake
""",
label: 'Upload artifacts to S3',
)
}
}
}
} else {
Utils.markStageSkippedForConditional('BUILD: GPU')
}
},
'BUILD: CPU': {
if (!skip_ci && is_docs_only_build != 1) {
node('CPU-SMALL') {
ws("workspace/exec_${env.EXECUTOR_NUMBER}/tvm/build-cpu") {
init_git()
docker_init(ci_cpu)
timeout(time: max_time, unit: 'MINUTES') {
sh (
script: "${docker_run} ${ci_cpu} ./tests/scripts/task_config_build_cpu.sh build",
label: 'Create CPU cmake config',
)
make(ci_cpu, 'build', '-j2')
sh(
script: """
set -eux
. ci/scripts/retry.sh
md5sum build/libvta_tsim.so
retry 3 aws s3 cp --no-progress build/libvta_tsim.so s3://${s3_prefix}/cpu/build/libvta_tsim.so
md5sum build/libtvm.so
retry 3 aws s3 cp --no-progress build/libtvm.so s3://${s3_prefix}/cpu/build/libtvm.so
md5sum build/libvta_fsim.so
retry 3 aws s3 cp --no-progress build/libvta_fsim.so s3://${s3_prefix}/cpu/build/libvta_fsim.so
md5sum build/libtvm_runtime.so
retry 3 aws s3 cp --no-progress build/libtvm_runtime.so s3://${s3_prefix}/cpu/build/libtvm_runtime.so
md5sum build/config.cmake
retry 3 aws s3 cp --no-progress build/config.cmake s3://${s3_prefix}/cpu/build/config.cmake
""",
label: 'Upload artifacts to S3',
)
ci_setup(ci_cpu)
// sh "${docker_run} ${ci_cpu} ./tests/scripts/task_golang.sh"
// TODO(@jroesch): need to resolve CI issue will turn back on in follow up patch
sh (script: "${docker_run} ${ci_cpu} ./tests/scripts/task_rust.sh", label: 'Rust build and test')
}
}
}
} else {
Utils.markStageSkippedForConditional('BUILD: CPU')
}
},
'BUILD: CPU MINIMAL': {
if (!skip_ci && is_docs_only_build != 1) {
node('CPU-SMALL') {
ws("workspace/exec_${env.EXECUTOR_NUMBER}/tvm/build-cpu-minimal") {
init_git()
docker_init(ci_minimal)
timeout(time: max_time, unit: 'MINUTES') {
sh (
script: "${docker_run} ${ci_minimal} ./tests/scripts/task_config_build_minimal.sh build",
label: 'Create CPU minimal cmake config',
)
make(ci_minimal, 'build', '-j2')
sh(
script: """
set -eux
. ci/scripts/retry.sh
md5sum build/libtvm.so
retry 3 aws s3 cp --no-progress build/libtvm.so s3://${s3_prefix}/cpu-minimal/build/libtvm.so
md5sum build/libtvm_runtime.so
retry 3 aws s3 cp --no-progress build/libtvm_runtime.so s3://${s3_prefix}/cpu-minimal/build/libtvm_runtime.so
md5sum build/config.cmake
retry 3 aws s3 cp --no-progress build/config.cmake s3://${s3_prefix}/cpu-minimal/build/config.cmake
""",
label: 'Upload artifacts to S3',
)
}
}
}
} else {
Utils.markStageSkippedForConditional('BUILD: CPU MINIMAL')
}
},
'BUILD: WASM': {
if (!skip_ci && is_docs_only_build != 1) {
node('CPU-SMALL') {
ws("workspace/exec_${env.EXECUTOR_NUMBER}/tvm/build-wasm") {
init_git()
docker_init(ci_wasm)
timeout(time: max_time, unit: 'MINUTES') {
sh (
script: "${docker_run} ${ci_wasm} ./tests/scripts/task_config_build_wasm.sh build",
label: 'Create WASM cmake config',
)
make(ci_wasm, 'build', '-j2')
cpp_unittest(ci_wasm)
ci_setup(ci_wasm)
sh (
script: "${docker_run} ${ci_wasm} ./tests/scripts/task_web_wasm.sh",
label: 'Run WASM lint and tests',
)
}
}
}
} else {
Utils.markStageSkippedForConditional('BUILD: WASM')
}
},
'BUILD: i386': {
if (!skip_ci && is_docs_only_build != 1) {
node('CPU-SMALL') {
ws("workspace/exec_${env.EXECUTOR_NUMBER}/tvm/build-i386") {
init_git()
docker_init(ci_i386)
timeout(time: max_time, unit: 'MINUTES') {
sh (
script: "${docker_run} ${ci_i386} ./tests/scripts/task_config_build_i386.sh build",
label: 'Create i386 cmake config',
)
make(ci_i386, 'build', '-j2')
sh(
script: """
set -eux
. ci/scripts/retry.sh
md5sum build/libvta_tsim.so
retry 3 aws s3 cp --no-progress build/libvta_tsim.so s3://${s3_prefix}/i386/build/libvta_tsim.so
md5sum build/libtvm.so
retry 3 aws s3 cp --no-progress build/libtvm.so s3://${s3_prefix}/i386/build/libtvm.so
md5sum build/libvta_fsim.so
retry 3 aws s3 cp --no-progress build/libvta_fsim.so s3://${s3_prefix}/i386/build/libvta_fsim.so
md5sum build/libtvm_runtime.so
retry 3 aws s3 cp --no-progress build/libtvm_runtime.so s3://${s3_prefix}/i386/build/libtvm_runtime.so
md5sum build/config.cmake
retry 3 aws s3 cp --no-progress build/config.cmake s3://${s3_prefix}/i386/build/config.cmake
""",
label: 'Upload artifacts to S3',
)
}
}
}
} else {
Utils.markStageSkippedForConditional('BUILD: i386')
}
},
'BUILD: arm': {
if (!skip_ci && is_docs_only_build != 1) {
node('ARM-SMALL') {
ws("workspace/exec_${env.EXECUTOR_NUMBER}/tvm/build-arm") {
init_git()
docker_init(ci_arm)
timeout(time: max_time, unit: 'MINUTES') {
sh (
script: "${docker_run} ${ci_arm} ./tests/scripts/task_config_build_arm.sh build",
label: 'Create ARM cmake config',
)
make(ci_arm, 'build', '-j4')
sh(
script: """
set -eux
. ci/scripts/retry.sh
md5sum build/libtvm.so
retry 3 aws s3 cp --no-progress build/libtvm.so s3://${s3_prefix}/arm/build/libtvm.so
md5sum build/libvta_fsim.so
retry 3 aws s3 cp --no-progress build/libvta_fsim.so s3://${s3_prefix}/arm/build/libvta_fsim.so
md5sum build/libtvm_runtime.so
retry 3 aws s3 cp --no-progress build/libtvm_runtime.so s3://${s3_prefix}/arm/build/libtvm_runtime.so
md5sum build/config.cmake
retry 3 aws s3 cp --no-progress build/config.cmake s3://${s3_prefix}/arm/build/config.cmake
""",
label: 'Upload artifacts to S3',
)
}
}
}
} else {
Utils.markStageSkippedForConditional('BUILD: arm')
}
},
'BUILD: Cortex-M': {
if (!skip_ci && is_docs_only_build != 1) {
node('CPU-SMALL') {
ws("workspace/exec_${env.EXECUTOR_NUMBER}/tvm/build-cortexm") {
init_git()
docker_init(ci_cortexm)
timeout(time: max_time, unit: 'MINUTES') {
sh (
script: "${docker_run} ${ci_cortexm} ./tests/scripts/task_config_build_cortexm.sh build",
label: 'Create Cortex-M cmake config',
)
make(ci_cortexm, 'build', '-j2')
sh(
script: """
set -eux
. ci/scripts/retry.sh
md5sum build/libtvm.so
retry 3 aws s3 cp --no-progress build/libtvm.so s3://${s3_prefix}/cortexm/build/libtvm.so
md5sum build/libtvm_runtime.so
retry 3 aws s3 cp --no-progress build/libtvm_runtime.so s3://${s3_prefix}/cortexm/build/libtvm_runtime.so
md5sum build/config.cmake
retry 3 aws s3 cp --no-progress build/config.cmake s3://${s3_prefix}/cortexm/build/config.cmake
retry 3 aws s3 cp --no-progress build/microtvm_template_projects s3://${s3_prefix}/cortexm/build/microtvm_template_projects --recursive
""",
label: 'Upload artifacts to S3',
)
}
}
}
} else {
Utils.markStageSkippedForConditional('BUILD: Cortex-M')
}
},
'BUILD: Hexagon': {
if (!skip_ci && is_docs_only_build != 1) {
node('CPU-SMALL') {
ws("workspace/exec_${env.EXECUTOR_NUMBER}/tvm/build-hexagon") {
init_git()