Skip to content

Commit 02fc85f

Browse files
authored
PYTHON-5239 Audit bash scripts for consistency (#2238)
1 parent 9ff5a17 commit 02fc85f

23 files changed

+72
-64
lines changed

.evergreen/combine-coverage.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
# Coverage combine merges (and removes) all the coverage files and
44
# generates a new .coverage file in the current directory.
55

6-
set -o xtrace # Write all commands first to stderr
7-
set -o errexit # Exit the script with error if any of the commands fail
6+
set -eu
87

98
. .evergreen/utils.sh
109

.evergreen/resync-specs.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
2-
# exit when any command fails
3-
set -e
2+
# Resync test files from the specifications repo.
3+
set -eu
44
PYMONGO=$(dirname "$(cd "$(dirname "$0")"; pwd)")
55
SPECS=${MDB_SPECS:-~/Work/specifications}
66

.evergreen/run-import-time-test.sh

Lines changed: 0 additions & 33 deletions
This file was deleted.

.evergreen/run-mongodb-aws-ecs-test.sh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#!/bin/bash
2-
3-
# Don't trace since the URI contains a password that shouldn't show up in the logs
4-
set -o errexit # Exit the script with error if any of the commands fail
2+
# Script run on an ECS host to test MONGODB-AWS.
3+
set -eu
54

65
############################################
76
# Main Program #

.evergreen/run-mongodb-oidc-test.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#!/bin/bash
2-
3-
set +x # Disable debug trace
2+
# Script run on a remote host to test MONGODB-OIDC.
43
set -eu
54

65
echo "Running MONGODB-OIDC authentication tests on ${OIDC_ENV}..."

.evergreen/run-tests.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/bin/bash
2+
# Run a test suite that was configured with setup-tests.sh.
23
set -eu
34

45
SCRIPT_DIR=$(dirname ${BASH_SOURCE:-$0})
Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,43 @@
11
#!/bin/bash
2+
# Check for regressions in the import time of pymongo.
3+
set -eu
24

3-
. .evergreen/scripts/env.sh
4-
set -x
5-
export BASE_SHA="$1"
6-
export HEAD_SHA="$2"
7-
bash .evergreen/run-import-time-test.sh
5+
HERE=$(dirname ${BASH_SOURCE:-$0})
6+
7+
source $HERE/env.sh
8+
9+
pushd $HERE/../.. >/dev/null
10+
11+
BASE_SHA="$1"
12+
HEAD_SHA="$2"
13+
14+
. .evergreen/utils.sh
15+
16+
if [ -z "${PYTHON_BINARY:-}" ]; then
17+
PYTHON_BINARY=$(find_python3)
18+
fi
19+
20+
# Use the previous commit if this was not a PR run.
21+
if [ "$BASE_SHA" == "$HEAD_SHA" ]; then
22+
BASE_SHA=$(git rev-parse HEAD~1)
23+
fi
24+
25+
function get_import_time() {
26+
local log_file
27+
createvirtualenv "$PYTHON_BINARY" import-venv
28+
python -m pip install -q ".[aws,encryption,gssapi,ocsp,snappy,zstd]"
29+
# Import once to cache modules
30+
python -c "import pymongo"
31+
log_file="pymongo-$1.log"
32+
python -X importtime -c "import pymongo" 2> $log_file
33+
}
34+
35+
get_import_time $HEAD_SHA
36+
git stash || true
37+
git checkout $BASE_SHA
38+
get_import_time $BASE_SHA
39+
git checkout $HEAD_SHA
40+
git stash apply || true
41+
python tools/compare_import_time.py $HEAD_SHA $BASE_SHA
42+
43+
popd >/dev/null

.evergreen/scripts/cleanup.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#!/bin/bash
2+
# Clean up resources at the end of an evergreen run.
3+
set -eu
24

35
HERE=$(dirname ${BASH_SOURCE:-$0})
46

@@ -9,4 +11,4 @@ if [ -f $HERE/env.sh ]; then
911
fi
1012

1113
rm -rf "${DRIVERS_TOOLS}" || true
12-
rm -f ./secrets-export.sh || true
14+
rm -f $HERE/../../secrets-export.sh || true

.evergreen/scripts/configure-env.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/bash
2-
2+
# Configure an evergreen test environment.
33
set -eu
44

55
# Get the current unique version of this checkout
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/bin/bash
2-
32
# Download all the task coverage files.
3+
set -eu
44
aws s3 cp --recursive s3://"$1"/coverage/"$2"/"$3"/coverage/ coverage/

0 commit comments

Comments
 (0)