mirror of
https://github.com/actions/setup-java.git
synced 2026-07-08 16:20:44 +03:00
dist: Migrate from Zulu Discovery API to Azul Metadata API (#1010)
* Use Azul metadata API * Document arm64 -> aarch64 mapping in README.md * Paginate through all available versions * Fix typo: win_aarhc4 * Only query for linux_glibc packages * Add Zulu CRaC package support to metadata migration Fold CRaC-related work into the Zulu metadata API migration by wiring crac_supported query handling, extending Zulu package docs, and updating installer tests for jdk+crac/jre+crac behavior. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Harden Zulu metadata pagination with safety cap - Stop paginating on a short page to avoid an extra empty request - Guard against undefined results (not just null) - Cap iterations at 100 pages and warn if the limit is hit to prevent a runaway loop if the API misbehaves Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Preserve JDK build number from Azul Metadata API The Azul Metadata API returns java_version as a 3-element array (e.g. [17,0,7]) and reports the build number separately in openjdk_build_number. The migration mapped version directly from java_version, dropping the build and breaking exact-version lookups like 17.0.7+7 (e2e failure: "No matching version found for SemVer"). Add openjdk_build_number to IZuluVersions and append it to java_version before converting to semver so resolved versions retain the build (e.g. 17.0.7+7). Update the zulu test fixtures to mirror the real API shape (3-element java_version plus openjdk_build_number) so unit tests exercise the actual response format, and rebuild dist. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Bruno Borges <brborges@microsoft.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
Vendored
+57
-24
@@ -81150,16 +81150,22 @@ class ZuluDistribution extends base_installer_1.JavaBase {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const availableVersionsRaw = yield this.getAvailableVersions();
|
||||
const availableVersions = availableVersionsRaw.map(item => {
|
||||
// The Azul Metadata API reports the JDK build number separately from
|
||||
// java_version (e.g. java_version=[17,0,7], openjdk_build_number=7).
|
||||
// Append it so the resulting semver retains the build (e.g. 17.0.7+7).
|
||||
const javaVersion = item.openjdk_build_number != null
|
||||
? [...item.java_version, item.openjdk_build_number]
|
||||
: item.java_version;
|
||||
return {
|
||||
version: (0, util_1.convertVersionToSemver)(item.jdk_version),
|
||||
url: item.url,
|
||||
zuluVersion: (0, util_1.convertVersionToSemver)(item.zulu_version)
|
||||
version: (0, util_1.convertVersionToSemver)(javaVersion),
|
||||
url: item.download_url,
|
||||
zuluVersion: (0, util_1.convertVersionToSemver)(item.distro_version)
|
||||
};
|
||||
});
|
||||
const satisfiedVersions = availableVersions
|
||||
.filter(item => (0, util_1.isVersionSatisfies)(version, item.version))
|
||||
.sort((a, b) => {
|
||||
// Azul provides two versions: jdk_version and azul_version
|
||||
// Azul provides two versions: java_version and distro_version
|
||||
// we should sort by both fields by descending
|
||||
return (-semver_1.default.compareBuild(a.version, b.version) ||
|
||||
-semver_1.default.compareBuild(a.zuluVersion, b.zuluVersion));
|
||||
@@ -81197,37 +81203,60 @@ class ZuluDistribution extends base_installer_1.JavaBase {
|
||||
getAvailableVersions() {
|
||||
var _a, _b;
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const { arch, hw_bitness, abi } = this.getArchitectureOptions();
|
||||
const arch = this.getArchitectureOptions();
|
||||
const [bundleType, features] = this.packageType.split('+');
|
||||
const platform = this.getPlatformOption();
|
||||
const extension = (0, util_1.getDownloadArchiveExtension)();
|
||||
const javafx = (_a = features === null || features === void 0 ? void 0 : features.includes('fx')) !== null && _a !== void 0 ? _a : false;
|
||||
const crac = (_b = features === null || features === void 0 ? void 0 : features.includes('crac')) !== null && _b !== void 0 ? _b : false;
|
||||
const releaseStatus = this.stable ? 'ga' : 'ea';
|
||||
if (core.isDebug()) {
|
||||
console.time('Retrieving available versions for Zulu took'); // eslint-disable-line no-console
|
||||
}
|
||||
const requestArguments = [
|
||||
const baseRequestArguments = [
|
||||
`os=${platform}`,
|
||||
`ext=${extension}`,
|
||||
`bundle_type=${bundleType}`,
|
||||
`javafx=${javafx}`,
|
||||
`archive_type=${extension}`,
|
||||
`java_package_type=${bundleType}`,
|
||||
`javafx_bundled=${javafx}`,
|
||||
`crac_supported=${crac}`,
|
||||
`arch=${arch}`,
|
||||
`hw_bitness=${hw_bitness}`,
|
||||
`release_status=${releaseStatus}`,
|
||||
abi ? `abi=${abi}` : null,
|
||||
features ? `features=${features}` : null
|
||||
]
|
||||
.filter(Boolean)
|
||||
.join('&');
|
||||
const availableVersionsUrl = `https://api.azul.com/zulu/download/community/v1.0/bundles/?${requestArguments}`;
|
||||
core.debug(`Gathering available versions from '${availableVersionsUrl}'`);
|
||||
const availableVersions = (_b = (yield this.http.getJson(availableVersionsUrl))
|
||||
.result) !== null && _b !== void 0 ? _b : [];
|
||||
`availability_types=ca`
|
||||
].join('&');
|
||||
// Need to iterate through all pages to retrieve the list of all versions.
|
||||
// The Azul API doesn't return a total page count, so paginate until a page
|
||||
// comes back empty (or short), guarding against a runaway loop with a cap.
|
||||
const pageSize = 100;
|
||||
const maxPages = 100;
|
||||
let pageIndex = 1;
|
||||
const availableVersions = [];
|
||||
while (pageIndex <= maxPages) {
|
||||
const requestArguments = `${baseRequestArguments}&page=${pageIndex}&page_size=${pageSize}`;
|
||||
const availableVersionsUrl = `https://api.azul.com/metadata/v1/zulu/packages/?${requestArguments}`;
|
||||
if (core.isDebug() && pageIndex === 1) {
|
||||
// the url is identical except for the page number, so print it once for debug
|
||||
core.debug(`Gathering available versions from '${availableVersionsUrl}'`);
|
||||
}
|
||||
const paginationPage = (yield this.http.getJson(availableVersionsUrl)).result;
|
||||
if (!paginationPage || paginationPage.length === 0) {
|
||||
// stop paginating because we have reached the end of the results
|
||||
break;
|
||||
}
|
||||
availableVersions.push(...paginationPage);
|
||||
if (paginationPage.length < pageSize) {
|
||||
// a short page means this was the last one; avoid an extra empty request
|
||||
break;
|
||||
}
|
||||
pageIndex++;
|
||||
}
|
||||
if (pageIndex > maxPages) {
|
||||
core.warning(`Reached the maximum of ${maxPages} pages while listing Zulu versions; results may be truncated.`);
|
||||
}
|
||||
if (core.isDebug()) {
|
||||
core.startGroup('Print information about available versions');
|
||||
console.timeEnd('Retrieving available versions for Zulu took'); // eslint-disable-line no-console
|
||||
core.debug(`Available versions: [${availableVersions.length}]`);
|
||||
core.debug(availableVersions.map(item => item.jdk_version.join('.')).join(', '));
|
||||
core.debug(availableVersions.map(item => item.java_version.join('.')).join(', '));
|
||||
core.endGroup();
|
||||
}
|
||||
return availableVersions;
|
||||
@@ -81237,14 +81266,14 @@ class ZuluDistribution extends base_installer_1.JavaBase {
|
||||
const arch = this.distributionArchitecture();
|
||||
switch (arch) {
|
||||
case 'x64':
|
||||
return { arch: 'x86', hw_bitness: '64', abi: '' };
|
||||
return 'x64';
|
||||
case 'x86':
|
||||
return { arch: 'x86', hw_bitness: '32', abi: '' };
|
||||
return 'x86';
|
||||
case 'aarch64':
|
||||
case 'arm64':
|
||||
return { arch: 'arm', hw_bitness: '64', abi: '' };
|
||||
return 'aarch64';
|
||||
default:
|
||||
return { arch: arch, hw_bitness: '', abi: '' };
|
||||
return arch;
|
||||
}
|
||||
}
|
||||
getPlatformOption() {
|
||||
@@ -81254,6 +81283,10 @@ class ZuluDistribution extends base_installer_1.JavaBase {
|
||||
return 'macos';
|
||||
case 'win32':
|
||||
return 'windows';
|
||||
case 'linux':
|
||||
// The new Metadata API's "linux" value returns both glibc and musl packages;
|
||||
// use "linux_glibc" to target only glibc, which is what standard runners use.
|
||||
return 'linux_glibc';
|
||||
default:
|
||||
return process.platform;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user