Skip to content

Commit 71668be

Browse files
Merge remote-tracking branch 'upstream/main' into harden-array-of-documents-oob
# Conflicts: # doc/changelog.rst
2 parents 776d885 + a54a062 commit 71668be

68 files changed

Lines changed: 2090 additions & 4359 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.evergreen/run-tests.sh

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,10 @@ else
2626
exit 1
2727
fi
2828

29-
cleanup_tests() {
30-
# Avoid leaving the lock file in a changed state when we change the resolution type.
31-
if [ -n "${TEST_MIN_DEPS:-}" ]; then
32-
git checkout uv.lock || true
33-
fi
34-
cd $PREV_DIR
35-
}
36-
37-
trap "cleanup_tests" SIGINT ERR
38-
3929
# Start the test runner.
4030
echo "Running tests with UV_PYTHON=${UV_PYTHON:-}..."
4131
echo "UV_ARGS=${UV_ARGS}"
4232
uv run ${UV_ARGS} --reinstall-package pymongo .evergreen/scripts/run_tests.py "$@"
4333
echo "Running tests with UV_PYTHON=${UV_PYTHON:-}... done."
4434

45-
cleanup_tests
35+
cd $PREV_DIR

.evergreen/scripts/configure-env.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ UV_TOOL_DIR=$PROJECT_DIRECTORY/.local/uv/tools
1818
UV_CACHE_DIR=$PROJECT_DIRECTORY/.local/uv/cache
1919
DRIVERS_TOOLS_BINARIES="$DRIVERS_TOOLS/.bin"
2020
MONGODB_BINARIES="$DRIVERS_TOOLS/mongodb/bin"
21+
# GNU date on Linux and Windows, BSD date on macOS.
22+
UV_EXCLUDE_NEWER="$(date -u -d '7 days ago' +%Y-%m-%d 2>/dev/null || date -u -v-7d +%Y-%m-%d)"
23+
if [ -z "$UV_EXCLUDE_NEWER" ]; then
24+
echo "Failed to compute UV_EXCLUDE_NEWER" >&2
25+
exit 1
26+
fi
2127

2228
# On Evergreen jobs, "CI" will be set, and we don't want to write to $HOME.
2329
if [ "${CI:-}" == "true" ]; then
@@ -65,6 +71,8 @@ export CARGO_HOME="$CARGO_HOME"
6571
export UV_TOOL_DIR="$UV_TOOL_DIR"
6672
export UV_CACHE_DIR="$UV_CACHE_DIR"
6773
export UV_TOOL_BIN_DIR="$DRIVERS_TOOLS_BINARIES"
74+
export UV_NO_LOCK=1
75+
export UV_EXCLUDE_NEWER="$UV_EXCLUDE_NEWER"
6876
export PYMONGO_BIN_DIR="$PYMONGO_BIN_DIR"
6977
export PATH="$PATH_EXT"
7078
# shellcheck disable=SC2154
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Set UV_EXCLUDE_NEWER
2+
description: >-
3+
Export UV_EXCLUDE_NEWER as 7 days before the current UTC date so uv
4+
resolution ignores packages published in the last week.
5+
runs:
6+
using: composite
7+
steps:
8+
- name: Set UV_EXCLUDE_NEWER
9+
shell: bash
10+
run: |
11+
set -euo pipefail
12+
# GNU date on Linux and Windows, BSD date on macOS.
13+
value="$(date -u -d '7 days ago' +%Y-%m-%d 2>/dev/null || date -u -v-7d +%Y-%m-%d)"
14+
if [ -z "$value" ]; then
15+
echo "Failed to compute UV_EXCLUDE_NEWER" >&2
16+
exit 1
17+
fi
18+
echo "UV_EXCLUDE_NEWER=$value" >> "$GITHUB_ENV"

.github/pull_request_template.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<!-- Thanks for contributing! -->
22
<!-- Please ensure that the title of the PR is in the following form:
3-
[JIRA TICKET]: Issue Title
3+
PYTHON-XXXX Issue Title
44
55
If you are an external contributor and there is no JIRA ticket associated with your change, then use your best judgement
66
for the PR title. A MongoDB employee will create a JIRA ticket and edit the name and links as appropriate.
@@ -9,7 +9,9 @@ Note on AI Contributions:
99
We only accept pull requests that are authored and submitted by human contributors who fully understand the changes they are proposing.
1010
All contributions must be written and understood by human contributors. Please read about our policy in our contributing guide.
1111
-->
12-
[JIRA TICKET]
12+
<!-- Replace XXXX with the ticket number. If you do not have a ticket (external contributors), you may leave PYTHON-XXXX;
13+
a MongoDB employee will create a JIRA ticket and update the PR title/links as appropriate. -->
14+
PYTHON-XXXX
1315

1416
## Changes in this PR
1517
<!-- What changes did you make to the code? What new APIs (public or private) were added, removed, or edited to generate

.github/workflows/codeql.yml

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ jobs:
2323
runs-on: "ubuntu-latest"
2424
timeout-minutes: 360
2525
permissions:
26-
# required for all workflows
2726
security-events: write
2827

2928
strategy:
@@ -32,37 +31,20 @@ jobs:
3231
include:
3332
- language: c-cpp
3433
build-mode: manual
34+
manual-build-command: pip install -e .
3535
- language: python
3636
build-mode: none
3737
- language: actions
3838
build-mode: none
3939
steps:
40-
- name: Checkout repository
41-
uses: actions/checkout@v7.0.0
40+
- uses: mongodb-labs/drivers-github-tools/codeql@95f9ce909bf0e44707fffdb92c18ed86e74aa2fd # v3
4241
with:
43-
ref: ${{ inputs.ref }}
44-
persist-credentials: false
45-
- uses: actions/setup-python@v6
46-
47-
# Initializes the CodeQL tools for scanning.
48-
- name: Initialize CodeQL
49-
uses: github/codeql-action/init@8aad20d150bbac5944a9f9d289da16a4b0d87c1e # v4
50-
with:
51-
languages: ${{ matrix.language }}
42+
language: ${{ matrix.language }}
5243
build-mode: ${{ matrix.build-mode }}
53-
# For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
54-
queries: security-extended
44+
manual-build-command: ${{ matrix.manual-build-command }}
45+
ref: ${{ inputs.ref }}
5546
config: |
5647
paths-ignore:
5748
- 'doc/**'
5849
- 'tools/**'
5950
- 'test/**'
60-
61-
- if: matrix.build-mode == 'manual'
62-
run: |
63-
pip install -e .
64-
65-
- name: Perform CodeQL Analysis
66-
uses: github/codeql-action/analyze@8aad20d150bbac5944a9f9d289da16a4b0d87c1e # v4
67-
with:
68-
category: "/language:${{matrix.language}}"

.github/workflows/release-python.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,6 @@ jobs:
7979
with:
8080
name: all-dist-${{ github.run_id }}
8181
path: dist/
82-
- name: Publish package distributions to TestPyPI
83-
uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b # release/v1
84-
with:
85-
repository-url: https://test.pypi.org/legacy/
86-
skip-existing: true
87-
attestations: ${{ env.DRY_RUN }}
8882
- name: Publish package distributions to PyPI
8983
if: startsWith(env.DRY_RUN, 'false')
9084
uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b # release/v1

.github/workflows/test-python.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ defaults:
1717
permissions:
1818
contents: read
1919

20+
env:
21+
UV_NO_LOCK: "1"
22+
2023
jobs:
2124

2225
static:
@@ -25,6 +28,7 @@ jobs:
2528
- uses: actions/checkout@v7.0.0
2629
with:
2730
persist-credentials: false
31+
- uses: ./.github/actions/set-uv-exclude-newer
2832
- name: Install uv
2933
uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0
3034
with:
@@ -49,6 +53,13 @@ jobs:
4953
- name: Run synchro smoke test
5054
run: |
5155
uv run --extra test --with unasync pytest tools/test_synchro.py -v --override-ini="addopts="
56+
- name: Validate pyproject.toml
57+
run: |
58+
uvx --from 'validate-pyproject[all]' validate-pyproject pyproject.toml
59+
- name: Check package metadata
60+
run: |
61+
uv build
62+
uvx twine check --strict dist/*
5263
- run: |
5364
sudo apt-get install -y cppcheck
5465
- run: |
@@ -70,6 +81,7 @@ jobs:
7081
- uses: actions/checkout@v7.0.0
7182
with:
7283
persist-credentials: false
84+
- uses: ./.github/actions/set-uv-exclude-newer
7385
- name: Install uv
7486
uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0
7587
with:
@@ -92,6 +104,7 @@ jobs:
92104
- uses: actions/checkout@v7.0.0
93105
with:
94106
persist-credentials: false
107+
- uses: ./.github/actions/set-uv-exclude-newer
95108
- name: Install uv
96109
uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0
97110
with:
@@ -120,6 +133,7 @@ jobs:
120133
- uses: actions/checkout@v7.0.0
121134
with:
122135
persist-credentials: false
136+
- uses: ./.github/actions/set-uv-exclude-newer
123137
- name: Install uv
124138
uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0
125139
with:
@@ -145,6 +159,7 @@ jobs:
145159
- uses: actions/checkout@v7.0.0
146160
with:
147161
persist-credentials: false
162+
- uses: ./.github/actions/set-uv-exclude-newer
148163
- name: Install uv
149164
uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0
150165
with:
@@ -167,6 +182,7 @@ jobs:
167182
- uses: actions/checkout@v7.0.0
168183
with:
169184
persist-credentials: false
185+
- uses: ./.github/actions/set-uv-exclude-newer
170186
- name: Install uv
171187
uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0
172188
with:
@@ -188,6 +204,7 @@ jobs:
188204
- uses: actions/checkout@v7.0.0
189205
with:
190206
persist-credentials: false
207+
- uses: ./.github/actions/set-uv-exclude-newer
191208
- name: Install uv
192209
uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0
193210
with:
@@ -278,6 +295,7 @@ jobs:
278295
- uses: actions/checkout@v7.0.0
279296
with:
280297
persist-credentials: false
298+
- uses: ./.github/actions/set-uv-exclude-newer
281299
- name: Install uv
282300
uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0
283301
with:

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,6 @@ xunit-results/
4545
coverage.xml
4646
server.log
4747
.coverage
48+
49+
# uv lockfiles
50+
uv.lock

.pre-commit-config.yaml

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -133,14 +133,3 @@ repos:
133133
language: python
134134
require_serial: true
135135
additional_dependencies: ["shrub.py>=3.10.0", "pyyaml>=6.0.2"]
136-
137-
- id: uv-lock
138-
name: uv-lock
139-
entry: uv lock
140-
language: python
141-
require_serial: true
142-
files: ^(uv\.lock|pyproject\.toml|requirements.txt|requirements/.*\.txt)$
143-
pass_filenames: false
144-
fail_fast: true
145-
additional_dependencies:
146-
- "uv>=0.8.4"

CONTRIBUTING.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,4 @@ From the spawn host or Ubuntu image, do the following:
566566
## Dependabot updates
567567

568568
Dependabot will raise PRs at most once per week, grouped by GitHub Actions updates and Python requirement
569-
file updates. We have a pre-commit hook that will update the `uv.lock` file when requirements change.
570-
To update the lock file on a failing PR, you can use a method like `gh pr checkout <pr number>`, then run
571-
`just lint uv-lock` to update the lock file, and then push the changes. If a typing dependency has changed,
572-
also run `just typing` and handle any new findings.
569+
file updates. If a typing dependency has changed, run `just typing` and handle any new findings.

0 commit comments

Comments
 (0)