diff --git a/.github/workflows/tests-cibw.yml b/.github/workflows/tests-cibw.yml index cd05bf11c9..dd939439f4 100644 --- a/.github/workflows/tests-cibw.yml +++ b/.github/workflows/tests-cibw.yml @@ -30,8 +30,12 @@ jobs: only: cp312-pyodide_wasm32 build-ios: - name: iOS wheel - runs-on: macos-latest + name: iOS wheel ${{ matrix.runs-on }} + runs-on: ${{ matrix.runs-on }} + strategy: + fail-fast: false + matrix: + runs-on: [macos-latest, macos-13] steps: - uses: actions/checkout@v4 with: @@ -45,3 +49,37 @@ jobs: CIBW_PLATFORM: ios with: package-dir: tests + + build-android: + name: Android wheel ${{ matrix.runs-on }} + runs-on: ${{ matrix.runs-on }} + strategy: + fail-fast: false + matrix: + runs-on: [macos-latest, macos-13, ubuntu-latest] + steps: + - uses: actions/checkout@v4 + with: + submodules: true + fetch-depth: 0 + + # GitHub Actions can't currently run the Android emulator on macOS. + - name: Skip Android tests on macOS + if: contains(matrix.runs-on, 'macos') + run: echo "CIBW_TEST_COMMAND=" >> "$GITHUB_ENV" + + # https://github.blog/changelog/2024-04-02-github-actions-hardware-accelerated-android-virtualization-now-available/ + - name: Enable KVM for Android emulator + if: contains(matrix.runs-on, 'ubuntu') + run: | + echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules + sudo udevadm control --reload-rules + sudo udevadm trigger --name-match=kvm + + - run: pipx install wheel patchelf + + - uses: mhsmith/cibuildwheel@android # TODO: update to a released version + env: + CIBW_PLATFORM: android + with: + package-dir: tests diff --git a/tests/env.py b/tests/env.py index d234c425d4..95cc1ac611 100644 --- a/tests/env.py +++ b/tests/env.py @@ -6,6 +6,7 @@ import pytest +ANDROID = sys.platform.startswith("android") LINUX = sys.platform.startswith("linux") MACOS = sys.platform.startswith("darwin") WIN = sys.platform.startswith("win32") or sys.platform.startswith("cygwin") diff --git a/tests/pyproject.toml b/tests/pyproject.toml index e58eb581ca..fa478122d3 100644 --- a/tests/pyproject.toml +++ b/tests/pyproject.toml @@ -1,5 +1,6 @@ -# Warning: this is currently used for pyodide, and is not a general out-of-tree -# builder for the tests (yet). Specifically, wheels can't be built from SDists. +# Warning: this is currently used to test cross-compilation, and is not a general +# out-of-tree builder for the tests (yet). Specifically, wheels can't be built from +# SDists. [build-system] requires = ["scikit-build-core"] @@ -29,6 +30,8 @@ test-sources = ["tests", "pyproject.toml"] test-command = "python -m pytest -o timeout=0 -p no:cacheprovider tests" environment.PIP_ONLY_BINARY = "numpy" environment.PIP_PREFER_BINARY = "1" + +android.environment.ANDROID_API_LEVEL = "24" # Needed to include libc++ in the wheel. pyodide.test-groups = ["numpy", "scipy"] ios.test-groups = ["numpy"] ios.xbuild-tools = ["cmake", "ninja"] diff --git a/tests/test_exceptions.py b/tests/test_exceptions.py index 921540194a..79b3879034 100644 --- a/tests/test_exceptions.py +++ b/tests/test_exceptions.py @@ -76,7 +76,7 @@ def test_cross_module_exceptions(msg): # TODO: FIXME @pytest.mark.xfail( - "env.MACOS and env.PYPY", + "(env.MACOS and env.PYPY) or env.ANDROID", raises=RuntimeError, reason="See Issue #2847, PR #2999, PR #4324", strict=not env.PYPY, # PR 5569