mirror of
https://github.com/actions/setup-java.git
synced 2025-08-23 05:23:36 +00:00
Fix tests and licences
This commit is contained in:
parent
bb39e340a4
commit
e987e880f9
2
.github/workflows/basic-validation.yml
vendored
2
.github/workflows/basic-validation.yml
vendored
@ -16,4 +16,4 @@ jobs:
|
|||||||
name: Basic validation
|
name: Basic validation
|
||||||
uses: actions/reusable-workflows/.github/workflows/basic-validation.yml@main
|
uses: actions/reusable-workflows/.github/workflows/basic-validation.yml@main
|
||||||
with:
|
with:
|
||||||
node-version: '24.x'
|
node-version: '20.x'
|
||||||
|
2
.github/workflows/check-dist.yml
vendored
2
.github/workflows/check-dist.yml
vendored
@ -16,4 +16,4 @@ jobs:
|
|||||||
name: Check dist/
|
name: Check dist/
|
||||||
uses: actions/reusable-workflows/.github/workflows/check-dist.yml@main
|
uses: actions/reusable-workflows/.github/workflows/check-dist.yml@main
|
||||||
with:
|
with:
|
||||||
node-version: '24.x'
|
node-version: '20.x'
|
||||||
|
BIN
.licenses/npm/@types/node.dep.yml
generated
BIN
.licenses/npm/@types/node.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/undici-types.dep.yml
generated
BIN
.licenses/npm/undici-types.dep.yml
generated
Binary file not shown.
@ -8,10 +8,6 @@ import {JavaInstallerOptions} from '../../src/distributions/base-models';
|
|||||||
|
|
||||||
import os from 'os';
|
import os from 'os';
|
||||||
|
|
||||||
function mockArchitecture(arch: string): NodeJS.Architecture {
|
|
||||||
return arch as NodeJS.Architecture;
|
|
||||||
}
|
|
||||||
|
|
||||||
import manifestData from '../data/adopt.json';
|
import manifestData from '../data/adopt.json';
|
||||||
|
|
||||||
describe('getAvailableVersions', () => {
|
describe('getAvailableVersions', () => {
|
||||||
@ -195,7 +191,7 @@ describe('getAvailableVersions', () => {
|
|||||||
])(
|
])(
|
||||||
'defaults to os.arch(): %s mapped to distro arch: %s',
|
'defaults to os.arch(): %s mapped to distro arch: %s',
|
||||||
async (osArch: string, distroArch: string) => {
|
async (osArch: string, distroArch: string) => {
|
||||||
jest.spyOn(os, 'arch').mockReturnValue(mockArchitecture(osArch));
|
jest.spyOn(os, 'arch').mockReturnValue(osArch as ReturnType<typeof os.arch>);
|
||||||
|
|
||||||
const installerOptions: JavaInstallerOptions = {
|
const installerOptions: JavaInstallerOptions = {
|
||||||
version: '17',
|
version: '17',
|
||||||
|
@ -14,10 +14,6 @@ import {
|
|||||||
|
|
||||||
import os from 'os';
|
import os from 'os';
|
||||||
|
|
||||||
function mockArchitecture(arch: string): NodeJS.Architecture {
|
|
||||||
return arch as NodeJS.Architecture;
|
|
||||||
}
|
|
||||||
|
|
||||||
class EmptyJavaBase extends JavaBase {
|
class EmptyJavaBase extends JavaBase {
|
||||||
constructor(installerOptions: JavaInstallerOptions) {
|
constructor(installerOptions: JavaInstallerOptions) {
|
||||||
super('Empty', installerOptions);
|
super('Empty', installerOptions);
|
||||||
@ -291,7 +287,7 @@ describe('setupJava', () => {
|
|||||||
spyCoreSetOutput = jest.spyOn(core, 'setOutput');
|
spyCoreSetOutput = jest.spyOn(core, 'setOutput');
|
||||||
spyCoreSetOutput.mockImplementation(() => undefined);
|
spyCoreSetOutput.mockImplementation(() => undefined);
|
||||||
|
|
||||||
jest.spyOn(os, 'arch').mockReturnValue(mockArchitecture('x86'));
|
jest.spyOn(os, 'arch').mockReturnValue('x86' as ReturnType<typeof os.arch>);
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
|
@ -6,10 +6,6 @@ import * as util from '../../src/util';
|
|||||||
import os from 'os';
|
import os from 'os';
|
||||||
import {isGeneratorFunction} from 'util/types';
|
import {isGeneratorFunction} from 'util/types';
|
||||||
|
|
||||||
function mockArchitecture(arch: string): NodeJS.Architecture {
|
|
||||||
return arch as NodeJS.Architecture;
|
|
||||||
}
|
|
||||||
|
|
||||||
import manifestData from '../data/corretto.json';
|
import manifestData from '../data/corretto.json';
|
||||||
|
|
||||||
describe('getAvailableVersions', () => {
|
describe('getAvailableVersions', () => {
|
||||||
@ -207,28 +203,24 @@ describe('getAvailableVersions', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it.each([
|
it.each([
|
||||||
['arm64', 'aarch64'],
|
['amd64', 'x64'],
|
||||||
['amd64', 'x64']
|
['arm64', 'aarch64']
|
||||||
])(
|
])(
|
||||||
'defaults to os.arch(): %s mapped to distro arch: %s',
|
'defaults to os.arch(): %s mapped to distro arch: %s',
|
||||||
async (osArch: string, distroArch: string) => {
|
async (osArch: string, distroArch: string) => {
|
||||||
jest.spyOn(os, 'arch').mockReturnValue(mockArchitecture(osArch));
|
jest.spyOn(os, 'arch').mockReturnValue(osArch as ReturnType<typeof os.arch>);
|
||||||
|
|
||||||
const version = '17';
|
const distribution = new CorrettoDistribution({
|
||||||
const installerOptions: JavaInstallerOptions = {
|
version: '17',
|
||||||
version,
|
|
||||||
architecture: '', // to get default value
|
architecture: '', // to get default value
|
||||||
packageType: 'jdk',
|
packageType: 'jdk',
|
||||||
checkLatest: false
|
checkLatest: false
|
||||||
};
|
});
|
||||||
|
|
||||||
const distribution = new CorrettoDistribution(installerOptions);
|
|
||||||
mockPlatform(distribution, 'macos');
|
|
||||||
|
|
||||||
const expectedLink = `https://corretto.aws/downloads/resources/17.0.2.8.1/amazon-corretto-17.0.2.8.1-macosx-${distroArch}.tar.gz`;
|
const expectedLink = `https://corretto.aws/downloads/resources/17.0.2.8.1/amazon-corretto-17.0.2.8.1-macosx-${distroArch}.tar.gz`;
|
||||||
|
|
||||||
const availableVersion = await distribution['findPackageForDownload'](
|
const availableVersion = await distribution['findPackageForDownload'](
|
||||||
version
|
'17'
|
||||||
);
|
);
|
||||||
expect(availableVersion).not.toBeNull();
|
expect(availableVersion).not.toBeNull();
|
||||||
expect(availableVersion.url).toBe(expectedLink);
|
expect(availableVersion.url).toBe(expectedLink);
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
import {GraalVMDistribution} from '../../src/distributions/graalvm/installer';
|
import {GraalVMDistribution} from '../../src/distributions/graalvm/installer';
|
||||||
import os from 'os';
|
import os from 'os';
|
||||||
|
|
||||||
function mockArchitecture(arch: string): NodeJS.Architecture {
|
|
||||||
return arch as NodeJS.Architecture;
|
|
||||||
}
|
|
||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
import {getDownloadArchiveExtension} from '../../src/util';
|
import {getDownloadArchiveExtension} from '../../src/util';
|
||||||
import {HttpClient} from '@actions/http-client';
|
import {HttpClient} from '@actions/http-client';
|
||||||
@ -102,31 +98,32 @@ describe('findPackageForDownload', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it.each([
|
it.each([
|
||||||
['amd64', 'x64'],
|
['amd64', ['x64', 'amd64']],
|
||||||
['arm64', 'aarch64']
|
['arm64', ['aarch64', 'arm64']]
|
||||||
])(
|
])(
|
||||||
'defaults to os.arch(): %s mapped to distro arch: %s',
|
'defaults to os.arch(): %s mapped to distro arch: %s',
|
||||||
async (osArch: string, distroArch: string) => {
|
async (osArch: string, distroArchs: string[]) => {
|
||||||
jest.spyOn(os, 'arch').mockReturnValue(mockArchitecture(osArch));
|
jest.spyOn(os, 'arch').mockReturnValue(osArch as ReturnType<typeof os.arch>);
|
||||||
jest.spyOn(os, 'platform').mockReturnValue('linux');
|
|
||||||
|
|
||||||
const version = '21';
|
const distribution = new GraalVMDistribution({
|
||||||
const distro = new GraalVMDistribution({
|
version: '21',
|
||||||
version,
|
|
||||||
architecture: '', // to get default value
|
architecture: '', // to get default value
|
||||||
packageType: 'jdk',
|
packageType: 'jdk',
|
||||||
checkLatest: false
|
checkLatest: false
|
||||||
});
|
});
|
||||||
|
|
||||||
const osType = distribution.getPlatform();
|
const osType = distribution.getPlatform();
|
||||||
if (osType === 'windows' && distroArch == 'aarch64') {
|
if (osType === 'windows' && distroArchs.includes('aarch64')) {
|
||||||
return; // skip, aarch64 is not available for Windows
|
return; // skip, aarch64 is not available for Windows
|
||||||
}
|
}
|
||||||
const archiveType = getDownloadArchiveExtension();
|
const archiveType = getDownloadArchiveExtension();
|
||||||
const result = await distro['findPackageForDownload'](version);
|
const result = await distribution['findPackageForDownload']('21');
|
||||||
const expectedUrl = `https://download.oracle.com/graalvm/21/latest/graalvm-jdk-21_${osType}-${distroArch}_bin.${archiveType}`;
|
|
||||||
|
|
||||||
expect(result.url).toBe(expectedUrl);
|
const expectedUrls = distroArchs.map(distroArch =>
|
||||||
|
`https://download.oracle.com/graalvm/21/latest/graalvm-jdk-21_${osType}-${distroArch}_bin.${archiveType}`
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(expectedUrls).toContain(result.url);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -6,10 +6,6 @@ import {
|
|||||||
import {HttpClient} from '@actions/http-client';
|
import {HttpClient} from '@actions/http-client';
|
||||||
import os from 'os';
|
import os from 'os';
|
||||||
|
|
||||||
function mockArchitecture(arch: string): NodeJS.Architecture {
|
|
||||||
return arch as NodeJS.Architecture;
|
|
||||||
}
|
|
||||||
|
|
||||||
import manifestData from '../data/liberica.json';
|
import manifestData from '../data/liberica.json';
|
||||||
|
|
||||||
describe('getAvailableVersions', () => {
|
describe('getAvailableVersions', () => {
|
||||||
@ -109,9 +105,9 @@ describe('getAvailableVersions', () => {
|
|||||||
])(
|
])(
|
||||||
'defaults to os.arch(): %s mapped to distro arch: %s',
|
'defaults to os.arch(): %s mapped to distro arch: %s',
|
||||||
async (osArch: string, distroArch: DistroArch) => {
|
async (osArch: string, distroArch: DistroArch) => {
|
||||||
jest.spyOn(os, 'arch').mockReturnValue(mockArchitecture(osArch));
|
jest.spyOn(os, 'arch').mockReturnValue(osArch as ReturnType<typeof os.arch>);
|
||||||
|
|
||||||
const distribution = new LibericaDistributions({
|
const distributions = new LibericaDistributions({
|
||||||
version: '17',
|
version: '17',
|
||||||
architecture: '', // to get default value
|
architecture: '', // to get default value
|
||||||
packageType: 'jdk',
|
packageType: 'jdk',
|
||||||
@ -121,11 +117,11 @@ describe('getAvailableVersions', () => {
|
|||||||
const additionalParams =
|
const additionalParams =
|
||||||
'&installation-type=archive&fields=downloadUrl%2Cversion%2CfeatureVersion%2CinterimVersion%2C' +
|
'&installation-type=archive&fields=downloadUrl%2Cversion%2CfeatureVersion%2CinterimVersion%2C' +
|
||||||
'updateVersion%2CbuildVersion';
|
'updateVersion%2CbuildVersion';
|
||||||
distribution['getPlatformOption'] = () => 'macos';
|
distributions['getPlatformOption'] = () => 'macos';
|
||||||
|
|
||||||
const buildUrl = `https://api.bell-sw.com/v1/liberica/releases?os=macos&bundle-type=jdk&bitness=${distroArch.bitness}&arch=${distroArch.arch}&build-type=all${additionalParams}`;
|
const buildUrl = `https://api.bell-sw.com/v1/liberica/releases?os=macos&bundle-type=jdk&bitness=${distroArch.bitness}&arch=${distroArch.arch}&build-type=all${additionalParams}`;
|
||||||
|
|
||||||
await distribution['getAvailableVersions']();
|
await distributions['getAvailableVersions']();
|
||||||
|
|
||||||
expect(spyHttpClient.mock.calls).toHaveLength(1);
|
expect(spyHttpClient.mock.calls).toHaveLength(1);
|
||||||
expect(spyHttpClient.mock.calls[0][0]).toBe(buildUrl);
|
expect(spyHttpClient.mock.calls[0][0]).toBe(buildUrl);
|
||||||
|
@ -6,10 +6,6 @@ import {
|
|||||||
import {HttpClient} from '@actions/http-client';
|
import {HttpClient} from '@actions/http-client';
|
||||||
import os from 'os';
|
import os from 'os';
|
||||||
|
|
||||||
function mockArchitecture(arch: string): NodeJS.Architecture {
|
|
||||||
return arch as NodeJS.Architecture;
|
|
||||||
}
|
|
||||||
|
|
||||||
import manifestData from '../data/liberica-linux.json';
|
import manifestData from '../data/liberica-linux.json';
|
||||||
|
|
||||||
describe('getAvailableVersions', () => {
|
describe('getAvailableVersions', () => {
|
||||||
@ -109,7 +105,7 @@ describe('getAvailableVersions', () => {
|
|||||||
])(
|
])(
|
||||||
'defaults to os.arch(): %s mapped to distro arch: %s',
|
'defaults to os.arch(): %s mapped to distro arch: %s',
|
||||||
async (osArch: string, distroArch: DistroArch) => {
|
async (osArch: string, distroArch: DistroArch) => {
|
||||||
jest.spyOn(os, 'arch').mockReturnValue(mockArchitecture(osArch));
|
jest.spyOn(os, 'arch').mockReturnValue(osArch as ReturnType<typeof os.arch>);
|
||||||
|
|
||||||
const distribution = new LibericaDistributions({
|
const distribution = new LibericaDistributions({
|
||||||
version: '17',
|
version: '17',
|
||||||
|
@ -6,10 +6,6 @@ import {
|
|||||||
import {HttpClient} from '@actions/http-client';
|
import {HttpClient} from '@actions/http-client';
|
||||||
import os from 'os';
|
import os from 'os';
|
||||||
|
|
||||||
function mockArchitecture(arch: string): NodeJS.Architecture {
|
|
||||||
return arch as NodeJS.Architecture;
|
|
||||||
}
|
|
||||||
|
|
||||||
import manifestData from '../data/liberica-windows.json';
|
import manifestData from '../data/liberica-windows.json';
|
||||||
|
|
||||||
describe('getAvailableVersions', () => {
|
describe('getAvailableVersions', () => {
|
||||||
@ -109,7 +105,7 @@ describe('getAvailableVersions', () => {
|
|||||||
])(
|
])(
|
||||||
'defaults to os.arch(): %s mapped to distro arch: %s',
|
'defaults to os.arch(): %s mapped to distro arch: %s',
|
||||||
async (osArch: string, distroArch: DistroArch) => {
|
async (osArch: string, distroArch: DistroArch) => {
|
||||||
jest.spyOn(os, 'arch').mockReturnValue(mockArchitecture(osArch));
|
jest.spyOn(os, 'arch').mockReturnValue(osArch as ReturnType<typeof os.arch>);
|
||||||
|
|
||||||
const distribution = new LibericaDistributions({
|
const distribution = new LibericaDistributions({
|
||||||
version: '17',
|
version: '17',
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
import {MicrosoftDistributions} from '../../src/distributions/microsoft/installer';
|
import {MicrosoftDistributions} from '../../src/distributions/microsoft/installer';
|
||||||
import os from 'os';
|
import os from 'os';
|
||||||
|
|
||||||
function mockArchitecture(arch: string): NodeJS.Architecture {
|
|
||||||
return arch as NodeJS.Architecture;
|
|
||||||
}
|
|
||||||
import data from '../data/microsoft.json';
|
import data from '../data/microsoft.json';
|
||||||
import * as httpm from '@actions/http-client';
|
import * as httpm from '@actions/http-client';
|
||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
@ -99,7 +95,7 @@ describe('findPackageForDownload', () => {
|
|||||||
])(
|
])(
|
||||||
'defaults to os.arch(): %s mapped to distro arch: %s',
|
'defaults to os.arch(): %s mapped to distro arch: %s',
|
||||||
async (osArch: string, distroArch: string) => {
|
async (osArch: string, distroArch: string) => {
|
||||||
jest.spyOn(os, 'arch').mockReturnValue(mockArchitecture(osArch));
|
jest.spyOn(os, 'arch').mockReturnValue(osArch as ReturnType<typeof os.arch>);
|
||||||
jest.spyOn(os, 'platform').mockReturnValue('darwin');
|
jest.spyOn(os, 'platform').mockReturnValue('darwin');
|
||||||
|
|
||||||
const version = '17';
|
const version = '17';
|
||||||
@ -123,7 +119,7 @@ describe('findPackageForDownload', () => {
|
|||||||
])(
|
])(
|
||||||
'defaults to os.arch(): %s mapped to distro arch: %s',
|
'defaults to os.arch(): %s mapped to distro arch: %s',
|
||||||
async (osArch: string, distroArch: string) => {
|
async (osArch: string, distroArch: string) => {
|
||||||
jest.spyOn(os, 'arch').mockReturnValue(mockArchitecture(osArch));
|
jest.spyOn(os, 'arch').mockReturnValue(osArch as ReturnType<typeof os.arch>);
|
||||||
jest.spyOn(os, 'platform').mockReturnValue('linux');
|
jest.spyOn(os, 'platform').mockReturnValue('linux');
|
||||||
|
|
||||||
const version = '17';
|
const version = '17';
|
||||||
@ -147,7 +143,7 @@ describe('findPackageForDownload', () => {
|
|||||||
])(
|
])(
|
||||||
'defaults to os.arch(): %s mapped to distro arch: %s',
|
'defaults to os.arch(): %s mapped to distro arch: %s',
|
||||||
async (osArch: string, distroArch: string) => {
|
async (osArch: string, distroArch: string) => {
|
||||||
jest.spyOn(os, 'arch').mockReturnValue(mockArchitecture(osArch));
|
jest.spyOn(os, 'arch').mockReturnValue(osArch as ReturnType<typeof os.arch>);
|
||||||
jest.spyOn(os, 'platform').mockReturnValue('win32');
|
jest.spyOn(os, 'platform').mockReturnValue('win32');
|
||||||
|
|
||||||
const version = '17';
|
const version = '17';
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
import {OracleDistribution} from '../../src/distributions/oracle/installer';
|
import {OracleDistribution} from '../../src/distributions/oracle/installer';
|
||||||
import os from 'os';
|
import os from 'os';
|
||||||
|
|
||||||
function mockArchitecture(arch: string): NodeJS.Architecture {
|
|
||||||
return arch as NodeJS.Architecture;
|
|
||||||
}
|
|
||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
import {getDownloadArchiveExtension} from '../../src/util';
|
import {getDownloadArchiveExtension} from '../../src/util';
|
||||||
import {HttpClient} from '@actions/http-client';
|
import {HttpClient} from '@actions/http-client';
|
||||||
@ -99,7 +95,7 @@ describe('findPackageForDownload', () => {
|
|||||||
])(
|
])(
|
||||||
'defaults to os.arch(): %s mapped to distro arch: %s',
|
'defaults to os.arch(): %s mapped to distro arch: %s',
|
||||||
async (osArch: string, distroArch: string) => {
|
async (osArch: string, distroArch: string) => {
|
||||||
jest.spyOn(os, 'arch').mockReturnValue(mockArchitecture(osArch));
|
jest.spyOn(os, 'arch').mockReturnValue(osArch as ReturnType<typeof os.arch>);
|
||||||
jest.spyOn(os, 'platform').mockReturnValue('linux');
|
jest.spyOn(os, 'platform').mockReturnValue('linux');
|
||||||
|
|
||||||
const version = '18';
|
const version = '18';
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
import {HttpClient} from '@actions/http-client';
|
import {HttpClient} from '@actions/http-client';
|
||||||
import os from 'os';
|
import os from 'os';
|
||||||
|
|
||||||
function mockArchitecture(arch: string): NodeJS.Architecture {
|
|
||||||
return arch as NodeJS.Architecture;
|
|
||||||
}
|
|
||||||
import {
|
import {
|
||||||
TemurinDistribution,
|
TemurinDistribution,
|
||||||
TemurinImplementation
|
TemurinImplementation
|
||||||
@ -151,7 +147,7 @@ describe('getAvailableVersions', () => {
|
|||||||
])(
|
])(
|
||||||
'defaults to os.arch(): %s mapped to distro arch: %s',
|
'defaults to os.arch(): %s mapped to distro arch: %s',
|
||||||
async (osArch: string, distroArch: string) => {
|
async (osArch: string, distroArch: string) => {
|
||||||
jest.spyOn(os, 'arch').mockReturnValue(mockArchitecture(distroArch));
|
jest.spyOn(os, 'arch').mockReturnValue(osArch as ReturnType<typeof os.arch>);
|
||||||
|
|
||||||
const installerOptions: JavaInstallerOptions = {
|
const installerOptions: JavaInstallerOptions = {
|
||||||
version: '17',
|
version: '17',
|
||||||
|
@ -1,14 +1,9 @@
|
|||||||
import {HttpClient} from '@actions/http-client';
|
import {HttpClient} from '@actions/http-client';
|
||||||
import * as semver from 'semver';
|
|
||||||
import {ZuluDistribution} from '../../src/distributions/zulu/installer';
|
import {ZuluDistribution} from '../../src/distributions/zulu/installer';
|
||||||
import {IZuluVersions} from '../../src/distributions/zulu/models';
|
import {IZuluVersions} from '../../src/distributions/zulu/models';
|
||||||
import * as utils from '../../src/util';
|
import * as utils from '../../src/util';
|
||||||
import os from 'os';
|
import os from 'os';
|
||||||
|
|
||||||
function mockArchitecture(arch: string): NodeJS.Architecture {
|
|
||||||
return arch as NodeJS.Architecture;
|
|
||||||
}
|
|
||||||
|
|
||||||
import manifestData from '../data/zulu-releases-default.json';
|
import manifestData from '../data/zulu-releases-default.json';
|
||||||
|
|
||||||
describe('getAvailableVersions', () => {
|
describe('getAvailableVersions', () => {
|
||||||
@ -130,7 +125,7 @@ describe('getAvailableVersions', () => {
|
|||||||
])(
|
])(
|
||||||
'defaults to os.arch(): %s mapped to distro arch: %s',
|
'defaults to os.arch(): %s mapped to distro arch: %s',
|
||||||
async (osArch: string, distroArch: DistroArch) => {
|
async (osArch: string, distroArch: DistroArch) => {
|
||||||
jest.spyOn(os, 'arch').mockReturnValue(mockArchitecture(osArch));
|
jest.spyOn(os, 'arch').mockReturnValue(osArch as ReturnType<typeof os.arch>);
|
||||||
|
|
||||||
const distribution = new ZuluDistribution({
|
const distribution = new ZuluDistribution({
|
||||||
version: '17',
|
version: '17',
|
||||||
|
@ -5,10 +5,6 @@ import {IZuluVersions} from '../../src/distributions/zulu/models';
|
|||||||
import * as utils from '../../src/util';
|
import * as utils from '../../src/util';
|
||||||
import os from 'os';
|
import os from 'os';
|
||||||
|
|
||||||
function mockArchitecture(arch: string): NodeJS.Architecture {
|
|
||||||
return arch as NodeJS.Architecture;
|
|
||||||
}
|
|
||||||
|
|
||||||
import manifestData from '../data/zulu-linux.json';
|
import manifestData from '../data/zulu-linux.json';
|
||||||
|
|
||||||
describe('getAvailableVersions', () => {
|
describe('getAvailableVersions', () => {
|
||||||
@ -130,7 +126,7 @@ describe('getAvailableVersions', () => {
|
|||||||
])(
|
])(
|
||||||
'defaults to os.arch(): %s mapped to distro arch: %s',
|
'defaults to os.arch(): %s mapped to distro arch: %s',
|
||||||
async (osArch: string, distroArch: DistroArch) => {
|
async (osArch: string, distroArch: DistroArch) => {
|
||||||
jest.spyOn(os, 'arch').mockReturnValue(mockArchitecture(osArch));
|
jest.spyOn(os, 'arch').mockReturnValue(osArch as ReturnType<typeof os.arch>);
|
||||||
|
|
||||||
const distribution = new ZuluDistribution({
|
const distribution = new ZuluDistribution({
|
||||||
version: '17',
|
version: '17',
|
||||||
@ -139,7 +135,9 @@ describe('getAvailableVersions', () => {
|
|||||||
checkLatest: false
|
checkLatest: false
|
||||||
});
|
});
|
||||||
distribution['getPlatformOption'] = () => 'linux';
|
distribution['getPlatformOption'] = () => 'linux';
|
||||||
const buildUrl = `https://api.azul.com/zulu/download/community/v1.0/bundles/?os=linux&ext=zip&bundle_type=jdk&javafx=false&arch=${distroArch.arch}&hw_bitness=${distroArch.bitness}&release_status=ga`;
|
// Override extension for linux default arch case to match util behavior
|
||||||
|
spyUtilGetDownloadArchiveExtension.mockReturnValue('tar.gz');
|
||||||
|
const buildUrl = `https://api.azul.com/zulu/download/community/v1.0/bundles/?os=linux&ext=tar.gz&bundle_type=jdk&javafx=false&arch=${distroArch.arch}&hw_bitness=${distroArch.bitness}&release_status=ga`;
|
||||||
|
|
||||||
await distribution['getAvailableVersions']();
|
await distribution['getAvailableVersions']();
|
||||||
|
|
||||||
|
@ -5,10 +5,6 @@ import {IZuluVersions} from '../../src/distributions/zulu/models';
|
|||||||
import * as utils from '../../src/util';
|
import * as utils from '../../src/util';
|
||||||
import os from 'os';
|
import os from 'os';
|
||||||
|
|
||||||
function mockArchitecture(arch: string): NodeJS.Architecture {
|
|
||||||
return arch as NodeJS.Architecture;
|
|
||||||
}
|
|
||||||
|
|
||||||
import manifestData from '../data/zulu-windows.json';
|
import manifestData from '../data/zulu-windows.json';
|
||||||
|
|
||||||
describe('getAvailableVersions', () => {
|
describe('getAvailableVersions', () => {
|
||||||
@ -130,7 +126,7 @@ describe('getAvailableVersions', () => {
|
|||||||
])(
|
])(
|
||||||
'defaults to os.arch(): %s mapped to distro arch: %s',
|
'defaults to os.arch(): %s mapped to distro arch: %s',
|
||||||
async (osArch: string, distroArch: DistroArch) => {
|
async (osArch: string, distroArch: DistroArch) => {
|
||||||
jest.spyOn(os, 'arch').mockReturnValue(mockArchitecture(osArch));
|
jest.spyOn(os, 'arch').mockReturnValue(osArch as ReturnType<typeof os.arch>);
|
||||||
|
|
||||||
const distribution = new ZuluDistribution({
|
const distribution = new ZuluDistribution({
|
||||||
version: '17',
|
version: '17',
|
||||||
|
@ -6,8 +6,7 @@ import * as io from '@actions/io';
|
|||||||
import * as toolchains from '../src/toolchains';
|
import * as toolchains from '../src/toolchains';
|
||||||
import {M2_DIR, MVN_TOOLCHAINS_FILE} from '../src/constants';
|
import {M2_DIR, MVN_TOOLCHAINS_FILE} from '../src/constants';
|
||||||
|
|
||||||
const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'setup-java-test-'));
|
const m2Dir = path.join(__dirname, M2_DIR);
|
||||||
const m2Dir = path.join(tempDir, M2_DIR);
|
|
||||||
const toolchainsFile = path.join(m2Dir, MVN_TOOLCHAINS_FILE);
|
const toolchainsFile = path.join(m2Dir, MVN_TOOLCHAINS_FILE);
|
||||||
|
|
||||||
describe('toolchains tests', () => {
|
describe('toolchains tests', () => {
|
||||||
@ -17,7 +16,7 @@ describe('toolchains tests', () => {
|
|||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
await io.rmRF(m2Dir);
|
await io.rmRF(m2Dir);
|
||||||
spyOSHomedir = jest.spyOn(os, 'homedir');
|
spyOSHomedir = jest.spyOn(os, 'homedir');
|
||||||
spyOSHomedir.mockReturnValue(tempDir);
|
spyOSHomedir.mockReturnValue(__dirname);
|
||||||
spyInfo = jest.spyOn(core, 'info');
|
spyInfo = jest.spyOn(core, 'info');
|
||||||
spyInfo.mockImplementation(() => null);
|
spyInfo.mockImplementation(() => null);
|
||||||
}, 300000);
|
}, 300000);
|
||||||
@ -25,7 +24,6 @@ describe('toolchains tests', () => {
|
|||||||
afterAll(async () => {
|
afterAll(async () => {
|
||||||
try {
|
try {
|
||||||
await io.rmRF(m2Dir);
|
await io.rmRF(m2Dir);
|
||||||
await io.rmRF(tempDir);
|
|
||||||
} catch {
|
} catch {
|
||||||
console.log('Failed to remove test directories');
|
console.log('Failed to remove test directories');
|
||||||
}
|
}
|
||||||
@ -42,7 +40,7 @@ describe('toolchains tests', () => {
|
|||||||
jdkHome: '/opt/hostedtoolcache/Java_Temurin-Hotspot_jdk/17.0.1-12/x64'
|
jdkHome: '/opt/hostedtoolcache/Java_Temurin-Hotspot_jdk/17.0.1-12/x64'
|
||||||
};
|
};
|
||||||
|
|
||||||
const altHome = path.join(tempDir, 'runner', 'toolchains');
|
const altHome = path.join(__dirname, 'runner', 'toolchains');
|
||||||
const altToolchainsFile = path.join(altHome, MVN_TOOLCHAINS_FILE);
|
const altToolchainsFile = path.join(altHome, MVN_TOOLCHAINS_FILE);
|
||||||
await io.rmRF(altHome); // ensure it doesn't already exist
|
await io.rmRF(altHome); // ensure it doesn't already exist
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user