Skip to content

Commit 3e28edf

Browse files
authored
chore: Unify the pg-libs and tket workspaces (#2024)
Closes #2010. Things should continue working as usual. The main changes are to the `just` commands. Running `just test` / `just check` / etc. from the root will run things for both sub-projects. Use `just tket/test` or `just pg-libs/check` to run focused commands.
1 parent 2fee39b commit 3e28edf

34 files changed

Lines changed: 454 additions & 2037 deletions

File tree

‎.github/actions/check-changes/action.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ outputs:
1616
description: "The extension definitions have changed"
1717
value: ${{ steps.override.outputs.out == 'true' || steps.change-filters.outputs.extensions == 'true' }}
1818
pg-libs:
19-
description: "The pg-libs workspace has changed"
19+
description: "The pg-libs crates or shared workspace configuration have changed"
2020
value: ${{ steps.override.outputs.out == 'true' || steps.change-filters.outputs.pg-libs == 'true' }}
2121
rust:
2222
description: "Rust files have changed"

‎.github/change-filters.yml‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ rust-core: &rust-core
55
- "tket/tket-rs/**"
66
- "Cargo.toml"
77
- "Cargo.lock"
8+
- "rust-toolchain.toml"
89
- "hugrenv.lock"
910

1011
rust:
@@ -18,6 +19,13 @@ rust:
1819

1920
pg-libs:
2021
- "pg-libs/**"
22+
- "justfile"
23+
- "devenv.nix"
24+
- "Cargo.toml"
25+
- "Cargo.lock"
26+
- "rust-toolchain.toml"
27+
- "pyproject.toml"
28+
- "uv.lock"
2129

2230
python:
2331
- *rust-core

‎.github/workflows/build_docs.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ jobs:
5858

5959
- name: Run the docs build
6060
run: |
61-
just build-pydocs
61+
just tket/build-pydocs
6262
6363
- name: Upload artifact.
6464
uses: actions/upload-pages-artifact@v5

‎.github/workflows/ci.yml‎

Lines changed: 33 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ jobs:
6262
- name: Check formatting
6363
run: cargo fmt -- --check
6464
- name: Run clippy
65-
run: cargo clippy --all-targets --all-features --workspace -- -D warnings
65+
run: cargo clippy --all-targets --all-features --workspace --exclude 'pg-*' -- -D warnings
6666
- name: Build docs
67-
run: cargo doc --no-deps --all-features --workspace
67+
run: cargo doc --no-deps --all-features --workspace --exclude 'pg-*'
6868
env:
6969
RUSTDOCFLAGS: "-Dwarnings"
7070

@@ -90,11 +90,11 @@ jobs:
9090
# avoid building qis-compiler
9191
run: uv sync --package=tket --exact --all-extras --python ${{ env.PYTHON_LOWEST }}
9292
- name: Type check with mypy
93-
run: uv run mypy .
93+
run: uv run mypy tket scripts
9494
- name: Check formatting with ruff
95-
run: uv run ruff format --check
95+
run: uv run ruff format --check tket scripts test_files
9696
- name: Lint with ruff
97-
run: uv run ruff check
97+
run: uv run ruff check tket scripts test_files
9898

9999
check-pg-libs-rs:
100100
name: Check pg-libs 🦀
@@ -110,13 +110,13 @@ jobs:
110110
components: rustfmt, clippy
111111
- name: Check formatting
112112
working-directory: pg-libs
113-
run: cargo fmt -- --check
113+
run: cargo fmt --all -- --check
114114
- name: Run clippy
115115
working-directory: pg-libs
116-
run: cargo clippy --all-targets --workspace -- -D warnings
116+
run: cargo clippy --all-targets -p 'pg-*' -- -D warnings
117117
- name: Build docs
118118
working-directory: pg-libs
119-
run: cargo doc --no-deps --workspace
119+
run: cargo doc --no-deps -p 'pg-*'
120120
env:
121121
RUSTDOCFLAGS: "-Dwarnings"
122122

@@ -136,16 +136,16 @@ jobs:
136136
run: uv python install ${{ env.PYTHON_HIGHEST }}
137137
- name: Setup dependencies
138138
working-directory: pg-libs
139-
run: uv sync --python ${{ env.PYTHON_HIGHEST }}
139+
run: uv sync --only-group pg-libs --python ${{ env.PYTHON_HIGHEST }}
140140
- name: Type check with mypy
141141
working-directory: pg-libs
142-
run: uv run mypy .
142+
run: uv run --only-group pg-libs mypy .
143143
- name: Check formatting with ruff
144144
working-directory: pg-libs
145-
run: uv run ruff format --check
145+
run: uv run --only-group pg-libs ruff format --check
146146
- name: Lint with ruff
147147
working-directory: pg-libs
148-
run: uv run ruff check
148+
run: uv run --only-group pg-libs ruff check
149149

150150
tests-pg-libs:
151151
name: pg-libs tests
@@ -166,10 +166,10 @@ jobs:
166166
run: uv python install ${{ env.PYTHON_HIGHEST }}
167167
- name: Install pg-libs dev dependencies
168168
working-directory: pg-libs
169-
run: uv sync --python ${{ env.PYTHON_HIGHEST }}
169+
run: uv sync --only-group pg-libs --python ${{ env.PYTHON_HIGHEST }}
170170
- name: Run stable tests
171171
working-directory: pg-libs
172-
run: cargo test --workspace
172+
run: uv run --only-group pg-libs cargo test -p 'pg-*'
173173

174174
tests-pg-libs-nightly:
175175
name: pg-libs tests (nightly)
@@ -179,10 +179,14 @@ jobs:
179179
steps:
180180
- uses: actions/checkout@v7
181181
- uses: mozilla-actions/sccache-action@v0.0.11
182+
- uses: extractions/setup-just@v4
183+
- name: Read nightly toolchain
184+
id: nightly-toolchain
185+
run: echo "channel=$(just --evaluate nightly_toolchain)" >> "$GITHUB_OUTPUT"
182186
- name: Install pinned nightly toolchain
183187
uses: dtolnay/rust-toolchain@master
184188
with:
185-
toolchain: nightly-2026-09-22
189+
toolchain: ${{ steps.nightly-toolchain.outputs.channel }}
186190
- name: Set up uv
187191
uses: astral-sh/setup-uv@v7
188192
with:
@@ -192,10 +196,10 @@ jobs:
192196
run: uv python install ${{ env.PYTHON_HIGHEST }}
193197
- name: Install pg-libs dev dependencies
194198
working-directory: pg-libs
195-
run: uv sync --python ${{ env.PYTHON_HIGHEST }}
199+
run: uv sync --only-group pg-libs --python ${{ env.PYTHON_HIGHEST }}
196200
- name: Run simd tests
197201
working-directory: pg-libs
198-
run: cargo test -p pg-bitpacked -p pg-qm-tableau -p pg-greedy-synth --features simd
202+
run: uv run --only-group pg-libs cargo +${{ steps.nightly-toolchain.outputs.channel }} test -p pg-bitpacked -p pg-qm-tableau -p pg-greedy-synth --features simd
199203

200204
benches:
201205
name: Continuous benchmarking 🏋️
@@ -267,9 +271,9 @@ jobs:
267271
# Crates using pyo3 cdylib require libpython to link test binaries;
268272
# they are tested separately in their own jobs.
269273
- name: Build with all features
270-
run: cargo nextest r --verbose --workspace --exclude tket-py --exclude selene-hugr-qis-compiler --all-features --no-run
274+
run: cargo nextest r --verbose --workspace --exclude 'pg-*' --exclude tket-py --exclude selene-hugr-qis-compiler --all-features --no-run
271275
- name: Tests with all features
272-
run: cargo nextest r --verbose --workspace --exclude tket-py --exclude selene-hugr-qis-compiler --all-features
276+
run: cargo nextest r --verbose --workspace --exclude 'pg-*' --exclude tket-py --exclude selene-hugr-qis-compiler --all-features
273277

274278
# Run tests on other toolchains
275279
tests-rs-other:
@@ -298,13 +302,13 @@ jobs:
298302
# Crates using pyo3 cdylib require libpython to link test binaries;
299303
# they are tested separately in their own jobs.
300304
- name: Build with no features
301-
run: cargo nextest r --verbose --workspace --exclude tket-py --exclude selene-hugr-qis-compiler --no-default-features --no-run
305+
run: cargo nextest r --verbose --workspace --exclude 'pg-*' --exclude tket-py --exclude selene-hugr-qis-compiler --no-default-features --no-run
302306
- name: Tests with no features
303-
run: cargo nextest r --verbose --workspace --exclude tket-py --exclude selene-hugr-qis-compiler --no-default-features
307+
run: cargo nextest r --verbose --workspace --exclude 'pg-*' --exclude tket-py --exclude selene-hugr-qis-compiler --no-default-features
304308
- name: Build with all features
305-
run: cargo nextest r --verbose --workspace --exclude tket-py --exclude selene-hugr-qis-compiler --all-features --no-run
309+
run: cargo nextest r --verbose --workspace --exclude 'pg-*' --exclude tket-py --exclude selene-hugr-qis-compiler --all-features --no-run
306310
- name: Tests with all features
307-
run: cargo nextest r --verbose --workspace --exclude tket-py --exclude selene-hugr-qis-compiler --all-features
311+
run: cargo nextest r --verbose --workspace --exclude 'pg-*' --exclude tket-py --exclude selene-hugr-qis-compiler --all-features
308312

309313
tests-nightly-coverage:
310314
needs: [changes]
@@ -328,8 +332,8 @@ jobs:
328332
- name: Run tests with coverage instrumentation
329333
run: |
330334
cargo llvm-cov clean --workspace
331-
cargo llvm-cov --no-report --workspace --exclude tket-py --exclude selene-hugr-qis-compiler --no-default-features --doctests
332-
cargo llvm-cov --no-report --workspace --exclude tket-py --exclude selene-hugr-qis-compiler --all-features --doctests
335+
cargo llvm-cov --no-report -p tket -p tket-qsystem -p tket1-passes -p badger-optimiser -p compile-rewriter --no-default-features --doctests
336+
cargo llvm-cov --no-report -p tket -p tket-qsystem -p tket1-passes -p badger-optimiser -p compile-rewriter --all-features --doctests
333337
- name: Generate coverage report
334338
run: cargo llvm-cov report --codecov --output-path coverage.json
335339
- name: Upload coverage to codecov.io
@@ -377,13 +381,13 @@ jobs:
377381
# Crates using pyo3 cdylib require libpython to link test binaries;
378382
# they are tested separately in their own jobs.
379383
- name: Build with no features
380-
run: cargo minimal-versions --direct test --verbose --exclude tket-py --exclude selene-hugr-qis-compiler --no-default-features --no-run
384+
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
381385
- name: Tests with no features
382-
run: cargo minimal-versions --direct test --verbose --exclude tket-py --exclude selene-hugr-qis-compiler --no-default-features
386+
run: cargo minimal-versions --direct test --verbose -p tket -p tket-qsystem -p tket1-passes -p badger-optimiser -p compile-rewriter --no-default-features
383387
- name: Build with all features
384-
run: cargo minimal-versions --direct test --verbose --exclude tket-py --exclude selene-hugr-qis-compiler --all-features --no-run
388+
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
385389
- name: Tests with all features
386-
run: cargo minimal-versions --direct test --verbose --exclude tket-py --exclude selene-hugr-qis-compiler --all-features
390+
run: cargo minimal-versions --direct test --verbose -p tket -p tket-qsystem -p tket1-passes -p badger-optimiser -p compile-rewriter --all-features
387391

388392
tests-py:
389393
needs: changes

‎.pre-commit-config.yaml‎

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -39,70 +39,70 @@ repos:
3939
- repo: local
4040
hooks:
4141
- id: ruff-format
42-
name: ruff format
42+
name: ruff format (tket)
4343
description: Format python code with `ruff`.
44-
entry: uv run ruff format
44+
entry: uv run ruff format tket scripts test_files
4545
language: system
4646
files: \.py$
4747
exclude: ^pg-libs/
4848
pass_filenames: false
4949
- id: ruff-check
50-
name: ruff
50+
name: ruff (tket)
5151
description: Check python code with `ruff`.
52-
entry: uv run ruff check --fix --exit-non-zero-on-fix
52+
entry: uv run ruff check --fix --exit-non-zero-on-fix tket scripts test_files
5353
language: system
5454
files: \.py$
5555
exclude: ^pg-libs/
5656
pass_filenames: false
5757
- id: mypy-check-tket
5858
name: mypy (tket)
5959
description: Check tket Python code with `mypy`.
60-
entry: uv run --all-extras mypy .
60+
entry: uv run --all-extras mypy tket scripts
6161
language: system
6262
files: \.py$
6363
exclude: ^pg-libs/
6464
pass_filenames: false
6565
- id: cargo-fmt
6666
name: cargo format
6767
description: Format rust code with `cargo fmt`.
68-
entry: uv run -- cargo fmt --all -- --check
68+
entry: cargo fmt --all -- --check
6969
language: system
7070
files: \.rs$
7171
exclude: ^pg-libs/
7272
pass_filenames: false
7373
- id: cargo-check
74-
name: cargo check
74+
name: cargo check (tket)
7575
description: Check rust code with `cargo check`.
76-
entry: env RUSTFLAGS="-Dwarnings" uv run -- cargo check --all --all-features --workspace
76+
entry: env RUSTFLAGS="-Dwarnings" uv run -- cargo check --all --all-features --workspace --exclude 'pg-*'
7777
language: system
7878
files: \.rs$
7979
exclude: ^pg-libs/
8080
pass_filenames: false
8181
- id: cargo-test
82-
name: cargo nextest r
82+
name: cargo nextest r (tket)
8383
description: Run tests with `cargo nextest r`.
84-
entry: uv run -- cargo nextest r --all-features
84+
entry: just tket/test-rust
8585
language: system
8686
files: \.rs$
8787
exclude: ^pg-libs/
8888
pass_filenames: false
8989
- id: cargo-clippy
90-
name: cargo clippy
90+
name: cargo clippy (tket)
9191
description: Run clippy lints with `cargo clippy`.
92-
entry: uv run -- cargo clippy --all-features --all-targets --workspace -- -D warnings
92+
entry: uv run -- cargo clippy --all-features --all-targets --workspace --exclude 'pg-*' -- -D warnings
9393
language: system
9494
files: \.rs$
9595
exclude: ^pg-libs/
9696
pass_filenames: false
9797
- id: cargo-doc
98-
name: cargo doc
98+
name: cargo doc (tket)
9999
description: Generate documentation with `cargo doc`.
100-
entry: uv run -- cargo doc --no-deps --all-features --workspace
100+
entry: uv run -- cargo doc --no-deps --all-features --workspace --exclude 'pg-*'
101101
language: system
102102
files: \.rs$
103103
exclude: ^pg-libs/
104104
pass_filenames: false
105-
# pg-libs hooks (separate Cargo/uv workspace)
105+
# pg-libs hooks (scoped to the pg-libs crates and Python tools)
106106
- id: ruff-format-pg-libs
107107
name: ruff format (pg-libs)
108108
description: Format pg-libs python code with `ruff`.
@@ -120,44 +120,42 @@ repos:
120120
- id: mypy-check-pg-libs
121121
name: mypy (pg-libs)
122122
description: Check pg-libs Python code with `mypy`.
123-
entry: sh -c "cd pg-libs && env -u UV_PROJECT_ENVIRONMENT -u VIRTUAL_ENV uv run mypy ."
123+
entry: sh -c "cd pg-libs && uv run --only-group pg-libs mypy ."
124124
language: system
125125
files: ^pg-libs/.*\.py$
126126
pass_filenames: false
127127
- id: cargo-fmt-pg-libs
128128
name: cargo format (pg-libs)
129129
description: Format pg-libs rust code with `cargo fmt`.
130-
entry: sh -c "cd pg-libs && cargo fmt --all -- --check"
130+
entry: cargo fmt --all -- --check
131131
language: system
132132
files: ^pg-libs/.*\.rs$
133133
pass_filenames: false
134134
- id: cargo-check-pg-libs
135135
name: cargo check (pg-libs)
136136
description: Check pg-libs rust code with `cargo check`.
137-
entry: sh -c "cd pg-libs && env RUSTFLAGS='-Dwarnings' cargo check --workspace"
137+
entry: sh -c "cd pg-libs && env RUSTFLAGS='-Dwarnings' cargo check -p 'pg-*'"
138138
language: system
139139
files: ^pg-libs/.*\.rs$
140140
pass_filenames: false
141141
- id: cargo-clippy-pg-libs
142142
name: cargo clippy (pg-libs)
143143
description: Run clippy lints on pg-libs with `cargo clippy`.
144-
entry: sh -c "cd pg-libs && cargo clippy --all-targets --workspace -- -D warnings"
144+
entry: sh -c "cd pg-libs && cargo clippy --all-targets -p 'pg-*' -- -D warnings"
145145
language: system
146146
files: ^pg-libs/.*\.rs$
147147
pass_filenames: false
148148
- id: cargo-test-pg-libs
149149
name: cargo nextest r (pg-libs)
150150
description: Run pg-libs tests with `cargo nextest r`.
151-
# cd into pg-libs so Cargo picks up pg-libs/.cargo/config.toml.
152-
entry: sh -c "cd pg-libs && cargo nextest r"
151+
entry: sh -c "cd pg-libs && uv run --only-group pg-libs cargo nextest r -p 'pg-*'"
153152
language: system
154153
files: ^pg-libs/.*\.rs$
155154
pass_filenames: false
156155
- id: py-test
157-
name: pytest
156+
name: pytest (tket)
158157
description: Run python tests
159-
# Ensure that we are using the local version of `tket-eccs` and not the one from PyPI
160-
entry: uv run -- sh -c "maturin develop && pytest --cov=./ --cov-report=html"
158+
entry: just tket/test-python
161159
language: system
162160
files: \.py$
163161
exclude: ^pg-libs/

0 commit comments

Comments
 (0)