Skip to content

Commit 6bb008c

Browse files
authored
Merge branch 'main' into DRIVERS-2917
2 parents 90643e5 + 4761579 commit 6bb008c

File tree

93 files changed

+3633
-1764
lines changed

Some content is hidden

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

93 files changed

+3633
-1764
lines changed

.evergreen/run-tests.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ pip install -e ..
1515
pip install -r requirements/py3.txt
1616
popd
1717

18-
# Copy the test settings file
19-
cp ./.github/workflows/mongodb_settings.py django_repo/tests/
18+
# Copy the test settings files
19+
cp ./.github/workflows/*_settings.py django_repo/tests/
2020

2121
# Copy the test runner file
2222
cp ./.github/workflows/runtests.py django_repo/tests/runtests_.py
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
JIRA TICKET
2+
3+
## Changes in this PR
4+
5+
<!-- What changes did you make to the code? What new APIs (public or private) were added, removed, or edited to generate the desired outcome explained in the above summary? -->
6+
7+
## Test Plan
8+
9+
<!-- How did you test the code? If you added unit tests, you can say that. If you didn’t introduce unit tests, explain why. All code should be tested in some way – so please list what your validation strategy was. -->
10+
11+
## Checklist
12+
13+
<!-- Do not delete the items provided on this checklist -->
14+
15+
### Checklist for Author
16+
17+
- [ ] Did you update the changelog (if necessary)?
18+
- [ ] Is the intention of the code captured in relevant tests?
19+
- [ ] If there are new TODOs, has a related JIRA ticket been created?
20+
21+
### Checklist for Reviewer
22+
23+
- [ ] Does the title of the PR reference a JIRA Ticket?
24+
- [ ] Do you fully understand the implementation? (Would you be comfortable explaining how this code works to someone else?)
25+
- [ ] Have you checked for spelling & grammar errors?
26+
- [ ] Is all relevant documentation (README or docstring) updated?

.github/workflows/codeql.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ jobs:
4545

4646
steps:
4747
- name: Checkout repository
48-
uses: actions/checkout@v5
48+
uses: actions/checkout@v6
4949
with:
5050
ref: ${{ inputs.ref }}
5151
persist-credentials: false
@@ -56,7 +56,7 @@ jobs:
5656

5757
# Initializes the CodeQL tools for scanning.
5858
- name: Initialize CodeQL
59-
uses: github/codeql-action/init@192325c86100d080feab897ff886c34abd4c83a3 # v3.30.3
59+
uses: github/codeql-action/init@cf1bb45a277cb3c205638b2cd5c984db1c46a412 # v4.31.7
6060
with:
6161
languages: ${{ matrix.language }}
6262
build-mode: none
@@ -72,6 +72,6 @@ jobs:
7272
pip install -e .
7373
7474
- name: Perform CodeQL Analysis
75-
uses: github/codeql-action/analyze@192325c86100d080feab897ff886c34abd4c83a3 # v3.30.3
75+
uses: github/codeql-action/analyze@cf1bb45a277cb3c205638b2cd5c984db1c46a412 # v4.31.7
7676
with:
7777
category: "/language:${{ matrix.language }}"

.github/workflows/dist.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
runs-on: ubuntu-latest
2020
environment: release
2121
steps:
22-
- uses: actions/checkout@v5
22+
- uses: actions/checkout@v6
2323
with:
2424
ref: ${{ inputs.ref }}
2525
persist-credentials: false
@@ -32,7 +32,7 @@ jobs:
3232
- name: Create packages
3333
run: python -m build .
3434
- name: Store package artifacts
35-
uses: actions/upload-artifact@v4
35+
uses: actions/upload-artifact@v5
3636
with:
3737
name: all-dist-${{ github.run_id }}
3838
path: "dist/*"
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Settings for django/tests.
2+
import os
3+
4+
from pymongo.uri_parser import parse_uri
5+
6+
if mongodb_uri := os.getenv("MONGODB_URI"):
7+
db_settings = {
8+
"ENGINE": "django_mongodb_backend",
9+
"HOST": mongodb_uri,
10+
}
11+
# Workaround for https://github.com/mongodb-labs/mongo-orchestration/issues/268
12+
uri = parse_uri(mongodb_uri)
13+
if uri.get("username") and uri.get("password"):
14+
db_settings["OPTIONS"] = {"tls": True, "tlsAllowInvalidCertificates": True}
15+
DATABASES = {
16+
"default": {**db_settings, "NAME": "djangotests"},
17+
"other": {**db_settings, "NAME": "djangotests-other"},
18+
}
19+
else:
20+
DATABASES = {
21+
"default": {
22+
"ENGINE": "django_mongodb_backend",
23+
"NAME": "djangotests",
24+
# Required when connecting to the Atlas image in Docker.
25+
"OPTIONS": {"directConnection": True},
26+
},
27+
"other": {
28+
"ENGINE": "django_mongodb_backend",
29+
"NAME": "djangotests-other",
30+
"OPTIONS": {"directConnection": True},
31+
},
32+
}
33+
34+
DEFAULT_AUTO_FIELD = "django_mongodb_backend.fields.ObjectIdAutoField"
35+
PASSWORD_HASHERS = ("django.contrib.auth.hashers.MD5PasswordHasher",)
36+
SECRET_KEY = "django_tests_secret_key" # noqa: S105
37+
USE_TZ = False

.github/workflows/linters.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
lint:
1313
runs-on: ubuntu-latest
1414
steps:
15-
- uses: actions/checkout@v5
15+
- uses: actions/checkout@v6
1616
with:
1717
persist-credentials: false
1818
- uses: actions/setup-python@v6
@@ -32,7 +32,7 @@ jobs:
3232
name: Docs Checks
3333
runs-on: ubuntu-latest
3434
steps:
35-
- uses: actions/checkout@v5
35+
- uses: actions/checkout@v6
3636
with:
3737
persist-credentials: false
3838
- uses: actions/setup-python@v6
Lines changed: 3 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,4 @@
1-
import os
1+
# Settings for django_mongodb_backend/tests.
2+
from django_settings import * # noqa: F403
23

3-
from pymongo.uri_parser import parse_uri
4-
5-
if mongodb_uri := os.getenv("MONGODB_URI"):
6-
db_settings = {
7-
"ENGINE": "django_mongodb_backend",
8-
"HOST": mongodb_uri,
9-
}
10-
# Workaround for https://github.com/mongodb-labs/mongo-orchestration/issues/268
11-
uri = parse_uri(mongodb_uri)
12-
if uri.get("username") and uri.get("password"):
13-
db_settings["OPTIONS"] = {"tls": True, "tlsAllowInvalidCertificates": True}
14-
DATABASES = {
15-
"default": {**db_settings, "NAME": "djangotests"},
16-
"other": {**db_settings, "NAME": "djangotests-other"},
17-
}
18-
else:
19-
DATABASES = {
20-
"default": {
21-
"ENGINE": "django_mongodb_backend",
22-
"NAME": "djangotests",
23-
# Required when connecting to the Atlas image in Docker.
24-
"OPTIONS": {"directConnection": True},
25-
},
26-
"other": {
27-
"ENGINE": "django_mongodb_backend",
28-
"NAME": "djangotests-other",
29-
"OPTIONS": {"directConnection": True},
30-
},
31-
}
32-
33-
DEFAULT_AUTO_FIELD = "django_mongodb_backend.fields.ObjectIdAutoField"
34-
PASSWORD_HASHERS = ("django.contrib.auth.hashers.MD5PasswordHasher",)
35-
SECRET_KEY = "django_tests_secret_key"
36-
USE_TZ = False
4+
DATABASE_ROUTERS = ["django_mongodb_backend.routers.MongoRouter"]

.github/workflows/release-python.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,17 @@ jobs:
3939
outputs:
4040
version: ${{ steps.pre-publish.outputs.version }}
4141
steps:
42-
- uses: mongodb-labs/drivers-github-tools/secure-checkout@v2
42+
- uses: mongodb-labs/drivers-github-tools/secure-checkout@v3 # Cannot be pinned
4343
with:
4444
app_id: ${{ vars.APP_ID }}
4545
private_key: ${{ secrets.APP_PRIVATE_KEY }}
46-
- uses: mongodb-labs/drivers-github-tools/setup@v2
46+
- uses: mongodb-labs/drivers-github-tools/setup@v3 # Cannot be pinned
4747
with:
4848
aws_role_arn: ${{ secrets.AWS_ROLE_ARN }}
4949
aws_region_name: ${{ vars.AWS_REGION_NAME }}
5050
aws_secret_id: ${{ secrets.AWS_SECRET_ID }}
5151
artifactory_username: ${{ vars.ARTIFACTORY_USERNAME }}
52-
- uses: mongodb-labs/drivers-github-tools/python/pre-publish@v2
52+
- uses: mongodb-labs/drivers-github-tools/python/pre-publish@v3 # Cannot be pinned
5353
id: pre-publish
5454
with:
5555
dry_run: ${{ env.DRY_RUN }}
@@ -75,7 +75,7 @@ jobs:
7575
id-token: write
7676
steps:
7777
- name: Download all the dists
78-
uses: actions/download-artifact@v5
78+
uses: actions/download-artifact@v6
7979
with:
8080
name: all-dist-${{ github.run_id }}
8181
path: dist/
@@ -99,17 +99,17 @@ jobs:
9999
attestations: write
100100
security-events: write
101101
steps:
102-
- uses: mongodb-labs/drivers-github-tools/secure-checkout@v2
102+
- uses: mongodb-labs/drivers-github-tools/secure-checkout@v3 # Cannot be pinned
103103
with:
104104
app_id: ${{ vars.APP_ID }}
105105
private_key: ${{ secrets.APP_PRIVATE_KEY }}
106-
- uses: mongodb-labs/drivers-github-tools/setup@v2
106+
- uses: mongodb-labs/drivers-github-tools/setup@v3 # Cannot be pinned
107107
with:
108108
aws_role_arn: ${{ secrets.AWS_ROLE_ARN }}
109109
aws_region_name: ${{ vars.AWS_REGION_NAME }}
110110
aws_secret_id: ${{ secrets.AWS_SECRET_ID }}
111111
artifactory_username: ${{ vars.ARTIFACTORY_USERNAME }}
112-
- uses: mongodb-labs/drivers-github-tools/python/post-publish@v2
112+
- uses: mongodb-labs/drivers-github-tools/python/post-publish@v3 # Cannot be pinned
113113
with:
114114
following_version: ${{ env.FOLLOWING_VERSION }}
115115
product_name: ${{ env.PRODUCT_NAME }}

.github/workflows/runtests.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,11 +172,19 @@
172172
test_apps.extend(["gis_tests", "gis_tests_"])
173173

174174
runtests = pathlib.Path(__file__).parent.resolve() / "runtests.py"
175-
run_tests_cmd = f"python3 {runtests} %s --settings mongodb_settings -v 2"
175+
run_tests_cmd = f"python3 {runtests} %s --settings %s -v 2"
176176

177177
shouldFail = False
178178
for app_name in test_apps:
179-
res = os.system(run_tests_cmd % app_name) # noqa: S605
179+
# Use the custom settings module only for django_mongodb_backend's tests
180+
# (which always end with an underscore). Some of Django's tests aren't
181+
# compatible with extra DATABASE_ROUTERS or other DATABASES aliases.
182+
settings_module = (
183+
os.environ.get("DJANGO_SETTINGS_MODULE", "mongodb_settings")
184+
if app_name.endswith("_")
185+
else "django_settings"
186+
)
187+
res = os.system(run_tests_cmd % (app_name, settings_module)) # noqa: S605
180188
if res != 0:
181189
shouldFail = True
182190
sys.exit(1 if shouldFail else 0)

.github/workflows/test-python-atlas.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@ jobs:
2222
runs-on: ubuntu-latest
2323
steps:
2424
- name: Checkout django-mongodb-backend
25-
uses: actions/checkout@v5
25+
uses: actions/checkout@v6
2626
with:
2727
persist-credentials: false
2828
- name: install django-mongodb-backend
2929
run: |
3030
pip3 install --upgrade pip
3131
pip3 install -e .
3232
- name: Checkout Django
33-
uses: actions/checkout@v5
33+
uses: actions/checkout@v6
3434
with:
3535
repository: 'mongodb-forks/django'
3636
ref: 'mongodb-5.2.x'
@@ -45,8 +45,8 @@ jobs:
4545
cd django_repo/tests/
4646
pip3 install -e ..
4747
pip3 install -r requirements/py3.txt
48-
- name: Copy the test settings file
49-
run: cp .github/workflows/mongodb_settings.py django_repo/tests/
48+
- name: Copy the test settings files
49+
run: cp .github/workflows/*_settings.py django_repo/tests/
5050
- name: Copy the test runner file
5151
run: cp .github/workflows/runtests.py django_repo/tests/runtests_.py
5252
- name: Start local Atlas

0 commit comments

Comments
 (0)