Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Do not require capnp to be installed to compile hugr-model #1907

Merged
merged 5 commits into from
Feb 5, 2025
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
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
**/snapshots/*.snap -diff

hugr-model/src/capnp/hugr_*.rs linguist-generated=true
6 changes: 4 additions & 2 deletions .github/change-filters.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
# Filters used by [dorny/path-filters](https://github.com/dorny/paths-filter)
# to detect changes in each subproject, and only run the corresponding jobs.

model: &model
- "hugr-model/**"

rust: &rust
- "hugr/**"
- "hugr-cli/**"
- "hugr-core/**"
- "hugr-passes/**"
- "hugr-model/**"
- *model
- "Cargo.toml"
- "specification/schema/**"
- ".github/workflows/ci-rs.yml"
Expand All @@ -19,6 +22,5 @@ python:
- "specification/schema/**"
- ".github/workflows/ci-py.yml"


llvm:
- "hugr-llvm/**"
2 changes: 0 additions & 2 deletions .github/workflows/ci-py.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,6 @@ jobs:
- uses: mozilla-actions/sccache-action@v0.0.7
- name: Install stable toolchain
uses: dtolnay/rust-toolchain@stable
- name: Install CapnProto
run: sudo apt-get install -y capnproto
- name: Build HUGR binary
run: cargo build -p hugr-cli
- name: Upload the binary to the artifacts
Expand Down
45 changes: 33 additions & 12 deletions .github/workflows/ci-rs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ jobs:
outputs:
rust: ${{ steps.filter.outputs.rust == 'true' || steps.override.outputs.out == 'true' }}
python: ${{ steps.filter.outputs.python == 'true' || steps.override.outputs.out == 'true' }}
model: ${{ steps.filter.outputs.model == 'true' || steps.override.outputs.out == 'true' }}
llvm: ${{ steps.filter.outputs.llvm == 'true' || steps.override.outputs.out == 'true' }}
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -73,8 +74,6 @@ jobs:
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- name: Install CapnProto
run: sudo apt-get install -y capnproto
- name: Check formatting
run: cargo fmt -- --check
- name: Install LLVM and Clang
Expand All @@ -98,8 +97,6 @@ jobs:
- uses: mozilla-actions/sccache-action@v0.0.7
- name: Install stable toolchain
uses: dtolnay/rust-toolchain@stable
- name: Install CapnProto
run: sudo apt-get install -y capnproto
- name: Install LLVM and Clang
uses: KyleMayes/install-llvm-action@v2
with:
Expand All @@ -125,8 +122,6 @@ jobs:
- name: Configure default rust toolchain
run: rustup override set ${{steps.toolchain.outputs.name}}

- name: Install CapnProto
run: sudo apt-get install -y capnproto
- name: Install LLVM and Clang
uses: KyleMayes/install-llvm-action@v2
with:
Expand All @@ -153,8 +148,6 @@ jobs:
- name: Configure default rust toolchain
run: rustup override set ${{steps.toolchain.outputs.name}}

- name: Install CapnProto
run: sudo apt-get install -y capnproto
- name: Install LLVM and Clang
uses: KyleMayes/install-llvm-action@v2
with:
Expand Down Expand Up @@ -198,8 +191,6 @@ jobs:
toolchain: ${{ matrix.rust }}
- name: Configure default rust toolchain
run: rustup override set ${{steps.toolchain.outputs.name}}
- name: Install CapnProto
run: sudo apt-get install -y capnproto
- name: Install LLVM and Clang
uses: KyleMayes/install-llvm-action@v2
with:
Expand Down Expand Up @@ -239,6 +230,38 @@ jobs:
exit 1
fi

# Ensure that the generated capnp implementation in `hugr-model` is up to date
model-capnp:
needs: [changes]
if: ${{ needs.changes.outputs.model == 'true' && github.event_name != 'merge_group' }}
name: Keep hugr-model capnp schema updated
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: mozilla-actions/sccache-action@v0.0.7
- name: Install stable toolchain
uses: dtolnay/rust-toolchain@stable
- name: Install CapnProto
run: sudo apt-get install -y capnproto
- name: Get cargo binstall
uses: cargo-bins/cargo-binstall@main
- name: Install capnproto-rust plugin
run: cargo binstall capnpc
- name: Regenerate the capnp code
run: |
capnp compile \
-orust:hugr-model/src \
--src-prefix=hugr-model \
hugr-model/capnp/hugr-v0.capnp
- name: Check if the generated capnproto code is up to date
run: |
git diff --exit-code --name-only hugr-model/capnp/
if [ $? -ne 0 ]; then
echo "The capnp generated code is not up to date"
echo "Please run 'just update-model-capnp' and commit the changes"
exit 1
fi

tests-nightly-coverage:
needs: changes
# Run only if there are changes in the relevant files
Expand All @@ -253,8 +276,6 @@ jobs:
# Nightly is required to count doctests coverage
toolchain: "nightly"
components: llvm-tools-preview
- name: Install CapnProto
run: sudo apt-get install -y capnproto
- name: Install LLVM and Clang
uses: KyleMayes/install-llvm-action@v2
with:
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/release-plz.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ jobs:

# These are needed when doing a crate release, since `cargo release`
# checks that the crate can be compiled before publishing it.
- name: Install CapnProto
run: sudo apt-get install -y capnproto
- name: Install LLVM and Clang
uses: KyleMayes/install-llvm-action@v2
with:
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/semver-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,5 @@ jobs:
needs: [changes]
if: ${{ needs.changes.outputs.rust == 'true' }}
uses: CQCL/hugrverse-actions/.github/workflows/rs-semver-checks.yml@main
with:
apt-dependencies: llvm-14 capnproto
secrets:
GITHUB_PAT: ${{ secrets.HUGRBOT_PAT }}
2 changes: 0 additions & 2 deletions .github/workflows/unsoundness.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ jobs:
- uses: Swatinem/rust-cache@v2
with:
prefix-key: v0-miri
- name: Install CapnProto
run: sudo apt-get install -y capnproto
- name: Test with Miri
run: cargo miri test

Expand Down
6 changes: 6 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ debug_assert_with_mut_call = "warn"
portgraph = { version = "0.13.0" }
insta = { version = "1.34.0" }
bitvec = "1.0.1"
capnp = "0.20.1"
cgmath = "0.18.0"
cool_asserts = "2.0.3"
criterion = "0.5.1"
Expand Down Expand Up @@ -72,6 +73,11 @@ fxhash = "0.2.1"
bumpalo = { version = "3.16.0" }
pathsearch = "0.2.0"
base64 = "0.22.1"
ordered-float = "4.6.0"
pest = "2.7.12"
pest_derive = "2.7.12"
pretty = "0.12.3"
pretty_assertions = "1.4.1"

[profile.dev.package]
insta.opt-level = 3
Expand Down
3 changes: 2 additions & 1 deletion DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ To setup the environment manually you will need:
- Just: https://just.systems/
- Rust `>=1.75`: https://www.rust-lang.org/tools/install
- uv `>=0.3`: docs.astral.sh/uv/getting-started/installation
- capnproto `>=1.0`: https://capnproto.org/install.html
- Optional: capnproto `>=1.0`: https://capnproto.org/install.html
Required when modifying the `hugr-model` serialization schema.
- Optional: llvm `== 14.0`. The "llvm" feature (backed by the sub-crate `hugr-llvm`)
requires LLVM installed. We use the rust bindings
[llvm-sys](https://crates.io/crates/llvm-sys) to [llvm](https://llvm.org/).
Expand Down
19 changes: 8 additions & 11 deletions hugr-model/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,20 @@ bench = false
[dependencies]
base64 = { workspace = true }
bumpalo = { workspace = true, features = ["collections"] }
capnp = "0.20.1"
derive_more = { version = "1.0.0", features = ["display"] }
capnp = { workspace = true }
derive_more = { workspace = true, features = ["display"] }
fxhash.workspace = true
indexmap.workspace = true
ordered-float = "4.6.0"
pest = "2.7.12"
pest_derive = "2.7.12"
pretty = "0.12.3"
ordered-float = { workspace = true }
pest = { workspace = true }
pest_derive = { workspace = true }
pretty = { workspace = true }
smol_str = { workspace = true, features = ["serde"] }
thiserror.workspace = true

[lints]
workspace = true

[build-dependencies]
capnpc = "0.20.0"

[dev-dependencies]
insta.workspace = true
pretty_assertions = "1.4.1"
insta = { workspace = true }
pretty_assertions = { workspace = true }
12 changes: 0 additions & 12 deletions hugr-model/build.rs

This file was deleted.

Loading
Loading