Skip to content

Commit 9001281

Browse files
authored
fix(template/ci): Use local rustfmt hook (#483)
* fix(template/ci): Use local rustfmt hook * chore: Add note about nightly Rust version
1 parent d64a1bb commit 9001281

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

config/versions.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44
# docker-images/ubi8-rust-builder/Dockerfile & docker-images/ubi9-rust-builder/Dockerfile
55
rust_version: 1.82.0
66

7+
# This nightly version is only used for cargo fmt invocations, because we use nightly-only
8+
# rustfmt config options in rustfmt.toml. The version should be kept in line with the version
9+
# used in the operator-rs repository.
10+
rust_nightly_version: nightly-2025-01-15
11+
712
# IMPORTANT
813
# If you change the Hadolint version here, make sure to also change the hook
914
# refs in the local and templated .pre-commit-config.yaml files.

template/.github/workflows/pr_pre-commit.yaml.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66

77
env:
88
CARGO_TERM_COLOR: always
9-
RUST_TOOLCHAIN_VERSION: "{[ rust_version }]"
9+
RUST_TOOLCHAIN_VERSION: "{[ rust_nightly_version }]"
1010
HADOLINT_VERSION: "{[ hadolint_version }]"
1111
PYTHON_VERSION: "{[ python_version }]"
1212

template/.pre-commit-config.yaml.j2

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@ repos:
1717
- repo: https://github.com/doublify/pre-commit-rust
1818
rev: eeee35a89e69d5772bdee97db1a6a898467b686e # 1.0
1919
hooks:
20-
- id: fmt
21-
# Pinning to a specific rustc version, so that we get consistent formatting
22-
entry: RUSTUP_TOOLCHAIN=nightly-2025-01-15 cargo fmt
23-
args: ["--all", "--", "--check"]
2420
- id: clippy
2521
args: ["--all-targets", "--", "-D", "warnings"]
2622

@@ -78,3 +74,10 @@ repos:
7874
entry: cargo test
7975
stages: [pre-commit, pre-merge-commit, manual]
8076
pass_filenames: false
77+
78+
- id: cargo-rustfmt
79+
name: cargo-rustfmt
80+
language: system
81+
entry: cargo +{[rust_nightly_version}] fmt --all -- --check
82+
stages: [pre-commit]
83+
pass_filenames: false

0 commit comments

Comments
 (0)