From 18d163a2b1990b91e2a7a5d51ca11bfa6f64b263 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Evrard Date: Tue, 28 Jul 2026 12:42:25 +0200 Subject: [PATCH] Ensure mise and go.mod are aligned go.mod and the tool versions (here, mise) need to be in sync. This creates a test to verify they are aligned. Signed-off-by: Jean-Philippe Evrard --- .github/workflows/on-branch-push-and-prs.yaml | 17 +++++++++++++++++ Makefile | 14 ++++++++++++-- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/.github/workflows/on-branch-push-and-prs.yaml b/.github/workflows/on-branch-push-and-prs.yaml index 2cf97e4..98fa37a 100644 --- a/.github/workflows/on-branch-push-and-prs.yaml +++ b/.github/workflows/on-branch-push-and-prs.yaml @@ -9,6 +9,23 @@ permissions: contents: read jobs: + go-version: + name: Check Go version consistency + runs-on: ubuntu-latest + steps: + - name: Harden Runner + uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4 + with: + egress-policy: audit + + - name: checkout + uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 + with: + persist-credentials: false + + - name: Check Go version consistency + run: make check-go-version + pr-short-tests: name: Run short go tests runs-on: ubuntu-latest diff --git a/Makefile b/Makefile index f57c6f4..687fe95 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ .DEFAULT: all -.PHONY: all clean install-tools dev-image release dev-manifest e2e-test minikube-publish test lint lint-go lint-sh lint-ghactions lint-docs +.PHONY: all clean install-tools dev-image release dev-manifest e2e-test minikube-publish test lint lint-go lint-sh lint-ghactions lint-docs check-go-version REGISTRY ?= ghcr.io IMAGE_NAME ?= kubereboot/kured @@ -54,6 +54,15 @@ test: lint lint: lint-sh lint-ghactions lint-go +check-go-version: + @echo "Checking Go version consistency" + @go_version="$$(sed -nE 's/^go[[:space:]]+([0-9]+\.[0-9]+\.[0-9]+)[[:space:]]*$$/\1/p' go.mod)"; \ + mise_version="$$(sed -nE 's/^go[[:space:]]*=[[:space:]]*"([0-9]+\.[0-9]+\.[0-9]+)"[[:space:]]*$$/\1/p' .config/mise.toml)"; \ + if [ -z "$$go_version" ] || [ -z "$$mise_version" ] || [ "$$go_version" != "$$mise_version" ]; then \ + echo "Go version mismatch or invalid format: go.mod=$${go_version:-invalid}, .config/mise.toml=$${mise_version:-invalid}" >&2; \ + exit 1; \ + fi + lint-sh: @echo "Running shellcheck" find . -name '*.sh' | xargs -n1 shellcheck @@ -72,4 +81,5 @@ lint-docs: lint-goreleaser: @echo "Checking goreleaser" - goreleaser check \ No newline at end of file + goreleaser check +