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 - mkdocs.yml - noxfile.py workflow_dispatch: # allow manual runs on branches without a PR concurrency: group: test-${{ github.ref }} cancel-in-progress: true jobs: lint: name: Linters (mypy, flake8, etc.) runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 id: python with: python-version: "3.x" - uses: pre-commit/action@v3.0.1 - name: PyLint checks run: pipx run --python "${{ steps.python.outputs.python-path }}" nox -s pylint -- --output-format=github test: name: Test on ${{ matrix.os }} (${{ matrix.python_version }}) needs: lint runs-on: ${{ matrix.os }} strategy: matrix: os: [ubuntu-latest, ubuntu-24.04-arm, windows-latest, windows-11-arm, macos-13, macos-15] python_version: ['3.13'] include: - os: ubuntu-latest python_version: '3.11' - os: ubuntu-latest python_version: '3.14' timeout-minutes: 180 steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 name: Install Python ${{ matrix.python_version }} with: python-version: ${{ matrix.python_version }} allow-prereleases: true - uses: astral-sh/setup-uv@v6 # free some space to prevent reaching GHA disk space limits - name: Clean docker images if: runner.os == 'Linux' run: | docker system prune -a -f df -h # for oci_container unit tests - name: Set up QEMU if: runner.os == 'Linux' uses: docker/setup-qemu-action@v3 - name: Install dependencies run: | uv sync --no-dev --group test - uses: joerick/pr-labels-action@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 fi echo "CIBW_ENABLE=${CIBW_ENABLE}" >> $GITHUB_ENV - name: Generate a sample project run: | uv run --no-sync -m test.test_projects test.test_0_basic.basic_project 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: 'build[uv]' - name: Run a sample build (GitHub Action, only) uses: ./ with: package-dir: sample_proj output-dir: wheelhouse_only only: cp312-${{ 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@v4 - uses: actions/setup-python@v5 with: python-version: "3.x" - uses: astral-sh/setup-uv@v6 - name: Install dependencies run: uv sync --no-dev --group test - name: Set up QEMU uses: docker/setup-qemu-action@v3 - name: Run the emulation tests run: uv run --no-sync pytest --run-emulation ${{ matrix.arch }} test/test_emulation.py test-pyodide: name: Test pyodide needs: lint runs-on: ubuntu-24.04 timeout-minutes: 180 steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 name: Install Python 3.12 with: python-version: '3.12' - uses: astral-sh/setup-uv@v6 - 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 - name: Run a sample build (GitHub Action) uses: ./ with: package-dir: sample_proj output-dir: wheelhouse env: CIBW_PLATFORM: pyodide - name: Run a sample build (GitHub Action) for an overridden Pyodide version uses: ./ with: package-dir: sample_proj output-dir: wheelhouse # In case this breaks at any point in time, switch to using the latest version # available or any other version that is not the same as the default one set # in cibuildwheel/resources/build-platforms.toml. env: CIBW_PLATFORM: pyodide CIBW_BUILD: "cp312*" CIBW_PYODIDE_VERSION: "0.27.6" - name: Run tests with 'CIBW_PLATFORM' set to 'pyodide' run: | uv run --no-sync ./bin/run_tests.py env: CIBW_PLATFORM: pyodide