Skip to content

Commit 8a0ffd5

Browse files
kkloberdanzvector-of-boolrcsanchez97kevinAlbs
authored
Auto download C Driver (#967)
CXX-2695 - Auto download the C driver if it is not already installed. - Make auto downloading the C driver the default for CI. - Libmongocrypt is not yet supported for auto downloading, so use the classic method of installing the C driver separately for tasks that require libmongocrypt. --------- Co-authored-by: vector-of-bool <[email protected]> Co-authored-by: Roberto C. Sánchez <[email protected]> Co-authored-by: Kevin Albertson <[email protected]>
1 parent 35ee078 commit 8a0ffd5

File tree

9 files changed

+245
-155
lines changed

9 files changed

+245
-155
lines changed

.mci.yml

Lines changed: 73 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,18 @@ functions:
283283
add_expansions_to_env: true
284284
script: mongo-cxx-driver/.evergreen/install_c_driver.sh
285285

286+
# fetch_c_driver_source may be used to fetch the C driver source without installing the C driver.
287+
# This can be used when only CI scripts are needed.
288+
"fetch_c_driver_source":
289+
- command: shell.exec
290+
params:
291+
shell: bash
292+
working_dir: "."
293+
script: |
294+
set -o errexit
295+
set -o pipefail
296+
git clone --depth 1 https://github.com/mongodb/mongo-c-driver mongoc
297+
286298
"lint":
287299
- command: shell.exec
288300
params:
@@ -832,45 +844,49 @@ tasks:
832844
- name: clang-tidy
833845
commands:
834846
- func: "setup"
835-
- func: "install_c_driver"
847+
- func: "fetch_c_driver_source"
836848
- func: "compile"
837849
- func: "clang-tidy"
838850

839851
- name: compile_and_test_with_shared_libs
840852
commands:
841853
- func: "setup"
842854
- func: "start_mongod"
843-
- func: "install_c_driver"
855+
- func: "fetch_c_driver_source"
844856
- func: "compile"
845857
vars:
846858
RUN_DISTCHECK: 1
847859
- func: "clone_drivers-evergreen-tools"
848860
- func: "run_kms_servers"
861+
# Call "install_c_driver" before "test" to build static C driver libraries. Example projects require static C driver libraries.
862+
- func: "install_c_driver"
849863
- func: "test"
850864

851865
- name: compile_and_test_with_shared_libs_extra_alignment
852866
commands:
853867
- func: "setup"
854868
- func: "start_mongod"
855-
- func: "install_c_driver"
869+
- func: "fetch_c_driver_source"
856870
vars:
857871
BSON_EXTRA_ALIGNMENT: 1
858872
- func: "compile"
859873
- func: "clone_drivers-evergreen-tools"
860874
- func: "run_kms_servers"
875+
- func: "install_c_driver"
861876
- func: "test"
862877

863878
- name: compile_and_test_with_shared_libs_cxx20
864879
commands:
865880
- func: "setup"
866881
- func: "start_mongod"
867-
- func: "install_c_driver"
882+
- func: "fetch_c_driver_source"
868883
- func: "compile"
869884
vars:
870885
RUN_DISTCHECK: 1
871886
REQUIRED_CXX_STANDARD: 20
872887
- func: "clone_drivers-evergreen-tools"
873888
- func: "run_kms_servers"
889+
- func: "install_c_driver"
874890
- func: "test"
875891
vars:
876892
REQUIRED_CXX_STANDARD: 20
@@ -880,14 +896,15 @@ tasks:
880896
commands:
881897
- func: "setup"
882898
- func: "start_mongod"
883-
- func: "install_c_driver"
899+
- func: "fetch_c_driver_source"
884900
vars:
885901
BSON_EXTRA_ALIGNMENT: 1
886902
- func: "compile"
887903
vars:
888904
REQUIRED_CXX_STANDARD: 20
889905
- func: "clone_drivers-evergreen-tools"
890906
- func: "run_kms_servers"
907+
- func: "install_c_driver"
891908
- func: "test"
892909
vars:
893910
REQUIRED_CXX_STANDARD: 20
@@ -897,13 +914,13 @@ tasks:
897914
commands:
898915
- func: "setup"
899916
- func: "start_mongod"
900-
- func: "install_c_driver"
917+
- func: "fetch_c_driver_source"
901918
- func: "compile"
902919

903920
- name: compile_without_tests
904921
commands:
905922
- func: "setup"
906-
- func: "install_c_driver"
923+
- func: "fetch_c_driver_source"
907924
- func: "compile"
908925
vars:
909926
ENABLE_TESTS: OFF
@@ -914,7 +931,7 @@ tasks:
914931
- func: "start_mongod"
915932
vars:
916933
AUTH: auth
917-
- func: "install_c_driver"
934+
- func: "fetch_c_driver_source"
918935
- func: "compile"
919936
- func: "test auth"
920937
- func: "test atlas connectivity"
@@ -923,13 +940,14 @@ tasks:
923940
commands:
924941
- func: "setup"
925942
- func: "start_mongod"
926-
- func: "install_c_driver"
943+
- func: "fetch_c_driver_source"
927944
- func: "compile"
928945
vars:
929946
USE_STATIC_LIBS: 1
930947
RUN_DISTCHECK: 1
931948
- func: "clone_drivers-evergreen-tools"
932949
- func: "run_kms_servers"
950+
- func: "install_c_driver"
933951
- func: "test"
934952
vars:
935953
USE_STATIC_LIBS: 1
@@ -938,19 +956,39 @@ tasks:
938956
commands:
939957
- func: "setup"
940958
- func: "start_mongod"
941-
- func: "install_c_driver"
959+
- func: "fetch_c_driver_source"
942960
vars:
943961
BSON_EXTRA_ALIGNMENT: 1
944962
- func: "compile"
945963
vars:
946964
USE_STATIC_LIBS: 1
947965
- func: "clone_drivers-evergreen-tools"
948966
- func: "run_kms_servers"
967+
- func: "install_c_driver"
949968
- func: "test"
950969
vars:
951970
USE_STATIC_LIBS: 1
952971

953972
- name: compile_and_test_with_shared_libs_replica_set
973+
commands:
974+
- func: "setup"
975+
- func: "start_mongod"
976+
vars:
977+
TOPOLOGY: "replica_set"
978+
- func: "fetch_c_driver_source"
979+
- func: "compile"
980+
vars:
981+
RUN_DISTCHECK: 1
982+
- func: "clone_drivers-evergreen-tools"
983+
- func: "run_kms_servers"
984+
- func: "install_c_driver"
985+
- func: "test"
986+
987+
# Auto downloading the C driver in the C++ build does not currently include
988+
# support for libmongocrypt, therefore it is not configured with
989+
# -DENABLE_CLIENT_SIDE_ENCRYPTION=ON. For now, CSFLE tests will need to have
990+
# a manually configured C driver, hence the need to seperate this task.
991+
- name: compile_and_test_with_shared_libs_replica_set_with_libmongocrypt
954992
commands:
955993
- func: "setup"
956994
- func: "start_mongod"
@@ -967,7 +1005,7 @@ tasks:
9671005
- name: uninstall_check
9681006
commands:
9691007
- func: "setup"
970-
- func: "install_c_driver"
1008+
- func: "fetch_c_driver_source"
9711009
- func: "compile"
9721010
- command: expansions.update
9731011
params:
@@ -987,7 +1025,7 @@ tasks:
9871025
- name: uninstall_check_windows
9881026
commands:
9891027
- func: "setup"
990-
- func: "install_c_driver"
1028+
- func: "fetch_c_driver_source"
9911029
- func: "compile"
9921030
- command: expansions.update
9931031
params:
@@ -1023,7 +1061,7 @@ tasks:
10231061
export CMAKE="$(find_cmake_latest)"
10241062
cd build
10251063
$CMAKE ..
1026-
$CMAKE --build . -- -j 8
1064+
$CMAKE --build . -- -j $(nproc)
10271065
./hello_mongocxx
10281066
10291067
- name: debian-package-build
@@ -1098,7 +1136,7 @@ tasks:
10981136
- name: test_mongohouse
10991137
commands:
11001138
- func: "setup"
1101-
- func: "install_c_driver"
1139+
- func: "fetch_c_driver_source"
11021140
- func: "compile"
11031141
- func: "build_mongohouse"
11041142
- func: "run_mongohouse"
@@ -1113,7 +1151,7 @@ tasks:
11131151
# Authentication with versioned API should already be tested
11141152
# in the C driver.
11151153
AUTH: noauth
1116-
- func: "install_c_driver"
1154+
- func: "fetch_c_driver_source"
11171155
- func: "compile"
11181156
- func: "clone_drivers-evergreen-tools"
11191157
- func: "run_kms_servers"
@@ -1128,7 +1166,7 @@ tasks:
11281166
vars:
11291167
ORCHESTRATION_FILE: versioned-api-testing.json
11301168
AUTH: noauth
1131-
- func: "install_c_driver"
1169+
- func: "fetch_c_driver_source"
11321170
- func: "compile"
11331171
- func: "clone_drivers-evergreen-tools"
11341172
- func: "run_kms_servers"
@@ -1220,7 +1258,7 @@ buildvariants:
12201258
matrix_spec: {os: "ubuntu-1804", mongodb_version: "*"}
12211259
display_name: "${os} replica set (MongoDB ${mongodb_version})"
12221260
tasks:
1223-
- name: compile_and_test_with_shared_libs_replica_set
1261+
- name: compile_and_test_with_shared_libs_replica_set_with_libmongocrypt
12241262

12251263
- matrix_name: "auth"
12261264
matrix_spec: {os: "*", mongodb_version: "latest"}
@@ -1265,7 +1303,7 @@ buildvariants:
12651303
- name: compile_and_test_with_shared_libs_extra_alignment_cxx20
12661304
- name: compile_and_test_with_static_libs
12671305
- name: compile_and_test_with_static_libs_extra_alignment
1268-
- name: compile_and_test_with_shared_libs_replica_set
1306+
- name: compile_and_test_with_shared_libs_replica_set_with_libmongocrypt
12691307
- name: build_example_with_add_subdirectory
12701308
distros:
12711309
- rhel90-large
@@ -1288,7 +1326,7 @@ buildvariants:
12881326
- name: compile_and_test_with_shared_libs_extra_alignment_cxx20
12891327
- name: compile_and_test_with_static_libs
12901328
- name: compile_and_test_with_static_libs_extra_alignment
1291-
- name: compile_and_test_with_shared_libs_replica_set
1329+
- name: compile_and_test_with_shared_libs_replica_set_with_libmongocrypt
12921330
- name: build_example_with_add_subdirectory
12931331
distros:
12941332
- rhel90-arm64-large
@@ -1310,7 +1348,7 @@ buildvariants:
13101348
- name: compile_and_test_with_shared_libs_extra_alignment_cxx20
13111349
- name: compile_and_test_with_static_libs
13121350
- name: compile_and_test_with_static_libs_extra_alignment
1313-
- name: compile_and_test_with_shared_libs_replica_set
1351+
- name: compile_and_test_with_shared_libs_replica_set_with_libmongocrypt
13141352
- name: build_example_with_add_subdirectory
13151353
distros:
13161354
- debian11-large
@@ -1354,7 +1392,7 @@ buildvariants:
13541392
- name: compile_and_test_with_shared_libs_extra_alignment
13551393
- name: compile_and_test_with_static_libs
13561394
- name: compile_and_test_with_static_libs_extra_alignment
1357-
- name: compile_and_test_with_shared_libs_replica_set
1395+
- name: compile_and_test_with_shared_libs_replica_set_with_libmongocrypt
13581396
- name: build_example_with_add_subdirectory
13591397
distros:
13601398
- debian10-large
@@ -1381,6 +1419,18 @@ buildvariants:
13811419
- debian10-large
13821420
- name: uninstall_check
13831421

1422+
# Add matrix for specification test requirement of mongocryptd:
1423+
# "Drivers MUST run all tests with mongocryptd on at least one platform for all tested server versions (4.2+)."
1424+
- matrix_name: "mongocryptd"
1425+
matrix_spec:
1426+
os: "ubuntu-1804"
1427+
mongodb_version: ["4.2", "4.4", "5.0", "latest"]
1428+
display_name: "${os} (MongoDB ${mongodb_version}) with mongocryptd"
1429+
tasks:
1430+
- name: compile_and_test_with_shared_libs_replica_set_with_libmongocrypt
1431+
expansions:
1432+
use_mongocryptd: true
1433+
13841434
- name: ubuntu2004-release-latest
13851435
display_name: "Ubuntu 20.04 Release (MongoDB Latest)"
13861436
expansions:
@@ -1396,7 +1446,7 @@ buildvariants:
13961446
- name: compile_and_test_with_shared_libs_extra_alignment
13971447
- name: compile_and_test_with_static_libs
13981448
- name: compile_and_test_with_static_libs_extra_alignment
1399-
- name: compile_and_test_with_shared_libs_replica_set
1449+
- name: compile_and_test_with_shared_libs_replica_set_with_libmongocrypt
14001450
- name: build_example_with_add_subdirectory
14011451
distros:
14021452
- ubuntu2004-large
@@ -1439,7 +1489,7 @@ buildvariants:
14391489
- name: compile_and_test_with_shared_libs_extra_alignment
14401490
- name: compile_and_test_with_static_libs
14411491
- name: compile_and_test_with_static_libs_extra_alignment
1442-
- name: compile_and_test_with_shared_libs_replica_set
1492+
- name: compile_and_test_with_shared_libs_replica_set_with_libmongocrypt
14431493
- name: build_example_with_add_subdirectory
14441494
distros:
14451495
- ubuntu1804-build

0 commit comments

Comments
 (0)