Skip to content

Commit 7de5dd6

Browse files
committed
ci: add check for Go version consistency
1 parent aeb1c57 commit 7de5dd6

File tree

3 files changed

+44
-0
lines changed

3 files changed

+44
-0
lines changed

.github/workflows/release.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ jobs:
1919
name: Run Integration Tests
2020
runs-on: ubuntu-latest
2121
steps:
22+
- name: Check Go Versions
23+
run: ./scripts/check_go_version.sh
24+
2225
- name: Set up Go
2326
uses: actions/setup-go@v5
2427
with:
@@ -77,6 +80,9 @@ jobs:
7780
- name: Unshallow
7881
run: git fetch --prune --unshallow
7982

83+
- name: Check Go Versions
84+
run: ./scripts/check_go_version.sh
85+
8086
- name: Set up Go
8187
uses: actions/setup-go@v5
8288
with:

.github/workflows/test.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ jobs:
1919
runs-on: ubuntu-latest
2020
timeout-minutes: 5
2121
steps:
22+
- name: Check Go Versions
23+
run: ./scripts/check_go_version.sh
24+
2225
- name: Set up Go
2326
uses: actions/setup-go@v5
2427
with:
@@ -122,6 +125,9 @@ jobs:
122125
runs-on: ubuntu-latest
123126
timeout-minutes: 5
124127
steps:
128+
- name: Check Go Versions
129+
run: ./scripts/check_go_version.sh
130+
125131
- name: Set up Go
126132
uses: actions/setup-go@v5
127133
with:

scripts/check_go_version.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
MOD_VERSION=$(go mod edit -json | jq -r .Go)
5+
echo "go.mod version: $MOD_VERSION"
6+
7+
for wf in .github/workflows/*.yml; do
8+
echo "Checking $wf ..."
9+
10+
WF_VERSIONS=$(yq -r '.jobs[].steps[] | select(.with["go-version"]) | .with["go-version"]' -o=tsv "$wf" | grep -v '^---$' || true)
11+
if [ -z "$WF_VERSIONS" ]; then
12+
echo "ℹ️ No go-version found in $wf (skipped)"
13+
continue
14+
fi
15+
16+
UNIQUE_WF_VERSIONS=$(echo "$WF_VERSIONS" | sort -u)
17+
if [ "$(echo "$UNIQUE_WF_VERSIONS" | wc -l)" -ne 1 ]; then
18+
echo "❌ Multiple Go versions found in $wf:"
19+
echo "$UNIQUE_WF_VERSIONS"
20+
exit 1
21+
fi
22+
23+
# At this point there's only one unique Go version
24+
if [ "$UNIQUE_WF_VERSIONS" != "$MOD_VERSION" ]; then
25+
echo "❌ Mismatch in $wf: go.mod=$MOD_VERSION but workflow uses $UNIQUE_WF_VERSIONS"
26+
exit 1
27+
fi
28+
29+
echo "$wf matches go.mod ($MOD_VERSION)"
30+
done
31+
32+
echo "✅ All workflows consistent with go.mod ($MOD_VERSION)"

0 commit comments

Comments
 (0)