-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main' into refactor/one_extensio…
…n_solution
- Loading branch information
Showing
78 changed files
with
3,385 additions
and
1,230 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,163 @@ | ||
name: Continuous integration 🐍 | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
merge_group: | ||
types: [checks_requested] | ||
workflow_dispatch: {} | ||
|
||
env: | ||
SCCACHE_GHA_ENABLED: "true" | ||
|
||
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: | ||
name: Check for changes in Python files | ||
runs-on: ubuntu-latest | ||
# Required permissions | ||
permissions: | ||
pull-requests: read | ||
# Set job outputs to values from filter step | ||
outputs: | ||
python: ${{ github.ref_name == github.event.repository.default_branch || steps.filter.outputs.python }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: dorny/paths-filter@v3 | ||
id: filter | ||
with: | ||
filters: | | ||
python: | ||
- 'quantinuum-hugr-py/**' | ||
- 'pyproject.toml' | ||
- 'specification/schema/**' | ||
check: | ||
needs: changes | ||
if: ${{ needs.changes.outputs.python == 'true' }} | ||
|
||
name: check python | ||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
matrix: | ||
python-version: ['3.10'] | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Run sccache-cache | ||
uses: mozilla-actions/[email protected] | ||
- name: Install poetry | ||
run: pipx install poetry | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
cache: "poetry" | ||
|
||
- name: Install the project libraries | ||
run: poetry install | ||
|
||
- name: Type check with mypy | ||
run: poetry run mypy . | ||
|
||
- name: Check formatting with ruff | ||
run: poetry run ruff format --check | ||
|
||
- name: Lint with ruff | ||
run: poetry run ruff check | ||
|
||
- name: Run tests | ||
run: poetry run pytest | ||
|
||
# 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@v4 | ||
- name: Run sccache-cache | ||
uses: mozilla-actions/[email protected] | ||
- name: Install poetry | ||
run: pipx install poetry | ||
- name: Set up Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: "3.10" | ||
cache: "poetry" | ||
- name: Install the project libraries | ||
run: poetry install | ||
- name: Generate the updated schema | ||
run: | | ||
poetry run python 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 | ||
# 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, serialization-schema] | ||
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.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" | ||
coverage: | ||
needs: [changes, check] | ||
# Run only if there are changes in the relevant files and the check job passed or was skipped | ||
if: always() && !failure() && !cancelled() && needs.changes.outputs.python == 'true' && github.event_name != 'merge_group' | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Run sccache-cache | ||
uses: mozilla-actions/[email protected] | ||
- name: Install poetry | ||
run: pipx install poetry | ||
- name: Set up Python 3.10 | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.10' | ||
cache: "poetry" | ||
|
||
- name: Install the project libraries | ||
run: poetry install | ||
|
||
- name: Run python tests with coverage instrumentation | ||
run: poetry run pytest --cov=./ --cov-report=xml | ||
|
||
- name: Upload python coverage to codecov.io | ||
uses: codecov/codecov-action@v4 | ||
with: | ||
files: coverage.xml | ||
name: python | ||
flags: python | ||
token: ${{ secrets.CODECOV_TOKEN }} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,183 @@ | ||
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: | ||
name: Check for changes in Rust files | ||
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: | ||
- uses: actions/checkout@v4 | ||
- uses: dorny/paths-filter@v3 | ||
id: filter | ||
with: | ||
filters: | | ||
rust: | ||
- 'quantinuum-hugr/**' | ||
- 'Cargo.toml' | ||
- 'specification/schema/**' | ||
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 | ||
|
||
# Run tests on Rust stable | ||
tests-stable: | ||
needs: changes | ||
if: ${{ needs.changes.outputs.rust == 'true' }} | ||
runs-on: ubuntu-latest | ||
name: tests (Rust stable) | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: mozilla-actions/[email protected] | ||
- id: toolchain | ||
uses: dtolnay/rust-toolchain@master | ||
with: | ||
toolchain: 'stable' | ||
- 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 | ||
|
||
# Run tests on other toolchains | ||
tests-other: | ||
needs: changes | ||
if: ${{ needs.changes.outputs.rust == 'true' && github.event_name != 'merge_group' }} | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: true | ||
matrix: | ||
rust: ['1.75', beta, nightly] | ||
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 | ||
|
||
# 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, tests-stable] | ||
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.tests-stable.result == 'failure' || needs.tests-stable.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" | ||
coverage: | ||
needs: [changes, tests-stable, tests-other, check] | ||
# Run only if there are changes in the relevant files and the check job passed or was skipped | ||
if: always() && !failure() && !cancelled() && 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 | ||
flags: rust | ||
token: ${{ secrets.CODECOV_TOKEN }} |
Oops, something went wrong.