Skip to content

Commit edb65e1

Browse files
authored
RUST-1283 Build docs in read-only directory and install cargo and rustup in project directory on Evergreen (#656)
* build docs in read-only directory * install cargo and rustup in project dir on Evg * check clippy and rustdoc with all available features
1 parent 5d2f876 commit edb65e1

24 files changed

+99
-55
lines changed

.evergreen/check-all.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/sh
1+
#!/bin/bash
22

33
set -o errexit
44

.evergreen/check-clippy.sh

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
#!/bin/sh
1+
#!/bin/bash
22

33
set -o errexit
44

5-
. ~/.cargo/env
5+
source ./.evergreen/configure-rust.sh
66
# Pin clippy to the lastest version. This should be updated when new versions of Rust are released.
77
rustup default 1.59.0
8-
cargo clippy --all-targets -p mongodb -- -D warnings
9-
# check clippy with compressors separately
10-
cargo clippy --all-targets -p mongodb --features zstd-compression,snappy-compression,zlib-compression -- -D warnings
11-
cargo clippy --all-targets --no-default-features --features async-std-runtime -p mongodb -- -D warnings
12-
cargo clippy --all-targets --no-default-features --features sync -p mongodb -- -D warnings
13-
cargo clippy --all-targets --features tokio-sync -p mongodb -- -D warnings
8+
9+
source ./.evergreen/feature-combinations.sh
10+
11+
for ((i = 0; i < ${#FEATURE_COMBINATIONS[@]}; i++)); do
12+
cargo clippy --all-targets ${FEATURE_COMBINATIONS[$i]} -p mongodb -- -D warnings
13+
done

.evergreen/check-rustdoc.sh

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,27 @@
1-
#!/bin/sh
1+
#!/bin/bash
22

33
set -o errexit
44

5-
. ~/.cargo/env
6-
cargo +nightly rustdoc -- -D warnings --cfg docsrs
7-
cargo +nightly rustdoc --no-default-features --features async-std-runtime -- -D warnings --cfg docsrs
8-
cargo +nightly rustdoc --no-default-features --features sync -- -D warnings --cfg docsrs
9-
cargo +nightly rustdoc --features tokio-sync -- -D warnings --cfg docsrs
5+
source ./.evergreen/configure-rust.sh
6+
7+
# docs.rs builds the driver on a read-only file system. to create a more realistic environment, we first
8+
# build the driver to ensure we have all the deps already in src, and then limit the permissions on that directory
9+
# and rebuild the docs.
10+
# this is to help us avoid introducing problems like those described here
11+
# https://docs.rs/about/builds#read-only-directories where we or a dependency modify source code during the
12+
# build process.
13+
14+
source ./.evergreen/feature-combinations.sh
15+
16+
# build with all available features to ensure all optional dependencies are brought in too.
17+
for ((i = 0; i < ${#FEATURE_COMBINATIONS[@]}; i++)); do
18+
cargo +nightly build ${FEATURE_COMBINATIONS[$i]}
19+
done
20+
cargo clean
21+
22+
chmod -R 555 ${CARGO_HOME}/registry/src
23+
24+
for ((i = 0; i < ${#FEATURE_COMBINATIONS[@]}; i++)); do
25+
cargo +nightly rustdoc ${FEATURE_COMBINATIONS[$i]} -- -D warnings --cfg docsrs
26+
done
27+

.evergreen/check-rustfmt.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33
set -o errexit
44

5-
. ~/.cargo/env
5+
source ./.evergreen/configure-rust.sh
66
rustfmt +nightly --unstable-features --check src/**/*.rs
77
rustfmt +nightly --unstable-features --check src/*.rs
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
#!/bin/sh
1+
#!/bin/bash
22

33
set -o errexit
44

5-
. ~/.cargo/env
5+
source ./.evergreen/configure-rust.sh
66

77
rustup run $RUST_VERSION cargo build --no-default-features --features async-std-runtime
88
rustup run $RUST_VERSION cargo build --no-default-features --features sync

.evergreen/compile-only-tokio.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
#!/bin/sh
1+
#!/bin/bash
22

33
set -o errexit
44

5-
. ~/.cargo/env
5+
source ./.evergreen/configure-rust.sh
66

77
# Enable snappy, zlib unconditionally
88
FEATURE_FLAGS=snappy-compression,zlib-compression

.evergreen/compile-only.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
#!/bin/sh
1+
#!/bin/bash
22

33
set -o errexit
44

5-
. ~/.cargo/env
5+
source ./.evergreen/configure-rust.sh
66
rustup update $RUST_VERSION
77

88
if [ "$ASYNC_RUNTIME" = "tokio" ]; then

.evergreen/config.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,7 @@ functions:
252252
- command: shell.exec
253253
type: test
254254
params:
255+
shell: bash
255256
working_dir: "src"
256257
script: |
257258
${PREPARE_SHELL}
@@ -265,7 +266,7 @@ functions:
265266
266267
# compile mini test project
267268
cd $PROJECT_DIRECTORY/.evergreen/aws-ecs-test
268-
. ~/.cargo/env
269+
. ${PROJECT_DIRECTORY}/.evergreen/configure-rust.sh
269270
cargo build
270271
cd -
271272
@@ -431,6 +432,7 @@ functions:
431432
export MONGO_ATLAS_TLS11_URI_SRV='${MONGO_ATLAS_TLS11_URI_SRV}'
432433
export MONGO_ATLAS_TLS12_URI='${MONGO_ATLAS_TLS12_URI}'
433434
export MONGO_ATLAS_TLS12_URI_SRV='${MONGO_ATLAS_TLS12_URI_SRV}'
435+
export PROJECT_DIRECTORY='${PROJECT_DIRECTORY}'
434436
ASYNC_RUNTIME=${ASYNC_RUNTIME} .evergreen/run-atlas-tests.sh
435437
436438
"run ocsp test":
@@ -617,7 +619,6 @@ functions:
617619
params:
618620
script: |
619621
${PREPARE_SHELL}
620-
rm -rf ~/.rustup
621622
rm -rf $DRIVERS_TOOLS || true
622623
623624
"fix absolute paths":

.evergreen/configure-rust.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
3+
export RUSTUP_HOME="${PROJECT_DIRECTORY}/.rustup"
4+
export PATH="${RUSTUP_HOME}/bin:$PATH"
5+
export CARGO_HOME="${PROJECT_DIRECTORY}/.cargo"
6+
export PATH="${CARGO_HOME}/bin:$PATH"
7+
8+
if [[ "Windows_NT" == "$OS" ]]; then
9+
# rustup/cargo need the native Windows paths; $PROJECT_DIRECTORY is a cygwin path
10+
export RUSTUP_HOME=$(cygpath ${RUSTUP_HOME} --windows)
11+
export CARGO_HOME=$(cygpath ${CARGO_HOME} --windows)
12+
fi
13+
14+
. ${CARGO_HOME}/env

.evergreen/env.sh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
#!/bin/bash
22

3-
export PATH="/opt/mongodbtoolchain/v2/bin:$PATH"
4-
5-
source ~/.cargo/env
3+
source ./.evergreen/configure-rust.sh
64

75
NODE_ARTIFACTS_PATH="${PROJECT_DIRECTORY}/node-artifacts"
86
export NVM_DIR="${NODE_ARTIFACTS_PATH}/nvm"

0 commit comments

Comments
 (0)