feat: expose cache-primary-key output (#597)#1088
Conversation
Expose the primary cache key computed by the caching logic as a new `cache-primary-key` action output, so workflows can compose the built-in setup-java cache key with actions/cache or actions/cache/restore across steps and dependent jobs. - src/cache.ts: set the `cache-primary-key` output in restore() - action.yml: declare the new output - README.md: document the new output - __tests__/cache.test.ts: assert the output is set - dist: rebuild Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR adds a new action output, cache-primary-key, to expose the primary dependency cache key computed by actions/setup-java, enabling users to reuse the exact same key in later steps or dependent jobs (e.g., with actions/cache / actions/cache/restore).
Changes:
- Set a new
cache-primary-keyoutput during cache restore. - Declare and document the new output in
action.ymlandREADME.md. - Add test coverage for the new output and rebuild
dist/bundles.
Show a summary per file
| File | Description |
|---|---|
| src/cache.ts | Sets the new cache-primary-key output during restore() after computing the primary key. |
| action.yml | Declares cache-primary-key as an action output with a description. |
| README.md | Documents the new output and its intended usage with actions/cache tooling. |
| tests/cache.test.ts | Adds an assertion that cache-primary-key is set during restore. |
| dist/setup/index.js | Rebuilt bundle reflecting the new output behavior in the main action. |
| dist/cleanup/index.js | Rebuilt bundle reflecting the updated cache module code included in the post action bundle. |
Review details
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 4/6 changed files
- Comments generated: 3
- Review effort level: Low
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Port the review feedback from the main-line PR (#1088) into the v5 backport: - src/cache.ts: use the STATE_CACHE_PRIMARY_KEY constant for the output name instead of a duplicated string literal - action.yml / README.md: clarify that the output is also empty when caching is skipped (e.g. the cache service is unavailable) - dist: rebuild Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* feat: expose cache-primary-key output (#597) Backport of the cache-primary-key output to the v5 release line. Expose the primary cache key computed by the caching logic as a new `cache-primary-key` action output, so workflows can compose the built-in setup-java cache key with actions/cache or actions/cache/restore across steps and dependent jobs. - src/cache.ts: set the `cache-primary-key` output in restore() - action.yml: declare the new output - README.md: document the new output - __tests__/cache.test.ts: assert the output is set - dist: rebuild (CommonJS) Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> * Apply PR #1088 review suggestions to v5 backport Port the review feedback from the main-line PR (#1088) into the v5 backport: - src/cache.ts: use the STATE_CACHE_PRIMARY_KEY constant for the output name instead of a duplicated string literal - action.yml / README.md: clarify that the output is also empty when caching is skipped (e.g. the cache service is unavailable) - dist: rebuild Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
@copilot rebase with main, rebuild the project and push the updated dist folder to this PR |
Done in I fetched latest |
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
What
Exposes the primary cache key computed by the caching logic as a new
cache-primary-keyaction output.Closes #597.
Why
Today the action computes a primary cache key internally (
setup-java-<os>-<arch>-<packageManager>-<hash>) but never surfaces it. Users who want to compose the built-in setup-java caching withactions/cache/actions/cache/restore— e.g. to force the same key across dependent jobs — have no way to reference it. This exposes it as an output, mirroring whatactions/setup-nodeandactions/cachealready do.Changes
src/cache.ts: set thecache-primary-keyoutput inrestore()action.yml: declare the newcache-primary-keyoutputREADME.md: document the new output__tests__/cache.test.ts: assert the output is setdist/: rebuildNotes
restore(), which runs only whencache:is set).releases/v5is in a separate PR.Testing
npm test(cache suite: 32/32 passing)