diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 4388d2e70..b80c8417d 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 0ebe04560..833358ab3 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 e6ac8d088..6c35eafd9 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: