Repository navigation
fix: filter Helm v4 plugin assets and clean up failed installs - #711
Conversation
a538a59 to
b9d83f1
Compare
When a plugin ships per-platform .tgz archives each with a .prov file (e.g. helm-diff v3.15.8), resolveHelmV4PluginAssets returned all of them instead of just the one matching the runner's OS/arch. This caused the action to attempt installing wrong-platform archives and fail. Add filterPlatformAsset() to match assets against the runner's platform and architecture using alias maps (darwin→macos, x64→amd64). Falls back to returning all assets if no match is found, preserving existing behavior. Fixes #710 Signed-off-by: yxxhero <[email protected]>
b9d83f1 to
3670153
Compare
There was a problem hiding this comment.
Pull request overview
This PR aims to fix Helm v4 plugin installation failures when GitHub releases ship per-platform .tgz archives each with a .prov file (e.g., helm-diff v3.15.8), by preventing the action from attempting to install the wrong-platform archive.
Changes:
- Added a platform/arch asset-filtering helper (
filterPlatformAsset) and new unit tests around platform/arch name matching. - Updated Helm v4 asset resolution and plugin install flow to avoid hard-failing when
.tgzinstallation fails and to fall back to the legacy install path. - Regenerated
dist/index.jsto include the updated action bundle.
Reviewed changes
Copilot reviewed 2 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
src/helm.ts |
Adds platform/arch filtering helper and adjusts Helm v4 plugin asset resolution + install fallback behavior. |
__tests__/helm.test.ts |
Adds/updates tests for platform filtering and Helm v4 plugin install fallback scenarios. |
dist/index.js |
Updates the bundled GitHub Action output to reflect source changes. |
| if (v4PluginAssets.length > 0) { | ||
| // Per-platform binary archives (e.g. helm-diff-linux-amd64.tgz) are not | ||
| // proper Helm v4 plugin packages — they install to the wrong directory | ||
| // name and cause plugin conflicts. Detect them by OS+arch in filenames | ||
| // and skip the v4 path so the legacy git repo install is used instead. | ||
| const osPattern = | ||
| /(?:linux|macos|darwin|windows|freebsd|netbsd|openbsd)/i; | ||
| const archPattern = | ||
| /(?:amd64|arm64|armv[67]|ppc64le|s390x|x86_64|aarch64)/i; | ||
| const hasPlatformBinaries = v4PluginAssets.some( | ||
| a => osPattern.test(a.name) && archPattern.test(a.name) | ||
| ); | ||
| if (hasPlatformBinaries) { | ||
| core.info( | ||
| `Detected per-platform binary archives for ${pluginUrl}, skipping v4 path` | ||
| ); | ||
| } else { | ||
| return v4PluginAssets.map(a => a.browser_download_url); | ||
| } | ||
| } |
| const platformRegex = new RegExp(`(?:${platformPatterns.join('|')})`, 'i'); | ||
| const archRegex = new RegExp(`(?:${archPatterns.join('|')})`, 'i'); |
| it('should return empty for per-platform archives with .prov files', async () => { | ||
| mockGetJson.mockResolvedValueOnce({ | ||
| result: { | ||
| assets: [ | ||
| { | ||
| name: 'helm-diff-linux-amd64.tgz', | ||
| browser_download_url: | ||
| 'https://example.com/helm-diff-linux-amd64.tgz' | ||
| }, | ||
| { | ||
| name: 'helm-diff-linux-amd64.tgz.prov', | ||
| browser_download_url: | ||
| 'https://example.com/helm-diff-linux-amd64.tgz.prov' | ||
| }, | ||
| { | ||
| name: 'helm-diff-macos-arm64.tgz', | ||
| browser_download_url: | ||
| 'https://example.com/helm-diff-macos-arm64.tgz' | ||
| }, | ||
| { | ||
| name: 'helm-diff-macos-arm64.tgz.prov', | ||
| browser_download_url: | ||
| 'https://example.com/helm-diff-macos-arm64.tgz.prov' | ||
| } | ||
| ] | ||
| } | ||
| }); | ||
|
|
||
| const result = await resolveHelmV4PluginAssets( | ||
| 'https://github.com/databus23/helm-diff', | ||
| 'v3.15.8' | ||
| ); | ||
|
|
||
| expect(result).toEqual([]); | ||
| expect(mockCore.info).toHaveBeenCalledWith( | ||
| expect.stringContaining('per-platform binary archives') | ||
| ); | ||
| }); |
|
@copilot fix comments |
|
@copilot fix ci issues. |
|
@copilot fix ci issue. |
| try { | ||
| assetName = decodeURIComponent(path.basename(new URL(assetUrl).pathname)); | ||
| } catch { | ||
| assetName = assetUrl.split('/').pop() ?? ''; | ||
| } |
|
@copilot fix comments. |
Fixed in the latest commit. |
|
@copilot fix ci issue. |
Fixed in the latest commit. The CI failure was a Prettier formatting issue — the long fallback line in |
| } else { | ||
| throw new Error( | ||
| await cleanupPartialPluginInstall(assetUrl); | ||
| core.warning( | ||
| `Failed to install Helm v4 plugin from ${assetUrl}: ${assetStderr}` | ||
| ); |
| await fs.rm(path.join(pluginsDir, assetName.replace(/\.tgz$/i, '')), { | ||
| recursive: true, | ||
| force: true | ||
| }); |
|
@copilot fix ci comments |
Summary
When a Helm v4 plugin ships per-platform
.tgzarchives each with a.provprovenance file (e.g.helm-diff v3.15.8),resolveHelmV4PluginAssetsshould filter them to the runner's OS/arch instead of returning all matching assets. This prevents the action from attempting to install wrong-platform archives (e.g.helm-diff-freebsd-amd64.tgzon alinux/amd64runner) and avoids falling back from a valid Helm v4 package selection.This PR also cleans up partially created Helm v4 plugin directories when a
.tgzinstall fails before falling back to the legacy install path. That prevents duplicate plugin registrations such ashelm-diffandhelm-diff-linux-amd64, which was causing CI failures inhelm plugin list.Changes
src/helm.ts: AddedfilterPlatformAsset()to filter.tgzassets by matching the runner's OS/arch against asset names, using alias maps for normalization (darwin→macos,x64→amd64).src/helm.ts: Updated asset matching to use token-aware regexes so Windows aliases do not incorrectly match substrings likedarwin.src/helm.ts: UpdatedresolveHelmV4PluginAssets()to return runner-matching Helm v4 plugin archives instead of skipping the Helm v4 path when releases contain per-platform.tgz+.provassets.src/helm.ts: Added cleanup for partially installed Helm v4 plugin directories before retry/fallback so failed.tgzinstalls do not leave duplicate plugin entries behind.__tests__/helm.test.ts: Added and updated tests covering exact platform match, darwin→macos aliasing, x64→amd64 normalization, token-boundary matching, no-match fallback, assets without platform info, runner-specific selection for per-platform.provassets, and cleanup of partial installs before legacy fallback.Testing
Build, lint, format check, tests, and packaging pass locally:
npm run buildnpm run lintnpm run format-checknpm testnpm run packageSigned-off-by: opencode