mirror of
https://github.com/actions/setup-java.git
synced 2026-08-10 16:39:28 +08: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:
Vendored
+17
-9
@@ -36380,8 +36380,9 @@ async function run() {
|
||||
jdkFile,
|
||||
toolchainIds
|
||||
};
|
||||
await validateCacheInput(cache);
|
||||
cacheRestore = cache
|
||||
? startCacheRestore(cache, cacheDependencyPath, cachePath)
|
||||
? settle(startCacheRestore(cache, cacheDependencyPath, cachePath))
|
||||
: undefined;
|
||||
toolchainConfigurations.push(await installVersion(versionInfo.version, installerInputsOptions));
|
||||
}
|
||||
@@ -36403,8 +36404,9 @@ async function run() {
|
||||
jdkFile,
|
||||
toolchainIds
|
||||
};
|
||||
await validateCacheInput(cache);
|
||||
cacheRestore = cache
|
||||
? startCacheRestore(cache, cacheDependencyPath, cachePath)
|
||||
? settle(startCacheRestore(cache, cacheDependencyPath, cachePath))
|
||||
: undefined;
|
||||
for (const [index, version] of versions.entries()) {
|
||||
toolchainConfigurations.push(await installVersion(version, installerInputsOptions, index));
|
||||
@@ -36419,19 +36421,25 @@ async function run() {
|
||||
actionError = error;
|
||||
}
|
||||
if (cacheRestore) {
|
||||
try {
|
||||
await cacheRestore;
|
||||
}
|
||||
catch (error) {
|
||||
if (!actionError) {
|
||||
actionError = error;
|
||||
}
|
||||
const cacheResult = await cacheRestore;
|
||||
if (cacheResult.status === 'rejected' && !actionError) {
|
||||
actionError = cacheResult.reason;
|
||||
}
|
||||
}
|
||||
if (actionError) {
|
||||
setup_java_core/* setFailed */.C1(actionError.message);
|
||||
}
|
||||
}
|
||||
async function validateCacheInput(cache) {
|
||||
if (!cache) {
|
||||
return;
|
||||
}
|
||||
const { validatePackageManager } = await Promise.all(/* import() */[__nccwpck_require__.e(824), __nccwpck_require__.e(971), __nccwpck_require__.e(377)]).then(__nccwpck_require__.bind(__nccwpck_require__, 7377));
|
||||
validatePackageManager(cache);
|
||||
}
|
||||
function settle(promise) {
|
||||
return promise.then(value => ({ status: 'fulfilled', value }), reason => ({ status: 'rejected', reason }));
|
||||
}
|
||||
if (process.argv[1] === (0,external_url_.fileURLToPath)(import.meta.url)) {
|
||||
run();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user