Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(ci): update rust lint workflows and just recipes #1871

Merged
merged 5 commits into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading