Skip to content

ci: read Go version from go.mod instead of hardcoding it - #48

Merged
deepakjois merged 2 commits into
mainfrom
claude/fix-go-version-mismatch-PejeC
Feb 22, 2026
Merged

deepakjois merged 2 commits into
mainfrom
claude/fix-go-version-mismatch-PejeC

Conversation

@deepakjois

Copy link
Copy Markdown
Owner

Replace go-version: '1.25' with go-version-file: 'go.mod' in all
GitHub Actions workflows. This ensures the CI always uses the exact
Go version declared in go.mod, eliminating version mismatches that
cause compilation errors when go.mod is updated.

https://claude.ai/code/session_01MJYZTEboQKuBBTGN79ev56

Replace go-version: '1.25' with go-version-file: 'go.mod' in all
GitHub Actions workflows. This ensures the CI always uses the exact
Go version declared in go.mod, eliminating version mismatches that
cause compilation errors when go.mod is updated.

https://claude.ai/code/session_01MJYZTEboQKuBBTGN79ev56
Add .github/actions/setup-and-build as a local composite action that
encapsulates the three repeated steps present in every workflow:
checkout, setup-go (from go.mod), and go build ./...

All four workflows now reference it with a single `uses` line instead
of duplicating these steps. The dependabot workflow's now-redundant
manual exit-code check is also removed since `go build` already fails
the step on a non-zero exit.

https://claude.ai/code/session_01MJYZTEboQKuBBTGN79ev56

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR updates GitHub Actions CI to derive the Go toolchain version from go.mod (via actions/setup-go’s go-version-file) instead of hardcoding a Go version in each workflow, reducing CI breakage when go.mod is updated.

Changes:

  • Introduces a reusable composite action to checkout, set up Go from go.mod, and run go build ./....
  • Updates multiple workflows to use the new composite action instead of duplicating checkout/setup/build steps.
  • Removes the previously hardcoded Go version from those workflows.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
.github/workflows/sync-build-deploy.yml Switches workflow to the shared setup/build composite action.
.github/workflows/newsletter.yml Switches workflow to the shared setup/build composite action.
.github/workflows/go-build-deploy.yml Switches workflow to the shared setup/build composite action.
.github/workflows/dependabot-build-check.yml Simplifies Dependabot build check by using the shared setup/build composite action.
.github/actions/setup-and-build/action.yml Adds composite action that reads Go version from go.mod and runs a build.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 17 to 19
steps:
- uses: actions/checkout@v6

- uses: actions/setup-go@v6
with:
go-version: '1.25'

- name: Build
run: go build ./...
- uses: ./.github/actions/setup-and-build

Copilot AI Feb 22, 2026

Copy link

Choose a reason for hiding this comment

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

The steps list item (- uses: ./.github/actions/setup-and-build) is not indented under steps:. GitHub Actions requires the list items to be more indented than the steps: key; otherwise the workflow YAML is invalid / the job will have no steps.

Copilot uses AI. Check for mistakes.
Comment on lines +9 to +13
- uses: actions/setup-go@v6
with:
go-version-file: 'go.mod'
cache: true

Copilot AI Feb 22, 2026

Copy link

Choose a reason for hiding this comment

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

This composite action enables cache: true for actions/setup-go. Some workflows in this PR set job-level permissions: (e.g., contents: read/write), which can implicitly drop the actions scope; that can prevent the cache from being saved/restored and cause the job to fail with permission errors. Consider either (a) making caching configurable via an input (default off), or (b) updating the affected workflows’ permissions to include the minimum required actions: read/actions: write for caching.

Copilot uses AI. Check for mistakes.
Comment on lines 14 to 16
steps:
- uses: actions/checkout@v6

- uses: actions/setup-go@v6
with:
go-version: '1.25'
cache: true

- name: Build
run: go build ./...
- uses: ./.github/actions/setup-and-build

Copilot AI Feb 22, 2026

Copy link

Choose a reason for hiding this comment

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

In GitHub Actions YAML, list items under steps: must be indented more than the steps: key. Here - uses: ./.github/actions/setup-and-build is aligned with steps:, which makes the workflow invalid YAML (the step won’t be part of steps). Indent the - uses line (and the rest of the steps list, if needed) under steps:.

Copilot uses AI. Check for mistakes.
Comment on lines 14 to 16
steps:
- uses: actions/checkout@v6

- uses: actions/setup-go@v6
with:
go-version: '1.25'

- name: Build
run: go build ./...
- uses: ./.github/actions/setup-and-build

Copilot AI Feb 22, 2026

Copy link

Choose a reason for hiding this comment

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

The - uses: ./.github/actions/setup-and-build line needs to be indented under steps: (list items must be more indented than their parent key). As written, it’s aligned with steps:, which makes the workflow YAML invalid / the step not included in the job’s steps.

Copilot uses AI. Check for mistakes.
@deepakjois
deepakjois merged commit 0ac986a into main Feb 22, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants