PYTHON-5239 Audit bash scripts for consistency (#2238)

This commit is contained in:
Steven Silvester 2025-03-31 19:27:56 -05:00 committed by GitHub
parent 9ff5a1755c
commit 02fc85f635
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
23 changed files with 72 additions and 64 deletions

View File

@ -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

View File

@ -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}

View File

@ -1,33 +0,0 @@
#!/bin/bash -ex
set -o errexit # Exit the script with error if any of the commands fail
set -x
. .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

View File

@ -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 #

View File

@ -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}..."

View File

@ -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})

View File

@ -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

View File

@ -1,4 +1,6 @@
#!/bin/bash
# Clean up resources at the end of an evergreen run.
set -eu
HERE=$(dirname ${BASH_SOURCE:-$0})
@ -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

View File

@ -1,5 +1,5 @@
#!/bin/bash
# Configure an evergreen test environment.
set -eu
# Get the current unique version of this checkout

View File

@ -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/

View File

@ -1,5 +1,5 @@
#!/bin/bash
# Install the dependencies needed for an evergreen run.
set -eu
HERE=$(dirname ${BASH_SOURCE:-$0})

View File

@ -1,4 +0,0 @@
#!/bin/bash
set -o xtrace
PYTHON_BINARY=${PYTHON_BINARY} bash "${PROJECT_DIRECTORY}"/.evergreen/just.sh docs-test

View File

@ -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
@ -20,3 +23,4 @@ ls -la /usr/local/Cellar/ || true
scan-build --version || true
genhtml --version || true
valgrind --version || true
set +x

View File

@ -1,5 +1,5 @@
#!/bin/bash
# Set up a development environment on an evergreen host.
set -eu
HERE=$(dirname ${BASH_SOURCE:-$0})

View File

@ -1,5 +1,5 @@
#!/bin/bash
# Set up the system on an evergreen host.
set -eu
HERE=$(dirname ${BASH_SOURCE:-$0})

View File

@ -1,4 +1,5 @@
#!/bin/bash
# Set up the test environment, including secrets and services.
set -eu
# Supported/used environment variables:

View File

@ -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})

View File

@ -1,4 +1,5 @@
#!/bin/bash
# Tear down any services that were used by tests.
set -eu
SCRIPT_DIR=$(dirname ${BASH_SOURCE:-$0})

View File

@ -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

View File

@ -1,5 +1,5 @@
#!/bin/bash
# Set up a remote evergreen spawn host.
set -eu
if [ -z "$1" ]

View File

@ -1,4 +1,6 @@
#!/bin/bash
# Synchronize local files to a remote Evergreen spawn host.
set -eu
if [ -z "$1" ]
then

View File

@ -1,5 +1,5 @@
#!/bin/bash
# Utility functions used by pymongo evergreen scripts.
set -eu
find_python3() {

View File

@ -1,5 +1,5 @@
#!/bin/bash
# Keep the synchronous folders in sync with there async counterparts.
set -eu
python ./tools/synchro.py "$@"