mirror of
https://github.com/actions/setup-java.git
synced 2026-08-16 18:32:58 +00:00
Handle early dependency cache failures during Java setup (#1226)
* Handle cache restore promise rejections 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> * Make cache-rejection regression test deterministic Reject the cache restore only after it has started and while the Java installation is still pending, instead of relying on event-loop timing. Verified the test fails against the pre-fix implementation. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> * Validate cache input after required input checks Move the package-manager validation out of the top of run() so that missing java-version/java-version-file and toolchain id errors keep their original precedence. Validation now happens immediately before the cache restore is started, which still fails fast before any JDK download. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Co-authored-by: Bruno Borges <brborges@microsoft.com>
This commit is contained in:
+15
-1
@@ -68,7 +68,7 @@ jest.unstable_mockModule('@actions/glob', () => ({
|
||||
const core = await import('@actions/core');
|
||||
const cache = await import('@actions/cache');
|
||||
const glob = await import('@actions/glob');
|
||||
const {restore, save} = await import('../src/cache.js');
|
||||
const {restore, save, validatePackageManager} = await import('../src/cache.js');
|
||||
|
||||
describe('dependency cache', () => {
|
||||
const ORIGINAL_RUNNER_OS = process.env['RUNNER_OS'];
|
||||
@@ -131,6 +131,20 @@ describe('dependency cache', () => {
|
||||
jest.restoreAllMocks();
|
||||
});
|
||||
|
||||
describe('validatePackageManager', () => {
|
||||
it('accepts supported package managers', () => {
|
||||
expect(() => validatePackageManager('maven')).not.toThrow();
|
||||
expect(() => validatePackageManager('gradle')).not.toThrow();
|
||||
expect(() => validatePackageManager('sbt')).not.toThrow();
|
||||
});
|
||||
|
||||
it('throws the targeted error for unsupported package managers', () => {
|
||||
expect(() => validatePackageManager('ant')).toThrow(
|
||||
'unknown package manager specified: ant'
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('restore', () => {
|
||||
let spyCacheRestore: any;
|
||||
let spyGlobHashFiles: any;
|
||||
|
||||
Reference in New Issue
Block a user