Skip to content

Commit

Permalink
chore: Add a rust workspace (#868)
Browse files Browse the repository at this point in the history
Moves the main crate to a directory.
This change does not alter the public package.

Closes #865
  • Loading branch information
aborgna-q authored Mar 7, 2024
1 parent fa54d0f commit d93e795
Show file tree
Hide file tree
Showing 96 changed files with 103 additions and 75 deletions.
20 changes: 10 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ jobs:
- name: Check formatting
run: cargo fmt -- --check
- name: Run clippy
run: cargo clippy --all-targets --all-features -- -D warnings
run: cargo clippy --all-targets --all-features --workspace -- -D warnings
- name: Build docs
run: cargo doc --no-deps --all-features
run: cargo doc --no-deps --all-features --workspace
env:
RUSTDOCFLAGS: "-Dwarnings"

Expand All @@ -48,9 +48,9 @@ jobs:
- name: Install stable toolchain
uses: dtolnay/rust-toolchain@stable
- name: Build benchmarks with no features
run: cargo bench --verbose --no-run --no-default-features
run: cargo bench --verbose --no-run --workspace --no-default-features
- name: Build benchmarks with all features
run: cargo bench --verbose --no-run --all-features
run: cargo bench --verbose --no-run --workspace --all-features

tests:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -79,13 +79,13 @@ jobs:
- name: Configure default rust toolchain
run: rustup override set ${{steps.toolchain.outputs.name}}
- name: Build with no features
run: cargo test --verbose --no-default-features --no-run
run: cargo test --verbose --workspace --no-default-features --no-run
- name: Tests with no features
run: cargo test --verbose --no-default-features
run: cargo test --verbose --workspace --no-default-features
- name: Build with all features
run: cargo test --verbose --all-features --no-run
run: cargo test --verbose --workspace --all-features --no-run
- name: Tests with all features
run: cargo test --verbose --all-features
run: cargo test --verbose --workspace --all-features

coverage:
if: github.event_name != 'merge_group'
Expand All @@ -102,8 +102,8 @@ jobs:
- name: Run tests with coverage instrumentation
run: |
cargo llvm-cov clean --workspace
cargo llvm-cov --no-report --no-default-features --doctests
cargo llvm-cov --no-report --all-features --doctests
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
Expand Down
81 changes: 18 additions & 63 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,70 +1,25 @@
[package]
name = "quantinuum-hugr"
version = "0.2.0"
edition = "2021"
rust-version = "1.75"

license = "Apache-2.0"
readme = "README.md"
documentation = "https://docs.rs/hugr/"
repository = "https://github.com/CQCL/hugr"
description = "Quantinuum's Hierarchical Unified Graph Representation"
keywords = ["Quantum", "Quantinuum"]
categories = ["compilers"]

[lib]
# Using different names for the lib and for the package is supported, but may be confusing.
# https://github.com/rust-lang/cargo/issues/6827
# TODO: Should we rename one of them?
name = "hugr"
bench = false
path = "src/lib.rs"
[profile.release]
lto = "thin"

[features]
extension_inference = []
[workspace]
resolver = "2"
members = ["quantinuum-hugr"]
default-members = ["quantinuum-hugr"]

[dependencies]
thiserror = "1.0.28"
portgraph = { version = "0.12.0", features = ["serde", "petgraph"] }
regex = "1.9.5"
cgmath = { version = "0.18.0", features = ["serde"] }
num-rational = { version = "0.4.1", features = ["serde"] }
downcast-rs = "1.2.0"
serde = { version = "1.0", features = [
# Rc used here for Extension, but unfortunately we must turn the feature on globally
"derive",
"rc",
] }
serde_yaml = "0.9.19"
typetag = "0.2.7"
smol_str = { version = "0.2.0", features = ["serde"] }
derive_more = "0.99.17"
itertools = "0.12.0"
html-escape = "0.2.13"
bitvec = { version = "1.0.1", features = ["serde"] }
enum_dispatch = "0.3.11"
lazy_static = "1.4.0"
petgraph = { version = "0.6.3", default-features = false }
context-iterators = "0.2.0"
serde_json = "1.0.97"
delegate = "0.12.0"
paste = "1.0"
strum = "0.26.1"
strum_macros = "0.26.1"

[dev-dependencies]
criterion = { version = "0.5.1", features = ["html_reports"] }
rstest = "0.18.1"
webbrowser = "0.8.10"
urlencoding = "2.1.2"
cool_asserts = "2.0.3"
insta = { version = "1.34.0", features = ["yaml"] }
jsonschema = "0.17.1"
[workspace.package]
rust-version = "1.75"
edition = "2021"
homepage = "https://github.com/CQCL/tket2"
repository = "https://github.com/CQCL/tket2"
license = "Apache-2.0"
# authors

[[bench]]
name = "bench_main"
harness = false
[workspace.lints.rust]
missing_docs = "warn"

[workspace.dependencies]
portgraph = { version = "0.12.0" }
insta = { version = "1.34.0" }

[profile.dev.package.insta]
opt-level = 3
64 changes: 64 additions & 0 deletions quantinuum-hugr/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
[package]
name = "quantinuum-hugr"
version = "0.2.0"
edition = { workspace = true }
rust-version = { workspace = true }

license = { workspace = true }
readme = "README.md"
documentation = "https://docs.rs/hugr/"
homepage = { workspace = true }
repository = { workspace = true }
description = "Quantinuum's Hierarchical Unified Graph Representation"
keywords = ["Quantum", "Quantinuum"]
categories = ["compilers"]

[lib]
name = "hugr"
bench = false
path = "src/lib.rs"

[features]
extension_inference = []

[dependencies]
portgraph = { workspace = true, features = ["serde", "petgraph"] }
thiserror = "1.0.28"
regex = "1.9.5"
cgmath = { version = "0.18.0", features = ["serde"] }
num-rational = { version = "0.4.1", features = ["serde"] }
downcast-rs = "1.2.0"
serde = { version = "1.0", features = [
# Rc used here for Extension, but unfortunately we must turn the feature on globally
"derive",
"rc",
] }
serde_yaml = "0.9.19"
typetag = "0.2.7"
smol_str = { version = "0.2.0", features = ["serde"] }
derive_more = "0.99.17"
itertools = "0.12.0"
html-escape = "0.2.13"
bitvec = { version = "1.0.1", features = ["serde"] }
enum_dispatch = "0.3.11"
lazy_static = "1.4.0"
petgraph = { version = "0.6.3", default-features = false }
context-iterators = "0.2.0"
serde_json = "1.0.97"
delegate = "0.12.0"
paste = "1.0"
strum = "0.26.1"
strum_macros = "0.26.1"

[dev-dependencies]
criterion = { version = "0.5.1", features = ["html_reports"] }
rstest = "0.18.1"
webbrowser = "0.8.10"
urlencoding = "2.1.2"
cool_asserts = "2.0.3"
insta = { workspace = true, features = ["yaml"] }
jsonschema = "0.17.1"

[[bench]]
name = "bench_main"
harness = false
1 change: 1 addition & 0 deletions quantinuum-hugr/README.md
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ pub mod test {
lazy_static! {
static ref SCHEMA: JSONSchema = {
let schema_val: serde_json::Value = serde_json::from_str(include_str!(
"../../specification/schema/hugr_schema_v0.json"
"../../../specification/schema/hugr_schema_v0.json"
))
.unwrap();
JSONSchema::options()
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 0 additions & 1 deletion src/lib.rs → quantinuum-hugr/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@
//! ```
//!
#![warn(missing_docs)]
// Unstable check, may cause false positives.
// https://github.com/rust-lang/rust-clippy/issues/5112
#![warn(clippy::debug_assert_with_mut_call)]
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
9 changes: 9 additions & 0 deletions release-plz.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,11 @@
[workspace]
changelog_config = "cliff.toml" # use a custom git-cliff configuration
# disable the changelog for all packages
changelog_update = false

[[package]]
name = "quantinuum-hugr"
# enable the changelog for this package
changelog_update = true
# set the path of the changelog to the root of the repository
changelog_path = "./CHANGELOG.md"

0 comments on commit d93e795

Please sign in to comment.