Skip to content

Commit 422d2c3

Browse files
boquan-fangBoquan FangWesleyRosenblum
authored
refactor(ci): consolidate clippy checks into one job (#2695)
* refactor(ci): consolidate clippy checks into one job --------- Co-authored-by: Boquan Fang <bqfang@amazon.com> Co-authored-by: Wesley Rosenblum <wesleyr@amazon.com>
1 parent b95ef18 commit 422d2c3

File tree

12 files changed

+28
-39
lines changed

12 files changed

+28
-39
lines changed

.github/workflows/ci.yml

Lines changed: 17 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ jobs:
4242
msrv: ${{ steps.definitions.outputs.msrv }}
4343
examples: ${{ steps.definitions.outputs.examples }}
4444
crates: ${{ steps.definitions.outputs.crates }}
45+
workspaces: ${{ steps.definitions.outputs.workspaces }}
4546
steps:
4647
- uses: actions/checkout@v4
4748
# examples is populated by
@@ -76,6 +77,9 @@ jobs:
7677
export CRATES=$(find quic common -name *Cargo.toml | jq -R | jq -s | jq '. += ["tools/xdp/s2n-quic-xdp/Cargo.toml","dc/s2n-quic-dc/Cargo.toml"]' | jq -c)
7778
echo "crates=$CRATES"
7879
echo "crates=$CRATES" >> $GITHUB_OUTPUT
80+
export WORKSPACES=$(find . -maxdepth 4 -name Cargo.toml -not -path './tools/xdp/ebpf/*' -exec grep -l '^\[workspace\]' {} \; | xargs -n1 dirname | sort | jq -R | jq -sc)
81+
echo "workspaces=$WORKSPACES"
82+
echo "workspaces=$WORKSPACES" >> $GITHUB_OUTPUT
7983
8084
rustfmt:
8185
runs-on: ubuntu-latest
@@ -96,14 +100,7 @@ jobs:
96100
97101
clippy:
98102
runs-on: ubuntu-latest
99-
strategy:
100-
fail-fast: false
101-
matrix:
102-
include:
103-
- toolchain: stable
104-
# fail on stable warnings
105-
args: "-D warnings"
106-
- toolchain: beta
103+
needs: env
107104
steps:
108105
- uses: actions/checkout@v4
109106
with:
@@ -112,15 +109,21 @@ jobs:
112109
- name: Install rust toolchain
113110
id: toolchain
114111
run: |
115-
rustup toolchain install ${{ matrix.toolchain }} --profile minimal --component clippy
116-
rustup override set ${{ matrix.toolchain }}
112+
rustup toolchain install stable --profile minimal --component clippy
113+
rustup override set stable
117114
118115
- uses: camshaft/rust-cache@v1
119116

120117
# TODO translate json reports to in-action warnings
121-
- name: Run cargo clippy
118+
- name: Run cargo clippy on all workspaces
122119
run: |
123-
cargo clippy --all-features --all-targets --workspace -- ${{ matrix.args }}
120+
WORKSPACES=$(echo '${{ needs.env.outputs.workspaces }}' | jq -r '.[]')
121+
for workspace in $WORKSPACES; do
122+
echo "Running clippy on $workspace"
123+
cd "$workspace"
124+
cargo clippy --all-features --all-targets --workspace -- -D warnings
125+
cd $GITHUB_WORKSPACE
126+
done
124127
125128
udeps:
126129
runs-on: ubuntu-latest
@@ -522,10 +525,6 @@ jobs:
522525
working-directory: ${{ matrix.example }}
523526
run: cargo +nightly fmt --all -- --check
524527

525-
- name: lint
526-
working-directory: ${{ matrix.example }}
527-
run: cargo clippy --all-features --all-targets -- -D warnings
528-
529528
# not all examples will build with the --manifest-path argument, since the
530529
# manifest-path argument will pull configuration from the current directory
531530
# instead of the directory with the Cargo.toml file
@@ -884,7 +883,7 @@ jobs:
884883
- name: Install rust toolchain
885884
id: toolchain
886885
run: |
887-
rustup toolchain install stable --profile minimal --component clippy,rustfmt
886+
rustup toolchain install stable --profile minimal --component rustfmt
888887
rustup override set stable
889888
890889
- uses: camshaft/install@v1
@@ -893,10 +892,6 @@ jobs:
893892

894893
- uses: camshaft/rust-cache@v1
895894

896-
- name: Run clippy
897-
working-directory: tools/xdp
898-
run: cargo +stable clippy
899-
900895
- name: Build ebpf
901896
working-directory: tools/xdp
902897
env:
@@ -917,7 +912,7 @@ jobs:
917912
- name: Install rust toolchain
918913
working-directory: dc/wireshark
919914
run: |
920-
rustup toolchain install stable --profile minimal --component clippy,rustfmt
915+
rustup toolchain install stable --profile minimal --component rustfmt
921916
rustup override set stable
922917
923918
- uses: camshaft/install@v1
@@ -935,10 +930,6 @@ jobs:
935930
working-directory: dc/wireshark
936931
run: cargo fmt --all -- --check
937932

938-
- name: Run clippy
939-
working-directory: dc/wireshark
940-
run: cargo clippy --tests
941-
942933
- name: Run tests
943934
working-directory: dc/wireshark
944935
run: cargo xtask test

dc/wireshark/.clippy.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
msrv = "1.77.0"
1+
msrv = "1.82.0"

dc/wireshark/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name = "wireshark_dcquic"
33
version = "0.0.0"
44
edition = "2021"
55
publish = false
6-
rust-version = "1.77"
6+
rust-version = "1.82"
77

88
[lib]
99
crate-type = ["rlib", "cdylib"]

dc/wireshark/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,6 @@ fn env<N: AsRef<str>>(name: N) -> String {
3333

3434
fn option_env<N: AsRef<str>>(name: N) -> Option<String> {
3535
let name = name.as_ref();
36-
println!("cargo:rerun-if-env-changed={}", name);
36+
println!("cargo:rerun-if-env-changed={name}");
3737
std::env::var(name).ok()
3838
}

dc/wireshark/rust-toolchain

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[toolchain]
2-
channel = "1.77.0"
2+
channel = "1.82.0"
33
components = [ "rustc", "clippy", "rustfmt" ]

dc/wireshark/src/wireshark.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ impl Info for Vec<u8> {
3636

3737
fn append<T: core::fmt::Display>(&mut self, v: T) {
3838
use std::io::Write;
39-
let _ = write!(self, "{}", v);
39+
let _ = write!(self, "{v}");
4040
}
4141

4242
fn append_str(&mut self, v: &str) {
@@ -51,7 +51,7 @@ impl Info for String {
5151

5252
fn append<T: core::fmt::Display>(&mut self, v: T) {
5353
use std::fmt::Write;
54-
let _ = write!(self, "{}", v);
54+
let _ = write!(self, "{v}");
5555
}
5656

5757
fn append_str(&mut self, v: &str) {

dc/wireshark/xtask/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ impl WiresharkVersion {
264264
let tshark = tshark(sh).unwrap();
265265
let output = cmd!(sh, "{tshark} --version").read().unwrap();
266266
let version = output.lines().next().unwrap();
267-
let version = version.trim_start_matches(|v: char| !v.is_digit(10));
267+
let version = version.trim_start_matches(|v: char| !v.is_ascii_digit());
268268
let (version, _) = version
269269
.split_once(char::is_whitespace)
270270
.unwrap_or((version, ""));

tools/udp-attack/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ name = "udp-attack"
33
version = "0.1.0"
44
edition = "2021"
55
publish = false
6+
rust-version = "1.82"
67

78
[dependencies]
89
clap = { version = "4", features = ["derive"] }

tools/udp-attack/rust-toolchain

Lines changed: 0 additions & 3 deletions
This file was deleted.

tools/xdp/rust-toolchain

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[toolchain]
2-
channel = "1.80.0"
2+
channel = "1.82.0"
33
components = [ "rustc", "clippy", "rustfmt" ]

0 commit comments

Comments
 (0)