feat: resolve latest patch for a major.minor version#293
Open
ejaifeobuks wants to merge 2 commits into
Open
Conversation
Allow the version input and version-file entries to be a major.minor value like
3.14 / v3.14, resolving to the newest available patch (e.g. v3.14.4).
Resolution probes the download host directly: sequential HEAD requests for
helm-v{major}.{minor}.{n} against downloadBaseURL, taking the highest that
returns 200. Works with any file-serving mirror and needs no token or extra
dependency, and cannot resolve to a version that is not downloadable. Only
major.minor.n URLs are probed, so prereleases are never considered.
- Add isMajorMinorShaped, helmPatchExists, and resolveLatestPatchVersion.
- Walk stops after 3 consecutive 404s (look-ahead) to tolerate a skipped patch
number, with a 100-probe safety cap; hitting the cap throws instead of
returning a bogus version.
- Wire resolution into run() and relax getVersionFromToolVersionsFile to accept
a major.minor value.
There was a problem hiding this comment.
Pull request overview
This PR adds support for specifying Helm as a major.minor input (e.g., 3.14 / v3.14) and resolves it to the newest downloadable patch release by probing the configured download host.
Changes:
- Add
isMajorMinorShaped(),helmPatchExists(), andresolveLatestPatchVersion()to resolvemajor.minortov{major}.{minor}.{latestPatch}via sequential host probes. - Wire
major.minorresolution intorun()and relax.tool-versionsparsing to acceptmajor.minor. - Add unit tests covering parsing/shape checks and patch-resolution behavior.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| src/run.ts | Adds major.minor detection and resolves it to the latest patch via HEAD probes against the download host. |
| src/run.test.ts | Adds tests for major.minor parsing and latest-patch resolution logic (including skipped patches and error paths). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Extend the major.minor latest-patch resolution to accept wildcard patch syntax (`3.12.x`, `v3.12.x`, `3.12.*`), matching the syntax requested in Azure#109. The following smaller fixes were made based on Copilot review feedback: - helmPatchExists now treats only 404 as "patch absent"; any other non-2xx status (403/405/429/5xx) and network errors are thrown, so rate-limiting, outages, or a host that disallows HEAD can no longer be misread as a missing patch (which could yield a stale version or a false "No Helm releases found"). - Clarify the version-file validation error to reflect that both a full version and a major.minor value are accepted, with concrete examples. - Tests: use vi.spyOn(globalThis, 'fetch') instead of vi.stubGlobal so restoreAllMocks() reliably restores fetch and the mock never leaks across tests; add coverage for wildcards and the non-404 throw path.
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.
This pull request adds support for specifying Helm versions as major.minor (e.g.,
3.14) or with a wildcard patch (e.g.,3.14.xor3.14.*) in addition to full semantic versions. It introduces logic to resolve these inputs to the latest available patch version by probing the download host. The tests have been expanded to cover these new behaviors, and error handling has been improved for version validation and network scenarios.Version resolution enhancements:
isMajorMinorShapedto detect major.minor and wildcard patch versions, and updated validation to accept these forms ingetVersionFromToolVersionsFile. [1] [2]resolveLatestPatchVersionto probe the download host and resolve a major.minor version (or wildcard patch) to the latest available patch version, with robust error handling for missing releases and network errors.runlogic to support resolving major.minor and wildcard patch versions before proceeding with download.Testing improvements:
vi.stubGlobaltovi.spyOn(globalThis, 'fetch')in tests to ensure reliable restoration of mocks and prevent test leakage.Error messaging:
.tool-versions, clarifying the accepted formats and providing actionable guidance.These changes improve flexibility for users specifying Helm versions and ensure robust, predictable behavior across a wider range of inputs.
This PR once merges will fix #109