Skip to content
Open
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
12 changes: 1 addition & 11 deletions .evergreen/run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,10 @@ else
exit 1
fi

cleanup_tests() {
# Avoid leaving the lock file in a changed state when we change the resolution type.
if [ -n "${TEST_MIN_DEPS:-}" ]; then
git checkout uv.lock || true
fi
cd $PREV_DIR
}

trap "cleanup_tests" SIGINT ERR

# Start the test runner.
echo "Running tests with UV_PYTHON=${UV_PYTHON:-}..."
echo "UV_ARGS=${UV_ARGS}"
uv run ${UV_ARGS} --reinstall-package pymongo .evergreen/scripts/run_tests.py "$@"
echo "Running tests with UV_PYTHON=${UV_PYTHON:-}... done."

cleanup_tests
cd $PREV_DIR
4 changes: 4 additions & 0 deletions .evergreen/scripts/configure-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ UV_TOOL_DIR=$PROJECT_DIRECTORY/.local/uv/tools
UV_CACHE_DIR=$PROJECT_DIRECTORY/.local/uv/cache
DRIVERS_TOOLS_BINARIES="$DRIVERS_TOOLS/.bin"
MONGODB_BINARIES="$DRIVERS_TOOLS/mongodb/bin"
# GNU date on Linux and Windows, BSD date on macOS.
UV_EXCLUDE_NEWER="$(date -u -d '7 days ago' +%Y-%m-%d 2>/dev/null || date -u -v-7d +%Y-%m-%d)"

# On Evergreen jobs, "CI" will be set, and we don't want to write to $HOME.
if [ "${CI:-}" == "true" ]; then
Expand Down Expand Up @@ -65,6 +67,8 @@ export CARGO_HOME="$CARGO_HOME"
export UV_TOOL_DIR="$UV_TOOL_DIR"
export UV_CACHE_DIR="$UV_CACHE_DIR"
export UV_TOOL_BIN_DIR="$DRIVERS_TOOLS_BINARIES"
export UV_NO_LOCK=1
export UV_EXCLUDE_NEWER="$UV_EXCLUDE_NEWER"
export PYMONGO_BIN_DIR="$PYMONGO_BIN_DIR"
export PATH="$PATH_EXT"
# shellcheck disable=SC2154
Expand Down
18 changes: 18 additions & 0 deletions .github/actions/set-uv-exclude-newer/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Set UV_EXCLUDE_NEWER
description: >-
Export UV_EXCLUDE_NEWER as 7 days before the current UTC date so uv
resolution ignores packages published in the last week.
runs:
using: composite
steps:
- name: Set UV_EXCLUDE_NEWER
shell: bash
run: |
set -euo pipefail
# GNU date on Linux and Windows, BSD date on macOS.
value="$(date -u -d '7 days ago' +%Y-%m-%d 2>/dev/null || date -u -v-7d +%Y-%m-%d)"
if [ -z "$value" ]; then
echo "Failed to compute UV_EXCLUDE_NEWER" >&2
exit 1
fi
echo "UV_EXCLUDE_NEWER=$value" >> "$GITHUB_ENV"
11 changes: 11 additions & 0 deletions .github/workflows/test-python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ defaults:
permissions:
contents: read

env:
UV_NO_LOCK: "1"

jobs:

static:
Expand All @@ -25,6 +28,7 @@ jobs:
- uses: actions/checkout@v6.0.3
with:
persist-credentials: false
- uses: ./.github/actions/set-uv-exclude-newer
- name: Install uv
uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0
with:
Expand Down Expand Up @@ -70,6 +74,7 @@ jobs:
- uses: actions/checkout@v6.0.3
with:
persist-credentials: false
- uses: ./.github/actions/set-uv-exclude-newer
- name: Install uv
uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0
with:
Expand All @@ -92,6 +97,7 @@ jobs:
- uses: actions/checkout@v6.0.3
with:
persist-credentials: false
- uses: ./.github/actions/set-uv-exclude-newer
- name: Install uv
uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0
with:
Expand Down Expand Up @@ -120,6 +126,7 @@ jobs:
- uses: actions/checkout@v6.0.3
with:
persist-credentials: false
- uses: ./.github/actions/set-uv-exclude-newer
- name: Install uv
uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0
with:
Expand All @@ -145,6 +152,7 @@ jobs:
- uses: actions/checkout@v6.0.3
with:
persist-credentials: false
- uses: ./.github/actions/set-uv-exclude-newer
- name: Install uv
uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0
with:
Expand All @@ -167,6 +175,7 @@ jobs:
- uses: actions/checkout@v6.0.3
with:
persist-credentials: false
- uses: ./.github/actions/set-uv-exclude-newer
- name: Install uv
uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0
with:
Expand All @@ -188,6 +197,7 @@ jobs:
- uses: actions/checkout@v6.0.3
with:
persist-credentials: false
- uses: ./.github/actions/set-uv-exclude-newer
- name: Install uv
uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0
with:
Expand Down Expand Up @@ -278,6 +288,7 @@ jobs:
- uses: actions/checkout@v6.0.3
with:
persist-credentials: false
- uses: ./.github/actions/set-uv-exclude-newer
- name: Install uv
uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0
with:
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,6 @@ xunit-results/
coverage.xml
server.log
.coverage

# uv lockfiles
uv.lock
11 changes: 0 additions & 11 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,3 @@ repos:
language: python
require_serial: true
additional_dependencies: ["shrub.py>=3.10.0", "pyyaml>=6.0.2"]

- id: uv-lock
name: uv-lock
entry: uv lock
language: python
require_serial: true
files: ^(uv\.lock|pyproject\.toml|requirements.txt|requirements/.*\.txt)$
pass_filenames: false
fail_fast: true
additional_dependencies:
- "uv>=0.8.4"
5 changes: 1 addition & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,4 @@ From the spawn host or Ubuntu image, do the following:
## Dependabot updates

Dependabot will raise PRs at most once per week, grouped by GitHub Actions updates and Python requirement
file updates. We have a pre-commit hook that will update the `uv.lock` file when requirements change.
To update the lock file on a failing PR, you can use a method like `gh pr checkout <pr number>`, then run
`just lint uv-lock` to update the lock file, and then push the changes. If a typing dependency has changed,
also run `just typing` and handle any new findings.
file updates. If a typing dependency has changed, run `just typing` and handle any new findings.
6 changes: 6 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# See https://just.systems/man/en/ for instructions
set shell := ["bash", "-c"]

# Don't let `uv` create or read uv.lock.
export UV_NO_LOCK := "1"
# Match CI's resolution window so local installs agree.
# GNU date on Linux and Windows, BSD date on macOS.
export UV_EXCLUDE_NEWER := `date -u -d '7 days ago' +%Y-%m-%d 2>/dev/null || date -u -v-7d +%Y-%m-%d`

# Commonly used command segments.
typing_run := "uv run --group typing --extra aws --extra encryption --with numpy --extra ocsp --extra snappy --extra test --extra zstd"
docs_run := "uv run --extra docs"
Expand Down
Loading
Loading