Skip to content

Commit

Permalink
chore(ci): update rust lint workflows and just recipes (#1871)
Browse files Browse the repository at this point in the history
## 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
  • Loading branch information
ethanoroshiba authored Dec 16, 2024
1 parent 1f2b967 commit bc2569a
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 14 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 8 additions & 11 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand All @@ -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
Expand All @@ -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
Expand All @@ -266,17 +265,15 @@ 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
DYLINT_DRIVER_PATH: ${{ github.workspace }}/target/dylint_drivers/
DYLINT_RUSTFLAGS: "-D warnings"
run: |
mkdir -p "$DYLINT_DRIVER_PATH"
cargo dylint --all --workspace
just lint rust-dylint
test:
if: ${{ always() && !cancelled() }}
Expand Down
35 changes: 33 additions & 2 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -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}}
Expand All @@ -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:
Expand Down

0 comments on commit bc2569a

Please sign in to comment.