mirror of
https://github.com/actions/setup-java.git
synced 2026-08-06 17:12:58 +00:00
Fix SapMachine early-access filtering (#1217)
* Fix SapMachine early-access filtering Ensure SapMachine EA requests exclude stable releases and cover string and boolean release metadata with competing fixture candidates.\n\nCo-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> * Update distribution bundle Regenerate the setup bundle for SapMachine release-class filtering.\n\nCo-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> * Format SapMachine regression tests Apply the repository Prettier format to the focused test additions.\n\nCo-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Bruno Borges <brborges@microsoft.com>
This commit is contained in:
@@ -0,0 +1,73 @@
|
|||||||
|
{
|
||||||
|
"25": {
|
||||||
|
"lts": "false",
|
||||||
|
"updates": {
|
||||||
|
"25.0.2": {
|
||||||
|
"sapmachine-25.0.2": {
|
||||||
|
"release_url": "https://example.test/releases/25.0.2",
|
||||||
|
"ea": false,
|
||||||
|
"assets": {
|
||||||
|
"jdk": {
|
||||||
|
"linux-x64": {
|
||||||
|
"tar.gz": {
|
||||||
|
"name": "sapmachine-jdk-25.0.2_linux-x64_bin.tar.gz",
|
||||||
|
"checksum": "stable-boolean",
|
||||||
|
"url": "https://example.test/sapmachine-25.0.2-ga.tar.gz"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"25.0.1": {
|
||||||
|
"sapmachine-25.0.1": {
|
||||||
|
"release_url": "https://example.test/releases/25.0.1",
|
||||||
|
"ea": "false",
|
||||||
|
"assets": {
|
||||||
|
"jdk": {
|
||||||
|
"linux-x64": {
|
||||||
|
"tar.gz": {
|
||||||
|
"name": "sapmachine-jdk-25.0.1_linux-x64_bin.tar.gz",
|
||||||
|
"checksum": "stable-string",
|
||||||
|
"url": "https://example.test/sapmachine-25.0.1-ga.tar.gz"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"25": {
|
||||||
|
"sapmachine-25+11": {
|
||||||
|
"release_url": "https://example.test/releases/25+11",
|
||||||
|
"ea": true,
|
||||||
|
"assets": {
|
||||||
|
"jdk": {
|
||||||
|
"linux-x64": {
|
||||||
|
"tar.gz": {
|
||||||
|
"name": "sapmachine-jdk-25-ea.11_linux-x64_bin.tar.gz",
|
||||||
|
"checksum": "ea-boolean",
|
||||||
|
"url": "https://example.test/sapmachine-25-ea.11.tar.gz"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"sapmachine-25+10": {
|
||||||
|
"release_url": "https://example.test/releases/25+10",
|
||||||
|
"ea": "true",
|
||||||
|
"assets": {
|
||||||
|
"jdk": {
|
||||||
|
"linux-x64": {
|
||||||
|
"tar.gz": {
|
||||||
|
"name": "sapmachine-jdk-25-ea.10_linux-x64_bin.tar.gz",
|
||||||
|
"checksum": "ea-string",
|
||||||
|
"url": "https://example.test/sapmachine-25-ea.10.tar.gz"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -11,6 +11,7 @@ import {
|
|||||||
import {HttpClient} from '@actions/http-client';
|
import {HttpClient} from '@actions/http-client';
|
||||||
|
|
||||||
import manifestData from '../data/sapmachine.json' with {type: 'json'};
|
import manifestData from '../data/sapmachine.json' with {type: 'json'};
|
||||||
|
import releaseClassManifestData from '../data/sapmachine-release-classes.json' with {type: 'json'};
|
||||||
|
|
||||||
// Mock @actions/core before importing source modules that depend on it
|
// Mock @actions/core before importing source modules that depend on it
|
||||||
jest.unstable_mockModule('@actions/core', () => ({
|
jest.unstable_mockModule('@actions/core', () => ({
|
||||||
@@ -132,9 +133,9 @@ describe('getAvailableVersions', () => {
|
|||||||
['11', 'aarch64', 'linux', 54],
|
['11', 'aarch64', 'linux', 54],
|
||||||
['17', 'riscv', 'linux', 0],
|
['17', 'riscv', 'linux', 0],
|
||||||
['16.0.1', 'x64', 'linux', 71],
|
['16.0.1', 'x64', 'linux', 71],
|
||||||
['23-ea', 'x64', 'linux', 798],
|
['23-ea', 'x64', 'linux', 727],
|
||||||
['23-ea', 'aarch64', 'windows', 0],
|
['23-ea', 'aarch64', 'windows', 0],
|
||||||
['23-ea', 'x64', 'windows', 750]
|
['23-ea', 'x64', 'windows', 679]
|
||||||
])(
|
])(
|
||||||
'should get right number of available versions from JSON',
|
'should get right number of available versions from JSON',
|
||||||
async (
|
async (
|
||||||
@@ -156,6 +157,45 @@ describe('getAvailableVersions', () => {
|
|||||||
expect(availableVersions.length).toBe(len);
|
expect(availableVersions.length).toBe(len);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
it.each([
|
||||||
|
[
|
||||||
|
'25',
|
||||||
|
[
|
||||||
|
'https://example.test/sapmachine-25.0.2-ga.tar.gz',
|
||||||
|
'https://example.test/sapmachine-25.0.1-ga.tar.gz'
|
||||||
|
]
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'25-ea',
|
||||||
|
[
|
||||||
|
'https://example.test/sapmachine-25-ea.11.tar.gz',
|
||||||
|
'https://example.test/sapmachine-25-ea.10.tar.gz'
|
||||||
|
]
|
||||||
|
]
|
||||||
|
])(
|
||||||
|
'should classify boolean and string EA metadata for %s requests',
|
||||||
|
async (version: string, expectedLinks: string[]) => {
|
||||||
|
spyHttpClient.mockReturnValue({
|
||||||
|
statusCode: 200,
|
||||||
|
headers: {},
|
||||||
|
result: releaseClassManifestData
|
||||||
|
});
|
||||||
|
const distribution = new SapMachineDistribution({
|
||||||
|
version,
|
||||||
|
architecture: 'x64',
|
||||||
|
packageType: 'jdk',
|
||||||
|
checkLatest: false
|
||||||
|
});
|
||||||
|
mockPlatform(distribution, 'linux');
|
||||||
|
|
||||||
|
const availableVersions = await distribution['getAvailableVersions']();
|
||||||
|
|
||||||
|
expect(availableVersions.map(item => item.downloadLink)).toStrictEqual(
|
||||||
|
expectedLinks
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('findPackageForDownload', () => {
|
describe('findPackageForDownload', () => {
|
||||||
@@ -314,6 +354,27 @@ describe('getAvailableVersions', () => {
|
|||||||
expect(release.checksum?.value).toBe(archiveChecksum);
|
expect(release.checksum?.value).toBe(archiveChecksum);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('does not select a newer stable release for an EA request', async () => {
|
||||||
|
spyHttpClient.mockReturnValue({
|
||||||
|
statusCode: 200,
|
||||||
|
headers: {},
|
||||||
|
result: releaseClassManifestData
|
||||||
|
});
|
||||||
|
const distribution = new SapMachineDistribution({
|
||||||
|
version: '25-ea',
|
||||||
|
architecture: 'x64',
|
||||||
|
packageType: 'jdk',
|
||||||
|
checkLatest: false
|
||||||
|
});
|
||||||
|
mockPlatform(distribution, 'linux');
|
||||||
|
|
||||||
|
const release = await distribution['findPackageForDownload']('25');
|
||||||
|
|
||||||
|
expect(release.url).toBe(
|
||||||
|
'https://example.test/sapmachine-25-ea.11.tar.gz'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
it.each([
|
it.each([
|
||||||
['8', 'linux', 'x64'],
|
['8', 'linux', 'x64'],
|
||||||
['8', 'macos', 'aarch64'],
|
['8', 'macos', 'aarch64'],
|
||||||
|
|||||||
Vendored
+2
-2
@@ -110,8 +110,8 @@ class SapMachineDistribution extends _base_installer_js__WEBPACK_IMPORTED_MODULE
|
|||||||
_actions_core__WEBPACK_IMPORTED_MODULE_0__/* .debug */ .Yz(`Invalid version: ${buildVersionWithoutPrefix}`);
|
_actions_core__WEBPACK_IMPORTED_MODULE_0__/* .debug */ .Yz(`Invalid version: ${buildVersionWithoutPrefix}`);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// skip earlyAccessVersions if stable version requested
|
const isEarlyAccess = buildVersionMap.ea === true || buildVersionMap.ea === 'true';
|
||||||
if (this.stable && buildVersionMap.ea === 'true') {
|
if (this.stable === isEarlyAccess) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
for (const [edition, editionAssets] of Object.entries(buildVersionMap.assets)) {
|
for (const [edition, editionAssets] of Object.entries(buildVersionMap.assets)) {
|
||||||
|
|||||||
@@ -175,8 +175,9 @@ export class SapMachineDistribution extends JavaBase {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// skip earlyAccessVersions if stable version requested
|
const isEarlyAccess =
|
||||||
if (this.stable && buildVersionMap.ea === 'true') {
|
buildVersionMap.ea === true || buildVersionMap.ea === 'true';
|
||||||
|
if (this.stable === isEarlyAccess) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ export interface ISapMachineAllVersions {
|
|||||||
[full_version: string]: {
|
[full_version: string]: {
|
||||||
[sapmachineBuild: string]: {
|
[sapmachineBuild: string]: {
|
||||||
release_url: string;
|
release_url: string;
|
||||||
ea: string;
|
ea: boolean | string;
|
||||||
assets: {
|
assets: {
|
||||||
[packageType: string]: {
|
[packageType: string]: {
|
||||||
[arch: string]: {
|
[arch: string]: {
|
||||||
|
|||||||
Reference in New Issue
Block a user