Skip to content

feat: resolve latest patch for a major.minor version#293

Open
ejaifeobuks wants to merge 2 commits into
Azure:mainfrom
ejaifeobuks:feat/latest-patch
Open

feat: resolve latest patch for a major.minor version#293
ejaifeobuks wants to merge 2 commits into
Azure:mainfrom
ejaifeobuks:feat/latest-patch

Conversation

@ejaifeobuks

@ejaifeobuks ejaifeobuks commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

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.x or 3.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:

  • Added isMajorMinorShaped to detect major.minor and wildcard patch versions, and updated validation to accept these forms in getVersionFromToolVersionsFile. [1] [2]
  • Implemented resolveLatestPatchVersion to 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.
  • Updated the main run logic to support resolving major.minor and wildcard patch versions before proceeding with download.

Testing improvements:

  • Added comprehensive tests for major.minor and wildcard patch version handling, including validation, patch resolution, network error propagation, and edge cases like missing releases or excessive matches. [1] [2] [3]
  • Switched from vi.stubGlobal to vi.spyOn(globalThis, 'fetch') in tests to ensure reliable restoration of mocks and prevent test leakage.

Error messaging:

  • Improved error messages for invalid version entries in .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

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.

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 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(), and resolveLatestPatchVersion() to resolve major.minor to v{major}.{minor}.{latestPatch} via sequential host probes.
  • Wire major.minor resolution into run() and relax .tool-versions parsing to accept major.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.

Comment thread src/run.ts
Comment thread src/run.ts Outdated
Comment thread src/run.ts Outdated
Comment thread src/run.test.ts Outdated
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.

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

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

Comment thread src/run.ts
Comment thread src/run.ts
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.

Feature Request: install latest patch version

2 participants