Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
132 changes: 112 additions & 20 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,61 +57,145 @@ jobs:
- 'Cargo.toml'
- 'pyproject.toml'

check-quizx:
name: 🦀 Check quizx package
# Rust formatting check
rust-fmt:
name: 🦀 Rust formatting
needs: changes
if: ${{ needs.changes.outputs.quizx == 'true' }}
if: ${{ needs.changes.outputs.quizx == 'true' || needs.changes.outputs.pybindings == 'true' }}
runs-on: ubuntu-latest
env:
RUSTC_WRAPPER: sccache
steps:
- uses: actions/checkout@v4
- name: Install stable toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
components: rustfmt
- uses: mozilla-actions/sccache-action@v0.0.9
- name: Check rust formatting (workspace)
run: cargo fmt --all -- --check

# Rust clippy check
rust-clippy:
name: 🦀 Rust clippy
needs: changes
if: ${{ needs.changes.outputs.quizx == 'true' || needs.changes.outputs.pybindings == 'true' }}
runs-on: ubuntu-latest
env:
RUSTC_WRAPPER: sccache
steps:
- uses: actions/checkout@v4
- name: Install stable toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: clippy
- uses: mozilla-actions/sccache-action@v0.0.9
- name: Run clippy (workspace)
run: cargo clippy --workspace --all-targets --all-features -- ${{ env.CLIPPY_FLAGS }}

# Rust documentation for quizx
rust-doc-quizx:
name: 🦀 Rust documentation (quizx)
needs: changes
if: ${{ needs.changes.outputs.quizx == 'true' }}
runs-on: ubuntu-latest
env:
RUSTC_WRAPPER: sccache
steps:
- uses: actions/checkout@v4
- name: Install stable toolchain
uses: dtolnay/rust-toolchain@stable
- uses: mozilla-actions/sccache-action@v0.0.9
- name: Check rust formatting
run: cargo fmt -p quizx -- --check
- name: Run clippy
run: cargo clippy --all-targets --all-features -p quizx -- ${{ env.CLIPPY_FLAGS }}
- name: Build docs
run: cargo doc --no-deps --all-features
env:
RUSTDOCFLAGS: "-Dwarnings"

check-pybindings:
name: 🦀🐍 Check quizx_pybindings
# Python type checking with mypy
python-mypy:
name: 🐍 Python type checking
needs: changes
if: ${{ needs.changes.outputs.pybindings == 'true' }}
runs-on: ubuntu-latest
env:
RUSTC_WRAPPER: sccache
steps:
- uses: actions/checkout@v4
- uses: mozilla-actions/sccache-action@v0.0.9
- name: Install rust stable toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- name: Build quizx crate
run: cargo build -p quizx
- name: Install uv
uses: astral-sh/setup-uv@v6
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 -- ${{ env.CLIPPY_FLAGS }}
- name: Type check python with mypy
run: uv run mypy .
run: uv run mypy pybindings

# Python formatting with ruff
python-ruff-format:
name: 🐍 Python formatting
needs: changes
if: ${{ needs.changes.outputs.pybindings == 'true' }}
runs-on: ubuntu-latest
env:
RUSTC_WRAPPER: sccache
steps:
- uses: actions/checkout@v4
- uses: mozilla-actions/sccache-action@v0.0.9
- name: Install rust stable toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- name: Build quizx crate
run: cargo build -p quizx
- name: Install uv
uses: astral-sh/setup-uv@v6
with:
enable-cache: true
- name: Install the project libraries
run: uv sync --frozen
- name: Check python formatting with ruff
run: uv run ruff format --check --exclude scratchpads
run: uv run ruff format --check

# Python linting with ruff
python-ruff-lint:
name: 🐍 Python linting
needs: changes
if: ${{ needs.changes.outputs.pybindings == 'true' }}
runs-on: ubuntu-latest
env:
RUSTC_WRAPPER: sccache
steps:
- uses: actions/checkout@v4
- uses: mozilla-actions/sccache-action@v0.0.9
- name: Install rust stable toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- name: Build quizx crate
run: cargo build -p quizx
- name: Install uv
uses: astral-sh/setup-uv@v6
with:
enable-cache: true
- name: Install the project libraries
run: uv sync --frozen
- name: Lint python with ruff
run: uv run ruff check --exclude scratchpads
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)
env:
RUSTC_WRAPPER: sccache
steps:
- uses: actions/checkout@v4
- uses: mozilla-actions/sccache-action@v0.0.9
Expand All @@ -137,6 +221,8 @@ jobs:
matrix:
rust: ['1.81', beta, nightly]
name: 🦀 Test quizx (Rust ${{ matrix.rust }})
env:
RUSTC_WRAPPER: sccache
steps:
- uses: actions/checkout@v4
- id: toolchain
Expand All @@ -158,6 +244,8 @@ jobs:
needs: changes
if: ${{ needs.changes.outputs.pybindings == 'true' }}
runs-on: ubuntu-latest
env:
RUSTC_WRAPPER: sccache
steps:
- uses: actions/checkout@v4
- uses: mozilla-actions/sccache-action@v0.0.9
Expand All @@ -184,7 +272,7 @@ jobs:
# 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]
needs: [changes, rust-fmt, rust-clippy, rust-doc-quizx, python-mypy, python-ruff-format, python-ruff-lint, test-quizx-stable, test-pybindings]
if: ${{ !cancelled() }}
runs-on: ubuntu-latest
steps:
Expand All @@ -195,8 +283,12 @@ jobs:
# 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.rust-fmt.result == 'failure' || needs.rust-fmt.result == 'cancelled' ||
needs.rust-clippy.result == 'failure' || needs.rust-clippy.result == 'cancelled' ||
needs.rust-doc-quizx.result == 'failure' || needs.rust-doc-quizx.result == 'cancelled' ||
needs.python-mypy.result == 'failure' || needs.python-mypy.result == 'cancelled' ||
needs.python-ruff-format.result == 'failure' || needs.python-ruff-format.result == 'cancelled' ||
needs.python-ruff-lint.result == 'failure' || needs.python-ruff-lint.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: |
Expand Down
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@ repos:
- id: ruff format
name: ruff format
description: Format python code with `ruff format`.
entry: uv run ruff format --exclude scratchpads
entry: uv run ruff format
language: system
files: \.py$
pass_filenames: false
- id: ruff lint
name: ruff lint
description: Lint python code with `ruff lint`.
entry: uv run ruff check --exclude scratchpads
entry: uv run ruff check
language: system
files: \.py$
pass_filenames: false
Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,6 @@ build-backend = "hatchling.build"
manifest-path = "pybindings/Cargo.toml"
python-source = "pybindings"
module-name = "quizx"

[tool.ruff]
exclude = ["scratchpads"]
Loading