Skip to content

Commit b7e15ba

Browse files
authored
RUST-1075 Upload xunit test results in evergreen (#501)
1 parent b9fcfa4 commit b7e15ba

File tree

7 files changed

+173
-13
lines changed

7 files changed

+173
-13
lines changed

.evergreen/config.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -626,6 +626,11 @@ functions:
626626
${PREPARE_SHELL}
627627
${DRIVERS_TOOLS}/.evergreen/run-load-balancer.sh stop
628628
629+
"upload test results":
630+
- command: attach.xunit_results
631+
params:
632+
file: src/results.xml
633+
629634
pre:
630635
- func: "fetch source"
631636
- func: "prepare resources"
@@ -638,6 +643,7 @@ pre:
638643
post:
639644
- func: "stop load balancer"
640645
- func: "stop mongo orchestration"
646+
- func: "upload test results"
641647
- func: "upload-mo-artifacts"
642648
- func: "cleanup"
643649

.evergreen/env.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/bash
2+
3+
export PATH="/opt/mongodbtoolchain/v2/bin:$PATH"
4+
5+
source ~/.cargo/env
6+
7+
NODE_ARTIFACTS_PATH="${PROJECT_DIRECTORY}/node-artifacts"
8+
export NVM_DIR="${NODE_ARTIFACTS_PATH}/nvm"
9+
10+
if [[ "$OS" == "Windows_NT" ]]; then
11+
NVM_HOME=$(cygpath -w "$NVM_DIR")
12+
export NVM_HOME
13+
NVM_SYMLINK=$(cygpath -w "$NODE_ARTIFACTS_PATH/bin")
14+
export NVM_SYMLINK
15+
NVM_ARTIFACTS_PATH=$(cygpath -w "$NODE_ARTIFACTS_PATH/bin")
16+
export NVM_ARTIFACTS_PATH
17+
PATH=$(cygpath $NVM_SYMLINK):$(cygpath $NVM_HOME):$PATH
18+
export PATH
19+
echo "updated path on windows PATH=$PATH"
20+
else
21+
[ -s "$NVM_DIR/nvm.sh" ] && source "$NVM_DIR/nvm.sh"
22+
fi

.evergreen/install-dependencies.sh

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

33
# Make sure to use msvc toolchain rather than gnu, which is the default for cygwin
44
if [ "Windows_NT" == "$OS" ]; then
@@ -19,7 +19,19 @@ echo 'export PATH=$PATH:~/.cargo/bin' >> ~/.cargo/env
1919

2020
echo "export CARGO_NET_GIT_FETCH_WITH_CLI=true" >> ~/.cargo/env
2121

22-
. ~/.cargo/env
22+
source ~/.cargo/env
2323

2424
# Install nightly rustfmt
2525
rustup toolchain install nightly -c rustfmt
26+
27+
# Install tool for converting cargo test output to junit
28+
cargo install cargo2junit
29+
30+
# install npm/node
31+
./.evergreen/install-node.sh
32+
33+
source ./.evergreen/env.sh
34+
35+
# Install tool for merging different junit reports into a single one
36+
npm install -g junit-report-merger
37+

.evergreen/install-node.sh

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
#!/bin/bash
2+
set -o errexit # Exit the script with error if any of the commands fail
3+
4+
NVM_WINDOWS_URL="https://github.com/coreybutler/nvm-windows/releases/download/1.1.7/nvm-noinstall.zip"
5+
NVM_URL="https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh"
6+
7+
NODE_LTS_NAME=${NODE_LTS_NAME:-erbium}
8+
MSVS_VERSION=${MSVS_VERSION:-2019}
9+
NODE_ARTIFACTS_PATH="${PROJECT_DIRECTORY}/node-artifacts"
10+
NPM_CACHE_DIR="${NODE_ARTIFACTS_PATH}/npm"
11+
NPM_TMP_DIR="${NODE_ARTIFACTS_PATH}/tmp"
12+
13+
# this needs to be explicitly exported for the nvm install below
14+
export NVM_DIR="${NODE_ARTIFACTS_PATH}/nvm"
15+
export XDG_CONFIG_HOME=${NODE_ARTIFACTS_PATH}
16+
17+
# create node artifacts path if needed
18+
mkdir -p ${NODE_ARTIFACTS_PATH}
19+
mkdir -p ${NPM_CACHE_DIR}
20+
mkdir -p "${NPM_TMP_DIR}"
21+
22+
case $NODE_LTS_NAME in
23+
"argon")
24+
VERSION=4
25+
;;
26+
"boron")
27+
VERSION=6
28+
;;
29+
"carbon")
30+
VERSION=8
31+
;;
32+
"dubnium")
33+
VERSION=10
34+
;;
35+
"erbium")
36+
VERSION=12
37+
;;
38+
"fermium")
39+
VERSION=14
40+
;;
41+
"gallium")
42+
VERSION=16
43+
;;
44+
"hydrogen")
45+
VERSION=18
46+
;;
47+
"iron")
48+
VERSION=20
49+
;;
50+
*)
51+
echo "Unsupported Node LTS version $1"
52+
exit 1
53+
;;
54+
esac
55+
56+
NODE_VERSION=$(curl --retry 8 --retry-delay 5 --max-time 50 --silent -o- https://nodejs.org/download/release/latest-v${VERSION}.x/SHASUMS256.txt | head -n 1 | awk '{print $2};' | cut -d- -f2)
57+
export NODE_VERSION=${NODE_VERSION:1} # :1 gets rid of the leading 'v'
58+
59+
# output node version to expansions file for use in subsequent scripts
60+
cat <<EOT > deps-expansion.yml
61+
NODE_VERSION: "$NODE_VERSION"
62+
EOT
63+
64+
# install Node.js on Windows
65+
if [[ "$OS" == "Windows_NT" ]]; then
66+
# Delete pre-existing node to avoid version conflicts
67+
rm -rf "/cygdrive/c/Program Files/nodejs"
68+
69+
70+
NVM_HOME=$(cygpath -w "$NVM_DIR")
71+
export NVM_HOME
72+
NVM_SYMLINK=$(cygpath -w "$NODE_ARTIFACTS_PATH/bin")
73+
export NVM_SYMLINK
74+
NVM_ARTIFACTS_PATH=$(cygpath -w "$NODE_ARTIFACTS_PATH/bin")
75+
export NVM_ARTIFACTS_PATH
76+
PATH=$(cygpath $NVM_SYMLINK):$(cygpath $NVM_HOME):$PATH
77+
export PATH
78+
79+
curl -L $NVM_WINDOWS_URL -o nvm.zip
80+
unzip -d "$NVM_DIR" nvm.zip
81+
rm nvm.zip
82+
83+
chmod 777 "$NVM_DIR"
84+
chmod -R a+rx "$NVM_DIR"
85+
86+
cat <<EOT > "$NVM_DIR/settings.txt"
87+
root: $NVM_HOME
88+
path: $NVM_SYMLINK
89+
EOT
90+
nvm install "$NODE_VERSION"
91+
nvm use "$NODE_VERSION"
92+
which node || echo "node not found, PATH=$PATH"
93+
which npm || echo "npm not found, PATH=$PATH"
94+
npm config set msvs_version ${MSVS_VERSION}
95+
npm config set scripts-prepend-node-path true
96+
97+
# install Node.js on Linux/MacOS
98+
else
99+
curl -o- $NVM_URL | bash
100+
[ -s "${NVM_DIR}/nvm.sh" ] && \. "${NVM_DIR}/nvm.sh"
101+
nvm install --no-progress "$NODE_VERSION"
102+
103+
# setup npm cache in a local directory
104+
cat <<EOT > .npmrc
105+
devdir=${NPM_CACHE_DIR}/.node-gyp
106+
init-module=${NPM_CACHE_DIR}/.npm-init.js
107+
cache=${NPM_CACHE_DIR}
108+
tmp=${NPM_TMP_DIR}
109+
EOT
110+
fi

.evergreen/run-async-std-tests.sh

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

33
set -o errexit
44

5-
. ~/.cargo/env
5+
source ./.evergreen/env.sh
6+
7+
OPTIONS="-- -Z unstable-options --format json --report-time"
68

79
if [ "$SINGLE_THREAD" = true ]; then
8-
OPTIONS="-- --test-threads=1"
10+
OPTIONS="$OPTIONS --test-threads=1"
911
fi
1012

1113
echo "cargo test options: ${OPTIONS}"
1214

13-
RUST_BACKTRACE=1 cargo test --no-default-features --features async-std-runtime $OPTIONS
14-
RUST_BACKTRACE=1 cargo test sync --no-default-features --features sync $OPTIONS
15-
RUST_BACKTRACE=1 cargo test --doc sync --no-default-features --features sync $OPTIONS
15+
RUST_BACKTRACE=1 cargo test --no-default-features --features async-std-runtime $OPTIONS | tee async-tests.json
16+
cat async-tests.json | cargo2junit > async-tests.xml
17+
RUST_BACKTRACE=1 cargo test sync --no-default-features --features sync $OPTIONS | tee sync-tests.json
18+
cat sync-tests.json | cargo2junit > sync-tests.xml
19+
RUST_BACKTRACE=1 cargo test --doc sync --no-default-features --features sync $OPTIONS | tee sync-doc-tests.json
20+
cat sync-doc-tests.json | cargo2junit > sync-doc-tests.xml
21+
22+
junit-report-merger results.xml async-tests.xml sync-tests.xml sync-doc-tests.xml

.evergreen/run-tests.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/run-tokio-tests.sh

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
1-
#!/bin/sh
1+
#!/bin/bash
22

33
set -o errexit
44

5-
. ~/.cargo/env
5+
source ./.evergreen/env.sh
6+
7+
OPTIONS="-- -Z unstable-options --format json --report-time"
68

79
if [ "$SINGLE_THREAD" = true ]; then
8-
OPTIONS="-- --test-threads=1"
10+
OPTIONS="$OPTIONS --test-threads=1"
911
fi
1012

1113
FEATURE_FLAGS="zstd-compression,snappy-compression,zlib-compression"
1214

1315
echo "cargo test options: --features $FEATURE_FLAGS ${OPTIONS}"
1416

15-
RUST_BACKTRACE=1 cargo test --features $FEATURE_FLAGS $OPTIONS
17+
RUST_BACKTRACE=1 cargo test --features $FEATURE_FLAGS $OPTIONS | tee results.json
18+
cat results.json | cargo2junit > results.xml

0 commit comments

Comments
 (0)