Skip to content

Commit

Permalink
ci: add per-crate checks via cargo-hack
Browse files Browse the repository at this point in the history
Suggested by @erwanor, based on the Astria CI config [0].
The goal is to ensure that our default feature sets actually work,
by compiling each crate in the workspace individually.

fix: feature-gating across the workspace
Satisifes the new CI check by massaging the feature sets.

[0] https://github.com/astriaorg/astria/blob/6cc8e2b828f8f5ee65e03c2b3383c4252b4c6b81/.github/workflows/test.yml#L64-L68
  • Loading branch information
conorsch committed Apr 8, 2024
1 parent 34d27f3 commit f7234c0
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 2 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,18 @@ jobs:
- name: Load rust cache
uses: astriaorg/[email protected]
- run: cargo fmt --all -- --check

check:
name: Check all crate features
runs-on: buildjet-8vcpu-ubuntu-2204
steps:
- uses: actions/checkout@v4
- name: Install rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Load rust cache
uses: astriaorg/[email protected]
- name: install cargo-hack
run: cargo install cargo-hack
# Build each crate separately, to validate that the feature-gating is working.
# This is a lighter-weight version of `cargo check-all-features --workspace --release`.
- run: ./deployments/scripts/check-crate-feature-sets
1 change: 1 addition & 0 deletions crates/core/component/compact-block/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ component = [
"tokio-stream",
"tokio",
"penumbra-governance/component",
"penumbra-dex/component",
]
# proving-keys = ["penumbra-proof-params/proving-keys"]
default = ["std", "component"]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use anyhow::{Context, Result};
use async_trait::async_trait;
use cnidarium::StateWrite;
#[cfg(feature = "component")]
use penumbra_dex::component::{StateReadExt, SwapManager as _};
use penumbra_fee::component::StateReadExt as _;
use penumbra_governance::StateReadExt as _;
Expand Down
2 changes: 1 addition & 1 deletion crates/misc/measure/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ penumbra-compact-block = {workspace = true, default-features = false}
penumbra-proto = {workspace = true, features = ["rpc"], default-features = true}
serde_json = {workspace = true}
tokio = {workspace = true, features = ["full"]}
tonic = {workspace = true}
tonic = {workspace = true, features = ["tls"]}
tracing = {workspace = true}
tracing-subscriber = {workspace = true, features = ["env-filter"]}
url = {workspace = true}
2 changes: 1 addition & 1 deletion crates/test/mock-consensus/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ ed25519-consensus = { workspace = true }
rand_core = { workspace = true }
sha2 = { workspace = true }
tap = { workspace = true }
tendermint = { workspace = true }
tendermint = { workspace = true, default-features = true }
tower = { workspace = true, features = ["full"] }
tracing = { workspace = true }
13 changes: 13 additions & 0 deletions deployments/scripts/check-crate-feature-sets
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env bash
# CI script to verify that each crate in the monorepo builds independently.
# This helps us ensure that the feature-gating for e.g. "component" is
# declared explicitly.
set -euo pipefail


if ! hash cargo-hack >/dev/null 2>&1 ; then
>&2 echo "ERROR: cargo-hack not found. Install it with: cargo install cargo-hack"
exit 1
fi

cargo hack check --workspace --all-targets --all-features --release

0 comments on commit f7234c0

Please sign in to comment.