-
Notifications
You must be signed in to change notification settings - Fork 0
1072 lines (1048 loc) · 43 KB
/
ci-test.yml
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
name: ci-test
on:
push:
branches: [auto, canary]
pull_request:
branches: [main, release-*, gha-test-*]
defaults:
run:
shell: bash
env:
max_threads: 16
nextest_tries: 3
pre_command: cd /opt/git/diem/
jobs:
prepare:
runs-on: ubuntu-latest
outputs:
changes-target-branch: ${{ steps.changes.outputs.changes-target-branch }}
changes-base-git-rev: ${{ steps.changes.outputs.changes-base-git-rev }}
changes-base-githash: ${{ steps.changes.outputs.changes-base-githash }}
changes-pull-request-number: ${{ steps.changes.outputs.changes-pull-request-number }}
build-images: ${{ steps.need-build-images.outputs.changes-found }}
any-changes-founds: ${{ steps.any-changes-found.outputs.changes-found }}
need-base-images: ${{ steps.need-base-images.outputs.need-extra }}
test-land-blocking: ${{ steps.need-land-blocking-test.outputs.need-lbt }}
test-compatibility: ${{ steps.need-compat-tests.outputs.need-compat }}
test-rust: ${{ steps.rust-changes.outputs.changes-found }}
test-helm: ${{ steps.helm-changes.outputs.changes-found }}
test-dev-setup: ${{ steps.dev-setup-sh-changes.outputs.changes-found }}
test-website-build: ${{ steps.website-changes.outputs.changes-found }}
test-non-rust-lint: ${{ steps.non-rust-lint-changes.outputs.changes-found }}
test-docker-compose: ${{ steps.docker-compose-changes.outputs.changes-found }}
test-test-coverage: ${{ steps.test-coverage.outputs.changes-found }}
steps:
- uses: actions/[email protected]
with:
# This ensures that the tip of the PR is checked out instead of the merge between the base ref and the tip
# On `push` this value will be empty and will "do-the-right-thing"
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0 #get all the history!!!
- name: Git Hooks and Checks
run: ./scripts/git-checks.sh
- id: changes
name: determine changes
uses: diem/actions/changes@faadd16607b77dfa2231a8f366883e01717b3225
with:
workflow-file: ci-test.yml
github-token: ${{secrets.GITHUB_TOKEN}}
- id: need-build-images
name: find changes need image build.
uses: diem/actions/matches@faadd16607b77dfa2231a8f366883e01717b3225
with:
pattern: '^documentation\|^developers.diem.com'
invert: "true"
- id: need-land-blocking-test
name: check KS if LBT should be run
if: ${{ github.event_name == 'push' }}
run: |
res=true
branches="${{ secrets.BRANCHES_TO_ENABLE_LBT }}"
if ! [[ -z "${branches}" ]] && [[ "${branches}" =~ .*"${{ steps.changes.outputs.changes-target-branch }}".* ]]; then
echo "LBT is enabled for target branch. Will trigger it."
else
echo "LBT is NOT enabled for target branch. Will skip it."
res=false
fi
echo "::set-output name=need-lbt::$(echo $res)";
- id: need-base-images
name: build extra images if it is needed by LBT
if: ${{ github.event_name == 'push' && steps.need-land-blocking-test.outputs.need-lbt == 'true' }}
run: |
res=true
branches="${{ secrets.BRANCHES_TO_ENABLE_LBT_COMPAT_SUITE }}"
if ! [[ -z "${branches}" ]] && [[ "${branches}" =~ .*"${{ steps.changes.outputs.changes-target-branch }}".* ]]; then
echo "LBT compatibility suite is enabled. Will use land_blocking_compat suite."
echo "Will trigger base images build if they not found."
else
echo "LBT compatibility sutie is NOT enabled. Will use land_blocking suite."
res=false
fi
echo "::set-output name=need-extra::$(echo $res)";
- id: need-compat-tests
name: determine if compat tests should run
run: |
res=true
branches="${{ secrets.BRANCHES_TO_DISABLE_COMPAT_TESTS }}"
if ! [[ -z "${branches}" ]] && [[ "${branches}" =~ .*"${{ steps.changes.outputs.changes-target-branch }}".* ]]; then
echo "compatibility suite is NOT enabled."
res=false
else
echo "compatibility suite is enabled."
fi
echo "::set-output name=need-compat::$(echo $res)";
- id: any-changes-found
name: determine if there are any files listed in the CHANGES_CHANGED_FILE_OUTPUTFILE.
run: |
res=true
if [[ ! -f "$CHANGES_CHANGED_FILE_OUTPUTFILE" ]] || [[ "$(cat "$CHANGES_CHANGED_FILE_OUTPUTFILE" | wc -l)" == 0 ]]; then
res=false;
fi
echo "::set-output name=changes-found::$(echo $res)";
- id: rust-changes
name: find rust/cargo changes.
uses: diem/actions/matches@faadd16607b77dfa2231a8f366883e01717b3225
with:
pattern: '^documentation\|^docker\|^scripts\|^developers.diem.com'
invert: "true"
- id: non-rust-lint-changes
name: find shell/dockerfile changes
uses: diem/actions/matches@faadd16607b77dfa2231a8f366883e01717b3225
with:
pattern: 'Dockerfile$\|.*.sh$|^developers.diem.com'
- id: helm-changes
name: find helm changes
uses: diem/actions/matches@faadd16607b77dfa2231a8f366883e01717b3225
with:
pattern: "^helm"
- id: dev-setup-sh-changes
name: find dev-setup.sh/base docker image changes
uses: diem/actions/matches@faadd16607b77dfa2231a8f366883e01717b3225
with:
pattern: 'docker/ci\|scripts/dev_setup.sh'
- id: docker-compose-changes
name: find changes that should trigger docker compose testing.
uses: diem/actions/matches@faadd16607b77dfa2231a8f366883e01717b3225
with:
pattern: "^documentation"
invert: "true"
- id: website-changes
name: find website changes.
uses: diem/actions/matches@faadd16607b77dfa2231a8f366883e01717b3225
with:
pattern: '^documentation\|^developers.diem.com\|^.github'
- id: test-coverage
name: check if we should see if code coverage still works.
uses: diem/actions/matches@faadd16607b77dfa2231a8f366883e01717b3225
with:
pattern: '^rust.toolchain\|^x.toml\|^devtools\|^.github\|common/logger'
dev-setup-sh-test:
runs-on: ubuntu-latest-xl
timeout-minutes: 30
needs: prepare
if: ${{ needs.prepare.outputs.test-dev-setup == 'true' }}
strategy:
fail-fast: false
matrix:
target_os: [alpine, arch, github]
steps:
- uses: actions/[email protected]
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: build image with dev-setup.sh
run: docker build -f docker/ci/${{ matrix.target_os }}/Dockerfile -t diem/build_environment:test .
build-images:
runs-on: ubuntu-latest-xl
needs: prepare
if: ${{ github.event_name == 'push' && needs.prepare.outputs.build-images == 'true' }}
outputs:
head-tag: ${{ steps.push-to-novi-ecr.outputs.head-tag }}
environment:
name: Docker
strategy:
matrix:
target_images:
[client faucet cluster-test forge, init tools validator validator-tcb]
steps:
- uses: actions/[email protected]
with:
fetch-depth: 0 #get all the history!!!
- id: changes
name: determine changes
uses: diem/actions/changes@faadd16607b77dfa2231a8f366883e01717b3225
with:
workflow-file: docker-publish.yml
- name: setup_aws_ecr_login
run: |
echo 'AWS_ECR_ACCOUNT_URL=${{ secrets.ENV_NOVI_ECR_AWS_ACCOUNT_NUM }}.dkr.ecr.${{ secrets.ENV_NOVI_ECR_AWS_REGION }}.amazonaws.com' >> $GITHUB_ENV
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.ENV_NOVI_ECR_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.ENV_NOVI_ECR_AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.ENV_NOVI_ECR_AWS_REGION }}
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/[email protected]
- name: Sign in to dockerhub, install image signing cert.
uses: ./.github/actions/dockerhub_login
with:
username: ${{ secrets.ENV_DOCKERHUB_USERNAME }}
password: ${{ secrets.ENV_DOCKERHUB_PASSWORD }}
key_material: ${{ secrets.ENV_DOCKERHUB_KEY_MATERIAL }}
key_name: ${{ secrets.ENV_DOCKERHUB_KEY_NAME }}
key_password: ${{ secrets.ENV_DOCKERHUB_KEY_PASSWORD }}
- name: pre-release docker images
run: |
BRANCH="$CHANGES_TARGET_BRANCH"
echo Target Images: ${{ matrix.target_images }}
IFS=' ' read -ra TARGET_IMAGES <<< "${{ matrix.target_images }}"
success=0
tmpfile=$(mktemp)
echo "Failed to push:" > "${tmpfile}"
for image in "${TARGET_IMAGES[@]}"; do
docker/build_push.sh -u -p -b ${BRANCH} -n "$image" || success=$(echo "$image" >> "${tmpfile}"; echo 1)
done
if [[ "$success" == "1" ]]; then
cat "${tmpfile}"
fi
exit $success
env:
DOCKER_CONTENT_TRUST_REPOSITORY_PASSPHRASE: ${{ secrets.ENV_DOCKERHUB_KEY_PASSWORD }}
- name: push to novi ecr
id: push-to-novi-ecr
run: |
#push to novi ecr with standard names
BRANCH="$CHANGES_TARGET_BRANCH"
GIT_REV=$(git rev-parse --short=8 HEAD)
echo "::set-output name=head-tag::land_$GIT_REV";
aws ecr get-login-password --region ${{ secrets.ENV_NOVI_ECR_AWS_REGION }} | \
docker login --username AWS --password-stdin "${AWS_ECR_ACCOUNT_URL}"
docker/docker_republish.sh -t pre_${BRANCH}_${GIT_REV} -o land_${GIT_REV} -r ${AWS_ECR_ACCOUNT_URL} -d -i "${{ matrix.target_images }}"
need-base-images:
runs-on: self-hosted
needs: prepare
if: ${{ github.event_name == 'push' && needs.prepare.outputs.build-images == 'true' && needs.prepare.outputs.need-base-images == 'true' }}
outputs:
# The last matrix build to succeed will set the output. Hilarious.
prev-tag: ${{ steps.build-extra-images.outputs.prev-tag }}
steps:
- uses: actions/[email protected]
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0 #get all the history!!!
- name: Setup env
run: |
echo "BASE_GIT_REV=${{ needs.prepare.outputs.changes-base-git-rev }}" >> $GITHUB_ENV
- name: find images
run: |
set +e
echo "Will run land_blocking_compat suite"
echo "Finding a previous image tag to test against"
.github/actions/land-blocking/find-lbt-images.sh > lbt_images_output.txt
if [ $? -ne 0 ]; then
echo "BUILD_PREV=1" >> $GITHUB_ENV
cat lbt_images_output.txt
jq -n \
--arg msg "*${{ github.job }}* job in ${{ github.workflow }} workflow failed. Could not find a recent image tag for Compat Test" \
--arg url "https://github.com/${{ github.repository }}/actions/runs/${{github.run_id}}" \
'{
"attachments": [
{
"text": $msg,
"actions": [
{
"type": "button",
"text": "Visit Job",
"url": $url
}
]
}
]
}' > /tmp/payload
curl -X POST -H 'Content-type: application/json' -d @/tmp/payload ${{ secrets.WEBHOOK_FLAKY_LAND_BLOCKING_CT }}
else
compat_prev_tag=$(tail -1 lbt_images_output.txt)
echo "Using previous image tag $compat_prev_tag"
echo "PREV_TAG=$compat_prev_tag" >> $GITHUB_ENV
echo "BUILD_PREV=0" >> $GITHUB_ENV
fi
- name: build extra images
id: build-extra-images
run: |
res=land_$BASE_GIT_REV
if [ $BUILD_PREV -eq 1 ]; then
compat_prev_tag=$res
echo "Starting codebuild for $compat_prev_tag"
VERSION=$BASE_GIT_REV ADDL_TAG=$compat_prev_tag .github/actions/land-blocking/cti-codebuild.sh &> codebuild-prev.log &
prev_build_pid=$!
wait $prev_build_pid
echo "====== codebuild-prev.log start ======"
cat codebuild-prev.log
else
res=$PREV_TAG;
fi
echo "::set-output name=prev-tag::$(echo $res)";
land-blocking-test:
name: Run land blocking test
runs-on: self-hosted
needs: [prepare, build-images, need-base-images]
if: ${{ always() && needs.build-images.result=='success' && needs.prepare.outputs.test-land-blocking == 'true' }}
timeout-minutes: 45
steps:
- uses: actions/[email protected]
with:
# This ensures that the tip of the PR is checked out instead of the merge between the base ref and the tip
# On `push` this value will be empty and will "do-the-right-thing"
ref: ${{ github.event.pull_request.head.sha }}
- name: Launch cluster test
# NOTE Remember to update PR comment payload if cti cmd is updated.
run: |
set +e
date
export CTI_OUTPUT_LOG=$(mktemp)
echo "CTI_OUTPUT_LOG=$CTI_OUTPUT_LOG" >> $GITHUB_ENV
cmd=""
if ${{ needs.need-base-images.result!='success' }}; then
cmd="./scripts/cti --tag ${{ needs.build-images.outputs.head-tag }} --report report.json --suite land_blocking"
else
cmd="./scripts/cti --tag ${{ needs.need-base-images.outputs.prev-tag }} --cluster-test-tag ${{ needs.build-images.outputs.head-tag }} -E BATCH_SIZE=15 -E UPDATE_TO_TAG=${{ needs.build-images.outputs.head-tag }} --report report.json --suite land_blocking_compat"
fi
eval $cmd
ret=$?
echo "cti exit code: $ret"
echo "CTI_REPRO_CMD=$cmd" >> $GITHUB_ENV
echo "CTI_EXIT_CODE=$ret" >> $GITHUB_ENV
msg_text="*${{ github.job }}* job in ${{ github.workflow }} workflow failed for PR ${{ needs.prepare.outputs.changes-pull-request-number }}."
if [ -s "report.json" ]; then
echo "report.json start"
cat report.json
echo "report.json end"
msg_text="$msg_text Report:\n$(cat report.json)"
else
echo "report.json is empty or not found."
msg_text="$msg_text Report:\nEmpty"
ret=1
fi
if [ $ret -ne 0 ]; then
jq -n \
--arg msg "$msg_text" \
--arg url "https://github.com/${{ github.repository }}/actions/runs/${{github.run_id}}" \
--arg pr_url "https://github.com/${{ github.repository }}/pull/${{ needs.prepare.outputs.changes-pull-request-number }}" \
'{
"attachments": [
{
"text": $msg,
"actions": [
{
"type": "button",
"text": "Visit Job",
"url": $url
},
{
"type": "button",
"text": "Visit PR",
"url": $pr_url
}
]
}
]
}' > /tmp/payload
curl -X POST -H 'Content-type: application/json' -d @/tmp/payload ${{ secrets.WEBHOOK_FLAKY_LAND_BLOCKING_CT }}
fi
- name: Post test results on PR
uses: actions/[email protected]
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
// Find the number of the pull request that trigggers this push
let pr_num = ${{ needs.prepare.outputs.changes-pull-request-number }};
if (!pr_num) {
console.warn("Did not find pull request num in previous step");
console.log("GH event payload\n", context.payload);
return;
}
// Read and check cluster test results
let should_fail = false;
let env_vars = process.env;
let body = '';
const fsp = require('fs').promises;
try {
data = await fsp.readFile('report.json', 'utf-8');
var result = JSON.parse(data);
// TODO - set P/F based on metrics TPS, latency
body = `Cluster Test Result
\`\`\`
${result.text}
${result.links}
\`\`\`
`;
// Check CTI exit code for errors
if (parseInt(env_vars.CTI_EXIT_CODE) != 0) {
body += "\n :exclamation: Cluster Test failed - non-zero exit code for `cti` \n"
should_fail = true;
} else {
let tps = result.metrics.find(m => m.experiment == "all up" && m.metric == "avg_tps").value;
let min_tps = 1100;
if (tps < min_tps) {
body += "\n :exclamation: Performance regression is detected on this PR";
body += "\n TPS with PR: " + tps + ", this is lower then minimum allowed " + min_tps + " TPS.";
console.log(body);
should_fail = true;
}
}
} catch (err) {
if (err.code === 'ENOENT') {
body = "Cluster Test failed - no test report found.\n";
// Check Cluster Test output log for infra error
try {
cti_log = await fsp.readFile(env_vars.CTI_OUTPUT_LOG, 'utf-8');
let re = /.*(^Failed\sto\s.*\"Service\sUnavailable.\sPlease\stry\sagain\slater\.\".*)/;
if (re.test(cti_log)) {
let match = re.exec(cti_log);
body += " There was service infra error:\n";
body += `
${match[1]}
`
+ "\n"
;
body += "To retry, comment your PR with `/land`.";
body += " If that doesn't trigger re-run, amend and push again.";
}
} catch (err) {
console.error("Failed to check infra error in CT output log.\n", err);
}
} else {
body = "Cluster Test runner failed.";
console.error(err);
}
body += " See https://github.com/diem/diem/actions/runs/${{github.run_id}}";
// Post comment on PR then fail this workflow
should_fail = true;
}
// Add repro cmd to message
try {
body += "\nRepro cmd:\n";
body += `
\`\`\`
${env_vars.CTI_REPRO_CMD}
\`\`\`
`
} catch (err) {
if (err.code === 'ReferenceError') {
console.error("One of the following env vars is not set");
} else {
body += "[GHA DEBUG]\nFound error in actions/github-script\n";
body += err;
}
}
// Post test result on original pull request
try {
if (!should_fail) {
body += "\n :tada: Land-blocking cluster test passed! :ok_hand:"
}
await github.issues.createComment(
{
issue_number: pr_num,
owner: context.repo.owner,
repo: context.repo.repo,
body: body,
}
);
} catch (err) {
if (err.status === 401) {
// Fail silently for auth but log to console.
console.warn("GH token has expired when trying to POST\n", err);
} else {
console.error("HttpError other than 401 is not bypassed");
throw err;
}
}
// Fail the workflow if test fails or perf regresses
if (should_fail) {
throw "Land-blocking test failed";
}
non-rust-lint:
runs-on: ubuntu-latest-xl
timeout-minutes: 10
needs: prepare
if: ${{ needs.prepare.outputs.test-non-rust-lint == 'true' }}
container:
image: diem/build_environment:${{ needs.prepare.outputs.changes-target-branch }}
steps:
- uses: actions/[email protected]
with:
ref: ${{ github.event.pull_request.head.sha }}
- uses: ./.github/actions/build-setup
- name: shell lints
run: |
shellcheck scripts/dev_setup.sh && \
shellcheck scripts/dockerhub_prune.sh && \
shellcheck docker/build_push.sh && \
shellcheck docker/docker_republish.sh && \
shellcheck scripts/weekly-dep-report.sh
- name: docker lints
uses: ./.github/actions/docker-checks
lint:
runs-on: ubuntu-latest-xl
timeout-minutes: 30
needs: prepare
if: ${{ needs.prepare.outputs.any-changes-founds == 'true' }}
container:
image: diem/build_environment:${{ needs.prepare.outputs.changes-target-branch }}
volumes:
- "${{github.workspace}}:/opt/git/diem"
steps:
- uses: actions/[email protected]
with:
ref: ${{ github.event.pull_request.head.sha }}
- uses: ./.github/actions/build-setup
- uses: Swatinem/rust-cache@c5ed9ba6b7e1bb8aff90d43acd2f0af4990fa57c
with:
key: ${{ needs.prepare.outputs.changes-target-branch }}
- name: cargo lint
run: $pre_command && cargo x lint
- name: cargo clippy
run: $pre_command && cargo xclippy --workspace --all-targets
- name: cargo clippy tcb
run: $pre_command && cargo xclippy --members lec --members lsr --members key-manager
- name: cargo fmt
run: $pre_command && cargo xfmt --check
- uses: ./.github/actions/build-teardown
unit-test:
runs-on: ubuntu-latest-xl
timeout-minutes: 60
needs: prepare
if: ${{ needs.prepare.outputs.test-rust == 'true' }}
container:
image: diem/build_environment:${{ needs.prepare.outputs.changes-target-branch }}
volumes:
- "${{github.workspace}}:/opt/git/diem"
steps:
- uses: actions/[email protected]
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0 #get all the history!!!
- uses: ./.github/actions/build-setup
- uses: Swatinem/rust-cache@c5ed9ba6b7e1bb8aff90d43acd2f0af4990fa57c
with:
key: ${{ needs.prepare.outputs.changes-target-branch }}
- name: run unit tests
run: |
$pre_command && mkdir -p target/junit-reports && cargo nextest --jobs ${max_threads} --tries ${nextest_tries} --unit --failure-output=immediate-final --changed-since "origin/$TARGET_BRANCH" --junit target/junit-reports/unit-test.xml
env:
TARGET_BRANCH: ${{ needs.prepare.outputs.changes-target-branch }}
- name: run jsonrpc integration tests
run: |
$pre_command && cargo xtest -p jsonrpc-integration-tests --changed-since "origin/$TARGET_BRANCH"
env:
TARGET_BRANCH: ${{ needs.prepare.outputs.changes-target-branch }}
- name: run doctests
run: |
$pre_command && cargo xtest --doc --jobs ${max_threads} --unit --changed-since "origin/$TARGET_BRANCH"
env:
TARGET_BRANCH: ${{ needs.prepare.outputs.changes-target-branch }}
- name: upload unit test results
if: always()
uses: actions/upload-artifact@v2
with:
name: unit-test-results
path: target/junit-reports/unit-test.xml
- uses: ./.github/actions/build-teardown
codegen-unit-test:
runs-on: ubuntu-latest-xl
timeout-minutes: 60
needs: prepare
if: ${{ needs.prepare.outputs.test-rust == 'true' }}
container:
image: diem/build_environment:${{ needs.prepare.outputs.changes-target-branch }}
volumes:
- "${{github.workspace}}:/opt/git/diem"
steps:
- uses: actions/[email protected]
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0 #get all the history!!!
- uses: ./.github/actions/build-setup
- uses: Swatinem/rust-cache@c5ed9ba6b7e1bb8aff90d43acd2f0af4990fa57c
with:
key: ${{ needs.prepare.outputs.changes-target-branch }}
- name: run codegen unit tests
run: |
$pre_command && mkdir -p target/junit-reports && cargo nextest --jobs ${max_threads} --tries ${nextest_tries} --failure-output=immediate-final -p transaction-builder-generator --unit --changed-since "origin/$TARGET_BRANCH" --run-ignored=ignored-only --junit target/junit-reports/codegen-unit-test.xml
env:
TARGET_BRANCH: ${{ needs.prepare.outputs.changes-target-branch }}
- name: upload codegen test results
if: always()
uses: actions/upload-artifact@v2
with:
name: codegen-unit-test-results
path: target/junit-reports/codegen-unit-test.xml
- uses: ./.github/actions/build-teardown
e2e-test:
runs-on: ubuntu-latest-xl
timeout-minutes: 40
needs: prepare
if: ${{ needs.prepare.outputs.test-rust == 'true' }}
container:
image: diem/build_environment:${{ needs.prepare.outputs.changes-target-branch }}
volumes:
- "${{github.workspace}}:/opt/git/diem"
strategy:
fail-fast: false
matrix:
runner: [0, 1] # set the env runners to the count below.
env:
runners: 2
E2E_RETRIES: 3
FLAKY_TESTS_FILE: /tmp/failures
MESSAGE_PAYLOAD_FILE: /tmp/message
steps:
- uses: actions/[email protected]
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0 #get all the history!!!
- uses: ./.github/actions/build-setup
- uses: Swatinem/rust-cache@c5ed9ba6b7e1bb8aff90d43acd2f0af4990fa57c
with:
key: ${{ needs.prepare.outputs.changes-target-branch }}
- name: split tests
run: |
cd /opt/git/diem/
cargo x test --package smoke-test -- --list | \
grep "::" | sed 's/: .*$//' > e2e_tests
echo -e "Found $(wc -l e2e_tests) tests."
# Splits the e2e test via round robin in to ${runners} number of files with single digit extensions.
split -n r/${runners} -d -a 1 e2e_tests /tmp/tests.
rm e2e_tests
mv /tmp/tests.${{ matrix.runner }} /tmp/tests_to_run
echo -e "This runner will run these tests\n$(cat /tmp/tests_to_run)"
- name: run e2e tests
run: |
set +e
num_fails=0
cd /opt/git/diem/
export RUST_BACKTRACE=full
failed_tests=
for target in $(cat /tmp/tests_to_run) ; do
retry=0
status=1
while [[ $status != 0 && $retry < ${E2E_RETRIES} ]]; do
cargo x test --package smoke-test -- $target --test-threads 1 --exact --nocapture
status=$?
retry=$((retry + 1))
if [[ $status != 0 ]] ; then
echo Failed to execute $target, $retry times
fi
sleep 10
done
if [[ $status != 0 ]] ; then
num_fails=$((num_fails + 1))
echo failed to execute $target
failed_tests="${target}\n${failed_tests}"
elif [[ $retry > 1 ]]; then
echo "$target passed after $retry tries" >> ${FLAKY_TESTS_FILE}
fi
done
if [ -e ${FLAKY_TESTS_FILE} ]; then
msg="Found flaky tests\n$(cat ${FLAKY_TESTS_FILE})"
echo -e $msg
echo -e $msg > ${MESSAGE_PAYLOAD_FILE}
fi
if [[ $num_fails != 0 ]]; then
echo -e "$num_fails test(s) failed:\n${failed_tests}"
else
echo -e "No issues detected in this build". > ${MESSAGE_PAYLOAD_FILE}
fi
exit $num_fails
- name: "Send Message"
uses: ./.github/actions/slack-file
if: ${{ always() }}
with:
payload-file: ${{ env.MESSAGE_PAYLOAD_FILE }}
webhook: ${{ secrets.WEBHOOK_FLAKY_TESTS }}
forge-test:
runs-on: ubuntu-latest-xl
timeout-minutes: 40
needs: prepare
if: ${{ needs.prepare.outputs.test-rust == 'true' && needs.prepare.outputs.test-compatibility == 'true' }}
container:
image: diem/build_environment:${{ needs.prepare.outputs.changes-target-branch }}
volumes:
- "${{github.workspace}}:/opt/git/diem"
steps:
- uses: actions/[email protected]
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0 #get all the history!!!
- uses: ./.github/actions/build-setup
- uses: actions/[email protected]
with:
path: "/opt/cargo/git\n/opt/cargo/registry\n/opt/cargo/.package-cache"
key: crates-${{ runner.os }}-${{ hashFiles('Cargo.lock') }}
restore-keys: "crates-${{ runner.os }}"
- name: compatibility tests
run: |
cargo test -p testcases --test forge-local-compatibility
- uses: ./.github/actions/build-teardown
docker-compose-test:
runs-on: ubuntu-latest-xl
timeout-minutes: 30
needs: prepare
if: ${{ needs.prepare.outputs.test-docker-compose == 'true' }}
steps:
- uses: actions/[email protected]
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: install expect
run: |
sudo apt --assume-yes update
sudo apt --assume-yes install expect
- name: build validator docker image
run: docker/diem-build.sh docker/validator/Dockerfile diem/validator:test
- name: build faucet image
run: docker/diem-build.sh docker/faucet/Dockerfile diem/faucet:test
- name: build client image
run: docker/diem-build.sh docker/client/Dockerfile diem/client:test
- name: run validator-client test
run: docker/compose/test_docker_compose.sh
env:
# this overrides the default docker tag of "testnet"
IMAGE_TAG: "test"
- name: run sdk-compatibility tests from main
run: cd sdk/compatibility && cargo test -- --include-ignored
env:
JSON_RPC_URL: "http://127.0.0.1:8080"
FAUCET_URL: "http://127.0.0.1:8000"
- uses: actions/[email protected]
with:
ref: diem-core-v1.2.0
# Unfortunately this is spelled wrong in the release branch
- name: run sdk-compatability tests from release
run: cd sdk/compatability && cargo test -- --include-ignored
env:
JSON_RPC_URL: "http://127.0.0.1:8080"
FAUCET_URL: "http://127.0.0.1:8000"
- uses: ./.github/actions/build-teardown
crypto-unit-test:
runs-on: ubuntu-latest
timeout-minutes: 20
needs: prepare
if: ${{ needs.prepare.outputs.test-rust == 'true' }}
container:
image: diem/build_environment:${{ needs.prepare.outputs.changes-target-branch }}
volumes:
- "${{github.workspace}}:/opt/git/diem"
steps:
- uses: actions/[email protected]
with:
ref: ${{ github.event.pull_request.head.sha }}
- uses: ./.github/actions/build-setup
- uses: Swatinem/rust-cache@c5ed9ba6b7e1bb8aff90d43acd2f0af4990fa57c
with:
key: ${{ needs.prepare.outputs.changes-target-branch }}
- name: run crypto unit tests
run: |
cd /opt/git/diem/crypto/crypto
cargo test --features='u64' --no-default-features
cargo test --features='u32' --no-default-features
- uses: ./.github/actions/build-teardown
coverage-unit-test:
runs-on: ubuntu-latest-xl
timeout-minutes: 10
needs: prepare
if: ${{ needs.prepare.outputs.test-test-coverage == 'true' }}
container:
image: diem/build_environment:${{ needs.prepare.outputs.changes-target-branch }}
volumes:
- "${{github.workspace}}:/opt/git/diem"
steps:
- uses: actions/[email protected]
with:
ref: ${{ github.event.pull_request.head.sha }}
- uses: ./.github/actions/build-setup
- uses: Swatinem/rust-cache@c5ed9ba6b7e1bb8aff90d43acd2f0af4990fa57c
with:
key: ${{ needs.prepare.outputs.changes-target-branch }}
- name: run coverage tests and verify coverage is calculated.
run: |
cargo xtest --html-cov-dir=/tmp/results/ -p diem-logger
export line_coverage=$( cat /tmp/results/index.html | grep '<abbr' | head -1 | sed 's/<[^>]*>//g' | sed 's/\..*//g' | sed 's/[[:blank:]]//g' )
echo Line Coverage: $line_coverage
if (( line_coverage < 80 )); then
echo Coverage appears to be broken, diem/logger should report more than 80% line coverage.
exit 1;
fi
- uses: ./.github/actions/build-teardown
helm-test:
runs-on: ubuntu-latest-xl
timeout-minutes: 20
needs: prepare
if: ${{ needs.prepare.outputs.test-helm == 'true' }}
steps:
- uses: actions/[email protected]
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Check machine details for minikube
run: |
kubectl version
helm version
lscpu
- name: Helm lint
working-directory: helm
run: helm lint fullnode
- name: Install minikube v1.17.1
run: |
curl -LO https://storage.googleapis.com/minikube/releases/v1.17.1/minikube-linux-amd64
checksum="03a6d6cccecb7a33a09afc6dae40d8d76ccfe168aa4aba1a18c1f45bbab120c2"
filename=minikube-linux-amd64
if [[ $(sha256sum $filename | awk '{print $1}') != "$checksum" ]]; then
echo "$filename checksum mismatch"
exit 1
fi
# TODO(rustielin): add minikube into scripts/dev_setup.sh
sudo install minikube-linux-amd64 /usr/local/bin/minikube
rm minikube-linux-amd64
- name: Start minikube
run: minikube start --driver=docker --cpus=3 --memory=5Gi
- name: Wait for node status
run: kubectl wait --for=condition=ready node/minikube --timeout=5m
- name: Interact with the cluster
run: kubectl get nodes
- name: Install fullnode helm chart
working-directory: helm/fullnode
run: |
helm install fullnode --set storage.class=standard --set storage.size=10Gi .
- name: Wait and check pods
run: |
echo "Sleep 30s while fullnode starts"
sleep 30
kubectl wait -l statefulset.kubernetes.io/pod-name=fullnode-diem-fullnode-0 --for=condition=ready pod --timeout=5m
echo "Sleep 1m while fullnode syncs"
sleep 60
kubectl get pods
- name: Run the fullnode helm chart tests
working-directory: helm/fullnode
run: helm test fullnode --logs
- name: Check resources
if: ${{ always() }}
run: |
echo "===== nodes ====="
kubectl get nodes
kubectl describe nodes
echo "===== pvcs ====="
kubectl get pvc
kubectl describe pvc
echo "===== pods ====="
kubectl get pods
kubectl describe pod fullnode-diem-fullnode-0
kubectl logs fullnode-diem-fullnode-0
kubectl logs fullnode-diem-fullnode-sync-test
- name: Clean up
if: ${{ always() }}
run: minikube delete
- uses: ./.github/actions/build-teardown
# Compile (but don't run) the benchmarks, to insulate against bit rot
build-benchmarks:
runs-on: ubuntu-latest-xl
timeout-minutes: 30
needs: prepare
if: ${{ needs.prepare.outputs.test-rust == 'true' }}
container:
image: diem/build_environment:${{ needs.prepare.outputs.changes-target-branch }}
volumes:
- "${{github.workspace}}:/opt/git/diem"
steps:
- uses: actions/[email protected]
with:
ref: ${{ github.event.pull_request.head.sha }}
- uses: ./.github/actions/build-setup
- uses: actions/[email protected]
with:
path: "/opt/cargo/git\n/opt/cargo/registry\n/opt/cargo/.package-cache"
key: crates-${{ runner.os }}-${{ hashFiles('Cargo.lock') }}
restore-keys: "crates-${{ runner.os }}"
- name: build benchmarks
run: cargo x bench --no-run
- uses: ./.github/actions/build-teardown
build-dev:
runs-on: ubuntu-latest-xl
timeout-minutes: 30
needs: prepare
if: ${{ needs.prepare.outputs.test-rust == 'true' }}
container:
image: diem/build_environment:${{ needs.prepare.outputs.changes-target-branch }}
volumes:
- "${{github.workspace}}:/opt/git/diem"
steps:
- uses: actions/[email protected]
with:
ref: ${{ github.event.pull_request.head.sha }}
- uses: ./.github/actions/build-setup
- uses: Swatinem/rust-cache@c5ed9ba6b7e1bb8aff90d43acd2f0af4990fa57c
with:
key: ${{ needs.prepare.outputs.changes-target-branch }}
- run: cd /opt/git/diem/ && cargo xcheck -j ${max_threads} --members production
- run: cd /opt/git/diem/ && cargo xcheck -j ${max_threads} --workspace --all-targets
- run: |
cd /opt/git/diem
rustup target add powerpc-unknown-linux-gnu
cargo xcheck -j ${max_threads} -p diem-transaction-builder -p move-vm-types --target powerpc-unknown-linux-gnu
- uses: ./.github/actions/build-teardown
perf-benchmarks:
name: run-perf-benchmarks
runs-on: ubuntu-latest-xl
timeout-minutes: 30
needs:
- prepare
- build-benchmarks
env:
CRITERION_HOME: /tmp/benches
steps:
- uses: actions/[email protected]
with:
ref: ${{ github.event.pull_request.head.sha }}
- uses: actions/[email protected]
with:
path: "/opt/cargo/git\n/opt/cargo/registry\n/opt/cargo/.package-cache"
key: crates-${{ runner.os }}-${{ hashFiles('Cargo.lock') }}
restore-keys: "crates-${{ runner.os }}"
- name: Download the previous baseline
continue-on-error: true
uses: actions/download-artifact@v2
with:
name: bench-baseline
- name: Run performance benchamrks
run: |
# Replace this with a cargo x bench
cargo bench --package language-benchmarks
- name: Archive criterion results
uses: actions/upload-artifact@v2
with:
name: bench-baseline
retention-days: 5
path: |
/tmp/benches
developers-site:
name: run-developer-site-build
runs-on: ubuntu-latest
if: ${{ needs.prepare.outputs.test-website-build == 'true' }}
steps:
# Checks-out the Diem website repository under $GITHUB_WORKSPACE, so job can access it
- uses: actions/[email protected]
with:
ref: ${{ github.event.pull_request.head.sha }}
- uses: actions/[email protected]
# Installs node and yarn
- name: Use Node.js 12
uses: actions/[email protected]
with:
node-version: '14'
# Install git
- name: Install git
run: |
sudo apt --assume-yes update
sudo apt --assume-yes install git
# Install Python 3.8
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: '3.8'
# Test that building the site is successful
- name: Build Site
run: |
cd developers.diem.com
# Only build the straight Docusaurus site now. Do not build rust `-r`
# or python docs `-p` on CI checks until we resolve the best way to
# build them for deployment
./scripts/build_docs.sh -b
land-blocking-test-forge:
name: Run land blocking test in Forge
runs-on: self-hosted
needs: [prepare, build-images, need-base-images]
if: ${{ always() && needs.build-images.result=='success' && needs.prepare.outputs.test-land-blocking == 'true' }}
outputs:
forge-result: ${{ steps.post-test-result.outputs.forge-result }}
timeout-minutes: 45
steps:
- uses: actions/[email protected]
with:
# This ensures that the tip of the PR is checked out instead of the merge between the base ref and the tip
# On `push` this value will be empty and will "do-the-right-thing"
ref: ${{ github.event.pull_request.head.sha }}
- name: Launch forge test
# NOTE Remember to update PR comment payload if cti cmd is updated.
run: |
set +e
date