Skip to content

Commit 47431d4

Browse files
ci: run some tests in parallel (#1004)
A bit faster. --------- Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent cb8b58b commit 47431d4

20 files changed

+112
-114
lines changed

.github/workflows/ci.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,19 +121,20 @@ jobs:
121121
run:
122122
uv pip install
123123
-e.[test,test-meta,test-numpy,test-schema,test-hatchling,wheels,cov,wheel-free-setuptools]
124-
--system
124+
pytest-xdist --system
125125

126126
- name: Install package (pip)
127127
if: matrix.python-version == 'pypy-3.8'
128128
run:
129129
pip install
130130
-e.[test,test-meta,test-numpy,test-schema,wheels,cov,wheel-free-setuptools]
131+
pytest-xdist
131132

132133
- name: Test package
133134
if: "!contains(matrix.python_version, 'pypy')"
134135
run: >-
135-
pytest -ra --showlocals --cov --cov-report=xml --cov-report=term
136-
--durations=20
136+
pytest -ra --showlocals --cov --cov-report=xml --cov-report=term -n
137+
auto --durations=20
137138
138139
- name: Test package (two attempts)
139140
uses: nick-fields/retry@v3
@@ -144,7 +145,7 @@ jobs:
144145
timeout_seconds: 5
145146
command: >-
146147
pytest -ra --showlocals --cov --cov-report=xml --cov-report=term
147-
--durations=20
148+
--durations=20 -n auto
148149
149150
- name: Upload coverage report
150151
uses: codecov/codecov-action@v5

docs/about/changelog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ CI and testing:
4848
- Update deployment a bit by @henryiii in #922
4949
- Use astral-sh/setup-uv instead by @henryiii in #923
5050
- Simpler noxfile by @henryiii in #924
51+
- Test on Linux ARM & Python 3.14 alphas by @henryiii in #1003
52+
- Support for parallel testing by @henryiii in #1004
5153

5254
Docs:
5355

noxfile.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def _run_tests(
6363
run_args: Sequence[str] = (),
6464
extras: Sequence[str] = (),
6565
) -> None:
66-
posargs = list(session.posargs)
66+
posargs = list(session.posargs) or ["-n", "auto"]
6767
env = {"PIP_DISABLE_PIP_VERSION_CHECK": "1"}
6868

6969
_prepare_cmake_ninja(session)
@@ -74,7 +74,7 @@ def _run_tests(
7474
posargs.append("--cov-config=pyproject.toml")
7575

7676
install_arg = f"-e.[{','.join(_extras)}]"
77-
session.install(install_arg, *install_args, silent=False)
77+
session.install(install_arg, *install_args, "pytest-xdist", silent=False)
7878
session.run("pytest", *run_args, *posargs, env=env)
7979

8080

src/scikit_build_core/program_search.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def __dir__() -> list[str]:
3333

3434

3535
# Make sure we don't wait forever for programs to respond
36-
TIMEOUT = 10 if sys.platform.startswith("win") else 4
36+
TIMEOUT = 10 if sys.platform.startswith("win") else 5
3737

3838

3939
class Program(NamedTuple):

src/scikit_build_core/setuptools/build_cmake.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ def run(self) -> None:
115115
_validate_settings(settings)
116116

117117
build_tmp_folder = Path(self.build_temp)
118-
build_temp = build_tmp_folder / "_skbuild" # TODO: include python platform
118+
build_temp = build_tmp_folder / "_skbuild"
119119

120120
dist = self.distribution
121121
dist_source_dir = getattr(self.distribution, "cmake_source_dir", None)

tests/conftest.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,9 +192,6 @@ def process_package(
192192
package_dir = tmp_path / "pkg"
193193
shutil.copytree(DIR / "packages" / package.name, package_dir)
194194
monkeypatch.chdir(package_dir)
195-
# Just in case this gets littered into the source tree, clear it out
196-
if Path("dist").is_dir():
197-
shutil.rmtree("dist")
198195

199196

200197
@pytest.fixture

tests/test_broken_fallback.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,12 @@
1313
@pytest.mark.configure
1414
@pytest.mark.usefixtures("broken_fallback")
1515
@pytest.mark.parametrize("broken_define", ["BROKEN_CMAKE", "BROKEN_CODE"])
16-
def test_broken_code(broken_define: str, capfd: pytest.CaptureFixture[str]):
17-
build_wheel("dist", {f"cmake.define.{broken_define}": "1"})
18-
wheel = Path("dist") / "broken_fallback-0.0.1-py3-none-any.whl"
16+
def test_broken_code(
17+
broken_define: str, capfd: pytest.CaptureFixture[str], tmp_path: Path
18+
):
19+
dist = tmp_path / "dist"
20+
build_wheel(str(dist), {f"cmake.define.{broken_define}": "1"})
21+
wheel = dist / "broken_fallback-0.0.1-py3-none-any.whl"
1922
with zipfile.ZipFile(wheel) as f:
2023
file_names = set(f.namelist())
2124

tests/test_dynamic_metadata.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -234,9 +234,9 @@ def test_dual_metadata():
234234
@pytest.mark.compile
235235
@pytest.mark.configure
236236
@pytest.mark.usefixtures("mock_entry_points", "package_dynamic_metadata")
237-
def test_pep517_wheel(virtualenv):
238-
dist = Path("dist")
239-
out = build_wheel("dist")
237+
def test_pep517_wheel(virtualenv, tmp_path: Path) -> None:
238+
dist = tmp_path / "dist"
239+
out = build_wheel(str(dist))
240240
(wheel,) = dist.glob("dynamic-0.0.2-*.whl")
241241
assert wheel == dist / out
242242

tests/test_fortran.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,7 @@
4040
)
4141
def test_pep517_wheel(tmp_path, monkeypatch, virtualenv):
4242
dist = tmp_path / "dist"
43-
dist.mkdir()
4443
monkeypatch.chdir(FORTRAN_EXAMPLE)
45-
if Path("dist").is_dir():
46-
shutil.rmtree("dist")
4744
out = build_wheel(str(dist))
4845
(wheel,) = dist.glob("fibby-0.0.1-*.whl")
4946
assert wheel == dist / out

tests/test_hatchling.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,11 @@
1111
@pytest.mark.network
1212
@pytest.mark.integration
1313
@pytest.mark.usefixtures("package_hatchling")
14-
def test_hatchling_sdist(isolated) -> None:
14+
def test_hatchling_sdist(isolated, tmp_path: Path) -> None:
15+
dist = tmp_path / "dist"
1516
isolated.install("build[virtualenv]")
16-
isolated.module("build", "--sdist")
17-
(sdist,) = Path("dist").iterdir()
17+
isolated.module("build", "--sdist", f"--outdir={dist}")
18+
(sdist,) = dist.iterdir()
1819
assert sdist.name == "hatchling_example-0.1.0.tar.gz"
1920
with tarfile.open(sdist) as f:
2021
file_names = set(f.getnames())
@@ -37,12 +38,13 @@ def test_hatchling_sdist(isolated) -> None:
3738
@pytest.mark.parametrize(
3839
"build_args", [(), ("--wheel",)], ids=["sdist_to_wheel", "wheel_directly"]
3940
)
40-
def test_hatchling_wheel(isolated, build_args) -> None:
41+
def test_hatchling_wheel(isolated, build_args, tmp_path: Path) -> None:
42+
dist = tmp_path / "dist"
4143
isolated.install("build[virtualenv]", "scikit-build-core", "hatchling", "pybind11")
42-
isolated.module("build", "--no-isolation", *build_args)
44+
isolated.module("build", "--no-isolation", f"--outdir={dist}", *build_args)
4345
ext_suffix = sysconfig.get_config_var("EXT_SUFFIX")
4446

45-
(wheel,) = Path("dist").glob("*.whl")
47+
(wheel,) = dist.glob("*.whl")
4648
with zipfile.ZipFile(wheel) as f:
4749
file_names = set(f.namelist())
4850
assert file_names == {

0 commit comments

Comments
 (0)