Skip to content

Commit 567aec4

Browse files
authored
Run tests in multiple shards and all Python versions (#1603)
1 parent 5f0e8bc commit 567aec4

File tree

4 files changed

+25
-8
lines changed

4 files changed

+25
-8
lines changed

.github/workflows/test.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ jobs:
2020
strategy:
2121
matrix:
2222
python-version: ['3.8', '3.9', '3.10', '3.11']
23+
fail-fast: false
2324
steps:
2425
- uses: actions/checkout@v3
2526
- name: Set up Python ${{ matrix.python-version }}
@@ -45,7 +46,9 @@ jobs:
4546
runs-on: ubuntu-latest
4647
strategy:
4748
matrix:
48-
python-version: ['3.11']
49+
python-version: ['3.8', '3.9', '3.10', '3.11']
50+
shard: [0, 1, 2, 3]
51+
fail-fast: false
4952
steps:
5053
- uses: actions/checkout@v3
5154
- name: Setup system dependencies
@@ -61,14 +64,16 @@ jobs:
6164
pip install -U pip setuptools wheel
6265
pip install -r ./requirements.txt
6366
67+
# Must match `shard` definition in the test matrix:
6468
- name: Run tests
65-
run: PYTHONPATH='.' pytest
69+
run: PYTHONPATH='.' pytest --num-shards=4 --shard-id=${{ matrix.shard }}
6670

6771
stubtest:
6872
runs-on: ubuntu-latest
6973
strategy:
7074
matrix:
7175
python-version: ['3.11']
76+
fail-fast: false
7277
steps:
7378
- uses: actions/checkout@v3
7479
- name: Setup system dependencies
@@ -90,6 +95,7 @@ jobs:
9095
matrix-test:
9196
runs-on: ubuntu-latest
9297
strategy:
98+
fail-fast: false
9399
matrix:
94100
python-version: ['3.8', '3.9', '3.10']
95101
django-version: ['3.2', '4.2']

requirements.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1+
# Dev tools:
12
black==23.3.0
23
pre-commit==3.3.3
34
pytest==7.4.0
45
pytest-mypy-plugins==2.0.0
6+
pytest-shard==0.1.2
7+
8+
# Django deps:
59
psycopg2-binary
610
Django==4.2.2
711
-e ./django_stubs_ext

tests/typecheck/core/test_checks.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
- case: test_checks_register
22
main: |
3-
from typing import Any, Sequence, Optional, Union
3+
from typing import Any, Sequence, Optional, Union, List
44
55
from django.apps.config import AppConfig
66
from django.core.checks import register, Warning, CheckMessage
77
88
99
@register("foo", deploy=True)
10-
def check_foo(app_configs: Union[Sequence[AppConfig], None], databases: Optional[Sequence[str]], **kwargs: Any) -> list[Warning]:
10+
def check_foo(app_configs: Union[Sequence[AppConfig], None], databases: Optional[Sequence[str]], **kwargs: Any) -> List[Warning]:
1111
if databases and 'databass' in databases:
1212
return [Warning("Naughty list")]
1313
return []

tests/typecheck/db/models/test_query.yml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,25 +19,32 @@
1919
pass
2020
out: |
2121
main:4: error: Type argument "int" of "ModelIterable" must be a subtype of "Model"
22+
23+
2224
- case: django_db_models_query_module_has_ValuesListIterable
2325
main: |
26+
from typing import Tuple
2427
from django.db.models.query import ValuesListIterable
2528
26-
class IntValuesListIterable(ValuesListIterable[tuple[int,int]]):
29+
class IntValuesListIterable(ValuesListIterable[Tuple[int,int]]):
2730
pass
28-
class StringsValuesListIterable(ValuesListIterable[tuple[str,str,str]]):
31+
class StringsValuesListIterable(ValuesListIterable[Tuple[str,str,str]]):
2932
pass
30-
class MultiTypeValuesListIterable(ValuesListIterable[tuple[str,int,float]]):
33+
class MultiTypeValuesListIterable(ValuesListIterable[Tuple[str,int,float]]):
3134
pass
3235
3336
class NonTupleValuesListIterable(ValuesListIterable[int]):
3437
pass
3538
out: |
36-
main:10: error: Type argument "int" of "ValuesListIterable" must be a subtype of "Tuple[Any, ...]"
39+
main:11: error: Type argument "int" of "ValuesListIterable" must be a subtype of "Tuple[Any, ...]"
40+
41+
3742
- case: django_db_models_query_module_has_NamedValuesListIterable
3843
main: |
3944
from django.db.models.query import NamedValuesListIterable
4045
out: |
46+
47+
4148
- case: QuerySet_has__iterable_class_defined
4249
main: |
4350
from django.db.models.query import QuerySet, ValuesIterable, ModelIterable

0 commit comments

Comments
 (0)