Skip to content

PYTHON-4706 Allow running pytest directly without hatch #1824

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 8 commits into from
Sep 6, 2024
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
9 changes: 8 additions & 1 deletion .evergreen/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,7 @@ functions:
SSL=${SSL} \
TEST_DATA_LAKE=${TEST_DATA_LAKE} \
MONGODB_API_VERSION=${MONGODB_API_VERSION} \
SKIP_HATCH=${SKIP_HATCH} \
bash ${PROJECT_DIRECTORY}/.evergreen/hatch.sh test:test-eg

"run enterprise auth tests":
Expand Down Expand Up @@ -561,7 +562,9 @@ functions:
working_dir: "src"
script: |
. .evergreen/scripts/env.sh
. .evergreen/hatch.sh encryption:teardown
if [ -f $DRIVERS_TOOLS/.evergreen/csfle/secrets-export.sh ]; then
. .evergreen/hatch.sh encryption:teardown
fi
rm -rf ${DRIVERS_TOOLS} || true
rm -f ./secrets-export.sh || true

Expand Down Expand Up @@ -2083,10 +2086,14 @@ axes:
display_name: "RHEL 8.3 (zSeries)"
run_on: rhel83-zseries-small
batchtime: 10080 # 7 days
variables:
SKIP_HATCH: true
- id: rhel81-power8
display_name: "RHEL 8.1 (POWER8)"
run_on: rhel81-power8-small
batchtime: 10080 # 7 days
variables:
SKIP_HATCH: true
- id: rhel82-arm64
display_name: "RHEL 8.2 (ARM64)"
run_on: rhel82-arm64-small
Expand Down
12 changes: 11 additions & 1 deletion .evergreen/hatch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,17 @@ if [ -z "$PYTHON_BINARY" ]; then
PYTHON_BINARY=$(find_python3)
fi

if $PYTHON_BINARY -m hatch --version; then
# Check if we should skip hatch and run the tests directly.
if [ -n "$SKIP_HATCH" ]; then
ENV_NAME=testenv-$RANDOM
createvirtualenv "$PYTHON_BINARY" $ENV_NAME
# shellcheck disable=SC2064
trap "deactivate; rm -rf $ENV_NAME" EXIT HUP
python -m pip install -e ".[test]"
run_hatch() {
bash ./.evergreen/run-tests.sh
}
elif $PYTHON_BINARY -m hatch --version; then
run_hatch() {
$PYTHON_BINARY -m hatch run "$@"
}
Expand Down
Loading