Skip to content

Commit 759a03e

Browse files
committed
PR comments
1 parent 6f452cd commit 759a03e

File tree

1 file changed

+10
-18
lines changed

1 file changed

+10
-18
lines changed

scripts/check_go_version.sh

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,22 @@ set -euo pipefail
33

44
MOD_VERSION=$(go mod edit -json | jq -r .Go)
55
echo "go.mod version: $MOD_VERSION"
6+
STATUS=0
67

78
for wf in .github/workflows/*.yml; do
8-
echo "Checking $wf ..."
9-
109
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)"
10+
if [[ -z "$WF_VERSIONS" ]]; then
1311
continue
1412
fi
1513

1614
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)"
15+
for ver in $UNIQUE_WF_VERSIONS; do
16+
if [[ "${ver}" != "$MOD_VERSION" ]]; then
17+
STATUS=1
18+
echo "$wf: go.mod=$MOD_VERSION but workflow uses $(tr '\n' ' ' <<<"$UNIQUE_WF_VERSIONS")"
19+
continue
20+
fi
21+
done
3022
done
3123

32-
echo "✅ All workflows consistent with go.mod ($MOD_VERSION)"
24+
exit $STATUS

0 commit comments

Comments
 (0)