Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 73 additions & 0 deletions __tests__/data/sapmachine-release-classes.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
}
}
}
}
}
}
}
65 changes: 63 additions & 2 deletions __tests__/distributors/sapmachine-installer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => ({
Expand Down Expand Up @@ -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 (
Expand All @@ -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', () => {
Expand Down Expand Up @@ -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'],
Expand Down
4 changes: 2 additions & 2 deletions dist/setup/557.index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
5 changes: 3 additions & 2 deletions src/distributions/sapmachine/installer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion src/distributions/sapmachine/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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]: {
Expand Down
Loading