diff --git a/__tests__/data/sapmachine-release-classes.json b/__tests__/data/sapmachine-release-classes.json new file mode 100644 index 00000000..79e88f6c --- /dev/null +++ b/__tests__/data/sapmachine-release-classes.json @@ -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" + } + } + } + } + } + } + } + } +} diff --git a/__tests__/distributors/sapmachine-installer.test.ts b/__tests__/distributors/sapmachine-installer.test.ts index e41419bf..6eee0b94 100644 --- a/__tests__/distributors/sapmachine-installer.test.ts +++ b/__tests__/distributors/sapmachine-installer.test.ts @@ -11,6 +11,7 @@ import { import {HttpClient} from '@actions/http-client'; 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 jest.unstable_mockModule('@actions/core', () => ({ @@ -132,9 +133,9 @@ describe('getAvailableVersions', () => { ['11', 'aarch64', 'linux', 54], ['17', 'riscv', 'linux', 0], ['16.0.1', 'x64', 'linux', 71], - ['23-ea', 'x64', 'linux', 798], + ['23-ea', 'x64', 'linux', 727], ['23-ea', 'aarch64', 'windows', 0], - ['23-ea', 'x64', 'windows', 750] + ['23-ea', 'x64', 'windows', 679] ])( 'should get right number of available versions from JSON', async ( @@ -156,6 +157,45 @@ describe('getAvailableVersions', () => { 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', () => { @@ -314,6 +354,27 @@ describe('getAvailableVersions', () => { 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([ ['8', 'linux', 'x64'], ['8', 'macos', 'aarch64'], diff --git a/dist/setup/557.index.js b/dist/setup/557.index.js index e2df254c..541609e0 100644 --- a/dist/setup/557.index.js +++ b/dist/setup/557.index.js @@ -110,8 +110,8 @@ class SapMachineDistribution extends _base_installer_js__WEBPACK_IMPORTED_MODULE _actions_core__WEBPACK_IMPORTED_MODULE_0__/* .debug */ .Yz(`Invalid version: ${buildVersionWithoutPrefix}`); continue; } - // skip earlyAccessVersions if stable version requested - if (this.stable && buildVersionMap.ea === 'true') { + const isEarlyAccess = buildVersionMap.ea === true || buildVersionMap.ea === 'true'; + if (this.stable === isEarlyAccess) { continue; } for (const [edition, editionAssets] of Object.entries(buildVersionMap.assets)) { diff --git a/src/distributions/sapmachine/installer.ts b/src/distributions/sapmachine/installer.ts index 19b24a95..c13e58cb 100644 --- a/src/distributions/sapmachine/installer.ts +++ b/src/distributions/sapmachine/installer.ts @@ -175,8 +175,9 @@ export class SapMachineDistribution extends JavaBase { continue; } - // skip earlyAccessVersions if stable version requested - if (this.stable && buildVersionMap.ea === 'true') { + const isEarlyAccess = + buildVersionMap.ea === true || buildVersionMap.ea === 'true'; + if (this.stable === isEarlyAccess) { continue; } diff --git a/src/distributions/sapmachine/models.ts b/src/distributions/sapmachine/models.ts index 8acb3621..cee20d6e 100644 --- a/src/distributions/sapmachine/models.ts +++ b/src/distributions/sapmachine/models.ts @@ -5,7 +5,7 @@ export interface ISapMachineAllVersions { [full_version: string]: { [sapmachineBuild: string]: { release_url: string; - ea: string; + ea: boolean | string; assets: { [packageType: string]: { [arch: string]: {