Skip to content

fix: version matching and tool cache keys for build-metadata tags#255

Open
Lauri "datafox" Heino (melodicore) wants to merge 5 commits into
mainfrom
fix/version-matching
Open

fix: version matching and tool cache keys for build-metadata tags#255
Lauri "datafox" Heino (melodicore) wants to merge 5 commits into
mainfrom
fix/version-matching

Conversation

@melodicore

@melodicore Lauri "datafox" Heino (melodicore) commented Jul 11, 2026

Copy link
Copy Markdown
Member

Summary

  • Cache collision fix: toSemverCacheKey now converts build-metadata tags (1.4.0+202607071.4.0-build.20260707) so the prerelease segment survives semver.clean() inside @actions/tool-cache. Previously, all 1.4.0+<anything> builds collapsed to the same 1.4.0 cache slot.
  • Version comparison fix: Extracted versionMatchesTag(ver, tag) which accepts the binary's self-reported version if it is the tag with a .{commithash} suffix appended — the format elide uses. Replaces two exact-string comparisons that always failed for build-metadata tags.
  • Mismatch warning fix: Non-archive installers (shell, apt, msi, pkg, rpm) were setting release.version.tag_name to the binary's own obtainVersion() output, so the post-install mismatch check was comparing a value against itself and could never fire. They now set tag_name to the requested version (options.version), and the check skips when the version is the symbolic value 'latest'.
  • CI cleanup: Removed the macos-amd64 test matrix entry — Elide no longer ships a macOS AMD64 binary; only macos-arm64 is distributed.

Tags like 1.4.0+20260707 were collapsed to 1.4.0 by semver.clean inside
tool-cache, causing cache collisions across different dated builds of the
same version. toSemverCacheKey now converts build metadata to a prerelease
segment (1.4.0+20260707 -> 1.4.0-build.20260707) which semver.clean preserves.

The existing-binary skip check and post-install mismatch warning were also
doing exact string equality against the tag, which always failed because
elide --version appends a commit hash suffix (.6f7ffa7) not present in the
tag. Both comparisons now accept the binary version if it starts with the
requested tag followed by a dot.
Pulling the binary-vs-tag comparison into a named exported function makes
it independently testable. New tests cover exact matches, commit-hash
suffixes, build-metadata tags, and false-positive guards (no dot separator,
mismatched build dates, binary ahead of prerelease tag).

Also adds a multi-part build metadata case to the toSemverCacheKey suite
(e.g. 1.4.0+20260707.abc123) to guard against future tag format changes.
Shell, apt, msi, pkg, and rpm installers all set ElideRelease.version.tag_name
to the binary's own obtainVersion() output. main.ts then compared that same
value against itself in the post-install mismatch check, so the warning could
never fire regardless of what version the user requested.

Fix: non-archive installers now set tag_name to options.version (the version
the user requested). The mismatch check gains an isSymbolic guard to skip
verification when tag_name is 'latest', since that cannot be compared against
a real binary version string.
@codecov

codecov Bot commented Jul 11, 2026

Copy link
Copy Markdown

Bundle Report

Changes will increase total bundle size by 223 bytes (0.01%) ⬆️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
setup-elide 2.23MB 223 bytes (0.01%) ⬆️

Affected Assets, Files, and Routes:

view changes for bundle: setup-elide

Assets Changed:

Asset Name Size Change Total Size Change (%)
index.js 223 bytes 1.46MB 0.02%

@codecov

codecov Bot commented Jul 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.70%. Comparing base (d2f7423) to head (9724abd).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #255      +/-   ##
==========================================
+ Coverage   86.40%   86.70%   +0.29%     
==========================================
  Files          13       13              
  Lines        1236     1256      +20     
==========================================
+ Hits         1068     1089      +21     
+ Misses        168      167       -1     
Files with missing lines Coverage Δ
src/install-apt.ts 81.25% <100.00%> (ø)
src/install-msi.ts 90.00% <100.00%> (+0.81%) ⬆️
src/install-pkg.ts 87.87% <100.00%> (+1.21%) ⬆️
src/install-rpm.ts 80.85% <100.00%> (+1.30%) ⬆️
src/install-shell.ts 85.10% <100.00%> (ø)
src/main.ts 86.71% <100.00%> (+0.33%) ⬆️
src/releases.ts 82.14% <100.00%> (+0.47%) ⬆️

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 fixes Elide version handling when tags include semver build metadata (e.g. 1.4.0+20260707), ensuring both tool-cache lookups and post-install version validation behave correctly across installers.

Changes:

  • Prevents tool-cache collisions by converting build-metadata tags into semver prerelease form for cache keys (so semver.clean() doesn’t drop the distinguishing segment).
  • Adds versionMatchesTag(ver, tag) to treat .{commithash}-suffixed binary versions as matching the requested tag, and uses it for both “existing binary” preservation and mismatch warnings.
  • Fixes mismatch detection for non-archive installers by recording the requested tag as release.version.tag_name (and skipping mismatch checks for symbolic latest).

Reviewed changes

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

Show a summary per file
File Description
src/releases.ts Adds build-metadata-aware cache key conversion to avoid tool-cache key collisions.
src/main.ts Introduces versionMatchesTag and uses it for preservation + mismatch warning logic (incl. skipping latest).
src/install-shell.ts Ensures tag_name reflects the requested version (not the binary’s self-reported version).
src/install-apt.ts Ensures tag_name reflects the requested version (not the binary’s self-reported version).
src/install-msi.ts Ensures tag_name reflects the requested version (not the binary’s self-reported version).
src/install-pkg.ts Ensures tag_name reflects the requested version (not the binary’s self-reported version).
src/install-rpm.ts Ensures tag_name reflects the requested version (not the binary’s self-reported version).
tests/releases.test.ts Adds unit coverage for toSemverCacheKey, including build-metadata cases.
tests/main.test.ts Adds unit coverage for versionMatchesTag and updates mismatch-warning test setup.
tests/install-shell.test.ts Updates expectations so returned tag_name matches the requested version.
tests/install-rpm.test.ts Updates expectations so returned tag_name matches the requested version.
tests/install-pkg.test.ts Updates expectations so returned tag_name matches the requested version.
tests/install-msi.test.ts Updates expectations so returned tag_name matches the requested version.
tests/install-apt.test.ts Updates expectations so returned tag_name matches the requested version.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Elide no longer ships a macOS AMD64 binary; only macos-arm64 is distributed.
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