Skip to content

ci: Build python wheels for wasm targets #7601

ci: Build python wheels for wasm targets

ci: Build python wheels for wasm targets #7601

Workflow file for this run

name: Continuous integration 🐍
on:
push:
branches:
- main
pull_request:
branches:
- '**'
merge_group:
types: [checks_requested]
workflow_dispatch: {}
env:
SCCACHE_GHA_ENABLED: "true"
# Pinned version for the uv package manager
UV_VERSION: "0.9.5"
UV_FROZEN: 1
jobs:
# Check if changes were made to the relevant files.
# Always returns true if running on the default branch, to ensure all changes are thoroughly checked.
changes:
name: Check for changes
runs-on: ubuntu-latest
permissions:
pull-requests: read
outputs:
python: ${{ steps.filter.outputs.python }}
extensions: ${{ steps.filter.outputs.llvm }}
steps:
- uses: actions/checkout@v6
- uses: ./.github/actions/check-changes
id: filter
check:
needs: changes
if: ${{ needs.changes.outputs.python == 'true' }}
name: check python ${{ matrix.python-version }}
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.10', '3.14']
steps:
- uses: actions/checkout@v6
- name: Run sccache-cache
uses: mozilla-actions/sccache-action@v0.0.9
- name: Set up uv
uses: astral-sh/setup-uv@v7
with:
version: ${{ env.UV_VERSION }}
enable-cache: true
- name: Setup dependencies.
run: uv sync --python ${{ matrix.python-version }}
- name: Type check with mypy
run: uv run mypy .
- name: Check formatting with ruff
run: uv run ruff format --check
- name: Lint with ruff
run: uv run ruff check
test:
needs: [changes]
if: ${{ needs.changes.outputs.python == 'true' }}
name: test python ${{ matrix.python-version.py }}
runs-on: ubuntu-latest
strategy:
matrix:
python-version:
- { py: '3.10', coverage: false }
- { py: '3.14', coverage: true }
steps:
- uses: actions/checkout@v6
- name: Set up uv
uses: astral-sh/setup-uv@v7
with:
version: ${{ env.UV_VERSION }}
enable-cache: true
- name: Setup dependencies
run: uv sync --python ${{ matrix.python-version.py }}
- name: Setup Graphviz
uses: ts-graphviz/setup-graphviz@v2
- name: Run tests
if: github.event_name == 'merge_group' || !matrix.python-version.coverage
run: |
HUGR_RENDER_DOT=1 uv run pytest
- name: Run python tests with coverage instrumentation
if: github.event_name != 'merge_group' && matrix.python-version.coverage
run: |
HUGR_RENDER_DOT=1 uv run pytest --cov=./ --cov-report=xml
- name: Upload python coverage to codecov.io
if: github.event_name != 'merge_group' && matrix.python-version.coverage
uses: codecov/codecov-action@v5
with:
files: coverage.xml
name: python
flags: python
token: ${{ secrets.CODECOV_TOKEN }}
# Ensure that the serialization schema is up to date
serialization-schema:
needs: [changes]
if: ${{ needs.changes.outputs.python == 'true' }}
name: Check serialization schema
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Run sccache-cache
uses: mozilla-actions/sccache-action@v0.0.9
- name: Set up uv
uses: astral-sh/setup-uv@v7
with:
version: ${{ env.UV_VERSION }}
enable-cache: true
- name: Setup dependencies.
run: uv sync
- name: Generate the updated schema
run: |
uv run scripts/generate_schema.py specification/schema/
- name: Check if the schema is up to date
run: |
git diff --exit-code --name-only specification/schema/
if [ $? -ne 0 ]; then
echo "The serialization schema is not up to date"
echo "Please run 'just update-schema' and commit the changes"
exit 1
fi
extension-versions:
runs-on: ubuntu-latest
needs: [changes]
if: ${{ needs.changes.outputs.extensions == 'true' }}
name: Check std extensions versions
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0 # Need full history to compare with main
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: '3.10'
- name: Check if extension versions are updated
run: |
# Check against latest tag on the target branch
# When not on a pull request, base_ref should be empty so we default to HEAD
if [ -z "$TARGET_REF" ]; then
BASE_SHA="HEAD~1"
else
BASE_SHA=$(git rev-parse origin/$TARGET_REF)
fi
echo "Comparing to ref: $BASE_SHA"
python ./scripts/check_extension_versions.py $BASE_SHA
env:
TARGET_REF: ${{ github.base_ref }}
# This is a meta job to mark successful completion of the required checks,
# even if they are skipped due to no changes in the relevant files.
required-checks:
name: Required checks 🐍
needs: [changes, check, test, serialization-schema, extension-versions]
if: ${{ !cancelled() }}
runs-on: ubuntu-latest
steps:
- name: Fail if required checks failed
# This condition should simply be `if: failure() || cancelled()`,
# but there seems to be a bug in the github workflow runner.
#
# See https://github.com/orgs/community/discussions/80788
if: |
needs.changes.result == 'failure' || needs.changes.result == 'cancelled' ||
needs.check.result == 'failure' || needs.check.result == 'cancelled' ||
needs.test.result == 'failure' || needs.test.result == 'cancelled' ||
needs.serialization-schema.result == 'failure' || needs.serialization-schema.result == 'cancelled'
run: |
echo "Required checks failed"
echo "Please check the logs for more information"
exit 1
- name: Pass if required checks passed
run: |
echo "All required checks passed"