Skip to content

Commit c10dda5

Browse files
authored
Merge pull request #13126 from ichard26/microoptimize-ci
Faster test session reruns & microoptimize CI
2 parents 7c218b9 + 5ce1145 commit c10dda5

File tree

3 files changed

+26
-26
lines changed

3 files changed

+26
-26
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

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ repos:
3535
args: ["--pretty", "--show-error-codes"]
3636
additional_dependencies: [
3737
'keyring==24.2.0',
38-
'nox==2023.4.22',
38+
'nox==2024.03.02',
3939
'pytest',
4040
'types-docutils==0.20.0.3',
4141
'types-setuptools==68.2.0.0',

noxfile.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
nox.options.reuse_existing_virtualenvs = True
2121
nox.options.sessions = ["lint"]
22+
nox.needs_version = ">=2024.03.02" # for session.run_install()
2223

2324
LOCATIONS = {
2425
"common-wheels": "tests/data/common_wheels",
@@ -44,7 +45,9 @@ def run_with_protected_pip(session: nox.Session, *arguments: str) -> None:
4445
env = {"VIRTUAL_ENV": session.virtualenv.location}
4546

4647
command = ("python", LOCATIONS["protected-pip"]) + arguments
47-
session.run(*command, env=env, silent=True)
48+
# By using run_install(), these installation steps can be skipped when -R
49+
# or --no-install is passed.
50+
session.run_install(*command, env=env, silent=True)
4851

4952

5053
def should_update_common_wheels() -> bool:
@@ -84,8 +87,13 @@ def test(session: nox.Session) -> None:
8487
session.log(msg)
8588

8689
# Build source distribution
90+
# HACK: we want to skip building and installing pip when nox's --no-install
91+
# flag is given (to save time when running tests back to back with different
92+
# arguments), but unfortunately nox does not expose this configuration state
93+
# yet. https://github.com/wntrblm/nox/issues/710
94+
no_install = "-R" in sys.argv or "--no-install" in sys.argv
8795
sdist_dir = os.path.join(session.virtualenv.location, "sdist")
88-
if os.path.exists(sdist_dir):
96+
if not no_install and os.path.exists(sdist_dir):
8997
shutil.rmtree(sdist_dir, ignore_errors=True)
9098

9199
run_with_protected_pip(session, "install", "build")
@@ -94,7 +102,7 @@ def test(session: nox.Session) -> None:
94102
# pip, so uninstall pip to force build to provision a known good version of pip.
95103
run_with_protected_pip(session, "uninstall", "pip", "-y")
96104
# fmt: off
97-
session.run(
105+
session.run_install(
98106
"python", "-I", "-m", "build", "--sdist", "--outdir", sdist_dir,
99107
silent=True,
100108
)

0 commit comments

Comments
 (0)