mirror of
https://github.com/actions/setup-java.git
synced 2025-08-19 19:21:04 +00:00
Fix tests and licences
This commit is contained in:
parent
bb39e340a4
commit
e987e880f9
18 changed files with 49 additions and 103 deletions
2
.github/workflows/basic-validation.yml
vendored
2
.github/workflows/basic-validation.yml
vendored
|
@ -16,4 +16,4 @@ jobs:
|
|||
name: Basic validation
|
||||
uses: actions/reusable-workflows/.github/workflows/basic-validation.yml@main
|
||||
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/
|
||||
uses: actions/reusable-workflows/.github/workflows/check-dist.yml@main
|
||||
with:
|
||||
node-version: '24.x'
|
||||
node-version: '20.x'
|
||||
|
|
2
.licenses/npm/@types/node.dep.yml
generated
2
.licenses/npm/@types/node.dep.yml
generated
|
@ -1,6 +1,6 @@
|
|||
---
|
||||
name: "@types/node"
|
||||
version: 20.11.24
|
||||
version: 24.1.0
|
||||
type: npm
|
||||
summary: TypeScript definitions for node
|
||||
homepage: https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node
|
||||
|
|
6
.licenses/npm/undici-types.dep.yml
generated
6
.licenses/npm/undici-types.dep.yml
generated
|
@ -1,15 +1,17 @@
|
|||
---
|
||||
name: undici-types
|
||||
version: 5.26.5
|
||||
version: 7.8.0
|
||||
type: npm
|
||||
summary: A stand-alone types package for Undici
|
||||
homepage: https://undici.nodejs.org
|
||||
license: mit
|
||||
licenses:
|
||||
- sources: Auto-generated MIT license text
|
||||
- sources: LICENSE
|
||||
text: |
|
||||
MIT License
|
||||
|
||||
Copyright (c) Matteo Collina and Undici contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
|
|
|
@ -8,10 +8,6 @@ import {JavaInstallerOptions} from '../../src/distributions/base-models';
|
|||
|
||||
import os from 'os';
|
||||
|
||||
function mockArchitecture(arch: string): NodeJS.Architecture {
|
||||
return arch as NodeJS.Architecture;
|
||||
}
|
||||
|
||||
import manifestData from '../data/adopt.json';
|
||||
|
||||
describe('getAvailableVersions', () => {
|
||||
|
@ -195,7 +191,7 @@ describe('getAvailableVersions', () => {
|
|||
])(
|
||||
'defaults to os.arch(): %s mapped to distro arch: %s',
|
||||
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 = {
|
||||
version: '17',
|
||||
|
|
|
@ -14,10 +14,6 @@ import {
|
|||
|
||||
import os from 'os';
|
||||
|
||||
function mockArchitecture(arch: string): NodeJS.Architecture {
|
||||
return arch as NodeJS.Architecture;
|
||||
}
|
||||
|
||||
class EmptyJavaBase extends JavaBase {
|
||||
constructor(installerOptions: JavaInstallerOptions) {
|
||||
super('Empty', installerOptions);
|
||||
|
@ -291,7 +287,7 @@ describe('setupJava', () => {
|
|||
spyCoreSetOutput = jest.spyOn(core, 'setOutput');
|
||||
spyCoreSetOutput.mockImplementation(() => undefined);
|
||||
|
||||
jest.spyOn(os, 'arch').mockReturnValue(mockArchitecture('x86'));
|
||||
jest.spyOn(os, 'arch').mockReturnValue('x86' as ReturnType<typeof os.arch>);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
|
|
|
@ -6,10 +6,6 @@ import * as util from '../../src/util';
|
|||
import os from 'os';
|
||||
import {isGeneratorFunction} from 'util/types';
|
||||
|
||||
function mockArchitecture(arch: string): NodeJS.Architecture {
|
||||
return arch as NodeJS.Architecture;
|
||||
}
|
||||
|
||||
import manifestData from '../data/corretto.json';
|
||||
|
||||
describe('getAvailableVersions', () => {
|
||||
|
@ -207,28 +203,24 @@ describe('getAvailableVersions', () => {
|
|||
});
|
||||
|
||||
it.each([
|
||||
['arm64', 'aarch64'],
|
||||
['amd64', 'x64']
|
||||
['amd64', 'x64'],
|
||||
['arm64', 'aarch64']
|
||||
])(
|
||||
'defaults to os.arch(): %s mapped to distro arch: %s',
|
||||
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 installerOptions: JavaInstallerOptions = {
|
||||
version,
|
||||
const distribution = new CorrettoDistribution({
|
||||
version: '17',
|
||||
architecture: '', // to get default value
|
||||
packageType: 'jdk',
|
||||
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 availableVersion = await distribution['findPackageForDownload'](
|
||||
version
|
||||
'17'
|
||||
);
|
||||
expect(availableVersion).not.toBeNull();
|
||||
expect(availableVersion.url).toBe(expectedLink);
|
||||
|
|
|
@ -1,9 +1,5 @@
|
|||
import {GraalVMDistribution} from '../../src/distributions/graalvm/installer';
|
||||
import os from 'os';
|
||||
|
||||
function mockArchitecture(arch: string): NodeJS.Architecture {
|
||||
return arch as NodeJS.Architecture;
|
||||
}
|
||||
import * as core from '@actions/core';
|
||||
import {getDownloadArchiveExtension} from '../../src/util';
|
||||
import {HttpClient} from '@actions/http-client';
|
||||
|
@ -102,31 +98,32 @@ describe('findPackageForDownload', () => {
|
|||
});
|
||||
|
||||
it.each([
|
||||
['amd64', 'x64'],
|
||||
['arm64', 'aarch64']
|
||||
['amd64', ['x64', 'amd64']],
|
||||
['arm64', ['aarch64', 'arm64']]
|
||||
])(
|
||||
'defaults to os.arch(): %s mapped to distro arch: %s',
|
||||
async (osArch: string, distroArch: string) => {
|
||||
jest.spyOn(os, 'arch').mockReturnValue(mockArchitecture(osArch));
|
||||
jest.spyOn(os, 'platform').mockReturnValue('linux');
|
||||
async (osArch: string, distroArchs: string[]) => {
|
||||
jest.spyOn(os, 'arch').mockReturnValue(osArch as ReturnType<typeof os.arch>);
|
||||
|
||||
const version = '21';
|
||||
const distro = new GraalVMDistribution({
|
||||
version,
|
||||
const distribution = new GraalVMDistribution({
|
||||
version: '21',
|
||||
architecture: '', // to get default value
|
||||
packageType: 'jdk',
|
||||
checkLatest: false
|
||||
});
|
||||
|
||||
const osType = distribution.getPlatform();
|
||||
if (osType === 'windows' && distroArch == 'aarch64') {
|
||||
if (osType === 'windows' && distroArchs.includes('aarch64')) {
|
||||
return; // skip, aarch64 is not available for Windows
|
||||
}
|
||||
const archiveType = getDownloadArchiveExtension();
|
||||
const result = await distro['findPackageForDownload'](version);
|
||||
const expectedUrl = `https://download.oracle.com/graalvm/21/latest/graalvm-jdk-21_${osType}-${distroArch}_bin.${archiveType}`;
|
||||
const result = await distribution['findPackageForDownload']('21');
|
||||
|
||||
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 os from 'os';
|
||||
|
||||
function mockArchitecture(arch: string): NodeJS.Architecture {
|
||||
return arch as NodeJS.Architecture;
|
||||
}
|
||||
|
||||
import manifestData from '../data/liberica.json';
|
||||
|
||||
describe('getAvailableVersions', () => {
|
||||
|
@ -109,9 +105,9 @@ describe('getAvailableVersions', () => {
|
|||
])(
|
||||
'defaults to os.arch(): %s mapped to distro arch: %s',
|
||||
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',
|
||||
architecture: '', // to get default value
|
||||
packageType: 'jdk',
|
||||
|
@ -121,11 +117,11 @@ describe('getAvailableVersions', () => {
|
|||
const additionalParams =
|
||||
'&installation-type=archive&fields=downloadUrl%2Cversion%2CfeatureVersion%2CinterimVersion%2C' +
|
||||
'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}`;
|
||||
|
||||
await distribution['getAvailableVersions']();
|
||||
await distributions['getAvailableVersions']();
|
||||
|
||||
expect(spyHttpClient.mock.calls).toHaveLength(1);
|
||||
expect(spyHttpClient.mock.calls[0][0]).toBe(buildUrl);
|
||||
|
|
|
@ -6,10 +6,6 @@ import {
|
|||
import {HttpClient} from '@actions/http-client';
|
||||
import os from 'os';
|
||||
|
||||
function mockArchitecture(arch: string): NodeJS.Architecture {
|
||||
return arch as NodeJS.Architecture;
|
||||
}
|
||||
|
||||
import manifestData from '../data/liberica-linux.json';
|
||||
|
||||
describe('getAvailableVersions', () => {
|
||||
|
@ -109,7 +105,7 @@ describe('getAvailableVersions', () => {
|
|||
])(
|
||||
'defaults to os.arch(): %s mapped to distro arch: %s',
|
||||
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({
|
||||
version: '17',
|
||||
|
|
|
@ -6,10 +6,6 @@ import {
|
|||
import {HttpClient} from '@actions/http-client';
|
||||
import os from 'os';
|
||||
|
||||
function mockArchitecture(arch: string): NodeJS.Architecture {
|
||||
return arch as NodeJS.Architecture;
|
||||
}
|
||||
|
||||
import manifestData from '../data/liberica-windows.json';
|
||||
|
||||
describe('getAvailableVersions', () => {
|
||||
|
@ -109,7 +105,7 @@ describe('getAvailableVersions', () => {
|
|||
])(
|
||||
'defaults to os.arch(): %s mapped to distro arch: %s',
|
||||
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({
|
||||
version: '17',
|
||||
|
|
|
@ -1,9 +1,5 @@
|
|||
import {MicrosoftDistributions} from '../../src/distributions/microsoft/installer';
|
||||
import os from 'os';
|
||||
|
||||
function mockArchitecture(arch: string): NodeJS.Architecture {
|
||||
return arch as NodeJS.Architecture;
|
||||
}
|
||||
import data from '../data/microsoft.json';
|
||||
import * as httpm from '@actions/http-client';
|
||||
import * as core from '@actions/core';
|
||||
|
@ -99,7 +95,7 @@ describe('findPackageForDownload', () => {
|
|||
])(
|
||||
'defaults to os.arch(): %s mapped to distro arch: %s',
|
||||
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');
|
||||
|
||||
const version = '17';
|
||||
|
@ -123,7 +119,7 @@ describe('findPackageForDownload', () => {
|
|||
])(
|
||||
'defaults to os.arch(): %s mapped to distro arch: %s',
|
||||
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');
|
||||
|
||||
const version = '17';
|
||||
|
@ -147,7 +143,7 @@ describe('findPackageForDownload', () => {
|
|||
])(
|
||||
'defaults to os.arch(): %s mapped to distro arch: %s',
|
||||
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');
|
||||
|
||||
const version = '17';
|
||||
|
|
|
@ -1,9 +1,5 @@
|
|||
import {OracleDistribution} from '../../src/distributions/oracle/installer';
|
||||
import os from 'os';
|
||||
|
||||
function mockArchitecture(arch: string): NodeJS.Architecture {
|
||||
return arch as NodeJS.Architecture;
|
||||
}
|
||||
import * as core from '@actions/core';
|
||||
import {getDownloadArchiveExtension} from '../../src/util';
|
||||
import {HttpClient} from '@actions/http-client';
|
||||
|
@ -99,7 +95,7 @@ describe('findPackageForDownload', () => {
|
|||
])(
|
||||
'defaults to os.arch(): %s mapped to distro arch: %s',
|
||||
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');
|
||||
|
||||
const version = '18';
|
||||
|
|
|
@ -1,9 +1,5 @@
|
|||
import {HttpClient} from '@actions/http-client';
|
||||
import os from 'os';
|
||||
|
||||
function mockArchitecture(arch: string): NodeJS.Architecture {
|
||||
return arch as NodeJS.Architecture;
|
||||
}
|
||||
import {
|
||||
TemurinDistribution,
|
||||
TemurinImplementation
|
||||
|
@ -151,7 +147,7 @@ describe('getAvailableVersions', () => {
|
|||
])(
|
||||
'defaults to os.arch(): %s mapped to distro arch: %s',
|
||||
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 = {
|
||||
version: '17',
|
||||
|
|
|
@ -1,14 +1,9 @@
|
|||
import {HttpClient} from '@actions/http-client';
|
||||
import * as semver from 'semver';
|
||||
import {ZuluDistribution} from '../../src/distributions/zulu/installer';
|
||||
import {IZuluVersions} from '../../src/distributions/zulu/models';
|
||||
import * as utils from '../../src/util';
|
||||
import os from 'os';
|
||||
|
||||
function mockArchitecture(arch: string): NodeJS.Architecture {
|
||||
return arch as NodeJS.Architecture;
|
||||
}
|
||||
|
||||
import manifestData from '../data/zulu-releases-default.json';
|
||||
|
||||
describe('getAvailableVersions', () => {
|
||||
|
@ -130,7 +125,7 @@ describe('getAvailableVersions', () => {
|
|||
])(
|
||||
'defaults to os.arch(): %s mapped to distro arch: %s',
|
||||
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({
|
||||
version: '17',
|
||||
|
|
|
@ -5,10 +5,6 @@ import {IZuluVersions} from '../../src/distributions/zulu/models';
|
|||
import * as utils from '../../src/util';
|
||||
import os from 'os';
|
||||
|
||||
function mockArchitecture(arch: string): NodeJS.Architecture {
|
||||
return arch as NodeJS.Architecture;
|
||||
}
|
||||
|
||||
import manifestData from '../data/zulu-linux.json';
|
||||
|
||||
describe('getAvailableVersions', () => {
|
||||
|
@ -130,7 +126,7 @@ describe('getAvailableVersions', () => {
|
|||
])(
|
||||
'defaults to os.arch(): %s mapped to distro arch: %s',
|
||||
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({
|
||||
version: '17',
|
||||
|
@ -139,7 +135,9 @@ describe('getAvailableVersions', () => {
|
|||
checkLatest: false
|
||||
});
|
||||
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']();
|
||||
|
||||
|
|
|
@ -5,10 +5,6 @@ import {IZuluVersions} from '../../src/distributions/zulu/models';
|
|||
import * as utils from '../../src/util';
|
||||
import os from 'os';
|
||||
|
||||
function mockArchitecture(arch: string): NodeJS.Architecture {
|
||||
return arch as NodeJS.Architecture;
|
||||
}
|
||||
|
||||
import manifestData from '../data/zulu-windows.json';
|
||||
|
||||
describe('getAvailableVersions', () => {
|
||||
|
@ -130,7 +126,7 @@ describe('getAvailableVersions', () => {
|
|||
])(
|
||||
'defaults to os.arch(): %s mapped to distro arch: %s',
|
||||
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({
|
||||
version: '17',
|
||||
|
|
|
@ -6,8 +6,7 @@ import * as io from '@actions/io';
|
|||
import * as toolchains from '../src/toolchains';
|
||||
import {M2_DIR, MVN_TOOLCHAINS_FILE} from '../src/constants';
|
||||
|
||||
const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'setup-java-test-'));
|
||||
const m2Dir = path.join(tempDir, M2_DIR);
|
||||
const m2Dir = path.join(__dirname, M2_DIR);
|
||||
const toolchainsFile = path.join(m2Dir, MVN_TOOLCHAINS_FILE);
|
||||
|
||||
describe('toolchains tests', () => {
|
||||
|
@ -17,7 +16,7 @@ describe('toolchains tests', () => {
|
|||
beforeEach(async () => {
|
||||
await io.rmRF(m2Dir);
|
||||
spyOSHomedir = jest.spyOn(os, 'homedir');
|
||||
spyOSHomedir.mockReturnValue(tempDir);
|
||||
spyOSHomedir.mockReturnValue(__dirname);
|
||||
spyInfo = jest.spyOn(core, 'info');
|
||||
spyInfo.mockImplementation(() => null);
|
||||
}, 300000);
|
||||
|
@ -25,7 +24,6 @@ describe('toolchains tests', () => {
|
|||
afterAll(async () => {
|
||||
try {
|
||||
await io.rmRF(m2Dir);
|
||||
await io.rmRF(tempDir);
|
||||
} catch {
|
||||
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'
|
||||
};
|
||||
|
||||
const altHome = path.join(tempDir, 'runner', 'toolchains');
|
||||
const altHome = path.join(__dirname, 'runner', 'toolchains');
|
||||
const altToolchainsFile = path.join(altHome, MVN_TOOLCHAINS_FILE);
|
||||
await io.rmRF(altHome); // ensure it doesn't already exist
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue