Handle early dependency cache failures during Java setup - #1226
Open
jdubois wants to merge 1 commit into
Open
Conversation
Validate dependency cache providers before Java installation and settle cache restore failures immediately while preserving setup error precedence. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves actions/setup-java orchestration by preventing early dependency-cache restore failures (including invalid cache provider inputs) from causing unhandled promise rejections, while ensuring Java setup/configuration failures keep precedence over cache failures.
Changes:
- Validate the dependency cache provider earlier via a shared
validatePackageManagerpath. - Convert cache restore to an immediately-handled “settled” promise to avoid unhandled rejections while it overlaps JDK installation.
- Add/extend unit tests covering early invalid cache input failures and early cache restore rejection handling.
Show a summary per file
| File | Description |
|---|---|
| src/setup-java.ts | Validates cache provider earlier and wraps cache restore in a settled promise to prevent unhandled rejections while preserving setup error precedence. |
| src/cache.ts | Exposes validatePackageManager to share cache-provider validation logic. |
| dist/setup/index.js | Regenerated bundle reflecting the new setup orchestration and settled cache restore handling. |
| dist/setup/377.index.js | Regenerated module bundle exporting validatePackageManager. |
| dist/cleanup/377.index.js | Regenerated cleanup bundle reflecting shared cache validation export. |
| tests/setup-java.test.ts | Adds tests for invalid cache inputs failing before distribution resolution and for early cache restore rejection handling without unhandled rejections. |
| tests/cache.test.ts | Adds direct tests for validatePackageManager behavior. |
Review details
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 4/7 changed files
- Comments generated: 1
- Review effort level: Lite
Comment on lines
+44
to
+47
| if (cache) { | ||
| const {validatePackageManager} = await import('./cache.js'); | ||
| validatePackageManager(cache); | ||
| } |
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.
Description:
Validate dependency cache providers before Java distribution installation, and attach rejection handling to cache restoration immediately while it continues to overlap JDK setup. Reconcile the settled cache result after setup so Java/configuration errors retain precedence and cache failures are reported through
core.setFailedwhen setup succeeds.Regenerate the setup and cleanup bundles for the shared cache validation path.
Related issue:
Fixes #1223
Check list:
npm run checklocally (format, lint, build, test) and all checks pass.