From 4d4d4a666cd19e0fc3b64a31a0fc4ada7ee5181e Mon Sep 17 00:00:00 2001 From: clabby Date: Sun, 10 Aug 2025 12:28:12 -0400 Subject: [PATCH] feat(ci): Add `zepter` for feature propagation checks --- .config/zepter.yaml | 39 ++++++++++++++++++++++++++++++++++ .github/workflows/rust_ci.yaml | 17 +++++++++++++++ crates/emu/Cargo.toml | 12 +++++------ crates/hw/Cargo.toml | 10 ++++----- crates/isa/Cargo.toml | 2 +- 5 files changed, 68 insertions(+), 12 deletions(-) create mode 100644 .config/zepter.yaml diff --git a/.config/zepter.yaml b/.config/zepter.yaml new file mode 100644 index 0000000..1d6551b --- /dev/null +++ b/.config/zepter.yaml @@ -0,0 +1,39 @@ +version: + format: 1 + # Minimum zepter version that is expected to work. This is just for printing a nice error + # message when someone tries to use an older version. + binary: 0.13.2 + +# The examples in the following comments assume crate `A` to have a dependency on crate `B`. +workflows: + check: + - [ + "lint", + # Check that `A` activates the features of `B`. + "propagate-feature", + # These are the features to check: + "--features=64-bit,m,a,c,test-utils", + # Do not try to add a new section into `[features]` of `A` only because `B` exposes that feature. There are edge-cases where this is still needed, but we can add them manually. + "--left-side-feature-missing=ignore", + # Ignore the case that `A` is outside of the workspace. Otherwise it will report errors in external dependencies that we have no influence on. + "--left-side-outside-workspace=ignore", + # Only check normal dependencies. + # Propagating to dev-dependencies leads to compilation issues. + "--dep-kinds=normal:check,dev:ignore", + "--show-path", + "--quiet", + ] + default: + # Running `zepter` with no subcommand will check & fix. + - [$check.0, "--fix"] + +# Will be displayed when any workflow fails: +help: + text: | + Brisc uses the Zepter CLI to detect abnormalities in Cargo features, e.g. missing propagation. + + It looks like one more checks failed; please check the console output. + + You can try to automatically address them by installing zepter (`cargo install zepter --locked`) and simply running `zepter` in the workspace root. + links: + - "https://github.com/ggwpez/zepter" diff --git a/.github/workflows/rust_ci.yaml b/.github/workflows/rust_ci.yaml index e14b5c1..3139971 100644 --- a/.github/workflows/rust_ci.yaml +++ b/.github/workflows/rust_ci.yaml @@ -168,3 +168,20 @@ jobs: uses: codecov/test-results-action@v1 with: token: ${{ secrets.CODECOV_TOKEN }} + + zepter: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + submodules: true + - name: Install zepter + run: | + cargo install zepter -f --locked + zepter --version + - name: Format features + run: | + zepter format features + - name: Lint features + run: | + zepter diff --git a/crates/emu/Cargo.toml b/crates/emu/Cargo.toml index 6f6c832..1487d43 100644 --- a/crates/emu/Cargo.toml +++ b/crates/emu/Cargo.toml @@ -27,14 +27,14 @@ rstest.workspace = true criterion.workspace = true [features] -default = ["64-bit", "m", "a", "c"] -test-utils = ["dep:rstest"] +default = [ "64-bit", "a", "c", "m" ] +test-utils = [ "dep:rstest" ] # Architecture features -64-bit = ["brisc-hw/64-bit"] -m = ["brisc-hw/m"] -a = ["brisc-hw/a"] -c = ["brisc-hw/c"] +64-bit = [ "brisc-hw/64-bit" ] +m = [ "brisc-hw/m" ] +a = [ "brisc-hw/a" ] +c = [ "brisc-hw/c" ] [[bench]] harness = false diff --git a/crates/hw/Cargo.toml b/crates/hw/Cargo.toml index 2583fa8..2620ec3 100644 --- a/crates/hw/Cargo.toml +++ b/crates/hw/Cargo.toml @@ -25,10 +25,10 @@ cfg-if.workspace = true rstest.workspace = true [features] -default = ["64-bit", "m", "a", "c"] +default = [ "64-bit", "a", "c", "m" ] # Architecture features -64-bit = ["brisc-isa/64-bit"] -m = ["brisc-isa/m"] -a = ["brisc-isa/a"] -c = ["brisc-isa/c"] +64-bit = [ "brisc-isa/64-bit" ] +m = [ "brisc-isa/m" ] +a = [ "brisc-isa/a" ] +c = [ "brisc-isa/c" ] diff --git a/crates/isa/Cargo.toml b/crates/isa/Cargo.toml index 5db6317..3aa4abe 100644 --- a/crates/isa/Cargo.toml +++ b/crates/isa/Cargo.toml @@ -21,7 +21,7 @@ num-traits.workspace = true rstest.workspace = true [features] -default = ["64-bit", "m", "a", "c"] +default = [ "64-bit", "a", "c", "m" ] 64-bit = [] m = [] a = []