Skip to content

Commit 958b8bb

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 c52f4a3 commit 958b8bb

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
@@ -66,16 +66,36 @@ jobs:
6666
with:
6767
toolchain: stable
6868
components: rustfmt, clippy
69-
- uses: taiki-e/install-action@68675c5a5f1a6950c3975d33f3ae0ef155e5bf3d # v2.68.15
70-
with:
71-
tool: cargo-hack
7269
- uses: arduino/setup-protoc@c65c819552d16ad3c9b72d9dfd5ba5237b9c906b # v3.0.0
7370
with:
7471
repo-token: ${{ secrets.GITHUB_TOKEN }}
7572
- name: Format
7673
run: cargo fmt --all -- --check
7774
- name: Lint
7875
run: bash ./scripts/lint.sh
76+
lint-feature-matrix:
77+
runs-on: ubuntu-latest
78+
steps:
79+
- name: Harden the runner (Audit all outbound calls)
80+
uses: step-security/harden-runner@a90bcbc6539c36a85cdfeb73f7e2f433735f215b # v2.15.0
81+
with:
82+
egress-policy: audit
83+
84+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
85+
with:
86+
submodules: true
87+
- uses: dtolnay/rust-toolchain@e97e2d8cc328f1b50210efc529dca0028893a2d9
88+
with:
89+
toolchain: stable
90+
components: clippy
91+
- uses: taiki-e/install-action@68675c5a5f1a6950c3975d33f3ae0ef155e5bf3d # v2.68.15
92+
with:
93+
tool: cargo-hack
94+
- uses: arduino/setup-protoc@c65c819552d16ad3c9b72d9dfd5ba5237b9c906b # v3.0.0
95+
with:
96+
repo-token: ${{ secrets.GITHUB_TOKEN }}
97+
- name: Lint (per-feature matrix)
98+
run: bash ./scripts/lint_feature_matrix.sh
7999
external-types:
80100
strategy:
81101
matrix:

CONTRIBUTING.md

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

312312
## Style Guide
313313

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

319322
## Testing and Benchmarking
320323

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)