Skip to content

fix: filter Helm v4 plugin assets and clean up failed installs - #711

Merged
yxxhero merged 8 commits into
mainfrom
fix/platform-filter-helm-v4-plugin-assets
Jun 9, 2026
Merged

yxxhero merged 8 commits into
mainfrom
fix/platform-filter-helm-v4-plugin-assets

Conversation

@yxxhero

@yxxhero yxxhero commented Jun 8, 2026 •

Copy link
Copy Markdown
Member

Summary

When a Helm v4 plugin ships per-platform .tgz archives each with a .prov provenance file (e.g. helm-diff v3.15.8), resolveHelmV4PluginAssets should 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.tgz on a linux/amd64 runner) and avoids falling back from a valid Helm v4 package selection.

This PR also cleans up partially created Helm v4 plugin directories when a .tgz install fails before falling back to the legacy install path. That prevents duplicate plugin registrations such as helm-diff and helm-diff-linux-amd64, which was causing CI failures in helm plugin list.

Changes

  • src/helm.ts: Added filterPlatformAsset() to filter .tgz assets 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 like darwin.
  • src/helm.ts: Updated resolveHelmV4PluginAssets() to return runner-matching Helm v4 plugin archives instead of skipping the Helm v4 path when releases contain per-platform .tgz + .prov assets.
  • src/helm.ts: Added cleanup for partially installed Helm v4 plugin directories before retry/fallback so failed .tgz installs 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 .prov assets, and cleanup of partial installs before legacy fallback.

Testing

Build, lint, format check, tests, and packaging pass locally:

  • npm run build
  • npm run lint
  • npm run format-check
  • npm test
  • npm run package

Signed-off-by: opencode

@yxxhero
yxxhero force-pushed the fix/platform-filter-helm-v4-plugin-assets branch 3 times, most recently from a538a59 to b9d83f1 Compare June 8, 2026 23:34
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]>
@yxxhero
yxxhero force-pushed the fix/platform-filter-helm-v4-plugin-assets branch from b9d83f1 to 3670153 Compare June 8, 2026 23:38
@yxxhero
yxxhero requested a review from Copilot June 8, 2026 23:44

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 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 .tgz installation fails and to fall back to the legacy install path.
  • Regenerated dist/index.js to 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.

Comment thread src/helm.ts
Comment on lines +203 to 222
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);
}
}
Comment thread src/helm.ts Outdated
Comment on lines +124 to +125
const platformRegex = new RegExp(`(?:${platformPatterns.join('|')})`, 'i');
const archRegex = new RegExp(`(?:${archPatterns.join('|')})`, 'i');
Comment thread __tests__/helm.test.ts Outdated
Comment on lines +868 to +905
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')
);
});
@yxxhero

yxxhero commented Jun 8, 2026

Copy link
Copy Markdown
Member Author

@copilot fix comments

Copilot AI commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

@copilot fix comments

Addressed in 8f9d48b.

@yxxhero

yxxhero commented Jun 9, 2026

Copy link
Copy Markdown
Member Author

@copilot fix ci issues.

Copilot AI commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

@copilot fix ci issues.

Addressed in 598eed0.

Copilot AI changed the title fix: filter Helm v4 plugin assets by runner platform/arch fix: filter Helm v4 plugin assets and clean up failed installs Jun 9, 2026
@yxxhero

yxxhero commented Jun 9, 2026

Copy link
Copy Markdown
Member Author

@copilot fix ci issue.

Copilot AI commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

@copilot fix ci issue.

Addressed in e45d925.

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 4 changed files in this pull request and generated 1 comment.

Comment thread src/helm.ts
Comment on lines +115 to +119
try {
assetName = decodeURIComponent(path.basename(new URL(assetUrl).pathname));
} catch {
assetName = assetUrl.split('/').pop() ?? '';
}
@yxxhero

yxxhero commented Jun 9, 2026

Copy link
Copy Markdown
Member Author

@copilot fix comments.

Copilot AI commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

@copilot fix comments.

Fixed in the latest commit. path.basename is now called after decodeURIComponent in both the URL and fallback paths, so any %2F (or %2e%2e%2f) sequences decoded into real path separators are stripped by basename before the name is joined with the plugins directory.

@yxxhero

yxxhero commented Jun 9, 2026

Copy link
Copy Markdown
Member Author

@copilot fix ci issue.

Copilot AI commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

@copilot fix ci issue.

Fixed in the latest commit. The CI failure was a Prettier formatting issue — the long fallback line in cleanupPartialPluginInstall was reformatted to comply with the project's line-length rules.

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 4 changed files in this pull request and generated 2 comments.

Comment thread src/helm.ts
Comment on lines 392 to 396
} else {
throw new Error(
await cleanupPartialPluginInstall(assetUrl);
core.warning(
`Failed to install Helm v4 plugin from ${assetUrl}: ${assetStderr}`
);
Comment thread src/helm.ts Outdated
Comment on lines +125 to +128
await fs.rm(path.join(pluginsDir, assetName.replace(/\.tgz$/i, '')), {
recursive: true,
force: true
});
@yxxhero

yxxhero commented Jun 9, 2026

Copy link
Copy Markdown
Member Author

@copilot fix ci comments

Copilot AI commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

@copilot fix ci comments

Addressed in ddba931.

@yxxhero
yxxhero merged commit daefb3e into main Jun 9, 2026
12 checks passed
@yxxhero
yxxhero deleted the fix/platform-filter-helm-v4-plugin-assets branch June 9, 2026 01:28
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