Repository navigation
157 lines (136 loc) · 4.29 KB
/
Copy pathtest.yml
File metadata and controls
157 lines (136 loc) · 4.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
name: Test
on:
push:
pull_request:
type: [ "opened", "reopened", "synchronize" ]
schedule:
- cron: '0 12 * * 0' # run once a week on Sunday
# Allows running this workflow manually from the Actions tab
workflow_dispatch:
env:
FORCE_COLOR: 1
jobs:
tests:
name: py-${{ matrix.python-version }}:pytest-${{ matrix.pytest-version }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: [
"3.10",
"3.11",
"3.12",
"3.13",
"3.14",
"pypy-3.11",
]
pytest-version: [
"8.2.*",
"8.3.*",
"8.4.*",
"9.0.*",
"9.1.*",
"main",
]
steps:
- uses: actions/checkout@v7
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v7
with:
python-version: ${{ matrix.python-version }}
allow-prereleases: true
- name: Get pip cache dir
id: pip-cache
run: |
echo "dir=$(pip cache dir)" >> "$GITHUB_OUTPUT"
- name: Cache
uses: actions/cache@v6
with:
path: ${{ steps.pip-cache.outputs.dir }}
key:
${{ matrix.python-version }}-${{ matrix.pytest-version }}-v1-${{ hashFiles('**/pyproject.toml') }}
restore-keys: |
${{ matrix.python-version }}-${{ matrix.pytest-version }}-v1-
- name: Install dependencies
run: |
python -m pip install -U pip
if [[ '${{ matrix.pytest-version }}' == 'main' ]]; then
python -m pip install git+https://github.com/pytest-dev/pytest.git@main#egg=pytest
else
python -m pip install pytest==${{ matrix.pytest-version }}
fi
python -m pip install -e .
- name: Tests
shell: bash
run: |
pytest
xdist:
# The xdist specific tests are skipped unless pytest-xdist is installed,
# so run the test suite once with it on the newest Python and pytest.
name: xdist:py-3.14:pytest-9.1
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- name: Set up Python
uses: actions/setup-python@v7
with:
python-version: "3.14"
allow-prereleases: true
- name: Install dependencies
run: |
python -m pip install -U pip
python -m pip install pytest==9.1.* pytest-xdist
python -m pip install -e .
- name: Tests
run: pytest
freethreading:
# The free-threaded build is officially supported since Python 3.14 (PEP 779).
# The plugin coordinates reruns between xdist workers over a socket server
# with a thread per connection, so run the suite without the GIL to make
# sure that shared state stays safe.
name: free-threading:py-3.14t:pytest-9.1
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- name: Set up Python
uses: actions/setup-python@v7
with:
python-version: "3.14t"
- name: Install dependencies
run: |
python -m pip install -U pip
python -m pip install pytest==9.1.* pytest-xdist
python -m pip install -e .
- name: Verify the GIL stays disabled
# Importing an extension that does not declare free-threading support
# re-enables the GIL, which would make this job silently pointless.
run: |
python -c "
import sys, pytest, xdist, pytest_rerunfailures
assert not sys._is_gil_enabled(), 'importing the test dependencies re-enabled the GIL'
"
- name: Tests
run: pytest
platform:
# Test devel setup on different platforms.
name: Platform-${{ matrix.os }}
needs: [ tests ]
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Setup Python
uses: actions/setup-python@v7
with:
python-version: '3.x'
architecture: 'x64'
- name: Development setup on platform ${{ matrix.os }}
run: |
python -m pip install -U pip
python -m pip install pytest
python -m pip install -e .
- name: Tests
run: pytest tests/