-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtest.sh
executable file
·40 lines (40 loc) · 1.62 KB
/
test.sh
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
#!/bin/bash
set -eo pipefail
# variables
. ./.cicd/helpers/general.sh
# tests
if [[ $(uname) == 'Darwin' ]]; then # macOS
export PATH=$PATH:~/mongodb/bin
set +e # defer error handling to end
./"$@"
EXIT_STATUS=$?
else # Linux
COMMANDS="$MOUNTED_DIR/$@"
. $HELPERS_DIR/file-hash.sh $CICD_DIR/platforms/$PLATFORM_TYPE/$IMAGE_TAG.dockerfile
echo "$ docker run --rm --init -v $(pwd):$MOUNTED_DIR $(buildkite-intrinsics) -e JOBS -e BUILDKITE_API_KEY $FULL_TAG bash -c \"$COMMANDS\""
set +e # defer error handling to end
eval docker run --rm --init -v $(pwd):$MOUNTED_DIR $(buildkite-intrinsics) -e JOBS -e BUILDKITE_API_KEY $FULL_TAG bash -c \"$COMMANDS\"
EXIT_STATUS=$?
fi
# buildkite
if [[ "$BUILDKITE" == 'true' ]]; then
cd build
# upload artifacts
echo '+++ :arrow_up: Uploading Artifacts'
echo 'Compressing core dumps...'
[[ $((`ls -1 core.* 2>/dev/null | wc -l`)) != 0 ]] && tar czf core.tar.gz core.* || : # collect core dumps
echo 'Exporting xUnit XML'
mv -f ./Testing/$(ls ./Testing/ | grep '2' | tail -n 1)/Test.xml test-results.xml
echo 'Uploading artifacts'
[[ -f config.ini ]] && buildkite-agent artifact upload config.ini
[[ -f core.tar.gz ]] && buildkite-agent artifact upload core.tar.gz
[[ -f genesis.json ]] && buildkite-agent artifact upload genesis.json
[[ -f mongod.log ]] && buildkite-agent artifact upload mongod.log
buildkite-agent artifact upload test-results.xml
echo 'Done uploading artifacts.'
fi
# re-throw
if [[ "$EXIT_STATUS" != 0 ]]; then
echo "Failing due to non-zero exit status from ctest: $EXIT_STATUS"
exit $EXIT_STATUS
fi