-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathevergreen.yml
1363 lines (1236 loc) · 43 KB
/
evergreen.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
# Evergreen Project Config
# When a task that used to pass starts to fail
# Go through all versions that may have been skipped to detect
# when the task started failing
stepback: true
# Mark a failure as a system/bootstrap failure (purple box) rather then a task
# failure by default.
# Actual testing tasks are marked with `type: test`
command_type: system
# If any of the pre tasks fail, the task will be marked as a failure.
pre_error_fails_task: true
# Do not create patches for changes that only modify the following file types
ignore:
- "*.md"
# Protect ourselves against rogue test cases, or curl gone wild, that runs forever
exec_timeout_secs: 86400 # 24hrs for TPC-H benchmark
# What to do when evergreen hits the timeout (`post:` tasks are run automatically)
timeout:
- command: shell.exec
params:
script: |
ls -la
include:
# https://jira.mongodb.org/browse/DEVPROD-12779
# - filename: evergreen/grpc.yml
- filename: evergreen/mongosqltranslate.yml
- filename: evergreen/suite-tasks.yml
pre:
- func: "fetch source"
- func: "create expansions"
- func: "prepare resources"
post:
- func: "stop mongo orchestration"
functions:
"fetch source":
- command: git.get_project
params:
directory: mongosql-rs
"prepare resources":
- command: subprocess.exec
params:
working_dir: mongosql-rs
include_expansions_in_env:
- DRIVERS_TOOLS
binary: bash
args:
- ./evergreen/fetch-drivers-tools.sh
"bootstrap mongo-orchestration":
- command: subprocess.exec
params:
binary: sh
args:
- ${DRIVERS_TOOLS}/.evergreen/run-orchestration.sh
include_expansions_in_env:
- DRIVERS_TOOLS
- TOPOLOGY
- MONGODB_VERSION
- MONGODB_BINARIES
"stop mongo orchestration":
- command: shell.exec
params:
include_expansions_in_env:
- DRIVERS_TOOLS
- MONGO_ORCHESTRATION_HOME
- PROJECT_DIRECTORY
script: |
${PREPARE_SHELL}
cd ${MONGO_ORCHESTRATION_HOME}
# source the mongo-orchestration virtualenv if it exists
if [ -f venv/bin/activate ]; then
. venv/bin/activate
elif [ -f venv/Scripts/activate ]; then
. venv/Scripts/activate
fi
mongo-orchestration stop
"create expansions":
- command: subprocess.exec
params:
working_dir: mongosql-rs
binary: bash
env:
triggered_by_git_tag: ${triggered_by_git_tag}
args:
- ./evergreen/create-expansions.sh
add_expansions_to_env: true
- command: expansions.update
params:
file: mongosql-rs/expansions.yml
"install rust toolchain":
- command: shell.exec
params:
shell: bash
script: |
${prepare_shell}
# make sure to use msvc toolchain rather than gnu, which is
# the default for cygwin
if [ "Windows_NT" == "$OS" ]; then
export DEFAULT_HOST_OPTIONS='--default-host x86_64-pc-windows-msvc'
fi
# install rustup from scratch
rm -rf ~/.rustup
curl https://sh.rustup.rs -sSf | sh -s -- -y --no-modify-path $DEFAULT_HOST_OPTIONS
# rustup installs into C:\Users\$USER instead of
# C:\home\$USER, so we symlink both .rustup and .cargo
if [ "Windows_NT" == "$OS" ]; then
ln -sf /cygdrive/c/Users/$USER/.rustup/ ~/.rustup
ln -sf /cygdrive/c/Users/$USER/.cargo/ ~/.cargo
fi
"set and check packages version":
- command: shell.exec
type: test
params:
shell: bash
working_dir: mongosql-rs
script: |
${prepare_shell}
#no-op when not triggered by a tag
if [[ "${triggered_by_git_tag}" != "" ]]; then
cargo install cargo-edit
# we only release one project at a time, so setting the version on all Cargo.toml files is safe
cargo set-version $release_version
fi
cargo install cargo-get
# check all of the releasable packages in the monorepo to verify that whichever is being released has the correct version
MONGOSQL_CARGO_PKGS_VERSION=$(cargo get --entry="mongosql/Cargo.toml" package.version)
MONGOSQLTRANSLATE_CARGO_PKGS_VERSION=$(cargo get --entry="mongosqltranslate/Cargo.toml" package.version)
if [[ "${triggered_by_git_tag}" == "" ]]; then
EXPECTED_RELEASE_VERSION="0.0.0"
else
EXPECTED_RELEASE_VERSION="$release_version"
fi
if [[ "$MONGOSQL_CARGO_PKGS_VERSION" != "$EXPECTED_RELEASE_VERSION" || "$MONGOSQLTRANSLATE_CARGO_PKGS_VERSION" != "$EXPECTED_RELEASE_VERSION" ]]; then
>&2 echo "Expected version $EXPECTED_RELEASE_VERSION doesn't match for at least one package ; mongosql version $MONGOSQL_CARGO_PKGS_VERSION, mongosqltranslate version $MONGOSQLTRANSLATE_CARGO_PKGS_VERSION"
exit 1
fi
"check clippy":
- command: shell.exec
type: test
params:
shell: bash
working_dir: mongosql-rs
script: |
${prepare_shell}
cargo clippy --all-targets -- -D warnings
"check gofmt":
- command: shell.exec
type: test
params:
shell: bash
working_dir: mongosql-rs/go
script: |
${prepare_shell}
gofmt -s -d .
"check unused dependencies":
- command: shell.exec
type: test
params:
shell: bash
working_dir: mongosql-rs
script: |
${prepare_shell}
cargo install cargo-machete
cargo build --all-features
set +e
cargo machete
RETURN=$?
set -e
if [ $RETURN -ne 0 ]; then
>&2 echo "Unused dependencies found"
>&2 cargo machete
exit 1
fi
"check goimports":
- command: shell.exec
type: test
params:
shell: bash
working_dir: mongosql-rs/go
script: |
${prepare_shell}
go get golang.org/x/tools/cmd/goimports
if [[ $("$GOPATH/bin/goimports" -l .) ]]; then
echo "some files not formatted according to goimports"
"$GOPATH/bin/goimports" -d -e .
exit 1
else
echo "files all formatted according to goimports"
exit 0
fi
"check go mod tidy":
- command: shell.exec
type: test
params:
shell: bash
working_dir: mongosql-rs/go
script: |
${prepare_shell}
# save original files
cp go.mod go.mod.original
cp go.sum go.sum.original
# tidy files and save tidied versions
go mod tidy
cp go.mod go.mod.tidied
cp go.sum go.sum.tidied
# restore original files
rm go.mod && cp go.mod.original go.mod
rm go.sum && cp go.sum.original go.sum
# fail if tidying changed files
diff go.mod.original go.mod.tidied || exit 1
diff go.sum.original go.sum.tidied || exit 1
"check rustfmt":
- command: shell.exec
type: test
params:
shell: bash
working_dir: mongosql-rs
script: |
${prepare_shell}
rustfmt --check $(find . -not \( -path \./e2e-tests -prune -o -path \./target -prune \) -name \*.rs)
# "mongosql-rs" is the name of the library we release for Atlas SQL.
"compile mongosql-rs":
- command: shell.exec
type: test
retry_on_failure: true
params:
shell: bash
working_dir: mongosql-rs
script: |
${prepare_shell}
cargo build --release --features "mongosql-c/test" --target-dir "test_target"
cargo build --release
# "libmongosqltranslate" is the name of the library we release for on-prem SQL.
"compile libmongosqltranslate":
- command: shell.exec
type: test
retry_on_failure: true
params:
shell: bash
working_dir: mongosql-rs
script: |
${prepare_shell}
cargo build --release
"download c library":
- command: s3.get
params:
build_variants:
["macos", "macos-arm64", "rhel76", "ubuntu1804", "amazon2-arm64"]
aws_key: ${aws_key}
aws_secret: ${aws_secret}
remote_file: mongosql-rs/artifacts/test/${version_id}/${build_variant}/libmongosql.a
local_file: mongosql-rs/libmongosql.a
bucket: mciuploads
- command: s3.get
params:
build_variants: ["windows"]
aws_key: ${aws_key}
aws_secret: ${aws_secret}
remote_file: mongosql-rs/artifacts/test/${version_id}/${build_variant}/mongosql.dll
local_file: mongosql-rs/go/mongosql/mongosql.dll
bucket: mciuploads
"perform release":
- command: s3.get
params:
aws_key: ${aws_key}
aws_secret: ${aws_secret}
remote_file: mongosql-rs/artifacts/${version_id}/macos/libmongosql.a
local_file: mongosql-rs/release/macos/libmongosql.a
bucket: mciuploads
- command: s3.put
params:
aws_key: ${release_aws_key}
aws_secret: ${release_aws_secret}
local_file: mongosql-rs/release/macos/libmongosql.a
remote_file: mongosql-rs/macos/${release_version}/libmongosql.a
bucket: translators-connectors-releases
permissions: public-read
content_type: application/octet-stream
- command: s3.get
params:
aws_key: ${aws_key}
aws_secret: ${aws_secret}
remote_file: mongosql-rs/artifacts/${version_id}/macos-arm64/libmongosql.a
local_file: mongosql-rs/release/macos-arm64/libmongosql.a
bucket: mciuploads
- command: s3.put
params:
aws_key: ${release_aws_key}
aws_secret: ${release_aws_secret}
local_file: mongosql-rs/release/macos-arm64/libmongosql.a
remote_file: mongosql-rs/macos-arm64/${release_version}/libmongosql.a
bucket: translators-connectors-releases
permissions: public-read
content_type: application/octet-stream
- command: s3.get
params:
aws_key: ${aws_key}
aws_secret: ${aws_secret}
remote_file: mongosql-rs/artifacts/${version_id}/rhel76/libmongosql.a
local_file: mongosql-rs/release/rhel76/libmongosql.a
bucket: mciuploads
- command: s3.put
params:
aws_key: ${release_aws_key}
aws_secret: ${release_aws_secret}
local_file: mongosql-rs/release/rhel76/libmongosql.a
remote_file: mongosql-rs/rhel76/${release_version}/libmongosql.a
bucket: translators-connectors-releases
permissions: public-read
content_type: application/octet-stream
- command: s3.get
params:
aws_key: ${aws_key}
aws_secret: ${aws_secret}
remote_file: mongosql-rs/artifacts/${version_id}/ubuntu1804/libmongosql.a
local_file: mongosql-rs/release/ubuntu1804/libmongosql.a
bucket: mciuploads
- command: s3.put
params:
aws_key: ${release_aws_key}
aws_secret: ${release_aws_secret}
local_file: mongosql-rs/release/ubuntu1804/libmongosql.a
remote_file: mongosql-rs/ubuntu1804/${release_version}/libmongosql.a
bucket: translators-connectors-releases
permissions: public-read
content_type: application/octet-stream
- command: s3.get
params:
aws_key: ${aws_key}
aws_secret: ${aws_secret}
remote_file: mongosql-rs/artifacts/${version_id}/amazon2-arm64/libmongosql.a
local_file: mongosql-rs/release/amazon2-arm64/libmongosql.a
bucket: mciuploads
- command: s3.put
params:
aws_key: ${release_aws_key}
aws_secret: ${release_aws_secret}
local_file: mongosql-rs/release/amazon2-arm64/libmongosql.a
remote_file: mongosql-rs/amazon2-arm64/${release_version}/libmongosql.a
bucket: translators-connectors-releases
permissions: public-read
content_type: application/octet-stream
- command: s3.get
params:
aws_key: ${aws_key}
aws_secret: ${aws_secret}
remote_file: mongosql-rs/artifacts/${version_id}/windows/mongosql.dll
local_file: mongosql-rs/release/windows/mongosql.dll
bucket: mciuploads
- command: s3.put
params:
aws_key: ${release_aws_key}
aws_secret: ${release_aws_secret}
local_file: mongosql-rs/release/windows/mongosql.dll
remote_file: mongosql-rs/windows/${release_version}/mongosql.dll
bucket: translators-connectors-releases
permissions: public-read
content_type: application/octet-stream
"run criterion benchmarks":
- command: shell.exec
type: test
params:
shell: bash
working_dir: mongosql-rs
script: |
${prepare_shell}
cargo bench --bench translate
"run criterion profile":
- command: shell.exec
type: test
params:
shell: bash
working_dir: mongosql-rs
script: |
${prepare_shell}
cargo bench --bench translate -- --profile-time 10
"run go tests":
- command: shell.exec
type: test
params:
shell: bash
working_dir: mongosql-rs/go
script: |
${prepare_shell}
export LIBRARY_PATH="$(cd .. && pwd)"
go test -v ./... | tee go-test-results.txt
# Just running the spec tests on RHEL 7.6 for now
# This function should be used to run rust tests that need a running mongod
# Additional flags can be passed in via the calling task
# e.g. cargo_test_flags: "-- --ignored"
"run rust integration tests":
- command: shell.exec
type: test
params:
shell: bash
working_dir: mongosql-rs
script: |
${prepare_shell}
if [[ "${load_data_cmd}" != "" ]]; then
echo "loading data"
eval ${load_data_cmd}
fi
echo ${description}
set +e
cargo test ${cargo_test_flags}
EXITCODE=$?
set -e
exit $EXITCODE
# This function should be used to run rust tests that do not need a running
# mongod instance. Additional flags can be passed in via the calling task.
# e.g. cargo_test_flags: "-- --ignored"
"run rust tests":
- command: shell.exec
type: test
params:
shell: bash
working_dir: mongosql-rs
script: |
${prepare_shell}
echo ${description}
cargo test ${cargo_test_flags}
"run pipeline generator":
- command: shell.exec
type: test
params:
shell: bash
working_dir: mongosql-rs
script: |
${prepare_shell}
cargo run --bin pipeline_generator
"upload c library":
- command: s3.put
params:
build_variants:
["macos", "macos-arm64", "rhel76", "ubuntu1804", "amazon2-arm64"]
aws_key: ${aws_key}
aws_secret: ${aws_secret}
local_file: mongosql-rs/target/release/libmongosql.a
remote_file: mongosql-rs/artifacts/${version_id}/${build_variant}/libmongosql.a
bucket: mciuploads
permissions: public-read
content_type: application/octet-stream
- command: s3.put
params:
build_variants: ["windows"]
aws_key: ${aws_key}
aws_secret: ${aws_secret}
local_file: mongosql-rs/target/release/mongosql.dll
remote_file: mongosql-rs/artifacts/${version_id}/${build_variant}/mongosql.dll
bucket: mciuploads
permissions: public-read
content_type: application/octet-stream
- command: s3.put
params:
build_variants:
["macos", "macos-arm64", "rhel76", "ubuntu1804", "amazon2-arm64"]
aws_key: ${aws_key}
aws_secret: ${aws_secret}
local_file: mongosql-rs/test_target/release/libmongosql.a
remote_file: mongosql-rs/artifacts/test/${version_id}/${build_variant}/libmongosql.a
bucket: mciuploads
permissions: public-read
content_type: application/octet-stream
- command: s3.put
params:
build_variants: ["windows"]
aws_key: ${aws_key}
aws_secret: ${aws_secret}
local_file: mongosql-rs/test_target/release/mongosql.dll
remote_file: mongosql-rs/artifacts/test/${version_id}/${build_variant}/mongosql.dll
bucket: mciuploads
permissions: public-read
content_type: application/octet-stream
"upload criterion artifacts":
- command: s3.put
params:
aws_key: ${aws_key}
aws_secret: ${aws_secret}
local_file: mongosql-rs/target/criterion/translate_simple/profile/flamegraph.svg
remote_file: mongosql-rs/artifacts/test/${version_id}/${build_variant}/criterion/flamegraph_translate_simple.svg
bucket: mciuploads
permissions: public-read
content_type: application/octet-stream
"upload go test results":
- command: gotest.parse_files
type: test
params:
files:
- mongosql-rs/go/go-test-results.txt
"run TPC-H benchmark":
- command: shell.exec
timeout_secs: 86400 # 24 hour timeout for new log entry
type: test
params:
shell: bash
working_dir: mongosql-rs
script: |
${prepare_shell}
benchmark/scripts/run_tpch.sh ${pipeline_dir} ${workload_filename} ${dataset_filename} ${EVERGREEN_SF0_01_LIMIT} ${EVERGREEN_SF0_1_LIMIT}
- command: perf.send
params:
file: ./mongosql-rs/processed-tpch-perf-results.json
- command: s3.put
params:
aws_key: ${aws_key}
aws_secret: ${aws_secret}
local_file: mongosql-rs/tpch.metrics.tgz
remote_file: mongosql-rs/artifacts/${version_id}/${pipeline_dir}/${s3_prefix}.tpch.metrics.tgz
display_name: ${s3_prefix}.tpch.metrics.tgz
bucket: mciuploads
permissions: public-read
content_type: application/octet-stream
"validate TPC-H benchmark":
- command: shell.exec
timeout_secs: 43200 # 12 hour timeout for new log entry
type: test
params:
shell: bash
working_dir: mongosql-rs
script: |
${prepare_shell}
benchmark/scripts/run_tpch.sh ${pipeline_dir} ${workload_filename} ${dataset_filename}
"install heaptrack":
- command: shell.exec
type: test
params:
shell: bash
working_dir: mongosql-rs
script: |
${prepare_shell}
curl -LO https://mongosql-noexpire.s3.us-east-2.amazonaws.com/mem_usage/heaptrack_build.tar.gz
tar -xzvf heaptrack_build.tar.gz
cat <<EOT >> expansions.yml
export PATH="$PATH:$PWD/heaptrack/bin"
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$PWD/heaptrack/lib"
EOT
- command: expansions.update
params:
file: mongosql-rs/expansions.yml
"generate memory usage tasks":
- command: shell.exec
type: test
params:
shell: bash
working_dir: mongosql-rs
script: |
${prepare_shell}
benchmark/scripts/generate_profiler_tasks.sh
# Print generated json for inspection in case of failure
cat generated_profiler_tasks.json
- command: generate.tasks
params:
files:
- generated_profiler_tasks.json
"run memory usage profiler":
- command: shell.exec
type: test
params:
shell: bash
working_dir: mongosql-rs
script: |
${prepare_shell}
cargo build --bin profiler --release
# run_mem_profiler.sh writes three files
# - memory-usage-results.log: Memory usage metrics to upload to S3
# - memory-usage-cedar-data.json: Metrics to use in perf.send command
# - heaptrack.profiler.gz: compressed file of full heaptrack profiling results
benchmark/scripts/run_mem_profiler.sh "target/release/profiler" ${test_file}
cat memory-usage-results.log
- command: s3.put
params:
aws_key: ${aws_key}
aws_secret: ${aws_secret}
local_file: mongosql-rs/memory-usage-results.log
remote_file: mongosql-rs/${version_id}/${build_variant}/${test_file_basename}/memory-usage-results.log
bucket: mciuploads
permissions: public-read
content_type: text/plain
- command: s3.put
params:
aws_key: ${aws_key}
aws_secret: ${aws_secret}
local_file: mongosql-rs/heaptrack.profiler.gz
remote_file: mongosql-rs/${version_id}/${build_variant}/${test_file_basename}/heaptrack.profiler.gz
bucket: mciuploads
permissions: public-read
content_type: application/octet-stream
- command: perf.send
params:
file: ./mongosql-rs/memory-usage-cedar-data.json
- command: shell.exec
type: test
params:
shell: bash
working_dir: mongosql-rs
script: |
${prepare_shell}
echo "Configured RSS memory limit: ${mem_usage_rss_limit}MB"
echo "Configured memory leak limit: ${mem_usage_mem_leak_limit}MB"
rss_peak=$(cat memory-usage-results.log | grep "peak RSS (including heaptrack overhead)" | cut -f2 -d: | tr -d M | tr -d ' ')
mem_leak=$(cat memory-usage-results.log | grep "total memory leaked" | cut -f2 -d: | tr -d M | tr -d ' ')
if (( $(bc <<< "$rss_peak > ${mem_usage_rss_limit}") )) || \
(( $(bc <<< "$mem_leak > ${mem_usage_mem_leak_limit}") )); then
echo "Memory limit exceeded"
echo "Peak RSS memory: $rss_peak"
echo "Memory leaked: $mem_leak"
exit 1
fi
"generate SBOM":
- command: shell.exec
type: test
params:
shell: bash
working_dir: mongosql-rs
script: |
${prepare_shell}
echo ">>>> Install SBOM tool..."
OS=$(uname)
echo "OS=$OS"
ARCH="$(uname -m)"
echo "Arch=$ARCH"
SBOM_FINAL=${project_folder}.full.cdx.json
mkdir $SBOM_DIR
echo "SBOM with vulnerabilities: ./${project_folder}/${project_folder}.cdx.json";
echo "SBOM with license: $SBOM_VULN";
echo "Final SBOM with all information: $SBOM_FINAL"
# Install cargo-cyclonedx
echo "-- Installing cargo-cyclonedx --"
cargo install cargo-cyclonedx
echo "------------------------------------"
# Install Grype
echo "-- Downloading Grype --"
curl -sSfL https://raw.githubusercontent.com/anchore/grype/main/install.sh | sh -s -- -b $SBOM_DIR
echo "------------------------------------"
# Install CycloneDX CLI and JQ
JQ_URL="https://github.com/jqlang/jq/releases/download/jq-1.7.1/jq-linux-amd64"
echo "-- Downloading JQ $JQ_URL --"
curl -L -o $SBOM_DIR/jq "$JQ_URL" \
--silent \
--fail \
--max-time 60 \
--retry 5 \
--retry-delay 0
chmod +x ./$SBOM_DIR/jq
echo "------------------------------------"
echo "<<<< Done installing SBOM tools"
echo ">>>> Generate SBOM..."
echo "-- Generating SBOMs with the licenses information --"
cargo cyclonedx --target all -v -f json
echo "------------------------------------"
echo "-- Generating SBOM with vulnerabilities information --"
echo "./$SBOM_DIR/grype sbom:./${project_folder}/${project_folder}.cdx.json -o cyclonedx-json > $SBOM_VULN"
./$SBOM_DIR/grype sbom:./${project_folder}/${project_folder}.cdx.json -o cyclonedx-json > $SBOM_VULN
echo "------------------------------------"
echo "-- Merging the SBOMs with the licenses information and the SBOM with the vulnerabilities information in $SBOM_FINAL --"
temp_output="temp_output.json"
if [[ -f "$temp_output" ]] ; then
rm "$temp_output"
fi
touch $temp_output
while IFS= read -r line
do
if [[ "$line" == *"purl"* ]]; then
bash_purl=$(echo $line | cut -d '"' -f4)
command=$(echo "./$SBOM_DIR/jq '.components[] | select(.purl == \"$bash_purl\").licenses' ./${project_folder}/${project_folder}.cdx.json")
# Add the license information back in the augmented SBOM.
licenseInfo=$(eval " $command")
if [[ -z "$licenseInfo" ]]; then
echo "\"licenses\" : []," >> $temp_output
else
echo "\"licenses\" : $licenseInfo," >> $temp_output
fi
fi
echo "$line" >> $temp_output
done < $SBOM_VULN
echo "------------------------------------"
echo "-- Adding the name of the team responsible for each dependency as required by Silk and format the json file --"
echo "./$SBOM_DIR/jq '.components[].properties += [{\"name\": \"internal:team_responsible\", \"value\": \"Atlas SQL\"}]' $temp_output > $SBOM_FINAL"
./$SBOM_DIR/jq '.components[].properties += [{"name": "internal:team_responsible", "value": "Atlas SQL"}]' $temp_output > $SBOM_FINAL
echo "------------------------------------"
echo "-- Adding VEX info for vulnerabilities still present in SBOM--"
IFS=','; for vuln_id in $ALLOW_VULNS; do
echo "-- Updating SBOM with VEX info for vulnerability with id $vuln_id--"
export VULN_ID=$vuln_id
echo "jq --argjson vexinfo "$(<resources/ssdlc/$VULN_ID.analysis.json)" '(.vulnerabilities[] | select(.id == $ENV.VULN_ID)).analysis = ($vexinfo) ' $SBOM_FINAL > output.tmp && mv output.tmp $SBOM_FINAL"
jq --argjson vexinfo "$(<resources/ssdlc/$VULN_ID.analysis.json)" '(.vulnerabilities[] | select(.id == $ENV.VULN_ID)).analysis = ($vexinfo) ' $SBOM_FINAL > output.tmp && mv output.tmp $SBOM_FINAL
echo "--------"
done
echo "-----------------------------"
echo "<<<< Done generating SBOM"
- command: s3.put
params:
aws_key: ${aws_key}
aws_secret: ${aws_secret}
local_files_include_filter:
- mongosql-rs/*.cdx.json
remote_file: mongosql-rs/artifacts/${version_id}/ssdlc/${project_folder}/
content_type: text/plain
bucket: mciuploads
permissions: public-read
"scan SBOM":
- command: shell.exec
type: test
params:
shell: bash
working_dir: mongosql-rs
script: |
${prepare_shell}
echo ">>>> Scan SBOM for vulnerabilities..."
if [[ "$ALLOW_VULNS" != "" ]]; then
echo "Vulnerability ids to ignore : $ALLOW_VULNS"
echo "-- Generate .grype.yaml specifying vulnerabilities to ignore --"
GRYPE_CONF_FILE=".grype.yaml"
touch $GRYPE_CONF_FILE
echo "ignore:" > $GRYPE_CONF_FILE
IFS=','; for VULN_ID in $ALLOW_VULNS; do
echo "Ignoring vulnerability with id $VULN_ID"
echo " - vulnerability: $VULN_ID" >> $GRYPE_CONF_FILE
done
echo "------------------------------------"
fi
echo "-- Scanning dependency for vulnerabilities --"
./$SBOM_DIR/grype sbom:./${project_folder}/${project_folder}.cdx.json --fail-on low
echo "---------------------------------------------"
echo "<<<< Done scanning SBOM"
"generate static code analysis":
- command: shell.exec
type: test
params:
shell: bash
working_dir: mongosql-rs
script: |
${prepare_shell}
export SEMGREP_APP_TOKEN=${semgrep_app_token}
echo "Running static code analysis with Semgrep..."
# Setup or use the existing virtualenv for semgrep
if [[ -f "venv/bin/activate" ]]; then
echo 'using existing virtualenv'
. venv/bin/activate
else
echo 'Creating new virtualenv'
python3 -m virtualenv venv
echo 'Activating new virtualenv'
. venv/bin/activate
fi
python3 -m pip install semgrep
# Confirm semgrep version
semgrep --version
set +e
timestamp=$(date +'%Y-%m-%dT%H_%M_%S')
semgrep --config p/rust --metrics=off --sarif --exclude "benchmark" --verbose --error --severity=ERROR --sarif-output=mongosqltranslate_$timestamp.sast.sarif > mongosqltranslate_$timestamp.sast.cmd.verbose.out 2>&1
SCAN_RESULT=$?
set -e
# Exit with a failure if the scan found an issue
exit $SCAN_RESULT
- command: s3.put
params:
aws_key: ${aws_key}
aws_secret: ${aws_secret}
local_files_include_filter:
- mongosqltranslate*.sast.*
remote_file: mongosql-rs/artifacts/${version_id}/ssdlc/
content_type: text/plain
bucket: mciuploads
permissions: public-read
tasks:
- name: clippy
commands:
- func: "install rust toolchain"
- func: "check clippy"
- name: rustfmt
commands:
- func: "install rust toolchain"
- func: "check rustfmt"
- name: unused-dependencies
commands:
- func: "install rust toolchain"
- func: "check unused dependencies"
- name: gofmt
commands:
- func: "check gofmt"
- name: goimports
commands:
- func: "check goimports"
- name: gomodtidy
commands:
- func: "check go mod tidy"
- name: compile
commands:
- func: "install rust toolchain"
- func: "set and check packages version"
- func: "compile mongosql-rs"
- func: "upload c library"
- name: test-go
commands:
- func: "install rust toolchain"
- func: "compile mongosql-rs"
- func: "upload c library"
- func: "download c library"
- func: "run go tests"
- func: "upload go test results"
- name: test-pipeline-generate
commands:
- func: "install rust toolchain"
- func: "run pipeline generator"
- name: test-rust
commands:
- func: "install rust toolchain"
- func: "run rust tests"
vars:
description: "run rust unit tests"
cargo_test_flags: >-
-- --skip fuzz_test
- name: test-rust-fuzz
tags: ["fuzz"]
commands:
- func: "install rust toolchain"
- func: "run rust tests"
retry_on_failure: true
vars:
description: "run rust fuzz tests"
cargo_test_flags: >-
fuzz_test
- name: test-spec-rewrite-and-type-constraints
commands:
- func: "install rust toolchain"
- func: "run rust tests"
vars:
description: "run rewrite and type constraint spec tests"
cargo_test_flags: >-
-- --ignored
- name: release
git_tag_only: true
depends_on:
- name: compile
variant: "*"
commands:
- func: "perform release"
- name: criterion
commands:
- func: "install rust toolchain"
- func: "run criterion benchmarks"
- func: "run criterion profile"
- func: "upload criterion artifacts"
- name: tpch-0.001-normalized-atlas-sql
depends_on:
- name: tpch-0.001-normalized-validation
allow_for_git_tag: false
disable: false
commands:
- func: "bootstrap mongo-orchestration"
vars:
MONGODB_VERSION: 8.0
TOPOLOGY: server
- func: "install rust toolchain"
- func: "run TPC-H benchmark"
vars:
dataset_filename: "tpch-0.001-normalized-indexed.archive.gz"
pipeline_dir: atlas_sql/normalized
workload_filename: "workload_norm_sf0.001.yml"
s3_prefix: "SF0.001"
- name: tpch-0.001-denormalized-atlas-sql
depends_on:
- name: tpch-0.001-denormalized-validation
allow_for_git_tag: false
disable: true
commands:
- func: "bootstrap mongo-orchestration"
vars:
MONGODB_VERSION: 8.0
TOPOLOGY: server
- func: "install rust toolchain"
- func: "run TPC-H benchmark"
vars:
dataset_filename: "tpch-0.001-denormalized-indexed.archive.gz"
pipeline_dir: atlas_sql/denormalized
workload_filename: "workload_denorm_sf0.001.yml"
s3_prefix: "SF0.001"
- name: tpch-0.01-normalized-atlas-sql
depends_on:
- name: tpch-0.001-normalized-validation
allow_for_git_tag: false
disable: false
commands:
- func: "bootstrap mongo-orchestration"
vars:
MONGODB_VERSION: 8.0
TOPOLOGY: server
- func: "install rust toolchain"
- func: "run TPC-H benchmark"
vars:
dataset_filename: "tpch-0.01-normalized-indexed.archive.gz"
pipeline_dir: atlas_sql/normalized
workload_filename: "workload_norm_sf0.01.yml"
s3_prefix: "SF0.01"
- name: tpch-0.01-denormalized-atlas-sql
depends_on:
- name: tpch-0.001-denormalized-validation
allow_for_git_tag: false
disable: true
commands:
- func: "bootstrap mongo-orchestration"
vars:
MONGODB_VERSION: 8.0