Skip to content

chore(tket): 🦀 release #8936

chore(tket): 🦀 release

chore(tket): 🦀 release #8936

Workflow file for this run

name: Continuous integration
on:
push:
branches:
- main
pull_request:
merge_group:
types: [checks_requested]
workflow_dispatch: {}
env:
CARGO_TERM_COLOR: always
CARGO_INCREMENTAL: 0
RUSTFLAGS: "--cfg=ci_run"
MIRIFLAGS: "-Zmiri-permissive-provenance" # Required due to warnings in bitvec 1.0.1
CI: true # insta snapshots behave differently on ci
SCCACHE_GHA_ENABLED: "true"
RUSTC_WRAPPER: "sccache"
# Pinned version for the uv package manager
UV_VERSION: "0.11.15"
UV_FROZEN: 1
# The highest and lowest supported Python versions, used for testing
PYTHON_HIGHEST: "3.14"
PYTHON_LOWEST: "3.10"
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:
pg-libs: ${{ steps.filter.outputs.pg-libs }}
tket: ${{ steps.filter.outputs.tket }}
python: ${{ steps.filter.outputs.python }}
extensions: ${{ steps.filter.outputs.extensions }}
qis: ${{ steps.filter.outputs.qis }}
steps:
- uses: actions/checkout@v7
- uses: ./.github/actions/check-changes
id: filter
check-rs:
name: Check Rust code 🦀
needs: [changes]
if: ${{ needs.changes.outputs.tket == 'true' }}
runs-on: ubuntu-latest
env:
# Fail on rust compiler warnings.
RUSTFLAGS: -D warnings
steps:
- uses: actions/checkout@v7
- uses: mozilla-actions/sccache-action@v0.0.11
- name: Install stable toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- uses: quantinuum/hugrverse-env/install-hugrenv-action@main
- name: Check formatting
run: cargo fmt -- --check
- name: Run clippy
run: cargo clippy --all-targets --all-features --workspace --exclude 'tk-pg-*' -- -D warnings
- name: Build docs
run: cargo doc --no-deps --all-features --workspace --exclude 'tk-pg-*'
env:
RUSTDOCFLAGS: "-Dwarnings"
check-py:
name: Check tket-py 🐍
needs: changes
if: ${{ needs.changes.outputs.python == 'true' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: mozilla-actions/sccache-action@v0.0.11
- name: Install stable toolchain
uses: dtolnay/rust-toolchain@stable
- name: Set up uv
uses: astral-sh/setup-uv@v7
with:
version: ${{ env.UV_VERSION }}
enable-cache: true
- uses: quantinuum/hugrverse-env/install-hugrenv-action@main
- name: Install Python ${{ env.PYTHON_LOWEST }}
run: uv python install ${{ env.PYTHON_LOWEST }}
- name: Setup dependencies
# avoid building qis-compiler
run: uv sync --package=tket --exact --all-extras --python ${{ env.PYTHON_LOWEST }}
- name: Type check with mypy
run: uv run mypy tket scripts
- name: Check formatting with ruff
run: uv run ruff format --check tket scripts test_files
- name: Lint with ruff
run: uv run ruff check tket scripts test_files
check-pg-libs-rs:
name: Check pg-libs 🦀
needs: [changes]
if: ${{ needs.changes.outputs.pg-libs == 'true' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: mozilla-actions/sccache-action@v0.0.11
- name: Install stable toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- name: Check formatting
working-directory: pg-libs
run: cargo fmt --all -- --check
- name: Run clippy
working-directory: pg-libs
run: cargo clippy --all-targets -p 'tk-pg-*' -- -D warnings
- name: Build docs
working-directory: pg-libs
run: cargo doc --no-deps -p 'tk-pg-*'
env:
RUSTDOCFLAGS: "-Dwarnings"
check-pg-libs-py:
name: Check pg-libs 🐍
needs: [changes]
if: ${{ needs.changes.outputs.pg-libs == 'true' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- name: Set up uv
uses: astral-sh/setup-uv@v7
with:
version: ${{ env.UV_VERSION }}
enable-cache: true
- name: Install Python ${{ env.PYTHON_HIGHEST }}
run: uv python install ${{ env.PYTHON_HIGHEST }}
- name: Setup dependencies
working-directory: pg-libs
run: uv sync --only-group pg-libs --python ${{ env.PYTHON_HIGHEST }}
- name: Type check with mypy
working-directory: pg-libs
run: uv run --only-group pg-libs mypy .
- name: Check formatting with ruff
working-directory: pg-libs
run: uv run --only-group pg-libs ruff format --check
- name: Lint with ruff
working-directory: pg-libs
run: uv run --only-group pg-libs ruff check
tests-pg-libs:
name: pg-libs tests
needs: [changes]
if: ${{ needs.changes.outputs.pg-libs == 'true' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: mozilla-actions/sccache-action@v0.0.11
- name: Install stable toolchain
uses: dtolnay/rust-toolchain@stable
- name: Set up uv
uses: astral-sh/setup-uv@v7
with:
version: ${{ env.UV_VERSION }}
enable-cache: true
- name: Install Python ${{ env.PYTHON_HIGHEST }}
run: uv python install ${{ env.PYTHON_HIGHEST }}
- name: Install pg-libs dev dependencies
working-directory: pg-libs
run: uv sync --only-group pg-libs --python ${{ env.PYTHON_HIGHEST }}
- name: Run stable tests
working-directory: pg-libs
run: uv run --only-group pg-libs cargo test -p 'tk-pg-*'
tests-pg-libs-nightly:
name: pg-libs tests (nightly)
needs: [changes]
if: ${{ needs.changes.outputs.pg-libs == 'true' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: mozilla-actions/sccache-action@v0.0.11
- uses: extractions/setup-just@v4
- name: Read nightly toolchain
id: nightly-toolchain
run: echo "channel=$(just --evaluate nightly_toolchain)" >> "$GITHUB_OUTPUT"
- name: Install pinned nightly toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ steps.nightly-toolchain.outputs.channel }}
- name: Set up uv
uses: astral-sh/setup-uv@v7
with:
version: ${{ env.UV_VERSION }}
enable-cache: true
- name: Install Python ${{ env.PYTHON_HIGHEST }}
run: uv python install ${{ env.PYTHON_HIGHEST }}
- name: Install pg-libs dev dependencies
working-directory: pg-libs
run: uv sync --only-group pg-libs --python ${{ env.PYTHON_HIGHEST }}
- name: Run unstable_simd tests
working-directory: pg-libs
run: uv run --only-group pg-libs cargo +${{ steps.nightly-toolchain.outputs.channel }} test -p tk-pg-bitpacked -p tk-pg-qm-tableau -p tk-pg-greedy-synth -p tk-pg-t-optimize --features unstable_simd
benches:
name: Continuous benchmarking 🏋️
needs: changes
if: ${{ needs.changes.outputs.tket == 'true' && github.event_name != 'merge_group' }}
runs-on: ubuntu-latest
permissions:
checks: write
steps:
- uses: actions/checkout@v7
- uses: mozilla-actions/sccache-action@v0.0.11
- name: Install stable toolchain
uses: dtolnay/rust-toolchain@stable
- uses: quantinuum/hugrverse-env/install-hugrenv-action@main
- uses: cargo-bins/cargo-binstall@main
- name: Install cargo-codspeed
run: cargo binstall cargo-codspeed --force
- name: Override criterion with the CodSpeed harness
run: |
cargo add --dev codspeed-criterion-compat --rename criterion --package tket
- name: Build benchmarks
run: cargo codspeed build --profile bench --features portmatching,binary-eccs,rewrite-tracing
- name: Run benchmarks
uses: CodSpeedHQ/action@v5
with:
token: ${{ secrets.CODSPEED_TOKEN }}
run: "cargo codspeed run"
mode: simulation
exclude-allocations: "true"
# Run tests on Rust stable
tests-rs-stable-no-features:
needs: changes
if: ${{ needs.changes.outputs.tket == 'true' }}
runs-on: ubuntu-latest
name: tests (Rust stable, no features)
steps:
- uses: actions/checkout@v7
- uses: mozilla-actions/sccache-action@v0.0.11
- id: toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: "stable"
- name: Configure default rust toolchain
run: rustup override set ${{steps.toolchain.outputs.name}}
- uses: quantinuum/hugrverse-env/install-hugrenv-action@main
- uses: taiki-e/install-action@nextest
- name: Build with no features
run: cargo nextest r --verbose -p tket -p tket-py -p tket-qsystem --no-default-features --no-run
- name: Tests with no features
run: cargo nextest r --verbose -p tket -p tket-py -p tket-qsystem --no-default-features
# Run tests on Rust stable
tests-rs-stable-all-features:
needs: [changes]
if: ${{ needs.changes.outputs.tket == 'true' }}
runs-on: ubuntu-latest
name: tests (Rust stable, all features)
steps:
- uses: actions/checkout@v7
- uses: mozilla-actions/sccache-action@v0.0.11
- id: toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: "stable"
- name: Configure default rust toolchain
run: rustup override set ${{steps.toolchain.outputs.name}}
- uses: quantinuum/hugrverse-env/install-hugrenv-action@main
- uses: taiki-e/install-action@nextest
# Crates using pyo3 cdylib require libpython to link test binaries;
# they are tested separately in their own jobs.
- name: Build with all features
run: cargo nextest r --verbose --workspace --exclude 'tk-pg-*' --exclude tket-py --exclude selene-hugr-qis-compiler --all-features --no-run
- name: Tests with all features
run: cargo nextest r --verbose --workspace --exclude 'tk-pg-*' --exclude tket-py --exclude selene-hugr-qis-compiler --all-features
# Run tests on other toolchains
tests-rs-other:
needs: [changes]
if: ${{ needs.changes.outputs.tket == 'true' && github.event_name != 'merge_group' }}
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
# Stable is covered by `tests-stable-no-features` and `tests-stable-all-features`
# Nightly is covered by `tests-nightly-coverage`
# MSRV is covered by `tests-msrv`
rust: [beta]
name: tests (Rust ${{ matrix.rust }})
steps:
- uses: actions/checkout@v7
- uses: mozilla-actions/sccache-action@v0.0.11
- id: toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust }}
- uses: quantinuum/hugrverse-env/install-hugrenv-action@main
- name: Configure default rust toolchain
run: rustup override set ${{steps.toolchain.outputs.name}}
- uses: taiki-e/install-action@nextest
# Crates using pyo3 cdylib require libpython to link test binaries;
# they are tested separately in their own jobs.
- name: Build with no features
run: cargo nextest r --verbose --workspace --exclude 'tk-pg-*' --exclude tket-py --exclude selene-hugr-qis-compiler --no-default-features --no-run
- name: Tests with no features
run: cargo nextest r --verbose --workspace --exclude 'tk-pg-*' --exclude tket-py --exclude selene-hugr-qis-compiler --no-default-features
- name: Build with all features
run: cargo nextest r --verbose --workspace --exclude 'tk-pg-*' --exclude tket-py --exclude selene-hugr-qis-compiler --all-features --no-run
- name: Tests with all features
run: cargo nextest r --verbose --workspace --exclude 'tk-pg-*' --exclude tket-py --exclude selene-hugr-qis-compiler --all-features
tests-nightly-coverage:
needs: [changes]
# Run only if there are changes in the relevant files
if: ${{ needs.changes.outputs.tket == 'true' && github.event_name != 'merge_group' }}
runs-on: ubuntu-latest
name: tests (Rust nightly, coverage)
steps:
- uses: actions/checkout@v7
- uses: mozilla-actions/sccache-action@v0.0.11
- uses: dtolnay/rust-toolchain@master
with:
# Nightly is required to count doctests coverage
toolchain: "nightly"
components: llvm-tools-preview
- uses: quantinuum/hugrverse-env/install-hugrenv-action@main
- name: Install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov
# Crates using pyo3 cdylib require libpython to link test binaries;
# they are tested separately in their own jobs.
- name: Run tests with coverage instrumentation
run: |
cargo llvm-cov clean --workspace
cargo llvm-cov --no-report -p tket -p tket-qsystem -p tket1-passes -p badger-optimiser -p compile-rewriter --no-default-features --doctests
cargo llvm-cov --no-report -p tket -p tket-qsystem -p tket1-passes -p badger-optimiser -p compile-rewriter --all-features --doctests
- name: Generate coverage report
run: cargo llvm-cov report --codecov --output-path coverage.json
- name: Upload coverage to codecov.io
uses: codecov/codecov-action@v7
with:
files: coverage.json
name: rust
flags: rust
fail_ci_if_error: false
token: ${{ secrets.CODECOV_TOKEN }}
# Run tests on the minimum supported rust version, with minimal dependency versions
tests-msrv:
needs: changes
if: ${{ needs.changes.outputs.tket == 'true' && github.event_name != 'merge_group' }}
runs-on: ubuntu-latest
name: tests (Rust MSRV, min dependencies)
steps:
- uses: actions/checkout@v7
- uses: mozilla-actions/sccache-action@v0.0.11
- name: Install MSRV toolchain
id: toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: "1.91"
- name: Install nightly toolchain
uses: dtolnay/rust-toolchain@master
with:
# Nightly must be installed for `cargo-minimal-versions` to work
toolchain: "nightly"
- name: Configure default rust toolchain
run: rustup override set ${{steps.toolchain.outputs.name}}
- uses: quantinuum/hugrverse-env/install-hugrenv-action@main
- uses: cargo-bins/cargo-binstall@main
- name: Install cargo-minimal-versions
run: |
cargo binstall cargo-hack --force
cargo binstall cargo-minimal-versions --force
- name: Pin transitive dependencies not compatible with our MSRV
# Add new dependencies as needed if the check fails due to
# "package `XXX` cannot be built because it requires rustc YYY or newer, while the currently active rustc version is 1.91.0"
run: |
rm Cargo.lock
# cargo add -p tket insta@2.4.1
# Crates using pyo3 cdylib require libpython to link test binaries;
# they are tested separately in their own jobs.
- name: Build with no features
run: cargo minimal-versions --direct test --verbose -p tket -p tket-qsystem -p tket1-passes -p badger-optimiser -p compile-rewriter --no-default-features --no-run
- name: Tests with no features
run: cargo minimal-versions --direct test --verbose -p tket -p tket-qsystem -p tket1-passes -p badger-optimiser -p compile-rewriter --no-default-features
- name: Build with all features
run: cargo minimal-versions --direct test --verbose -p tket -p tket-qsystem -p tket1-passes -p badger-optimiser -p compile-rewriter --all-features --no-run
- name: Tests with all features
run: cargo minimal-versions --direct test --verbose -p tket -p tket-qsystem -p tket1-passes -p badger-optimiser -p compile-rewriter --all-features
tests-py:
needs: changes
if: ${{ needs.changes.outputs.python == 'true' }}
runs-on: ubuntu-latest
name: tket-py tests (Python, coverage)
env:
PKGS: tket/tket-py tket/tket-eccs tket/tket-exts
steps:
- uses: actions/checkout@v7
- uses: mozilla-actions/sccache-action@v0.0.11
- name: Install stable toolchain
uses: dtolnay/rust-toolchain@stable
- name: Set up uv
uses: astral-sh/setup-uv@v7
with:
version: ${{ env.UV_VERSION }}
enable-cache: true
- uses: quantinuum/hugrverse-env/install-hugrenv-action@main
- name: Install Python ${{ env.PYTHON_LOWEST }}
run: uv python install ${{ env.PYTHON_LOWEST }}
- name: Setup dependencies
# avoid building qis-compiler
run: uv sync --package=tket --exact --all-extras --python ${{ env.PYTHON_LOWEST }}
- name: Run python tests with coverage instrumentation
run: uv run pytest --cov=./ --cov-report=xml ${{ env.PKGS }}
- name: Upload python coverage to codecov.io
if: github.event_name != 'merge_group'
uses: codecov/codecov-action@v7
with:
files: ./coverage.xml
# Ensures we only upload this file
disable_search: true
name: python
flags: python
fail_ci_if_error: false
token: ${{ secrets.CODECOV_TOKEN }}
tests-qis-compiler:
needs: changes
if: ${{ needs.changes.outputs.qis == 'true' }}
runs-on: ubuntu-latest
name: qis-compiler test
steps:
- uses: actions/checkout@v7
- uses: mozilla-actions/sccache-action@v0.0.11
- name: Install stable toolchain
uses: dtolnay/rust-toolchain@stable
- name: Set up uv
uses: astral-sh/setup-uv@v7
with:
version: ${{ env.UV_VERSION }}
enable-cache: true
- uses: quantinuum/hugrverse-env/install-hugrenv-action@main
- name: Install Python ${{ env.PYTHON_LOWEST }}
run: |
uv python install ${{ env.PYTHON_LOWEST }}
PYTHON=$(uv python find ${{ env.PYTHON_LOWEST }})
echo "PYO3_PYTHON=$PYTHON" >> "$GITHUB_ENV"
echo "LD_LIBRARY_PATH=$($PYTHON -c 'import sysconfig; print(sysconfig.get_config_var("LIBDIR"))')" >> "$GITHUB_ENV"
- name: Run Rust unit tests
run: cargo test -p selene-hugr-qis-compiler
- name: Run qis-compiler tests
run: uv run --python ${{ env.PYTHON_LOWEST }} --exact --package selene_hugr_qis_compiler pytest --cov=./ --cov-report=xml tket/qis-compiler
- name: Upload python coverage to codecov.io
if: github.event_name != 'merge_group'
uses: codecov/codecov-action@v7
with:
files: ./coverage.xml
# Ensures we only upload this file
disable_search: true
name: python
flags: qis-compiler
fail_ci_if_error: false
token: ${{ secrets.CODECOV_TOKEN }}
# Ensure that serialized extensions match rust implementation
tket-extensions:
needs: [changes, tests-rs-stable-all-features]
if: ${{ needs.changes.outputs.tket == 'true' && github.event_name != 'merge_group' }}
name: Check standard extensions
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: mozilla-actions/sccache-action@v0.0.11
- uses: quantinuum/hugrverse-env/install-hugrenv-action@main
- name: Install stable toolchain
uses: dtolnay/rust-toolchain@stable
- uses: extractions/setup-just@v4
- name: Generate the updated definitions
run: just tket/gen-extensions
- name: Check if the declarations are up to date
run: |
git diff --exit-code --name-only tket/tket-exts/src/tket_exts/data
if [ $? -ne 0 ]; then
echo "The serialized standard extensions are not up to date"
echo "Please run 'just tket/gen-extensions' and commit the changes.
Bump the version of tket-exts according to semver.
"
exit 1
fi
extension-versions:
runs-on: ubuntu-latest
needs: [changes]
if: ${{ needs.changes.outputs.extensions == 'true' }}
name: Check extension versions
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0 # Need full history to compare with main
- name: Set up Python
uses: actions/setup-python@v7
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-pg-libs-rs,
check-pg-libs-py,
check-rs,
check-py,
tests-pg-libs,
tests-pg-libs-nightly,
tests-rs-stable-no-features,
tests-rs-stable-all-features,
tests-py,
tket-extensions,
extension-versions,
tests-qis-compiler,
]
if: ${{ !cancelled() }}
runs-on: ubuntu-latest
steps:
- name: Debug changes step output
run: |
echo "pg-libs: ${{ needs.changes.outputs.pg-libs }}"
echo "tket: ${{ needs.changes.outputs.tket }}"
echo "python: ${{ needs.changes.outputs.python }}"
echo "extensions: ${{ needs.changes.outputs.extensions }}"
echo "qis: ${{ needs.changes.outputs.qis }}"
- name: Fail if required checks failed
if: ${{ contains(needs.*.result, 'failure') || contains(needs.*.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"