Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,18 @@ jobs:
name: Run Integration Tests
runs-on: ubuntu-latest
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v5

- name: Check Go Versions
run: ./scripts/check_go_version.sh

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.22"
go-version: "1.24.2"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do these need this to be in sync? IIRC Go will run as the version defined in go.mod even if it's a lower version. Higher version of course takes precedence.

See:

~
❯ go1.23.7 version
go version go1.23.7 darwin/arm64
~/Code/coder main*
❯ go1.23.7 version
go version go1.24.6 darwin/arm64

Btw, go.mod says 1.24.6.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The actions/setup-go action has a breaking change:

Breaking Changes
Improve toolchain handling to ensure more reliable and consistent toolchain selection and management by [@​matthewhughes934](https://github.com/matthewhughes934) in [actions/setup-go#460](https://redirect.github.com/actions/setup-go/pull/460)

see #437

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, gotcha, so they're preventing that behavior now.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#439 stacked the original PR on top and it's green ✅

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ignore my comment about 1.24.6 btw, originally thought this was a PR to coder/coder repo 😄

id: go

- name: Check out code into the Go module directory
uses: actions/checkout@v5

- name: Get dependencies
run: |
go mod download
Expand Down Expand Up @@ -74,13 +77,16 @@ jobs:
- name: Checkout
uses: actions/checkout@v5

- name: Check Go Versions
run: ./scripts/check_go_version.sh

- name: Unshallow
run: git fetch --prune --unshallow

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.22'
go-version: "1.24.2"

- name: Import GPG key
id: import_gpg
Expand Down
33 changes: 21 additions & 12 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,18 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v5

- name: Check Go Versions
run: ./scripts/check_go_version.sh

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.22"
go-version: "1.24.2"
id: go

- name: Check out code into the Go module directory
uses: actions/checkout@v5

- name: Get dependencies
run: |
go mod download
Expand Down Expand Up @@ -92,20 +95,23 @@ jobs:
- "1.10.*"
- "1.11.*"
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v5

- name: Check Go Versions
run: ./scripts/check_go_version.sh

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.22"
go-version: "1.24.2"
id: go

- uses: hashicorp/setup-terraform@v3
with:
terraform_version: ${{ matrix.terraform }}
terraform_wrapper: false

- name: Check out code into the Go module directory
uses: actions/checkout@v5

- name: Get dependencies
run: |
go mod download
Expand All @@ -122,20 +128,23 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v5

- name: Check Go Versions
run: ./scripts/check_go_version.sh

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.22"
go-version: "1.24.2"
id: go

- uses: hashicorp/setup-terraform@v3
with:
terraform_version: "latest"
terraform_wrapper: false

- name: Check out code into the Go module directory
uses: actions/checkout@v5

- name: Get dependencies
run: |
go mod download
Expand Down
35 changes: 35 additions & 0 deletions scripts/check_go_version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/env bash
set -euo pipefail

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

if [[ " $* " == *" --fix "* ]]; then
for wf in .github/workflows/*.{yml,yaml}; do
sed -i "s/go-version:.*/go-version: \"${MOD_VERSION}\"/g" "${wf}"
done
exit 0
fi

for wf in .github/workflows/*.{yml,yaml}; do
WF_VERSIONS=$(yq -r '.jobs[].steps[] | select(.with["go-version"]) | .with["go-version"]' -o=tsv "$wf" | grep -v '^---$' || true)
if [[ -z "$WF_VERSIONS" ]]; then
continue
fi

UNIQUE_WF_VERSIONS=$(sort -u <<<"$WF_VERSIONS")
for ver in $UNIQUE_WF_VERSIONS; do
if [[ $ver != "$MOD_VERSION" ]]; then
STATUS=1
echo "❌ $wf: go.mod=$MOD_VERSION but workflow uses $(tr '\n' ' ' <<<"$UNIQUE_WF_VERSIONS")"
continue
fi
done
done

if [[ $STATUS -eq 1 ]]; then
echo "Re-run this script with --fix to automatically update workflows to match go.mod"
fi

exit $STATUS