From bc2569a52e5aef9fe9098d99df1d604cb529f127 Mon Sep 17 00:00:00 2001 From: Ethan Oroshiba Date: Mon, 16 Dec 2024 12:19:26 -0600 Subject: [PATCH] chore(ci): update rust lint workflows and `just` recipes (#1871) ## Summary Moved rust lints to just recipes, added all to lint rust recipe. ## Background Discrepancies between the just recipe and GH workflow made it so that the lint command might succeed but then fail when a PR is opened. This is meant to make it easier to match the GH workflow locally and test to ensure this status check will pass. ## Changes - Moved all rust lints to just recipes. - Changed `_lint-rust` to call all of the above recipes. ## Testing Manually tested ## Changelogs No updates required --- .github/workflows/lint.yml | 4 +++- .github/workflows/test.yml | 19 ++++++++----------- justfile | 35 +++++++++++++++++++++++++++++++++-- 3 files changed, 44 insertions(+), 14 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 4388d2e707..b80c8417d8 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -68,12 +68,14 @@ jobs: if: needs.run_checker.outputs.run_lint_rust == 'true' steps: - uses: actions/checkout@v4 + - name: Install just + uses: taiki-e/install-action@just - uses: dtolnay/rust-toolchain@master with: toolchain: nightly-2024-09-15 components: rustfmt - name: run rustfmt - run: cargo +nightly-2024-09-15 fmt --all -- --check + run: just lint rust-fmt toml: runs-on: ubuntu-22.04 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0ebe04560b..833358ab33 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -217,6 +217,8 @@ jobs: - uses: actions/checkout@v4 with: submodules: 'true' + - name: Install just + uses: taiki-e/install-action@just - uses: dtolnay/rust-toolchain@master with: toolchain: ${{ env.RUSTUP_TOOLCHAIN }} @@ -230,15 +232,10 @@ jobs: repo-token: ${{ secrets.GITHUB_TOKEN }} - name: run pedantic clippy on workspace crates run: | - cargo clippy --all-targets --all-features \ - -- --warn clippy::pedantic --warn clippy::arithmetic-side-effects \ - --warn clippy::allow_attributes --warn clippy::allow_attributes_without_reason \ - --deny warnings + just lint rust-clippy - name: run pedantic clippy on tools/protobuf-compiler run: | - cargo clippy --manifest-path tools/protobuf-compiler/Cargo.toml \ - --all-targets --all-features \ - -- --warn clippy::pedantic --deny warnings + just lint rust-clippy-tools custom-lints: runs-on: buildjet-8vcpu-ubuntu-2204 @@ -248,6 +245,8 @@ jobs: - uses: actions/checkout@v4 with: submodules: 'true' + - name: Install just + uses: taiki-e/install-action@just - uses: dtolnay/rust-toolchain@master with: # This has to match `rust-toolchain` in the rust-toolchain file of the dylint lints @@ -266,9 +265,7 @@ jobs: run: | : # list all lint packages here to have clippy explicitly test them : # uses the same nightly installed above to work around the entry in rust-toolchain.toml - cargo +nightly-2024-09-05 clippy --all-targets --all-features \ - -p tracing_debug_field \ - -- --warn clippy::pedantic --deny warnings + just lint rust-clippy-custom - name: run dylint clippy on workspace crates env: # set the dylint driver path to the target/ directory so that it's hopefully cached by rust-cache @@ -276,7 +273,7 @@ jobs: DYLINT_RUSTFLAGS: "-D warnings" run: | mkdir -p "$DYLINT_DRIVER_PATH" - cargo dylint --all --workspace + just lint rust-dylint test: if: ${{ always() && !cancelled() }} diff --git a/justfile b/justfile index e6ac8d0884..6c35eafd9a 100644 --- a/justfile +++ b/justfile @@ -73,6 +73,8 @@ fmt lang=default_lang: @just _fmt-{{lang}} # Can lint 'rust', 'toml', 'proto', 'md' or 'all'. Defaults to all. +# Can also run the following sub-lints for rust: 'rust-fmt', 'rust-clippy', +# 'rust-clippy-custom', 'rust-clippy-tools', 'rust-dylint' lint lang=default_lang: @just _lint-{{lang}} @@ -93,9 +95,38 @@ _fmt-rust: [no-exit-message] _lint-rust: + just _lint-rust-fmt + just _lint-rust-clippy + just _lint-rust-clippy-custom + just _lint-rust-clippy-tools + just _lint-rust-dylint + +[no-exit-message] +_lint-rust-fmt: cargo +nightly-2024-09-15 fmt --all -- --check - cargo clippy -- --warn clippy::pedantic - cargo dylint --all + +[no-exit-message] +_lint-rust-clippy: + cargo clippy --all-targets --all-features \ + -- --warn clippy::pedantic --warn clippy::arithmetic-side-effects \ + --warn clippy::allow_attributes --warn clippy::allow_attributes_without_reason \ + --deny warnings + +[no-exit-message] +_lint-rust-clippy-custom: + cargo +nightly-2024-09-05 clippy --all-targets --all-features \ + -p tracing_debug_field \ + -- --warn clippy::pedantic --deny warnings + +[no-exit-message] +_lint-rust-clippy-tools: + cargo clippy --manifest-path tools/protobuf-compiler/Cargo.toml \ + --all-targets --all-features \ + -- --warn clippy::pedantic --deny warnings + +[no-exit-message] +_lint-rust-dylint: + cargo dylint --all --workspace [no-exit-message] _fmt-toml: