From 7e7222454bf7e7f1ca78b91ccbc444a4474dcf72 Mon Sep 17 00:00:00 2001 From: Techassi Date: Tue, 4 Feb 2025 09:44:04 +0100 Subject: [PATCH 1/2] fix(template/ci): Use local rustfmt hook --- config/versions.yaml | 4 ++++ template/.github/workflows/pr_pre-commit.yaml.j2 | 2 +- template/.pre-commit-config.yaml.j2 | 11 +++++++---- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/config/versions.yaml b/config/versions.yaml index ff82ae4d..d9bb0a0e 100644 --- a/config/versions.yaml +++ b/config/versions.yaml @@ -4,6 +4,10 @@ # 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. +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. diff --git a/template/.github/workflows/pr_pre-commit.yaml.j2 b/template/.github/workflows/pr_pre-commit.yaml.j2 index 766670ef..2b76e2dd 100644 --- a/template/.github/workflows/pr_pre-commit.yaml.j2 +++ b/template/.github/workflows/pr_pre-commit.yaml.j2 @@ -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 }]" diff --git a/template/.pre-commit-config.yaml.j2 b/template/.pre-commit-config.yaml.j2 index a36fdcb7..2bdd33c9 100644 --- a/template/.pre-commit-config.yaml.j2 +++ b/template/.pre-commit-config.yaml.j2 @@ -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"] @@ -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 From 9ed4c5d4dc085905b45ffcb3df90f1417dceb8f2 Mon Sep 17 00:00:00 2001 From: Techassi Date: Tue, 4 Feb 2025 09:49:18 +0100 Subject: [PATCH 2/2] chore: Add note about nightly Rust version --- config/versions.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/config/versions.yaml b/config/versions.yaml index d9bb0a0e..405a23fb 100644 --- a/config/versions.yaml +++ b/config/versions.yaml @@ -5,7 +5,8 @@ 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. +# 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