Skip to content

Commit

Permalink
fix(template/ci): Use local rustfmt hook (#483)
Browse files Browse the repository at this point in the history
* fix(template/ci): Use local rustfmt hook

* chore: Add note about nightly Rust version
  • Loading branch information
Techassi authored Feb 4, 2025
1 parent d64a1bb commit 9001281
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
5 changes: 5 additions & 0 deletions config/versions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
# docker-images/ubi8-rust-builder/Dockerfile & docker-images/ubi9-rust-builder/Dockerfile
rust_version: 1.82.0

# This nightly version is only used for cargo fmt invocations, because we use nightly-only
# rustfmt config options in rustfmt.toml. The version should be kept in line with the version
# used in the operator-rs repository.
rust_nightly_version: nightly-2025-01-15

# IMPORTANT
# If you change the Hadolint version here, make sure to also change the hook
# refs in the local and templated .pre-commit-config.yaml files.
Expand Down
2 changes: 1 addition & 1 deletion template/.github/workflows/pr_pre-commit.yaml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:

env:
CARGO_TERM_COLOR: always
RUST_TOOLCHAIN_VERSION: "{[ rust_version }]"
RUST_TOOLCHAIN_VERSION: "{[ rust_nightly_version }]"
HADOLINT_VERSION: "{[ hadolint_version }]"
PYTHON_VERSION: "{[ python_version }]"

Expand Down
11 changes: 7 additions & 4 deletions template/.pre-commit-config.yaml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ repos:
- repo: https://github.com/doublify/pre-commit-rust
rev: eeee35a89e69d5772bdee97db1a6a898467b686e # 1.0
hooks:
- id: fmt
# Pinning to a specific rustc version, so that we get consistent formatting
entry: RUSTUP_TOOLCHAIN=nightly-2025-01-15 cargo fmt
args: ["--all", "--", "--check"]
- id: clippy
args: ["--all-targets", "--", "-D", "warnings"]

Expand Down Expand Up @@ -78,3 +74,10 @@ repos:
entry: cargo test
stages: [pre-commit, pre-merge-commit, manual]
pass_filenames: false

- id: cargo-rustfmt
name: cargo-rustfmt
language: system
entry: cargo +{[rust_nightly_version}] fmt --all -- --check
stages: [pre-commit]
pass_filenames: false

0 comments on commit 9001281

Please sign in to comment.