chore(ci): split emulation tests per architecture (#1839)
This commit is contained in:
@@ -31,7 +31,7 @@ jobs:
|
|||||||
run: pipx run nox -s pylint -- --output-format=github
|
run: pipx run nox -s pylint -- --output-format=github
|
||||||
|
|
||||||
test:
|
test:
|
||||||
name: Test cibuildwheel on ${{ matrix.os }} (${{ matrix.python_version }})
|
name: Test on ${{ matrix.os }} (${{ matrix.python_version }})
|
||||||
needs: lint
|
needs: lint
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
strategy:
|
strategy:
|
||||||
@@ -125,19 +125,41 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
python ./bin/run_tests.py --run-podman
|
python ./bin/run_tests.py --run-podman
|
||||||
|
|
||||||
test-emulated:
|
emulated-archs:
|
||||||
name: Test emulated cibuildwheel using qemu
|
name: Get qemu emulated architectures
|
||||||
needs: lint
|
needs: lint
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
timeout-minutes: 180
|
outputs:
|
||||||
|
archs: ${{ steps.archs.outputs.archs }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- uses: actions/setup-python@v5
|
- uses: actions/setup-python@v5
|
||||||
with:
|
with:
|
||||||
python-version: "3.x"
|
python-version: "3.x"
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
|
run: python -m pip install ".[test]"
|
||||||
|
- name: Get qemu emulated architectures
|
||||||
|
id: archs
|
||||||
run: |
|
run: |
|
||||||
python -m pip install ".[test]"
|
OUTPUT=$(python -c "from json import dumps; from test.utils import EMULATED_ARCHS; print(dumps(EMULATED_ARCHS))")
|
||||||
|
echo "${OUTPUT}"
|
||||||
|
echo "archs=${OUTPUT}" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
|
test-emulated:
|
||||||
|
name: Test Linux ${{ matrix.arch }} using qemu
|
||||||
|
needs: emulated-archs
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
timeout-minutes: 180
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
arch: ${{ fromJSON(needs.emulated-archs.outputs.archs) }}
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: actions/setup-python@v5
|
||||||
|
with:
|
||||||
|
python-version: "3.x"
|
||||||
|
- name: Install dependencies
|
||||||
|
run: python -m pip install ".[test]"
|
||||||
|
|
||||||
- name: Set up QEMU
|
- name: Set up QEMU
|
||||||
id: qemu
|
id: qemu
|
||||||
@@ -146,5 +168,4 @@ jobs:
|
|||||||
platforms: all
|
platforms: all
|
||||||
|
|
||||||
- name: Run the emulation tests
|
- name: Run the emulation tests
|
||||||
run: |
|
run: pytest --run-emulation ${{ matrix.arch }} test/test_emulation.py
|
||||||
pytest --run-emulation test/test_emulation.py
|
|
||||||
|
|||||||
+6
-2
@@ -8,12 +8,16 @@ import pytest
|
|||||||
|
|
||||||
from cibuildwheel.util import detect_ci_provider
|
from cibuildwheel.util import detect_ci_provider
|
||||||
|
|
||||||
from .utils import platform
|
from .utils import EMULATED_ARCHS, platform
|
||||||
|
|
||||||
|
|
||||||
def pytest_addoption(parser) -> None:
|
def pytest_addoption(parser) -> None:
|
||||||
parser.addoption(
|
parser.addoption(
|
||||||
"--run-emulation", action="store_true", default=False, help="run emulation tests"
|
"--run-emulation",
|
||||||
|
action="store",
|
||||||
|
default=None,
|
||||||
|
help="run emulation tests",
|
||||||
|
choices=("all", *EMULATED_ARCHS),
|
||||||
)
|
)
|
||||||
parser.addoption("--run-podman", action="store_true", default=False, help="run podman tests")
|
parser.addoption("--run-podman", action="store_true", default=False, help="run podman tests")
|
||||||
parser.addoption(
|
parser.addoption(
|
||||||
|
|||||||
+10
-6
@@ -1,5 +1,6 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import itertools
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
@@ -18,9 +19,13 @@ def test_spam():
|
|||||||
|
|
||||||
|
|
||||||
def test(tmp_path, request):
|
def test(tmp_path, request):
|
||||||
if not request.config.getoption("--run-emulation"):
|
archs = request.config.getoption("--run-emulation")
|
||||||
|
if archs is None:
|
||||||
pytest.skip("needs --run-emulation option to run")
|
pytest.skip("needs --run-emulation option to run")
|
||||||
|
|
||||||
|
if archs == "all":
|
||||||
|
archs = " ".join(utils.EMULATED_ARCHS)
|
||||||
|
|
||||||
project_dir = tmp_path / "project"
|
project_dir = tmp_path / "project"
|
||||||
project_with_a_test.generate(project_dir)
|
project_with_a_test.generate(project_dir)
|
||||||
|
|
||||||
@@ -30,15 +35,14 @@ def test(tmp_path, request):
|
|||||||
add_env={
|
add_env={
|
||||||
"CIBW_TEST_REQUIRES": "pytest",
|
"CIBW_TEST_REQUIRES": "pytest",
|
||||||
"CIBW_TEST_COMMAND": "pytest {project}/test",
|
"CIBW_TEST_COMMAND": "pytest {project}/test",
|
||||||
"CIBW_ARCHS": "aarch64 ppc64le s390x",
|
"CIBW_ARCHS": archs,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
# also check that we got the right wheels
|
# also check that we got the right wheels
|
||||||
expected_wheels = (
|
expected_wheels = itertools.chain.from_iterable(
|
||||||
utils.expected_wheels("spam", "0.1.0", machine_arch="aarch64")
|
utils.expected_wheels("spam", "0.1.0", machine_arch=arch, single_arch=True)
|
||||||
+ utils.expected_wheels("spam", "0.1.0", machine_arch="ppc64le")
|
for arch in archs.split(" ")
|
||||||
+ utils.expected_wheels("spam", "0.1.0", machine_arch="s390x")
|
|
||||||
)
|
)
|
||||||
assert set(actual_wheels) == set(expected_wheels)
|
assert set(actual_wheels) == set(expected_wheels)
|
||||||
|
|
||||||
|
|||||||
+6
-1
@@ -13,8 +13,12 @@ import sys
|
|||||||
from tempfile import TemporaryDirectory
|
from tempfile import TemporaryDirectory
|
||||||
from typing import Final
|
from typing import Final
|
||||||
|
|
||||||
|
from cibuildwheel.architecture import Architecture
|
||||||
from cibuildwheel.util import CIBW_CACHE_PATH
|
from cibuildwheel.util import CIBW_CACHE_PATH
|
||||||
|
|
||||||
|
EMULATED_ARCHS: Final[list[str]] = sorted(
|
||||||
|
arch.value for arch in (Architecture.all_archs("linux") - Architecture.auto_archs("linux"))
|
||||||
|
)
|
||||||
SINGLE_PYTHON_VERSION: Final[tuple[int, int]] = (3, 12)
|
SINGLE_PYTHON_VERSION: Final[tuple[int, int]] = (3, 12)
|
||||||
|
|
||||||
platform: str
|
platform: str
|
||||||
@@ -154,6 +158,7 @@ def expected_wheels(
|
|||||||
python_abi_tags=None,
|
python_abi_tags=None,
|
||||||
include_universal2=False,
|
include_universal2=False,
|
||||||
single_python=False,
|
single_python=False,
|
||||||
|
single_arch=False,
|
||||||
):
|
):
|
||||||
"""
|
"""
|
||||||
Returns a list of expected wheels from a run of cibuildwheel.
|
Returns a list of expected wheels from a run of cibuildwheel.
|
||||||
@@ -237,7 +242,7 @@ def expected_wheels(
|
|||||||
if platform == "linux":
|
if platform == "linux":
|
||||||
architectures = [arch_name_for_linux(machine_arch)]
|
architectures = [arch_name_for_linux(machine_arch)]
|
||||||
|
|
||||||
if machine_arch == "x86_64":
|
if machine_arch == "x86_64" and not single_arch:
|
||||||
architectures.append("i686")
|
architectures.append("i686")
|
||||||
|
|
||||||
if len(manylinux_versions) > 0:
|
if len(manylinux_versions) > 0:
|
||||||
|
|||||||
Reference in New Issue
Block a user