Skip to content

PYTHON-5239 Audit bash scripts for consistency #2238

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .evergreen/combine-coverage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
# Coverage combine merges (and removes) all the coverage files and
# generates a new .coverage file in the current directory.

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

. .evergreen/utils.sh

Expand Down
4 changes: 2 additions & 2 deletions .evergreen/resync-specs.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash
# exit when any command fails
set -e
# Resync test files from the specifications repo.
set -eu
PYMONGO=$(dirname "$(cd "$(dirname "$0")"; pwd)")
SPECS=${MDB_SPECS:-~/Work/specifications}

Expand Down
33 changes: 0 additions & 33 deletions .evergreen/run-import-time-test.sh

This file was deleted.

5 changes: 2 additions & 3 deletions .evergreen/run-mongodb-aws-ecs-test.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#!/bin/bash

# Don't trace since the URI contains a password that shouldn't show up in the logs
set -o errexit # Exit the script with error if any of the commands fail
# Script run on an ECS host to test MONGODB-AWS.
set -eu

############################################
# Main Program #
Expand Down
3 changes: 1 addition & 2 deletions .evergreen/run-mongodb-oidc-test.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/bin/bash

set +x # Disable debug trace
# Script run on a remote host to test MONGODB-OIDC.
set -eu

echo "Running MONGODB-OIDC authentication tests on ${OIDC_ENV}..."
Expand Down
1 change: 1 addition & 0 deletions .evergreen/run-tests.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash
# Run a test suite that was configured with setup-tests.sh.
set -eu

SCRIPT_DIR=$(dirname ${BASH_SOURCE:-$0})
Expand Down
46 changes: 41 additions & 5 deletions .evergreen/scripts/check-import-time.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,43 @@
#!/bin/bash
# Check for regressions in the import time of pymongo.
set -eu

. .evergreen/scripts/env.sh
set -x
export BASE_SHA="$1"
export HEAD_SHA="$2"
bash .evergreen/run-import-time-test.sh
HERE=$(dirname ${BASH_SOURCE:-$0})

source $HERE/env.sh

pushd $HERE/../.. >/dev/null

BASE_SHA="$1"
HEAD_SHA="$2"

. .evergreen/utils.sh

if [ -z "${PYTHON_BINARY:-}" ]; then
PYTHON_BINARY=$(find_python3)
fi

# Use the previous commit if this was not a PR run.
if [ "$BASE_SHA" == "$HEAD_SHA" ]; then
BASE_SHA=$(git rev-parse HEAD~1)
fi

function get_import_time() {
local log_file
createvirtualenv "$PYTHON_BINARY" import-venv
python -m pip install -q ".[aws,encryption,gssapi,ocsp,snappy,zstd]"
# Import once to cache modules
python -c "import pymongo"
log_file="pymongo-$1.log"
python -X importtime -c "import pymongo" 2> $log_file
}

get_import_time $HEAD_SHA
git stash || true
git checkout $BASE_SHA
get_import_time $BASE_SHA
git checkout $HEAD_SHA
git stash apply || true
python tools/compare_import_time.py $HEAD_SHA $BASE_SHA

popd >/dev/null
4 changes: 3 additions & 1 deletion .evergreen/scripts/cleanup.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/bin/bash
# Clean up resources at the end of an evergreen run.
set -eu

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

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

rm -rf "${DRIVERS_TOOLS}" || true
rm -f ./secrets-export.sh || true
rm -f $HERE/../../secrets-export.sh || true
2 changes: 1 addition & 1 deletion .evergreen/scripts/configure-env.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash

# Configure an evergreen test environment.
set -eu

# Get the current unique version of this checkout
Expand Down
2 changes: 1 addition & 1 deletion .evergreen/scripts/download-and-merge-coverage.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash

# Download all the task coverage files.
set -eu
aws s3 cp --recursive s3://"$1"/coverage/"$2"/"$3"/coverage/ coverage/
2 changes: 1 addition & 1 deletion .evergreen/scripts/install-dependencies.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash

# Install the dependencies needed for an evergreen run.
set -eu

HERE=$(dirname ${BASH_SOURCE:-$0})
Expand Down
4 changes: 0 additions & 4 deletions .evergreen/scripts/run-doctests.sh

This file was deleted.

8 changes: 6 additions & 2 deletions .evergreen/scripts/run-getdata.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
#!/bin/bash
# Get the debug data for an evergreen task.
set -eu

set -o xtrace
. ${DRIVERS_TOOLS}/.evergreen/download-mongodb.sh || true
. ${DRIVERS_TOOLS}/.evergreen/get-distro.sh || true
get_distro || true
echo $DISTRO
echo $MARCH
echo $OS

set -x
uname -a || true
ls /etc/*release* || true
cc --version || true
Expand All @@ -20,3 +23,4 @@ ls -la /usr/local/Cellar/ || true
scan-build --version || true
genhtml --version || true
valgrind --version || true
set +x
2 changes: 1 addition & 1 deletion .evergreen/scripts/setup-dev-env.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash

# Set up a development environment on an evergreen host.
set -eu

HERE=$(dirname ${BASH_SOURCE:-$0})
Expand Down
2 changes: 1 addition & 1 deletion .evergreen/scripts/setup-system.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash

# Set up the system on an evergreen host.
set -eu

HERE=$(dirname ${BASH_SOURCE:-$0})
Expand Down
1 change: 1 addition & 0 deletions .evergreen/scripts/setup-tests.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash
# Set up the test environment, including secrets and services.
set -eu

# Supported/used environment variables:
Expand Down
2 changes: 1 addition & 1 deletion .evergreen/scripts/stop-server.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash

# Stop a server that was started using run-orchestration.sh in DRIVERS_TOOLS.
set -eu

HERE=$(dirname ${BASH_SOURCE:-$0})
Expand Down
1 change: 1 addition & 0 deletions .evergreen/scripts/teardown-tests.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash
# Tear down any services that were used by tests.
set -eu

SCRIPT_DIR=$(dirname ${BASH_SOURCE:-$0})
Expand Down
3 changes: 2 additions & 1 deletion .evergreen/scripts/upload-coverage-report.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/bin/bash

# Upload a coverate report to s3.
set -eu
aws s3 cp htmlcov/ s3://"$1"/coverage/"$2"/"$3"/htmlcov/ --recursive --acl public-read --region us-east-1
2 changes: 1 addition & 1 deletion .evergreen/setup-spawn-host.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash

# Set up a remote evergreen spawn host.
set -eu

if [ -z "$1" ]
Expand Down
2 changes: 2 additions & 0 deletions .evergreen/sync-spawn-host.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/bin/bash
# Synchronize local files to a remote Evergreen spawn host.
set -eu

if [ -z "$1" ]
then
Expand Down
2 changes: 1 addition & 1 deletion .evergreen/utils.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash

# Utility functions used by pymongo evergreen scripts.
set -eu

find_python3() {
Expand Down
2 changes: 1 addition & 1 deletion tools/synchro.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash

# Keep the synchronous folders in sync with there async counterparts.
set -eu

python ./tools/synchro.py "$@"
Expand Down
Loading