Add go-version-file-behavior input with latest-patch option - #785
Open
johnmaguire wants to merge 2 commits into
Open
Add go-version-file-behavior input with latest-patch option#785johnmaguire wants to merge 2 commits into
johnmaguire wants to merge 2 commits into
Conversation
By default an exact version read from go-version-file is used as written, so a "go 1.22.0" directive pins CI to the oldest patch release of the minor even when newer patches with security fixes exist. Dependencies can force such an exact version into go.mod. Setting go-version-file-behavior to latest-patch widens an exact major.minor.patch version into a ~X.Y.Z range, resolving the newest available patch release of the same minor while keeping the file's version as a floor. Bare minors and prereleases pass through unchanged. The default behavior (exact) is unchanged.
johnmaguire
force-pushed
the
go-version-file-behavior
branch
from
August 18, 2026 15:52
b71c866 to
71b6f89
Compare
…dling - latest-patch implies check-latest so the newest patch release comes from the versions manifest instead of a possibly stale runner tool cache, with a warning when the manifest cannot be reached - fail fast when latest-patch is combined with a custom download base URL - never widen an exact toolchain directive pin - validate go-version-file-behavior on every input path - widen v-prefixed versions and log when a version is used as written - document dependency cache invalidation on new patch releases
There was a problem hiding this comment.
Pull request overview
Adds a new go-version-file-behavior input to control whether an exact Go version read from go-version-file is treated as a strict pin (exact, default) or widened to “latest patch of the same minor” (latest-patch) via a semver ~X.Y.Z range, with corresponding runtime behavior, documentation, and tests.
Changes:
- Introduces
go-version-file-behaviorinput with validation andlatest-patchwidening logic for versions sourced fromgo-version-file. - Ensures
latest-patchimplies manifest-based resolution (check-latest), and adds a clear warning when the manifest can’t be used. - Documents the behavior and adds end-to-end + unit coverage for widening and key edge cases (bare minors, toolchain pins, invalid values, custom download base URL conflict).
Reviewed changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/main.ts | Adds go-version-file-behavior parsing/validation, applies widening for version-file inputs, and forces check-latest when widening is applied. |
| src/installer.ts | Extends getGo to warn when manifest resolution fails under latest-patch, returns richer parseGoVersionFile result, and adds latestPatchSpec. |
| action.yml | Defines the new go-version-file-behavior input with default exact and describes constraints. |
| README.md | Documents the new input in the usage snippet. |
| docs/advanced-usage.md | Adds “Using the latest patch release” section and updates TOC. |
| tests/setup-go.test.ts | Adds coverage for latest-patch behavior, fallbacks, conflicts, and unit tests for latestPatchSpec. |
| dist/setup/index.js | Updates the built distribution to reflect the new input and runtime behavior. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description:
Adds a new
go-version-file-behaviorinput that controls how an exact version read fromgo-version-fileis interpreted:exact(default): use the version as written. This is the current behavior and remains unchanged.latest-patch: widen an exactmajor.minor.patchversion into a~X.Y.Zsemver range, so the action resolves the newest available patch release of the same minor while keeping the file's version as a floor. For example,go 1.22.0in go.mod resolves to the newest 1.22.x.Because the newest patch is often not present in the runner's tool cache,
latest-patchimpliescheck-latest: the newest matching patch is resolved from the versions manifest rather than from whatever the cache happens to hold. If the manifest cannot be reached, the action emits a warning and falls back to resolving the range locally.Some versions are always used as written and are not affected by
latest-patch:go 1.22), which already resolve to the latest patch release.go1.22rc1), which have no patch series to float within.toolchaindirective: the pin is deliberate and is never widened.The behavior only applies to versions read from
go-version-file, not to thego-versioninput, which already supports ranges directly. An unsupported value fails the action with an error on every input path. Combininglatest-patchwithgo-download-base-urlfails fast with a clear error, since version ranges cannot be resolved against a direct download URL.Justification:
Dependencies can force an exact version into a consumer's go.mod (e.g. a module requiring
go 1.22.0propagates that directive), which silently pins CI to the oldest patch release of the minor even when newer patches with security fixes are available. There is currently no way to express "at least this version, latest patch" through go.mod.Closes #481
Tradeoffs:
Inherent consequences of floating on the newest patch, for reviewers to weigh:
cache: true, the dependency cache key includes the installed Go version, so each new patch release invalidates it: the first run after a patch release rebuilds the module and build caches from scratch. Documented in the advanced usage docs.check-latestadds a manifest lookup (and usually a download) even when the runner has a satisfying Go preinstalled, and overrides an explicitly setcheck-latest: false. The override is logged.go-versionoutput reflects the resolved patch, not the version written in the file, which affects anything downstream that assumes they match.Testing:
go 1.12.16in go.mod to 1.12.17 from the versions manifest withlatest-patch, including the impliedcheck-latestresolutionexactdefault,go-versioninput precedence, thego-download-base-urlconflict, and invalid input values on both input pathsnpm run pre-checkinpasses (format, lint, build, 137 tests)