Skip to content

Commit 971f7c1

Browse files
authored
chore: add lint rule to ensure Go versions stay in sync (#2627)
Adds lint rule to ensure Go versions remain in sync across go.mod files and Dockerfiles. Errors would show up as follows: <img width="807" height="199" alt="Screenshot 2026-07-16 at 13 11 33" src="https://github.com/user-attachments/assets/1338c22c-ca7e-4709-85c3-8a191b055cc3" />
1 parent 318b4d1 commit 971f7c1

6 files changed

Lines changed: 45 additions & 6 deletions

File tree

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:1.25.11-alpine3.23 as build
1+
FROM golang:1.25.12-alpine3.23 as build
22
ENV GO111MODULE=on
33
ENV CGO_ENABLED=0
44
ENV GOOS=linux

Dockerfile.dev

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:1.25.11-alpine3.23
1+
FROM golang:1.25.12-alpine3.23
22
ENV GO111MODULE=on
33
ENV CGO_ENABLED=0
44
ENV GOOS=linux

Makefile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
.PHONY: all build deps image migrate test vet sec vulncheck format unused release
2-
.PHONY: check-gosec check-govulncheck check-oapi-codegen check-staticcheck
2+
.PHONY: check-gosec check-govulncheck check-oapi-codegen check-staticcheck check-go-version
33
CHECK_FILES ?= ./...
44

55
ifdef RELEASE_VERSION
@@ -41,7 +41,7 @@ TOOL_TARGETS = \
4141
help: ## Show this help.
4242
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {sub("\\\\n",sprintf("\n%22c"," "), $$2);printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
4343

44-
all: vet sec static build ## Run the tests and build the binary.
44+
all: check-go-version vet sec static build ## Run the tests and build the binary.
4545

4646
build: auth auth-amd64 auth-arm64 auth-darwin-arm64 ## Build the binaries.
4747

@@ -73,6 +73,7 @@ deps: ## Install dependencies.
7373
@go mod verify
7474

7575
release-test: \
76+
check-go-version \
7677
vet \
7778
static \
7879
sec \
@@ -118,6 +119,9 @@ test: auth ## Run tests.
118119
vet: # Vet the code
119120
go vet $(CHECK_FILES)
120121

122+
check-go-version: ## Verify the pinned Go version matches across go.mod, Dockerfiles, and submodules.
123+
./hack/check-go-version.sh
124+
121125
.NOTPARALLEL: $(TOOL_TARGETS)
122126
$(TOOL_TARGETS):
123127
$(MAKE) -C tools

hack/check-go-version.sh

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/usr/bin/env bash
2+
3+
# Ensures the pinned Go patch version is identical everywhere it appears.
4+
# Source of truth is the `go` directive in the root go.mod.
5+
set -euo pipefail
6+
7+
cd "$(dirname "$0")/.."
8+
9+
# "X.Y.Z" from a go.mod `go` directive.
10+
gomod_version() { grep -m1 -E '^go [0-9]' "$1" | awk '{print $2}'; }
11+
# "X.Y.Z" from a Dockerfile `FROM golang:X.Y.Z-...` line.
12+
dockerfile_version() { grep -m1 -oE 'golang:[0-9]+\.[0-9]+\.[0-9]+' "$1" | cut -d: -f2; }
13+
14+
WANT="$(gomod_version go.mod)"
15+
FAIL=false
16+
17+
check() { # <label> <found>
18+
if [ "$2" != "$WANT" ]; then
19+
echo "$1 pins Go $2, expected $WANT (from go.mod)"
20+
FAIL=true
21+
fi
22+
}
23+
24+
check "tools/go.mod" "$(gomod_version tools/go.mod)"
25+
check "internal/forks/godotenv/go.mod" "$(gomod_version internal/forks/godotenv/go.mod)"
26+
check "Dockerfile" "$(dockerfile_version Dockerfile)"
27+
check "Dockerfile.dev" "$(dockerfile_version Dockerfile.dev)"
28+
29+
if [ "$FAIL" = true ]; then
30+
echo
31+
echo "Go version mismatch. Update every pinned spot above to match go.mod ($WANT)."
32+
exit 1
33+
fi
34+
35+
echo "Go version $WANT is consistent across all pinned files."

internal/forks/godotenv/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module github.com/joho/godotenv
22

3-
go 1.25.11
3+
go 1.25.12

tools/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/supabase/auth/tools
22

3-
go 1.25.11
3+
go 1.25.12
44

55
tool (
66
github.com/securego/gosec/v2/cmd/gosec

0 commit comments

Comments
 (0)