mirror of
https://github.com/actions/setup-java.git
synced 2026-08-19 04:02:51 +00:00
Fix JDK resolution cache platform identity (#1210)
* Fix JDK resolution cache platform identity Include the effective Linux libc platform in JDK resolution cache keys so Alpine/musl and glibc runners cannot restore each other's release metadata. Bump the cache namespace and share Alpine detection with affected distributors.\n\nCo-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>\nCopilot-Session: 4f95577c-567c-47a8-92f2-b4dced527866 * Update generated action bundles Regenerate setup and cleanup distributions for the platform-aware JDK resolution cache.\n\nCo-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>\nCopilot-Session: 4f95577c-567c-47a8-92f2-b4dced527866 * Cover the platform-identity fallback and Alpine short-circuit getJavaPlatformIdentity's `?? platform` fallback and the alias path for platforms other than linux/darwin/win32 had no coverage, and isAlpineLinux had no direct test at all. Verified by mutation: replacing the fallback with a constant, and dropping the `platform === 'linux'` short-circuit from isAlpineLinux, both left the existing suite fully green. The added cases fail on each. The short-circuit case matters beyond coverage bookkeeping: it is what keeps the /etc/alpine-release probe from running on non-Linux runners, so a stray file can never make Windows or macOS resolve as musl. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 74248bb0-72af-41d8-b85d-b0f5836e68db * Carry the platform identity into the floating resolution request Merging main brought in #1219, which added getFloatingResolutionRequest as a second construction site for JdkResolutionRequest. It predates the required `platform` field, so the merged tree did not compile. The floating request already carries `source`, which pins the artifact bytes, so this changes no lookup behaviour on its own -- it keeps the two request builders consistent and the tree building. Also refreshes dist/, which the textual merge left stale. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 74248bb0-72af-41d8-b85d-b0f5836e68db --------- Co-authored-by: Bruno Borges <brborges@microsoft.com> Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 74248bb0-72af-41d8-b85d-b0f5836e68db
This commit is contained in:
co-authored by
Bruno Borges
Copilot App
parent
fb58a661f3
commit
d0e61fe743
@@ -20,7 +20,10 @@ import {MACOS_JAVA_CONTENT_POSTFIX} from '../constants.js';
|
||||
import {RetryingHttpClient} from '../retrying-http-client.js';
|
||||
import os from 'os';
|
||||
import {expectedDigestLength, verifyChecksum} from '../checksum.js';
|
||||
import {normalizeArchitecture} from './platform-types.js';
|
||||
import {
|
||||
getJavaPlatformIdentity,
|
||||
normalizeArchitecture
|
||||
} from './platform-types.js';
|
||||
import type {JdkCache} from '../jdk-cache.js';
|
||||
|
||||
export abstract class JavaBase {
|
||||
@@ -313,6 +316,7 @@ export abstract class JavaBase {
|
||||
const request = {
|
||||
distribution: this.distribution,
|
||||
packageType: this.packageType,
|
||||
platform: getJavaPlatformIdentity(),
|
||||
architecture: this.architecture,
|
||||
versionSpec: this.version,
|
||||
stable: this.stable
|
||||
@@ -428,6 +432,7 @@ export abstract class JavaBase {
|
||||
return {
|
||||
distribution: this.distribution,
|
||||
packageType: this.packageType,
|
||||
platform: getJavaPlatformIdentity(),
|
||||
architecture: this.architecture,
|
||||
versionSpec: this.version,
|
||||
stable: this.stable,
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import fs from 'fs';
|
||||
import semver from 'semver';
|
||||
import {JavaDistribution} from './package-types.js';
|
||||
|
||||
@@ -191,6 +192,28 @@ export function normalizePlatform(
|
||||
return PLATFORM_ALIASES[platform];
|
||||
}
|
||||
|
||||
export function isAlpineLinux(
|
||||
platform: NodeJS.Platform = process.platform,
|
||||
alpineReleaseExists?: boolean
|
||||
): boolean {
|
||||
return (
|
||||
platform === 'linux' &&
|
||||
(alpineReleaseExists ?? fs.existsSync('/etc/alpine-release'))
|
||||
);
|
||||
}
|
||||
|
||||
export function getJavaPlatformIdentity(
|
||||
platform: NodeJS.Platform = process.platform,
|
||||
alpineReleaseExists?: boolean
|
||||
): string {
|
||||
if (platform === 'linux') {
|
||||
return isAlpineLinux(platform, alpineReleaseExists)
|
||||
? 'linux-musl'
|
||||
: 'linux-glibc';
|
||||
}
|
||||
return normalizePlatform(platform) ?? platform;
|
||||
}
|
||||
|
||||
export function validateJavaPlatform(
|
||||
distributionName: string,
|
||||
platform: NodeJS.Platform,
|
||||
|
||||
@@ -17,6 +17,7 @@ import {
|
||||
JavaInstallerOptions,
|
||||
JavaInstallerResults
|
||||
} from '../base-models.js';
|
||||
import {isAlpineLinux} from '../platform-types.js';
|
||||
import {ISapMachineAllVersions, ISapMachineVersions} from './models.js';
|
||||
|
||||
export class SapMachineDistribution extends JavaBase {
|
||||
@@ -242,7 +243,7 @@ export class SapMachineDistribution extends JavaBase {
|
||||
return 'macos';
|
||||
case 'linux':
|
||||
// figure out if alpine/musl
|
||||
if (fs.existsSync('/etc/alpine-release')) {
|
||||
if (isAlpineLinux()) {
|
||||
return 'linux-musl';
|
||||
}
|
||||
return 'linux';
|
||||
|
||||
@@ -24,6 +24,7 @@ import {
|
||||
MAX_PAGINATION_PAGES,
|
||||
validatePaginationUrl
|
||||
} from '../../util.js';
|
||||
import {isAlpineLinux} from '../platform-types.js';
|
||||
|
||||
export {ADOPTIUM_PUBLIC_KEY} from './adoptium-key.js';
|
||||
|
||||
@@ -274,7 +275,7 @@ export class TemurinDistribution extends JavaBase {
|
||||
case 'win32':
|
||||
return 'windows';
|
||||
case 'linux':
|
||||
if (fs.existsSync('/etc/alpine-release')) {
|
||||
if (isAlpineLinux()) {
|
||||
return 'alpine-linux';
|
||||
}
|
||||
return 'linux';
|
||||
|
||||
@@ -9,7 +9,7 @@ import {
|
||||
} from './distributions/base-models.js';
|
||||
|
||||
const STATE_JDK_RESOLUTIONS = 'jdk-resolutions';
|
||||
const JDK_RESOLUTION_KEY_VERSION = 1;
|
||||
const JDK_RESOLUTION_KEY_VERSION = 2;
|
||||
const RESOLUTION_DIRECTORY = 'setup-java-jdk-resolution';
|
||||
const RESOLUTION_FILE_NAME = 'release.json';
|
||||
|
||||
@@ -22,6 +22,7 @@ const RESOLUTION_FILE_NAME = 'release.json';
|
||||
export interface JdkResolutionRequest {
|
||||
distribution: string;
|
||||
packageType: string;
|
||||
platform: string;
|
||||
architecture: string;
|
||||
versionSpec: string;
|
||||
stable: boolean;
|
||||
@@ -214,6 +215,7 @@ function getResolutionIdentity(request: JdkResolutionRequest): string {
|
||||
runnerOs: getRunnerOs(),
|
||||
distribution: request.distribution.toLowerCase(),
|
||||
packageType: request.packageType.toLowerCase(),
|
||||
platform: request.platform.toLowerCase(),
|
||||
architecture: request.architecture.toLowerCase(),
|
||||
versionSpec: request.versionSpec,
|
||||
stable: request.stable,
|
||||
|
||||
Reference in New Issue
Block a user