Repository navigation
Conversation
@actions/tool-cache only does an exact lookup in find() for explicit semver versions. Installers and cumulative updates were cached under bare SQL Server versions such as '2022', which find() treats as a range and only matches against semver-named cache directories, so the cache was written but never read. Cache and look up tools through a small wrapper that maps versions to an explicit semver version (e.g. '2022.0.0') so cached media is reused by later runs on the same runner. Entries previously cached under the old directory names were never read and are left untouched. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The ODBC and Native Client MSI installers were cached under bare major versions such as '18', which @actions/tool-cache's find() never matches, so they were downloaded on every run. The lookup also used the installer's own arch (x64/x86) while caching used the host arch, which differ on arm64 runners. Use the semver-mapping tool-cache wrapper and pass the same arch when looking up and caching the installer. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Record that all tool-cache access must go through src/tool-cache.ts because find() only matches explicit semver versions, and that cached cumulative updates are intentionally reused per SQL Server version. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Problem
@actions/tool-cache'sfind()only does an exact lookup when the version is an explicit semver. For anything else (e.g.'2022') it treats the version as a range and resolves it viafindAllVersions(), which only returns cache directories whose names are explicit semver versions. Every installer was cached under a bare version (sqlserver/2022,sqlupdate/2019,msodbcsql/18,sqlncli/11), sofind()always returned''— the cache was written but never read, even on self-hosted runners. The unit tests didn't catch it because they mocktc.find.This was noticed while reviewing #296.
Reproduced against the real
@actions/tool-cache4.0.0:The MSI installer (ODBC / Native Client) also used inconsistent arch:
find()was givengetArch()(x64/x86) whilecacheFile()fell back toos.arch(), which differ on arm64 runners.Changes
fix: reuse cached SQL Server installers and updates— addssrc/tool-cache.ts, a thin wrapper (findCachedTool,cacheToolDir,cacheToolFile) that pads versions to an explicit semver ('2022'→'2022.0.0') for both writes and lookups.install.tsandutils.tsgo through it. Newtest/tool-cache.tsruns against the real@actions/tool-cache(only@actions/corelogging is silenced) and round-trips every supported SQL Server version; it fails without the mapping. Mocked tests now assert the semver-shaped version passed to tool-cache. README gains a "Caching" section.fix: reuse cached ODBC and Native Client installers— the MSI installer uses the wrapper and passes the same arch to lookup and cache.docs: document the tool-cache wrapper in agent instructions— records in.github/copilot-instructions.mdthat cache access must go through the wrapper, and that CU caching per SQL Server version is intentional.Behaviour notes
sqlupdateis removed from the tool cache (documented in the README). This is intentional.2022.0.0-style entries (their bare'2022'is treated as a satisfiable range); the cached layout is identical, so this is harmless.Testing
npm run lint,npm test(171 passing) andnpm run buildwith a cleangit diff-files -w, verified on each commit individually.🤖 Generated with Claude Code