Skip to content

Commit 6e1fbf9

Browse files
committed
verify run environment in CI
1 parent fabb416 commit 6e1fbf9

File tree

2 files changed

+53
-1
lines changed

2 files changed

+53
-1
lines changed

.github/workflows/test.yml

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ jobs:
4646
django-version: '5.0'
4747
env:
4848
COVERAGE_FILE: py${{ matrix.python-version }}-linux-dj${{ matrix.django-version }}.coverage
49+
TEST_PYTHON_VERSION: ${{ matrix.python-version }}
50+
TEST_DJANGO_VERSION: ${{ matrix.django-version }}
4951
steps:
5052
- uses: actions/checkout@v4
5153
- name: Set up Python ${{ matrix.python-version }}
@@ -72,8 +74,8 @@ jobs:
7274
sudo apt remove powershell
7375
- name: Run Unit Tests
7476
run: |
77+
just test ./tests/verify_environment.py
7578
just test-all
76-
7779
- name: Store coverage files
7880
uses: actions/upload-artifact@v4
7981
with:
@@ -99,6 +101,8 @@ jobs:
99101

100102
env:
101103
COVERAGE_FILE: py${{ matrix.python-version }}-windows-dj${{ matrix.django-version }}.coverage
104+
TEST_PYTHON_VERSION: ${{ matrix.python-version }}
105+
TEST_DJANGO_VERSION: ${{ matrix.django-version }}
102106
steps:
103107
- uses: actions/checkout@v4
104108
- name: Set up Python ${{ matrix.python-version }}
@@ -122,6 +126,7 @@ jobs:
122126
just pin-dependency Django~=${{ matrix.django-version }}
123127
- name: Run Unit Tests
124128
run: |
129+
just test ./tests/verify_environment.py
125130
just test-all
126131
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
127132
- name: Store coverage files
@@ -146,6 +151,8 @@ jobs:
146151

147152
env:
148153
COVERAGE_FILE: py${{ matrix.python-version }}-macos-dj${{ matrix.django-version }}.coverage
154+
TEST_PYTHON_VERSION: ${{ matrix.python-version }}
155+
TEST_DJANGO_VERSION: ${{ matrix.django-version }}
149156

150157
steps:
151158
- uses: actions/checkout@v4
@@ -172,6 +179,7 @@ jobs:
172179
just pin-dependency Django~=${{ matrix.django-version }}
173180
- name: Run Unit Tests
174181
run: |
182+
just test ./tests/verify_environment.py
175183
just test-all
176184
- name: Store coverage files
177185
uses: actions/upload-artifact@v4
@@ -189,6 +197,8 @@ jobs:
189197
POSTGRES_HOST: localhost
190198
POSTGRES_PORT: 5432
191199
COVERAGE_FILE: postgres-py${{ matrix.python-version }}-dj${{ matrix.django-version }}.coverage
200+
TEST_PYTHON_VERSION: ${{ matrix.python-version }}
201+
TEST_DJANGO_VERSION: ${{ matrix.django-version }}
192202
strategy:
193203
matrix:
194204
python-version: ['3.13']
@@ -239,6 +249,7 @@ jobs:
239249
just pin-dependency Django~=${{ matrix.django-version }}
240250
- name: Run Unit Tests
241251
run: |
252+
just test ./tests/verify_environment.py
242253
just test-all
243254
- name: Store coverage files
244255
uses: actions/upload-artifact@v4
@@ -261,6 +272,8 @@ jobs:
261272
django-version: '3.2'
262273
env:
263274
COVERAGE_FILE: linux-bash-py${{ matrix.python-version }}-dj${{ matrix.django-version }}.coverage
275+
TEST_PYTHON_VERSION: ${{ matrix.python-version }}
276+
TEST_DJANGO_VERSION: ${{ matrix.django-version }}
264277

265278
steps:
266279
- uses: actions/checkout@v4
@@ -286,6 +299,7 @@ jobs:
286299
just pin-dependency Django~=${{ matrix.django-version }}
287300
- name: Test Tab Completion
288301
run: |
302+
just test ./tests/verify_environment.py
289303
just test-bash || exit 1
290304
291305
- name: Store coverage files
@@ -309,6 +323,8 @@ jobs:
309323
django-version: '3.2'
310324
env:
311325
COVERAGE_FILE: linux-fish-py${{ matrix.python-version }}-dj${{ matrix.django-version }}.coverage
326+
TEST_PYTHON_VERSION: ${{ matrix.python-version }}
327+
TEST_DJANGO_VERSION: ${{ matrix.django-version }}
312328

313329
steps:
314330
- uses: actions/checkout@v4
@@ -338,6 +354,7 @@ jobs:
338354
sudo apt-get install -y fish
339355
- name: Test Tab Completion
340356
run: |
357+
just test ./tests/verify_environment.py
341358
just test-fish
342359
shell: fish {0}
343360

@@ -363,6 +380,8 @@ jobs:
363380

364381
env:
365382
COVERAGE_FILE: macos-zsh-py${{ matrix.python-version }}-dj${{ matrix.django-version }}.coverage
383+
TEST_PYTHON_VERSION: ${{ matrix.python-version }}
384+
TEST_DJANGO_VERSION: ${{ matrix.django-version }}
366385

367386
steps:
368387
- uses: actions/checkout@v4
@@ -399,6 +418,7 @@ jobs:
399418
- name: Run Unit Tests
400419
shell: zsh {0}
401420
run: |
421+
just test ./tests/verify_environment.py
402422
just test-zsh || exit 1
403423
404424
- name: Store coverage files
@@ -423,6 +443,8 @@ jobs:
423443

424444
env:
425445
COVERAGE_FILE: macos-bash-py${{ matrix.python-version }}-dj${{ matrix.django-version }}.coverage
446+
TEST_PYTHON_VERSION: ${{ matrix.python-version }}
447+
TEST_DJANGO_VERSION: ${{ matrix.django-version }}
426448

427449
steps:
428450
- uses: actions/checkout@v4
@@ -449,6 +471,7 @@ jobs:
449471
just pin-dependency Django~=${{ matrix.django-version }}
450472
- name: Run Unit Tests
451473
run: |
474+
just test ./tests/verify_environment.py
452475
just test-bash || exit 1
453476
454477
- name: Store coverage files
@@ -473,6 +496,8 @@ jobs:
473496

474497
env:
475498
COVERAGE_FILE: macos-fish-py${{ matrix.python-version }}-dj${{ matrix.django-version }}.coverage
499+
TEST_PYTHON_VERSION: ${{ matrix.python-version }}
500+
TEST_DJANGO_VERSION: ${{ matrix.django-version }}
476501

477502
steps:
478503
- uses: actions/checkout@v4
@@ -507,6 +532,7 @@ jobs:
507532
- name: Run Tab Completion Tests
508533
shell: fish {0}
509534
run: |
535+
just test ./tests/verify_environment.py
510536
just test-fish || exit 1
511537
512538
- name: Store coverage files
@@ -531,6 +557,8 @@ jobs:
531557

532558
env:
533559
COVERAGE_FILE: windows-powershell-py${{ matrix.python-version }}-dj${{ matrix.django-version }}.coverage
560+
TEST_PYTHON_VERSION: ${{ matrix.python-version }}
561+
TEST_DJANGO_VERSION: ${{ matrix.django-version }}
534562

535563
steps:
536564
- uses: actions/checkout@v4
@@ -559,6 +587,7 @@ jobs:
559587
shell: powershell
560588
- name: Run Powershell Tab Completion Tests
561589
run: |
590+
just test ./tests/verify_environment.py
562591
just test-powershell
563592
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
564593
just test-pwsh

tests/verify_environment.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import os
2+
import sys
3+
from django import VERSION
4+
5+
6+
def test():
7+
# verify that the environment is set up correctly - this is used in CI to make
8+
# sure we're testing against the dependencies we think we are
9+
10+
expected_python = os.environ["TEST_PYTHON_VERSION"]
11+
expected_django = os.environ["TEST_DJANGO_VERSION"]
12+
13+
expected_python = tuple(int(v) for v in expected_python.split(".") if v)
14+
assert sys.version_info[: len(expected_python)] == expected_python, (
15+
f"Python Version Mismatch: {sys.version_info[: len(expected_python)]} != "
16+
f"{expected_python}"
17+
)
18+
19+
expected_django = tuple(int(v) for v in expected_django.split(".") if v)
20+
assert VERSION[: len(expected_django)] == expected_django, (
21+
f"Django Version Mismatch: {VERSION[: len(expected_django)]} != "
22+
f"{expected_django}"
23+
)

0 commit comments

Comments
 (0)