Skip to content

Commit 5ce1145

Browse files
committed
CI: micro-optimize test collection & pass nox's --no-install
Pytest can be pretty slow to collect pip's entire test suite and prepare for test execution. I've observed a ~15s delay from invoking pytest to the first test running in CI in the worst case. This can be improved by reducing how many files pytest has to process while collecting tests. In short, passing tests/unit is faster than -m unit. In addition, use nox's --no-install flag to skip redundant build and install steps on the 2nd nox session invocation (for the integration tests), which was made possible by the previous commit.
1 parent c340d7e commit 5ce1145

File tree

1 file changed

+14
-22
lines changed

1 file changed

+14
-22
lines changed

.github/workflows/ci.yml

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -149,17 +149,17 @@ jobs:
149149
- name: Run unit tests
150150
run: >-
151151
nox -s test-${{ matrix.python.key || matrix.python }} --
152-
-m unit
152+
tests/unit
153153
--verbose --numprocesses auto --showlocals
154154
- name: Run integration tests
155155
run: >-
156-
nox -s test-${{ matrix.python.key || matrix.python }} --
157-
-m integration
156+
nox -s test-${{ matrix.python.key || matrix.python }} --no-install --
157+
tests/functional
158158
--verbose --numprocesses auto --showlocals
159159
--durations=5
160160
161161
tests-windows:
162-
name: tests / ${{ matrix.python }} / ${{ matrix.os }} / ${{ matrix.group }}
162+
name: tests / ${{ matrix.python }} / ${{ matrix.os }} / ${{ matrix.group.number }}
163163
runs-on: ${{ matrix.os }}-latest
164164

165165
needs: [packaging, determine-changes]
@@ -180,7 +180,9 @@ jobs:
180180
# - "3.11"
181181
# - "3.12"
182182
- "3.13"
183-
group: [1, 2]
183+
group:
184+
- { number: 1, pytest-filter: "not test_install" }
185+
- { number: 2, pytest-filter: "test_install" }
184186

185187
steps:
186188
- uses: actions/checkout@v4
@@ -198,29 +200,19 @@ jobs:
198200
TEMP: "C:\\Temp"
199201

200202
# Main check
201-
- name: Run unit tests
202-
if: matrix.group == 1
203+
- name: Run unit tests (group 1)
204+
if: matrix.group.number == 1
203205
run: >-
204206
nox -s test-${{ matrix.python }} --
205-
-m unit
207+
tests/unit
206208
--verbose --numprocesses auto --showlocals
207209
env:
208210
TEMP: "C:\\Temp"
209211

210-
- name: Run integration tests (group 1)
211-
if: matrix.group == 1
212+
- name: Run integration tests (group ${{ matrix.group.number }})
212213
run: >-
213-
nox -s test-${{ matrix.python }} --
214-
-m integration -k "not test_install"
215-
--verbose --numprocesses auto --showlocals
216-
env:
217-
TEMP: "C:\\Temp"
218-
219-
- name: Run integration tests (group 2)
220-
if: matrix.group == 2
221-
run: >-
222-
nox -s test-${{ matrix.python }} --
223-
-m integration -k "test_install"
214+
nox -s test-${{ matrix.python }} --no-install --
215+
tests/functional -k "${{ matrix.group.pytest-filter }}"
224216
--verbose --numprocesses auto --showlocals
225217
env:
226218
TEMP: "C:\\Temp"
@@ -251,7 +243,7 @@ jobs:
251243
- name: Run integration tests
252244
run: >-
253245
nox -s test-3.10 --
254-
-m integration
246+
tests/functional
255247
--verbose --numprocesses auto --showlocals
256248
--durations=5
257249
--use-zipapp

0 commit comments

Comments
 (0)