Skip to content

Commit 10157b4

Browse files
committed
ci: split lint into parallel jobs and remove redundant checks
Split the monolithic lint job into two parallel CI jobs for faster feedback: - `lint`: format check, workspace-wide clippy, and multi-feature combination checks (~1-2 min) - `lint-feature-matrix`: per-feature clippy via cargo hack (~5-6 min) Previously, all 150 clippy invocations ran sequentially in a single job. The most common CI failure on PRs is the per-feature matrix catching dead code or unused warnings that only surface when individual features are tested in isolation. By splitting these into parallel jobs, contributors get fast feedback on the common checks while the thorough feature matrix runs alongside. Also removes 6 redundant cargo_feature checks from lint.sh that are already covered by `cargo hack --each-feature`: - opentelemetry-otlp "default", "http-proto", "metrics" - opentelemetry-jaeger-propagator "default" - opentelemetry-proto "default", "full" Updates CONTRIBUTING.md to document the cargo hack lint command so contributors can catch per-feature issues locally before pushing.
1 parent 09b85b5 commit 10157b4

5 files changed

Lines changed: 46 additions & 20 deletions

File tree

.github/workflows/ci.yml

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,16 +65,36 @@ jobs:
6565
with:
6666
toolchain: stable
6767
components: rustfmt, clippy
68-
- uses: taiki-e/install-action@650c5ca14212efbbf3e580844b04bdccf68dac31 # v2.67.18
69-
with:
70-
tool: cargo-hack
7168
- uses: arduino/setup-protoc@c65c819552d16ad3c9b72d9dfd5ba5237b9c906b # v3.0.0
7269
with:
7370
repo-token: ${{ secrets.GITHUB_TOKEN }}
7471
- name: Format
7572
run: cargo fmt --all -- --check
7673
- name: Lint
7774
run: bash ./scripts/lint.sh
75+
lint-feature-matrix:
76+
runs-on: ubuntu-latest
77+
steps:
78+
- name: Harden the runner (Audit all outbound calls)
79+
uses: step-security/harden-runner@e3f713f2d8f53843e71c69a996d56f51aa9adfb9 # v2.14.1
80+
with:
81+
egress-policy: audit
82+
83+
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
84+
with:
85+
submodules: true
86+
- uses: dtolnay/rust-toolchain@e97e2d8cc328f1b50210efc529dca0028893a2d9
87+
with:
88+
toolchain: stable
89+
components: clippy
90+
- uses: taiki-e/install-action@650c5ca14212efbbf3e580844b04bdccf68dac31 # v2.67.18
91+
with:
92+
tool: cargo-hack
93+
- uses: arduino/setup-protoc@c65c819552d16ad3c9b72d9dfd5ba5237b9c906b # v3.0.0
94+
with:
95+
repo-token: ${{ secrets.GITHUB_TOKEN }}
96+
- name: Lint (per-feature matrix)
97+
run: bash ./scripts/lint_feature_matrix.sh
7898
external-types:
7999
strategy:
80100
matrix:

CONTRIBUTING.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -179,10 +179,13 @@ All such features should adhere to naming convention `<signal>_<feature_name>`
179179

180180
## Style Guide
181181

182-
- Run `cargo clippy --all` - this will catch common mistakes and improve
183-
your Rust code
184-
- Run `cargo fmt` - this will find and fix code formatting
185-
issues.
182+
- Run `cargo fmt` - this will find and fix code formatting issues.
183+
- Run `cargo clippy --workspace --all-targets --all-features -- -Dwarnings` - this will catch common
184+
mistakes and improve your Rust code.
185+
- Run `cargo hack --each-feature --no-dev-deps clippy -- -Dwarnings` - this checks clippy for each
186+
feature in isolation and catches issues like dead code or unused imports that only appear when
187+
individual features are enabled. Install with `cargo install cargo-hack` if you don't have it.
188+
This is the most common source of CI lint failures on PRs.
186189

187190
## Testing and Benchmarking
188191

scripts/lint.sh

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,33 +9,23 @@ cargo_feature() {
99
-Dwarnings
1010
}
1111

12-
if rustup component add clippy && \
13-
((cargo --list | grep -q hack) || cargo install cargo-hack); then
12+
if rustup component add clippy; then
1413
# Exit with a nonzero code if there are clippy warnings
1514
cargo clippy --workspace --all-targets --all-features -- -Dwarnings
1615

17-
# Run through all the features one by one and exit if there are clippy warnings
18-
cargo hack --each-feature --no-dev-deps clippy -- -Dwarnings
19-
2016
# `opentelemetry-prometheus` doesn't belong to the workspace
2117
cargo clippy --manifest-path=opentelemetry-prometheus/Cargo.toml --all-targets --all-features -- \
2218
-Dwarnings
2319

20+
# Multi-feature combinations not covered by per-feature checks
2421
cargo_feature opentelemetry "trace,metrics,logs,testing"
2522

26-
cargo_feature opentelemetry-otlp "default"
2723
cargo_feature opentelemetry-otlp "default,tls"
2824
cargo_feature opentelemetry-otlp "default,tls-roots"
29-
cargo_feature opentelemetry-otlp "http-proto"
3025
cargo_feature opentelemetry-otlp "http-proto, reqwest-blocking-client"
3126
cargo_feature opentelemetry-otlp "http-proto, reqwest-client"
3227
cargo_feature opentelemetry-otlp "http-proto, reqwest-rustls"
33-
cargo_feature opentelemetry-otlp "metrics"
34-
35-
cargo_feature opentelemetry-jaeger-propagator "default"
3628

37-
cargo_feature opentelemetry-proto "default"
38-
cargo_feature opentelemetry-proto "full"
3929
cargo_feature opentelemetry-proto "gen-tonic,trace"
4030
cargo_feature opentelemetry-proto "gen-tonic,trace,with-serde"
4131
cargo_feature opentelemetry-proto "gen-tonic,trace,with-schemars,with-serde"

scripts/lint_feature_matrix.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
3+
set -eu
4+
5+
# Run clippy for each feature individually across all workspace crates.
6+
# This catches dead code, unused imports, and other warnings that only
7+
# surface when features are tested in isolation (e.g., a function gated
8+
# behind feature A but missing #[cfg(feature = "A")]).
9+
10+
if rustup component add clippy && \
11+
((cargo --list | grep -q hack) || cargo install cargo-hack); then
12+
cargo hack --each-feature --no-dev-deps clippy -- -Dwarnings
13+
fi

scripts/precommit.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ REPO_ROOT=$(dirname $( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null
22

33
pushd "${REPO_ROOT}" > /dev/null
44

5-
cargo update && cargo fmt --all && ./scripts/lint.sh && ./scripts/test.sh
5+
cargo update && cargo fmt --all && ./scripts/lint.sh && ./scripts/lint_feature_matrix.sh && ./scripts/test.sh
66

77
popd > /dev/null

0 commit comments

Comments
 (0)