mirror of
https://github.com/renovatebot/renovate.git
synced 2026-10-25 06:51:11 +00:00
0d9888a4f2
* feat(datasource): add GraalVM version datasource with support for JDK and JRE releases * feat(datasource): add GraalVM version datasource with support for JDK and JRE releases * feat(datasource): add GraalVM version datasource with support for JDK and JRE releases * feat(datasource): add GraalVM version datasource with support for JDK and JRE releases * feat(datasource): add GraalVM version datasource with support for JDK and JRE releases * add coverage * fix * fix * fix * code cov * code cov * code cov * refactor(datasource): integrate GraalVM into java-version datasource Merges graalvm-version datasource into java-version as a unified multi-vendor Java distribution datasource. Implements vendor-based modular architecture with routing layer for Adoptium (Eclipse Temurin) and Oracle GraalVM. Architecture: - Vendor-specific handlers (adoptium.ts, graalvm.ts) with routing in index.ts - Vendor-aware system detection with different arch/os mappings per vendor - Custom registry support for GraalVM's mise-java API - Adoptium remains the default registry for backwards compatibility Package names: - New explicit: adoptium-jdk, adoptium-jre, oracle-graalvm-jdk, oracle-graalvm-jre - Legacy (map to Adoptium): java, java-jdk, java-jre Changes: - Created adoptium.ts and graalvm.ts vendor handlers - Enhanced common.ts with vendor detection and vendor-specific system mappings - Updated index.ts with routing layer and custom registry support - Merged test suites with comprehensive coverage for both vendors - Updated mise manager integration to use JavaVersionDatasource - Removed graalvm-version datasource directory All 65 datasource tests and 93 mise manager tests passing. * fix * test(datasource): add coverage for non-HttpError paths in java-version * fix(datasource): remove dead code and add coverage for java-version Remove unreachable HttpError handling from _getReleases catch block since both getAdoptiumReleases and getGraalvmReleases handle HttpError internally. Add test for the graalvmRegistryUrl fallback when registryUrl is undefined. * fix(datasource): address review comments for GraalVM datasource - Remove unused 'datasource-graalvm-version' cache namespace - Convert MiseJavaRelease interface to Zod schema and derive type from it - Use http.getJson() with the Zod schema in getGraalvmReleases instead of getJsonUnchecked, letting the schema handle invalid/empty responses - Update getGraalvmReleases test mock to use getJson * docs: remove unused datasource-graalvm-version from cacheTtlOverride docs * fix(datasource): preserve Adoptium config typing * fix(datasource): harden GraalVM release parsing * fix(datasource): address GraalVM review feedback * test: cover GraalVM mise package mapping * test(datasource): cover default GraalVM registry fallback * test(datasource): cover legacy registry resolution * test(datasource): type legacy datasource mocks * fix(datasource): harden GraalVM defaults and responses * refactor(datasource): use function-only registry accessors * test(datasource): cover registry accessor functions * test: restore coverage exclusions * chore: retrigger CI checks
280 lines
8.8 KiB
TypeScript
280 lines
8.8 KiB
TypeScript
import { logger } from '~test/util.ts';
|
|
import { parsePackage } from './common.ts';
|
|
import type { PackageConfig } from './types.ts';
|
|
|
|
describe('modules/datasource/java-version/common', () => {
|
|
const archMock = vi.spyOn(process, 'arch', 'get');
|
|
const osMock = vi.spyOn(process, 'platform', 'get');
|
|
|
|
describe('parsePackage', () => {
|
|
describe('vendor detection', () => {
|
|
it('detects oracle-graalvm vendor', () => {
|
|
const config = parsePackage('oracle-graalvm-jdk');
|
|
expect(config.vendor).toBe('oracle-graalvm');
|
|
});
|
|
|
|
it('detects oracle-graalvm vendor from JRE package', () => {
|
|
const config = parsePackage('oracle-graalvm-jre');
|
|
expect(config.vendor).toBe('oracle-graalvm');
|
|
});
|
|
|
|
it('defaults to adoptium for java', () => {
|
|
const config = parsePackage('java');
|
|
expect(config.vendor).toBe('adoptium');
|
|
});
|
|
|
|
it('defaults to adoptium for java-jdk', () => {
|
|
const config = parsePackage('java-jdk');
|
|
expect(config.vendor).toBe('adoptium');
|
|
});
|
|
|
|
it('defaults to adoptium for java-jre', () => {
|
|
const config = parsePackage('java-jre');
|
|
expect(config.vendor).toBe('adoptium');
|
|
});
|
|
|
|
it('defaults to adoptium for adoptium-jdk', () => {
|
|
const config = parsePackage('adoptium-jdk');
|
|
expect(config.vendor).toBe('adoptium');
|
|
});
|
|
|
|
it('defaults to adoptium for adoptium-jre', () => {
|
|
const config = parsePackage('adoptium-jre');
|
|
expect(config.vendor).toBe('adoptium');
|
|
});
|
|
|
|
it('defaults bare GraalVM packages to Linux x86_64', () => {
|
|
expect(parsePackage('oracle-graalvm-jdk')).toMatchObject({
|
|
vendor: 'oracle-graalvm',
|
|
architecture: 'x86_64',
|
|
os: 'linux',
|
|
});
|
|
});
|
|
});
|
|
|
|
describe('image type detection', () => {
|
|
it('detects jdk image type', () => {
|
|
const config = parsePackage('adoptium-jdk');
|
|
expect(config.imageType).toBe('jdk');
|
|
});
|
|
|
|
it('detects jre image type', () => {
|
|
const config = parsePackage('adoptium-jre');
|
|
expect(config.imageType).toBe('jre');
|
|
});
|
|
|
|
it('detects jre for java-jre', () => {
|
|
const config = parsePackage('java-jre');
|
|
expect(config.imageType).toBe('jre');
|
|
});
|
|
|
|
it('defaults to jdk for java', () => {
|
|
const config = parsePackage('java');
|
|
expect(config.imageType).toBe('jdk');
|
|
});
|
|
|
|
it('detects jdk for oracle-graalvm-jdk', () => {
|
|
const config = parsePackage('oracle-graalvm-jdk');
|
|
expect(config.imageType).toBe('jdk');
|
|
});
|
|
|
|
it('detects jre for oracle-graalvm-jre', () => {
|
|
const config = parsePackage('oracle-graalvm-jre');
|
|
expect(config.imageType).toBe('jre');
|
|
});
|
|
});
|
|
|
|
it('no os and architecture', () => {
|
|
expect(parsePackage('java-jre')).toEqual({
|
|
vendor: 'adoptium',
|
|
imageType: 'jre',
|
|
os: null,
|
|
architecture: null,
|
|
releaseType: undefined,
|
|
});
|
|
expect(logger.logger.warn).not.toBeCalled();
|
|
});
|
|
|
|
describe('uses system jdk', () => {
|
|
const input = 'java?system=true';
|
|
|
|
it.each<[NodeJS.Architecture, NodeJS.Platform, PackageConfig]>([
|
|
[
|
|
'ia32',
|
|
'win32',
|
|
{
|
|
vendor: 'adoptium',
|
|
imageType: 'jdk',
|
|
os: 'windows',
|
|
architecture: 'x86',
|
|
releaseType: undefined,
|
|
},
|
|
],
|
|
[
|
|
'x64',
|
|
'win32',
|
|
{
|
|
vendor: 'adoptium',
|
|
imageType: 'jdk',
|
|
os: 'windows',
|
|
architecture: 'x64',
|
|
releaseType: undefined,
|
|
},
|
|
],
|
|
[
|
|
'arm64',
|
|
'darwin',
|
|
{
|
|
vendor: 'adoptium',
|
|
imageType: 'jdk',
|
|
os: 'mac',
|
|
architecture: 'aarch64',
|
|
releaseType: undefined,
|
|
},
|
|
],
|
|
[
|
|
'arm',
|
|
'aix',
|
|
{
|
|
vendor: 'adoptium',
|
|
imageType: 'jdk',
|
|
os: 'aix',
|
|
architecture: 'arm',
|
|
releaseType: undefined,
|
|
},
|
|
],
|
|
[
|
|
'riscv64',
|
|
'linux',
|
|
{
|
|
vendor: 'adoptium',
|
|
imageType: 'jdk',
|
|
os: 'linux',
|
|
architecture: 'riscv64',
|
|
releaseType: undefined,
|
|
},
|
|
],
|
|
])('system jdk -> (%s, %s, %s) => %o', (arch, os, expected) => {
|
|
archMock.mockReturnValue(arch);
|
|
osMock.mockReturnValue(os);
|
|
expect(parsePackage(input)).toEqual(expected);
|
|
});
|
|
|
|
it('logs for unsupported os and architecture', () => {
|
|
// @ts-expect-error - test unsupported
|
|
archMock.mockReturnValue('unsupported');
|
|
// @ts-expect-error - test unsupported
|
|
osMock.mockReturnValue('unsupported');
|
|
expect(parsePackage(input)).toEqual({
|
|
vendor: 'adoptium',
|
|
imageType: 'jdk',
|
|
os: null,
|
|
architecture: null,
|
|
releaseType: undefined,
|
|
});
|
|
expect(logger.logger.warn).toBeCalledTimes(2);
|
|
});
|
|
});
|
|
|
|
describe('system detection - GraalVM', () => {
|
|
it('maps ia32 to i686 for graalvm', () => {
|
|
archMock.mockReturnValue('ia32');
|
|
osMock.mockReturnValue('linux');
|
|
const config = parsePackage('oracle-graalvm-jdk?system=true');
|
|
expect(config.architecture).toBe('i686');
|
|
expect(config.os).toBe('linux');
|
|
});
|
|
|
|
it('maps arm64 to aarch64 for graalvm', () => {
|
|
archMock.mockReturnValue('arm64');
|
|
osMock.mockReturnValue('linux');
|
|
const config = parsePackage('oracle-graalvm-jdk?system=true');
|
|
expect(config.architecture).toBe('aarch64');
|
|
expect(config.os).toBe('linux');
|
|
});
|
|
|
|
it('maps arm to arm32 for graalvm', () => {
|
|
archMock.mockReturnValue('arm');
|
|
osMock.mockReturnValue('linux');
|
|
const config = parsePackage('oracle-graalvm-jdk?system=true');
|
|
expect(config.architecture).toBe('arm32');
|
|
expect(config.os).toBe('linux');
|
|
});
|
|
|
|
it('maps x64 to x86_64 for graalvm', () => {
|
|
archMock.mockReturnValue('x64');
|
|
osMock.mockReturnValue('linux');
|
|
const config = parsePackage('oracle-graalvm-jdk?system=true');
|
|
expect(config.architecture).toBe('x86_64');
|
|
expect(config.os).toBe('linux');
|
|
});
|
|
|
|
it('maps darwin to macosx for graalvm', () => {
|
|
archMock.mockReturnValue('x64');
|
|
osMock.mockReturnValue('darwin');
|
|
const config = parsePackage('oracle-graalvm-jdk?system=true');
|
|
expect(config.architecture).toBe('x86_64');
|
|
expect(config.os).toBe('macosx');
|
|
});
|
|
|
|
it('maps win32 to windows for graalvm', () => {
|
|
archMock.mockReturnValue('x64');
|
|
osMock.mockReturnValue('win32');
|
|
const config = parsePackage('oracle-graalvm-jdk?system=true');
|
|
expect(config.architecture).toBe('x86_64');
|
|
expect(config.os).toBe('windows');
|
|
});
|
|
|
|
it('returns null for unsupported architecture for graalvm', () => {
|
|
// @ts-expect-error - test unsupported
|
|
archMock.mockReturnValue('unsupported');
|
|
osMock.mockReturnValue('linux');
|
|
const config = parsePackage('oracle-graalvm-jdk?system=true');
|
|
expect(config.architecture).toBeNull();
|
|
});
|
|
|
|
it('returns null for unsupported os for graalvm', () => {
|
|
archMock.mockReturnValue('x64');
|
|
// @ts-expect-error - test unsupported
|
|
osMock.mockReturnValue('unsupported');
|
|
const config = parsePackage('oracle-graalvm-jdk?system=true');
|
|
expect(config.os).toBeNull();
|
|
});
|
|
});
|
|
|
|
describe('query parameters', () => {
|
|
it('parses architecture from query params', () => {
|
|
const config = parsePackage('adoptium-jdk?architecture=x64');
|
|
expect(config.architecture).toBe('x64');
|
|
});
|
|
|
|
it('parses os from query params', () => {
|
|
const config = parsePackage('adoptium-jdk?os=windows');
|
|
expect(config.os).toBe('windows');
|
|
});
|
|
|
|
it('parses release-type from query params', () => {
|
|
const config = parsePackage(
|
|
'oracle-graalvm-jdk?release-type=ea&os=linux&architecture=x86_64',
|
|
);
|
|
expect(config.releaseType).toBe('ea');
|
|
});
|
|
|
|
it('defaults releaseType to undefined when not specified', () => {
|
|
const config = parsePackage('oracle-graalvm-jdk?os=linux');
|
|
expect(config.releaseType).toBeUndefined();
|
|
});
|
|
|
|
it('prefers explicit params over system detection', () => {
|
|
archMock.mockReturnValue('arm64');
|
|
osMock.mockReturnValue('darwin');
|
|
const config = parsePackage(
|
|
'adoptium-jdk?system=true&architecture=x86&os=linux',
|
|
);
|
|
expect(config.architecture).toBe('x86');
|
|
expect(config.os).toBe('linux');
|
|
});
|
|
});
|
|
});
|
|
});
|