feat: Add a python package #5
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Continuous integration 🦀 | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
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" | |
jobs: | |
# Check if changes were made to the relevant files. | |
# Always returns true if running on the default branch, to ensure all changes are throughly checked. | |
changes: | |
runs-on: ubuntu-latest | |
# Required permissions | |
permissions: | |
pull-requests: read | |
# Set job outputs to values from filter step | |
outputs: | |
rust: ${{ github.ref_name == github.event.repository.default_branch || steps.filter.outputs.rust }} | |
steps: | |
# For pull requests it's not necessary to checkout the code | |
- uses: dorny/paths-filter@v3 | |
id: filter | |
with: | |
filters: | | |
rust: | |
- 'quantinuum-hugr/**' | |
- 'Cargo.toml' | |
- 'specification/schema/**' | |
# - '!**/*.md' | |
check: | |
needs: changes | |
if: ${{ needs.changes.outputs.rust == 'true' }} | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: mozilla-actions/[email protected] | |
- name: Install stable toolchain | |
uses: dtolnay/rust-toolchain@stable | |
with: | |
components: rustfmt, clippy | |
- name: Check formatting | |
run: cargo fmt -- --check | |
- name: Run clippy | |
run: cargo clippy --all-targets --all-features --workspace -- -D warnings | |
- name: Build docs | |
run: cargo doc --no-deps --all-features --workspace | |
env: | |
RUSTDOCFLAGS: "-Dwarnings" | |
benches: | |
needs: changes | |
if: ${{ needs.changes.outputs.rust == 'true' }} && github.event_name != 'merge_group' | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: mozilla-actions/[email protected] | |
- name: Install stable toolchain | |
uses: dtolnay/rust-toolchain@stable | |
- name: Build benchmarks with no features | |
run: cargo bench --verbose --no-run --workspace --no-default-features | |
- name: Build benchmarks with all features | |
run: cargo bench --verbose --no-run --workspace --all-features | |
tests: | |
needs: changes | |
if: ${{ needs.changes.outputs.rust == 'true' }} | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
rust: ['1.75', stable, beta, nightly] | |
# workaround to ignore non-stable tests when running the merge queue checks | |
# see: https://github.community/t/how-to-conditionally-include-exclude-items-in-matrix-eg-based-on-branch/16853/6 | |
isMerge: | |
- ${{ github.event_name == 'merge_group' }} | |
exclude: | |
- rust: '1.75' | |
isMerge: true | |
- rust: beta | |
isMerge: true | |
- rust: nightly | |
isMerge: true | |
name: tests (Rust ${{ matrix.rust }}) | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: mozilla-actions/[email protected] | |
- id: toolchain | |
uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: ${{ matrix.rust }} | |
- name: Configure default rust toolchain | |
run: rustup override set ${{steps.toolchain.outputs.name}} | |
- name: Build with no features | |
run: cargo test --verbose --workspace --no-default-features --no-run | |
- name: Tests with no features | |
run: cargo test --verbose --workspace --no-default-features | |
- name: Build with all features | |
run: cargo test --verbose --workspace --all-features --no-run | |
- name: Tests with all features | |
run: cargo test --verbose --workspace --all-features | |
coverage: | |
needs: [changes, tests, check] | |
if: ${{ needs.changes.outputs.rust == 'true' }} && github.event_name != 'merge_group' | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: mozilla-actions/[email protected] | |
- uses: dtolnay/rust-toolchain@nightly | |
with: | |
components: llvm-tools-preview | |
- name: Install cargo-llvm-cov | |
uses: taiki-e/install-action@cargo-llvm-cov | |
- name: Run tests with coverage instrumentation | |
run: | | |
cargo llvm-cov clean --workspace | |
cargo llvm-cov --no-report --workspace --no-default-features --doctests | |
cargo llvm-cov --no-report --workspace --all-features --doctests | |
- name: Generate coverage report | |
run: cargo llvm-cov --all-features report --codecov --output-path coverage.json | |
- name: Upload coverage to codecov.io | |
uses: codecov/codecov-action@v4 | |
with: | |
files: coverage.json | |
name: rust | |
env: | |
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} |