5
0
mirror of https://gitea.com/actions/setup-java.git synced 2026-08-05 02:31:18 +00:00

Fix JDK cache CI validation

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
Bruno Borges
2026-08-04 19:44:02 -04:00
parent b16465116b
commit c4ba924625
5 changed files with 28 additions and 9 deletions
+5 -3
View File
@@ -113,18 +113,20 @@ async function saveJdkCaches() {
}
}
function buildJdkCacheKey(jdk) {
const runnerOs = process.env['RUNNER_OS'] ?? process.platform;
const normalizedArchitecture = jdk.architecture.toLowerCase();
const identity = JSON.stringify({
keyVersion: JDK_CACHE_KEY_VERSION,
runnerOs: process.env['RUNNER_OS'] ?? process.platform,
runnerOs,
platform: process.platform,
distribution: jdk.distribution.toLowerCase(),
packageType: jdk.packageType.toLowerCase(),
architecture: jdk.architecture.toLowerCase(),
architecture: normalizedArchitecture,
version: jdk.version,
source: jdk.source
});
const digest = createHash('sha256').update(identity).digest('hex');
return `setup-java-jdk-v${JDK_CACHE_KEY_VERSION}-${process.env['RUNNER_OS'] ?? process.platform}-${jdk.architecture}-${digest}`;
return `setup-java-jdk-v${JDK_CACHE_KEY_VERSION}-${runnerOs}-${normalizedArchitecture}-${digest}`;
}
function parseJdkCacheState(state) {
const value = JSON.parse(state);
+10 -2
View File
@@ -460,10 +460,18 @@ class JavaBase {
return version.replace('+', '-');
}
getJdkCachePath(version) {
return external_path_default().join(process.env['RUNNER_TOOL_CACHE'] ?? '', this.toolcacheFolderName, this.getToolcacheVersionName(version));
const toolCache = process.env['RUNNER_TOOL_CACHE'];
if (!toolCache) {
return '';
}
return external_path_default().join(toolCache, this.toolcacheFolderName, this.getToolcacheVersionName(version));
}
getRestoredJdkPath(version) {
const architecturePath = external_path_default().join(this.getJdkCachePath(version), this.architecture);
const basePath = this.getJdkCachePath(version);
if (!basePath) {
return null;
}
const architecturePath = external_path_default().join(basePath, this.architecture);
return external_fs_.existsSync(architecturePath) &&
external_fs_.existsSync(`${architecturePath}.complete`)
? architecturePath
+5 -3
View File
@@ -117,18 +117,20 @@ async function saveJdkCaches() {
}
}
function buildJdkCacheKey(jdk) {
const runnerOs = process.env['RUNNER_OS'] ?? process.platform;
const normalizedArchitecture = jdk.architecture.toLowerCase();
const identity = JSON.stringify({
keyVersion: JDK_CACHE_KEY_VERSION,
runnerOs: process.env['RUNNER_OS'] ?? process.platform,
runnerOs,
platform: process.platform,
distribution: jdk.distribution.toLowerCase(),
packageType: jdk.packageType.toLowerCase(),
architecture: jdk.architecture.toLowerCase(),
architecture: normalizedArchitecture,
version: jdk.version,
source: jdk.source
});
const digest = (0,crypto__WEBPACK_IMPORTED_MODULE_0__.createHash)('sha256').update(identity).digest('hex');
return `setup-java-jdk-v${JDK_CACHE_KEY_VERSION}-${process.env['RUNNER_OS'] ?? process.platform}-${jdk.architecture}-${digest}`;
return `setup-java-jdk-v${JDK_CACHE_KEY_VERSION}-${runnerOs}-${normalizedArchitecture}-${digest}`;
}
function parseJdkCacheState(state) {
const value = JSON.parse(state);