211 lines
6.0 KiB
YAML
211 lines
6.0 KiB
YAML
name: Test
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
pull_request:
|
|
paths-ignore:
|
|
- 'docs/**'
|
|
- .pre-commit-config.yaml
|
|
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
|
|
with:
|
|
python-version: "3.x"
|
|
- uses: pre-commit/action@v3.0.1
|
|
- name: Check manifest
|
|
run: pipx run nox -s check_manifest
|
|
- name: PyLint checks
|
|
run: pipx run 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, windows-latest, macos-13, macos-14]
|
|
python_version: ['3.12']
|
|
include:
|
|
- os: ubuntu-latest
|
|
python_version: '3.8'
|
|
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 }}
|
|
|
|
- uses: yezz123/setup-uv@v4
|
|
|
|
# Install podman on this CI instance for podman tests on linux
|
|
# Snippet from: https://github.com/redhat-actions/podman-login/blob/main/.github/workflows/example.yml
|
|
- name: Install latest podman
|
|
if: runner.os == 'Linux'
|
|
run: |
|
|
. /etc/os-release
|
|
echo "deb https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/xUbuntu_${VERSION_ID}/ /" | sudo tee /etc/apt/sources.list.d/devel:kubic:libcontainers:stable.list
|
|
curl -sSfL "https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/xUbuntu_${VERSION_ID}/Release.key" | sudo apt-key add -
|
|
sudo apt-get update
|
|
sudo apt-get -y install podman
|
|
|
|
# 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
|
|
|
|
- name: Install dependencies
|
|
run: |
|
|
uv pip install --system ".[test]"
|
|
|
|
- name: Generate a sample project
|
|
run: |
|
|
python -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]'
|
|
CIBW_FREE_THREADED_SUPPORT: 1
|
|
CIBW_PRERELEASE_PYTHONS: 1
|
|
|
|
- name: Run a sample build (GitHub Action, only)
|
|
uses: ./
|
|
with:
|
|
package-dir: sample_proj
|
|
output-dir: wheelhouse_only
|
|
only: cp312-${{ runner.os == 'Linux' && 'manylinux_x86_64' || (runner.os == 'Windows' && 'win_amd64' || 'macosx_x86_64') }}
|
|
|
|
- name: Create custom configuration file
|
|
shell: bash
|
|
run: |
|
|
cat > sample_proj/cibw.toml <<EOF
|
|
[tool.cibuildwheel]
|
|
# Only build on CPython 3.12 on native arch
|
|
archs = ["native"]
|
|
build = "cp312-*"
|
|
# Skip musllinux
|
|
skip = "*-musllinux*"
|
|
EOF
|
|
|
|
- name: Run a sample build (GitHub Action, config-file)
|
|
uses: ./
|
|
with:
|
|
package-dir: sample_proj
|
|
output-dir: wheelhouse_config_file
|
|
config-file: sample_proj/cibw.toml
|
|
|
|
- name: Check Action artefacts
|
|
shell: bash
|
|
run: |
|
|
test $(find wheelhouse -name '*.whl' | wc -l) -ge 1
|
|
test $(find wheelhouse_only -name '*.whl' | wc -l) -eq 1
|
|
test $(find wheelhouse_config_file -name '*.whl' | wc -l) -eq 1
|
|
|
|
- uses: actions/upload-artifact@v4
|
|
with:
|
|
name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }}
|
|
path: wheelhouse/*.whl
|
|
|
|
- name: Test cibuildwheel
|
|
run: |
|
|
python ./bin/run_tests.py --run-podman
|
|
|
|
emulated-archs:
|
|
name: Get qemu emulated architectures
|
|
needs: lint
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
archs: ${{ steps.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: Get qemu emulated architectures
|
|
id: archs
|
|
run: |
|
|
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,uv]"
|
|
|
|
- name: Set up QEMU
|
|
id: qemu
|
|
uses: docker/setup-qemu-action@v3
|
|
with:
|
|
platforms: all
|
|
|
|
- name: Run the emulation tests
|
|
run: pytest --run-emulation ${{ matrix.arch }} test/test_emulation.py
|
|
|
|
test-pyodide:
|
|
name: Test cibuildwheel building pyodide wheels
|
|
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'
|
|
|
|
- name: Install dependencies
|
|
run: |
|
|
python -m pip install ".[test]"
|
|
|
|
- name: Generate a sample project
|
|
run: |
|
|
python -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 tests with 'CIBW_PLATFORM' set to 'pyodide'
|
|
run: |
|
|
python ./bin/run_tests.py
|
|
env:
|
|
CIBW_PLATFORM: pyodide
|