Skip to content

Commit ec37867

Browse files
authored
Merge pull request #1398 from evrardjp/coherent-go-mod-and-mise-update
2 parents 0d6693c + 18d163a commit ec37867

2 files changed

Lines changed: 29 additions & 2 deletions

File tree

.github/workflows/on-branch-push-and-prs.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,23 @@ permissions:
99
contents: read
1010

1111
jobs:
12+
go-version:
13+
name: Check Go version consistency
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Harden Runner
17+
uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4
18+
with:
19+
egress-policy: audit
20+
21+
- name: checkout
22+
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
23+
with:
24+
persist-credentials: false
25+
26+
- name: Check Go version consistency
27+
run: make check-go-version
28+
1229
pr-short-tests:
1330
name: Run short go tests
1431
runs-on: ubuntu-latest

Makefile

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
.DEFAULT: all
2-
.PHONY: all clean install-tools dev-image release dev-manifest e2e-test minikube-publish test lint lint-go lint-sh lint-ghactions lint-docs
2+
.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
33

44
REGISTRY ?= ghcr.io
55
IMAGE_NAME ?= kubereboot/kured
@@ -54,6 +54,15 @@ test: lint
5454

5555
lint: lint-sh lint-ghactions lint-go
5656

57+
check-go-version:
58+
@echo "Checking Go version consistency"
59+
@go_version="$$(sed -nE 's/^go[[:space:]]+([0-9]+\.[0-9]+\.[0-9]+)[[:space:]]*$$/\1/p' go.mod)"; \
60+
mise_version="$$(sed -nE 's/^go[[:space:]]*=[[:space:]]*"([0-9]+\.[0-9]+\.[0-9]+)"[[:space:]]*$$/\1/p' .config/mise.toml)"; \
61+
if [ -z "$$go_version" ] || [ -z "$$mise_version" ] || [ "$$go_version" != "$$mise_version" ]; then \
62+
echo "Go version mismatch or invalid format: go.mod=$${go_version:-invalid}, .config/mise.toml=$${mise_version:-invalid}" >&2; \
63+
exit 1; \
64+
fi
65+
5766
lint-sh:
5867
@echo "Running shellcheck"
5968
find . -name '*.sh' | xargs -n1 shellcheck
@@ -72,4 +81,5 @@ lint-docs:
7281

7382
lint-goreleaser:
7483
@echo "Checking goreleaser"
75-
goreleaser check
84+
goreleaser check
85+

0 commit comments

Comments
 (0)