name: Test on: push: branches: - main - 2.x pull_request: types: - opened - synchronize - reopened - labeled paths-ignore: - .ci* - bin/* - docs/** - examples/azure-pipelines-* - examples/ci* - examples/travis-ci-* - .pre-commit-config.yaml - .readthedocs.yml - .travis.yml - README.md - azure-pipelines.yml - properdocs.yml - noxfile.py workflow_dispatch: # allow manual runs on branches without a PR permissions: {} concurrency: group: test-${{ github.ref }} cancel-in-progress: true env: # runners see short DNS/network outages; uv's default of 3 retries is too few UV_HTTP_RETRIES: "6" jobs: lint: name: Linters (mypy, ruff, etc.) runs-on: ubuntu-latest steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 with: python-version: "3.x" - uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1 - uses: j178/prek-action@4e14d07f9231acabce116ccfca13b13dd9755ece # v3.0.0 - name: PyLint checks run: uvx nox -s pylint -- --output-format=github sample: name: Generate a sample project needs: lint runs-on: ubuntu-latest steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 name: Install Python with: python-version: "3.x" - uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1 - name: Install dependencies run: uv sync --no-dev --group test - name: Generate a sample project run: uv run --no-sync -m test.test_projects test.test_0_basic.basic_project sample_proj - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 with: name: sample_proj path: sample_proj test: name: Test on ${{ matrix.os }} (${{ matrix.python_version }}) ${{ matrix.test_select }} needs: sample runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: include: # Min Python - os: ubuntu-latest python_version: '3.11' # Max Python - os: ubuntu-latest python_version: '3.15' - os: ubuntu-latest python_version: '3.14' test_select: android - os: ubuntu-24.04-arm python_version: '3.13' - os: windows-latest python_version: '3.13' - os: windows-11-arm python_version: '3.13' - os: macos-15-intel python_version: '3.13' - os: macos-15 python_version: '3.13' - os: macos-15-intel python_version: '3.13' test_select: ios - os: macos-15 python_version: '3.13' test_select: ios # Exercise iOS on a non-default simulator. test_runtime: 'args: --simulator "iPhone 16e,OS=18.5"' - os: macos-15-intel python_version: '3.13' test_select: android # Exercise Android on a non-default simulator test_runtime: 'args: --managed minVersion' - os: macos-15 python_version: '3.13' test_select: android timeout-minutes: 180 steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 name: Install Python ${{ matrix.python_version }} with: python-version: ${{ matrix.python_version }} allow-prereleases: true - uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1 - name: Free up disk space if: runner.os == 'Linux' && matrix.test_select != 'android' run: | sudo rm -rf $ANDROID_HOME/ndk /opt/hostedtoolcache/CodeQL \ /usr/local/lib/node_modules /usr/local/share/chromium \ /usr/local/share/powershell df -m # for oci_container unit tests - name: Set up QEMU if: runner.os == 'Linux' uses: docker/setup-qemu-action@96fe6ef7f33517b61c61be40b68a1882f3264fb8 # v4.2.0 - name: Set up Xcode if: ${{ startsWith(matrix.os, 'macos-15') }} run: | # GitHub recommends explicitly selecting the desired Xcode version sudo xcode-select --switch /Applications/Xcode_16.4.app - name: Install dependencies run: uv sync --no-dev --group test - uses: joerick/pr-labels-action@0543b277721e852d821c6738d449f2f4dea03d5f # v1.0.9 - name: Set CIBW_ENABLE shell: bash run: | if [[ "$GITHUB_REF_NAME" == "main" ]]; then CIBW_ENABLE=all else # get the default CIBW_ENABLE value from the test module CIBW_ENABLE=$(uv run --no-sync python -c 'import sys, test.utils as c; sys.stdout.write(c.DEFAULT_CIBW_ENABLE)') # if this is a PR, check for labels if [[ -n "$GITHUB_PR_LABEL_CI_PYPY" ]]; then CIBW_ENABLE+=" pypy" fi if [[ -n "$GITHUB_PR_LABEL_CI_GRAALPY" ]]; then CIBW_ENABLE+=" graalpy" fi if [[ -n "$GITHUB_PR_LABEL_CI_PYPY_EOL" ]]; then CIBW_ENABLE+=" pypy-eol" fi fi echo "CIBW_ENABLE=${CIBW_ENABLE}" >> $GITHUB_ENV - name: Download a sample project uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 with: name: sample_proj path: sample_proj - name: Run a sample build (GitHub Action) uses: ./ with: package-dir: sample_proj output-dir: wheelhouse env: CIBW_ARCHS_MACOS: x86_64 universal2 arm64 CIBW_BUILD_FRONTEND: ${{ matrix.test_select && 'build' || 'build[uv]' }} CIBW_PLATFORM: ${{ matrix.test_select }} CIBW_TEST_RUNTIME: ${{ matrix.test_runtime }} - name: Run a sample build (GitHub Action, only) uses: ./ if: matrix.test_select == '' with: package-dir: sample_proj output-dir: wheelhouse_only only: cp313-${{ runner.os == 'Linux' && (runner.arch == 'ARM64' && 'manylinux_aarch64' || 'manylinux_x86_64') || (runner.os == 'Windows' && 'win_amd64' || 'macosx_x86_64') }} - name: Create custom configuration file shell: bash run: | cat > sample_proj/cibw.toml <> "$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@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 with: python-version: "3.x" - uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1 - name: Install dependencies run: uv sync --no-dev --group test - name: Set up QEMU uses: docker/setup-qemu-action@96fe6ef7f33517b61c61be40b68a1882f3264fb8 # v4.2.0 - name: Run the emulation tests env: MATRIX_ARCH: ${{ matrix.arch }} run: uv run --no-sync pytest --run-emulation "$MATRIX_ARCH" test/test_emulation.py test-pyodide: name: Test pyodide needs: sample runs-on: ubuntu-24.04 timeout-minutes: 180 steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 name: Install Python 3.12 with: python-version: '3.12' - uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1 - name: Install dependencies run: uv sync --no-dev --group test - name: Download a sample project uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 with: name: sample_proj path: sample_proj - name: Run a sample build (GitHub Action) uses: ./ with: package-dir: sample_proj output-dir: wheelhouse env: CIBW_PLATFORM: pyodide CIBW_ENABLE: cpython-prerelease - name: Run tests with 'CIBW_PLATFORM' set to 'pyodide' run: uv run --no-sync ./bin/run_tests.py env: CIBW_PLATFORM: pyodide CIBW_ENABLE: cpython-prerelease test-uv-extras: name: Test uv extra on ${{ matrix.os }} ${{ matrix.test_select }} needs: sample runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: include: - os: ubuntu-latest test_select: android - os: windows-latest - os: windows-11-arm - os: macos-15-intel - os: macos-15 - os: macos-15-intel test_select: android - os: macos-15 test_select: android steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - name: Download a sample project uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 with: name: sample_proj path: sample_proj - name: Run a sample build (GitHub Action) uses: ./ with: extras: uv package-dir: sample_proj output-dir: wheelhouse env: CIBW_ARCHS_MACOS: x86_64 universal2 arm64 CIBW_BUILD: cp314-* CIBW_BUILD_FRONTEND: 'build[uv]' CIBW_PLATFORM: ${{ matrix.test_select }}