CI #149
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: CI | |
on: | |
push: | |
branches: | |
- master | |
pull_request: | |
branches: | |
- master | |
merge_group: | |
types: [checks_requested] | |
workflow_dispatch: {} | |
env: | |
CARGO_TERM_COLOR: always | |
CARGO_INCREMENTAL: 0 | |
RUSTFLAGS: "--cfg=ci_run" | |
MIRIFLAGS: '-Zmiri-permissive-provenance' | |
SCCACHE_GHA_ENABLED: "true" | |
RUSTC_WRAPPER: "sccache" | |
# Supported python version range | |
PYTHON_MIN_VERSION: 3.9 | |
PYTHON_MAX_VERSION: 3.13 | |
jobs: | |
# Computes if changes where made to each group of files, so we can run only the necessary checks. | |
# | |
# Always returns true if running on the default branch, to ensure all changes are throughly checked. | |
changes: | |
name: Compute file changes | |
runs-on: ubuntu-latest | |
# Required permissions | |
permissions: | |
pull-requests: read | |
# Set job outputs to values from filter step | |
# | |
# Always returns true if running on the default branch, to ensure all changes are throughly checked. | |
outputs: | |
quizx: ${{ github.ref_name == github.event.repository.default_branch || steps.filter.outputs.quizx }} | |
pybindings: ${{ github.ref_name == github.event.repository.default_branch || steps.filter.outputs.pybindings }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: dorny/paths-filter@v3 | |
id: filter | |
with: | |
filters: | | |
quizx: | |
- .github/workflows/ci.yml | |
- 'quizx/**' | |
- 'circuits/**' | |
- 'Cargo.toml' | |
pybindings: | |
- .github/workflows/ci.yml | |
- 'quizx/**' | |
- 'pybindings/**' | |
- 'Cargo.toml' | |
check-quizx: | |
name: π¦ Check quizx package | |
needs: changes | |
if: ${{ needs.changes.outputs.quizx == 'true' }} | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install stable toolchain | |
uses: dtolnay/rust-toolchain@stable | |
with: | |
components: rustfmt, clippy | |
- uses: mozilla-actions/[email protected] | |
- name: Check rust formatting | |
run: cargo fmt -p quizx -- --check | |
- name: Run clippy | |
run: cargo clippy --all-targets --all-features -p quizx -- -D warnings | |
- name: Build docs | |
run: cargo doc --no-deps --all-features | |
env: | |
RUSTDOCFLAGS: "-Dwarnings" | |
check-pybindings: | |
name: π¦π Check quizx_pybindings | |
needs: changes | |
if: ${{ needs.changes.outputs.pybindings == 'true' }} | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: mozilla-actions/[email protected] | |
- name: Install rust stable toolchain | |
uses: dtolnay/rust-toolchain@stable | |
with: | |
components: rustfmt, clippy | |
- name: Install uv | |
uses: astral-sh/setup-uv@v3 | |
with: | |
enable-cache: true | |
- name: Install the project libraries | |
run: uv sync --frozen | |
- name: Check rust formatting | |
run: cargo fmt -p quizx_pybindings -- --check | |
- name: Run clippy | |
run: cargo clippy --all-targets --all-features -p quizx_pybindings -- -D warnings | |
- name: Type check python with mypy | |
run: uv run mypy . | |
- name: Check python formatting with ruff | |
run: uv run ruff format --check | |
- name: Lint python with ruff | |
run: uv run ruff check | |
test-quizx-stable: | |
needs: changes | |
if: ${{ needs.changes.outputs.quizx == 'true' }} | |
runs-on: ubuntu-latest | |
name: π¦ Test quizx (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 -p quizx | |
- name: Tests with no features | |
run: cargo test --verbose --workspace --no-default-features -p quizx | |
test-quizx-other: | |
needs: changes | |
if: ${{ needs.changes.outputs.quizx == 'true' && github.event_name != 'merge_group' }} | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: true | |
matrix: | |
rust: ['1.75', beta, nightly] | |
name: π¦ Test quizx (Rust ${{ matrix.rust }}) | |
steps: | |
- uses: actions/checkout@v4 | |
- id: toolchain | |
uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: ${{ matrix.rust }} | |
- name: Configure default rust toolchain | |
run: rustup override set ${{steps.toolchain.outputs.name}} | |
- uses: mozilla-actions/[email protected] | |
- name: Build with all features | |
run: cargo test --verbose --all-features --no-run -p quizx | |
- name: Tests with all features | |
run: cargo test --verbose --all-features -p quizx | |
test-pybindings: | |
name: π Build and Test quizx_pybindings | |
needs: changes | |
if: ${{ needs.changes.outputs.pybindings == 'true' }} | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: mozilla-actions/[email protected] | |
- name: Install rust stable toolchain | |
uses: dtolnay/rust-toolchain@stable | |
with: | |
components: rustfmt, clippy | |
- name: Install poetry | |
run: pipx install poetry | |
- name: Install uv | |
uses: astral-sh/setup-uv@v3 | |
with: | |
enable-cache: true | |
- name: Build pyo3 bindings for minimum supported python version | |
run: uv run --python ${{ env.PYTHON_MIN_VERSION }} maturin develop | |
- name: Test pyo3 bindings for minimum supported python version | |
run: uv run --python ${{ env.PYTHON_MIN_VERSION }} pytest | |
- name: Build pyo3 bindings for latest supported python version | |
run: uv run --python ${{ env.PYTHON_MAX_VERSION }} maturin develop | |
- name: Test pyo3 bindings for latest supported python version | |
run: uv run --python ${{ env.PYTHON_MAX_VERSION }} pytest | |
# 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-quizx, check-pybindings, test-quizx-stable, test-pybindings] | |
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-quizx.result == 'failure' || needs.check-quizx.result == 'cancelled' || | |
needs.check-pybindings.result == 'failure' || needs.check-pybindings.result == 'cancelled' || | |
needs.test-quizx-stable.result == 'failure' || needs.test-quizx-stable.result == 'cancelled' || | |
needs.test-pybindings.result == 'failure' || needs.test-pybindings.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" |