Skip to content

Commit

Permalink
refactor(ci): improve rustfmt perf and cleanup
Browse files Browse the repository at this point in the history
- Install nightly through moonrepo, so it'll be cached.
- Always run rustfmt on --all for both push/pull.
It doesn't compile anything and runs on `--all` in a few seconds.

Benchmark: seems to reduce time from ~15 seconds to ~5 seconds, and
logs indeed show that nothing is installed, only rustfmt is run.

Unrelated: remove clippy/rustfmt from the components in
rust-toolchain.toml, when using the `default` profile they are already
included.
  • Loading branch information
Gilad Chase committed Dec 19, 2024
1 parent 6a98d8d commit d653a24
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 24 deletions.
1 change: 1 addition & 0 deletions .github/actions/install_rust/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ runs:
cache-base: main(-v[0-9].*)?
inherit-toolchain: true
bins: taplo-cli@0.9.0, cargo-machete
channel: nightly-2024-04-29 # Just install for rustfmt, rust-toolchain.toml overrides it.
env:
RUSTFLAGS: "-C link-arg=-fuse-ld=lld"
11 changes: 5 additions & 6 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,6 @@ jobs:
git diff --exit-code Cargo.lock
# Run code style on PR.
- name: "Run rustfmt pull request"
if: github.event_name == 'pull_request'
run: ci/bin/python scripts/run_tests.py --command rustfmt --changes_only --commit_id ${{ github.event.pull_request.base.sha }}
- name: "Run clippy pull request"
if: github.event_name == 'pull_request'
run: ci/bin/python scripts/run_tests.py --command clippy --changes_only --commit_id ${{ github.event.pull_request.base.sha }}
Expand All @@ -73,9 +70,11 @@ jobs:
run: ci/bin/python scripts/run_tests.py --command doc --changes_only --commit_id ${{ github.event.pull_request.base.sha }}

# Run code style on push.
- name: "Run rustfmt on push"
if: github.event_name == 'push'
run: ci/bin/python scripts/run_tests.py --command rustfmt
- name: "Run rustfmt"
# The nightly here is coupled with the one in install_rust/action.yml.
# If we move the install here we can use a const.
run: cargo +nightly-2024-04-29 fmt --all -- --check

- name: "Run clippy on push"
if: github.event_name == 'push'
run: ci/bin/python scripts/run_tests.py --command clippy
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[toolchain]
channel = "1.83"
components = ["clippy", "rustc-dev", "rustfmt"]
components = ["rustc-dev"]
profile = "default"
targets = ["x86_64-unknown-linux-gnu"]
4 changes: 0 additions & 4 deletions scripts/run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
class BaseCommand(Enum):
TEST = "test"
CODECOV = "codecov"
RUSTFMT = "rustfmt"
CLIPPY = "clippy"
DOC = "doc"

Expand All @@ -39,9 +38,6 @@ def cmd(self, crates: Set[str]) -> List[str]:
"--output-path",
"codecov.json",
] + package_args
elif self == BaseCommand.RUSTFMT:
fmt_args = package_args if len(package_args) > 0 else ["--all"]
return ["scripts/rust_fmt.sh"] + fmt_args + ["--", "--check"]
elif self == BaseCommand.CLIPPY:
clippy_args = package_args if len(package_args) > 0 else ["--workspace"]
return ["cargo", "clippy"] + clippy_args
Expand Down
13 changes: 0 additions & 13 deletions scripts/rust_fmt.sh

This file was deleted.

0 comments on commit d653a24

Please sign in to comment.