diff --git a/.github/workflows/basic-validation.yml b/.github/workflows/basic-validation.yml index 37fa323e6..e93e58009 100644 --- a/.github/workflows/basic-validation.yml +++ b/.github/workflows/basic-validation.yml @@ -16,4 +16,4 @@ jobs: name: Basic validation uses: actions/reusable-workflows/.github/workflows/basic-validation.yml@main with: - node-version: '20.x' + node-version: '24.x' diff --git a/.github/workflows/check-dist.yml b/.github/workflows/check-dist.yml index 509ea6cc7..90ef986ad 100644 --- a/.github/workflows/check-dist.yml +++ b/.github/workflows/check-dist.yml @@ -16,4 +16,4 @@ jobs: name: Check dist/ uses: actions/reusable-workflows/.github/workflows/check-dist.yml@main with: - node-version: '20.x' + node-version: '24.x' diff --git a/.licenses/npm/@types/node.dep.yml b/.licenses/npm/@types/node.dep.yml index 06fb919df..86544f488 100644 --- a/.licenses/npm/@types/node.dep.yml +++ b/.licenses/npm/@types/node.dep.yml @@ -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 diff --git a/.licenses/npm/undici-types.dep.yml b/.licenses/npm/undici-types.dep.yml index a65b8affc..370219bfa 100644 --- a/.licenses/npm/undici-types.dep.yml +++ b/.licenses/npm/undici-types.dep.yml @@ -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 diff --git a/__tests__/distributors/adopt-installer.test.ts b/__tests__/distributors/adopt-installer.test.ts index 8a112243f..0b35c3d3e 100644 --- a/__tests__/distributors/adopt-installer.test.ts +++ b/__tests__/distributors/adopt-installer.test.ts @@ -191,7 +191,9 @@ describe('getAvailableVersions', () => { ])( 'defaults to os.arch(): %s mapped to distro arch: %s', async (osArch: string, distroArch: string) => { - jest.spyOn(os, 'arch').mockReturnValue(osArch); + jest + .spyOn(os, 'arch') + .mockReturnValue(osArch as ReturnType); const installerOptions: JavaInstallerOptions = { version: '17', diff --git a/__tests__/distributors/base-installer.test.ts b/__tests__/distributors/base-installer.test.ts index b2c610260..08a95828c 100644 --- a/__tests__/distributors/base-installer.test.ts +++ b/__tests__/distributors/base-installer.test.ts @@ -287,7 +287,7 @@ describe('setupJava', () => { spyCoreSetOutput = jest.spyOn(core, 'setOutput'); spyCoreSetOutput.mockImplementation(() => undefined); - jest.spyOn(os, 'arch').mockReturnValue('x86'); + jest.spyOn(os, 'arch').mockReturnValue('x86' as ReturnType); }); afterEach(() => { diff --git a/__tests__/distributors/corretto-installer.test.ts b/__tests__/distributors/corretto-installer.test.ts index a8ffef229..524a78117 100644 --- a/__tests__/distributors/corretto-installer.test.ts +++ b/__tests__/distributors/corretto-installer.test.ts @@ -203,28 +203,26 @@ 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(osArch); + jest + .spyOn(os, 'arch') + .mockReturnValue(osArch as ReturnType); - 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); diff --git a/__tests__/distributors/graalvm-installer.test.ts b/__tests__/distributors/graalvm-installer.test.ts index ae2db43cb..479f34526 100644 --- a/__tests__/distributors/graalvm-installer.test.ts +++ b/__tests__/distributors/graalvm-installer.test.ts @@ -98,31 +98,35 @@ 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(osArch); - jest.spyOn(os, 'platform').mockReturnValue('linux'); + async (osArch: string, distroArchs: string[]) => { + jest + .spyOn(os, 'arch') + .mockReturnValue(osArch as ReturnType); - 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); } ); diff --git a/__tests__/distributors/liberica-installer.test.ts b/__tests__/distributors/liberica-installer.test.ts index 33a51017d..5e664d5f3 100644 --- a/__tests__/distributors/liberica-installer.test.ts +++ b/__tests__/distributors/liberica-installer.test.ts @@ -105,9 +105,11 @@ describe('getAvailableVersions', () => { ])( 'defaults to os.arch(): %s mapped to distro arch: %s', async (osArch: string, distroArch: DistroArch) => { - jest.spyOn(os, 'arch').mockReturnValue(osArch); + jest + .spyOn(os, 'arch') + .mockReturnValue(osArch as ReturnType); - const distribution = new LibericaDistributions({ + const distributions = new LibericaDistributions({ version: '17', architecture: '', // to get default value packageType: 'jdk', @@ -117,11 +119,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); diff --git a/__tests__/distributors/liberica-linux-installer.test.ts b/__tests__/distributors/liberica-linux-installer.test.ts index 8e6a665e0..58c4e4781 100644 --- a/__tests__/distributors/liberica-linux-installer.test.ts +++ b/__tests__/distributors/liberica-linux-installer.test.ts @@ -105,7 +105,9 @@ describe('getAvailableVersions', () => { ])( 'defaults to os.arch(): %s mapped to distro arch: %s', async (osArch: string, distroArch: DistroArch) => { - jest.spyOn(os, 'arch').mockReturnValue(osArch); + jest + .spyOn(os, 'arch') + .mockReturnValue(osArch as ReturnType); const distribution = new LibericaDistributions({ version: '17', diff --git a/__tests__/distributors/liberica-windows-installer.test.ts b/__tests__/distributors/liberica-windows-installer.test.ts index 1ccc57ede..22d287410 100644 --- a/__tests__/distributors/liberica-windows-installer.test.ts +++ b/__tests__/distributors/liberica-windows-installer.test.ts @@ -105,7 +105,9 @@ describe('getAvailableVersions', () => { ])( 'defaults to os.arch(): %s mapped to distro arch: %s', async (osArch: string, distroArch: DistroArch) => { - jest.spyOn(os, 'arch').mockReturnValue(osArch); + jest + .spyOn(os, 'arch') + .mockReturnValue(osArch as ReturnType); const distribution = new LibericaDistributions({ version: '17', diff --git a/__tests__/distributors/microsoft-installer.test.ts b/__tests__/distributors/microsoft-installer.test.ts index 00c4b6c6e..3e22b9021 100644 --- a/__tests__/distributors/microsoft-installer.test.ts +++ b/__tests__/distributors/microsoft-installer.test.ts @@ -95,7 +95,9 @@ describe('findPackageForDownload', () => { ])( 'defaults to os.arch(): %s mapped to distro arch: %s', async (osArch: string, distroArch: string) => { - jest.spyOn(os, 'arch').mockReturnValue(osArch); + jest + .spyOn(os, 'arch') + .mockReturnValue(osArch as ReturnType); jest.spyOn(os, 'platform').mockReturnValue('darwin'); const version = '17'; @@ -119,7 +121,9 @@ describe('findPackageForDownload', () => { ])( 'defaults to os.arch(): %s mapped to distro arch: %s', async (osArch: string, distroArch: string) => { - jest.spyOn(os, 'arch').mockReturnValue(osArch); + jest + .spyOn(os, 'arch') + .mockReturnValue(osArch as ReturnType); jest.spyOn(os, 'platform').mockReturnValue('linux'); const version = '17'; @@ -143,7 +147,9 @@ describe('findPackageForDownload', () => { ])( 'defaults to os.arch(): %s mapped to distro arch: %s', async (osArch: string, distroArch: string) => { - jest.spyOn(os, 'arch').mockReturnValue(osArch); + jest + .spyOn(os, 'arch') + .mockReturnValue(osArch as ReturnType); jest.spyOn(os, 'platform').mockReturnValue('win32'); const version = '17'; diff --git a/__tests__/distributors/oracle-installer.test.ts b/__tests__/distributors/oracle-installer.test.ts index de391a542..226eca905 100644 --- a/__tests__/distributors/oracle-installer.test.ts +++ b/__tests__/distributors/oracle-installer.test.ts @@ -95,7 +95,9 @@ describe('findPackageForDownload', () => { ])( 'defaults to os.arch(): %s mapped to distro arch: %s', async (osArch: string, distroArch: string) => { - jest.spyOn(os, 'arch').mockReturnValue(osArch); + jest + .spyOn(os, 'arch') + .mockReturnValue(osArch as ReturnType); jest.spyOn(os, 'platform').mockReturnValue('linux'); const version = '18'; diff --git a/__tests__/distributors/temurin-installer.test.ts b/__tests__/distributors/temurin-installer.test.ts index b8c9e7fde..f540901eb 100644 --- a/__tests__/distributors/temurin-installer.test.ts +++ b/__tests__/distributors/temurin-installer.test.ts @@ -147,7 +147,9 @@ describe('getAvailableVersions', () => { ])( 'defaults to os.arch(): %s mapped to distro arch: %s', async (osArch: string, distroArch: string) => { - jest.spyOn(os, 'arch').mockReturnValue(distroArch); + jest + .spyOn(os, 'arch') + .mockReturnValue(osArch as ReturnType); const installerOptions: JavaInstallerOptions = { version: '17', diff --git a/__tests__/distributors/zulu-installer.test.ts b/__tests__/distributors/zulu-installer.test.ts index f8b8a72cb..100429b30 100644 --- a/__tests__/distributors/zulu-installer.test.ts +++ b/__tests__/distributors/zulu-installer.test.ts @@ -1,5 +1,4 @@ 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'; @@ -126,7 +125,9 @@ describe('getAvailableVersions', () => { ])( 'defaults to os.arch(): %s mapped to distro arch: %s', async (osArch: string, distroArch: DistroArch) => { - jest.spyOn(os, 'arch').mockReturnValue(osArch); + jest + .spyOn(os, 'arch') + .mockReturnValue(osArch as ReturnType); const distribution = new ZuluDistribution({ version: '17', diff --git a/__tests__/distributors/zulu-linux-installer.test.ts b/__tests__/distributors/zulu-linux-installer.test.ts index 60f36ee59..a25344cbd 100644 --- a/__tests__/distributors/zulu-linux-installer.test.ts +++ b/__tests__/distributors/zulu-linux-installer.test.ts @@ -126,7 +126,9 @@ describe('getAvailableVersions', () => { ])( 'defaults to os.arch(): %s mapped to distro arch: %s', async (osArch: string, distroArch: DistroArch) => { - jest.spyOn(os, 'arch').mockReturnValue(osArch); + jest + .spyOn(os, 'arch') + .mockReturnValue(osArch as ReturnType); const distribution = new ZuluDistribution({ version: '17', @@ -135,7 +137,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'](); diff --git a/__tests__/distributors/zulu-windows-installer.test.ts b/__tests__/distributors/zulu-windows-installer.test.ts index dcac5aa0d..a3511ac90 100644 --- a/__tests__/distributors/zulu-windows-installer.test.ts +++ b/__tests__/distributors/zulu-windows-installer.test.ts @@ -126,7 +126,9 @@ describe('getAvailableVersions', () => { ])( 'defaults to os.arch(): %s mapped to distro arch: %s', async (osArch: string, distroArch: DistroArch) => { - jest.spyOn(os, 'arch').mockReturnValue(osArch); + jest + .spyOn(os, 'arch') + .mockReturnValue(osArch as ReturnType); const distribution = new ZuluDistribution({ version: '17', diff --git a/action.yml b/action.yml index 0969d5d42..21a4269d7 100644 --- a/action.yml +++ b/action.yml @@ -81,6 +81,6 @@ outputs: cache-hit: description: 'A boolean value to indicate an exact match was found for the primary key' runs: - using: 'node20' + using: 'node24' main: 'dist/setup/index.js' post: 'dist/cleanup/index.js' diff --git a/package-lock.json b/package-lock.json index ef4f83d23..89bde9fed 100644 --- a/package-lock.json +++ b/package-lock.json @@ -21,7 +21,7 @@ }, "devDependencies": { "@types/jest": "^29.5.14", - "@types/node": "^20.11.24", + "@types/node": "^24.1.0", "@types/semver": "^7.5.8", "@typescript-eslint/eslint-plugin": "^8.35.1", "@typescript-eslint/parser": "^8.35.1", @@ -35,6 +35,9 @@ "prettier": "^2.8.4", "ts-jest": "^29.3.0", "typescript": "^5.3.3" + }, + "engines": { + "node": ">=24.0.0" } }, "node_modules/@aashutoshrathi/word-wrap": { @@ -1644,11 +1647,12 @@ } }, "node_modules/@types/node": { - "version": "20.11.24", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.11.24.tgz", - "integrity": "sha512-Kza43ewS3xoLgCEpQrsT+xRo/EJej1y0kVYGiLFE1NEODXGzTfwiC6tXTLMQskn1X4/Rjlh0MQUvx9W+L9long==", + "version": "24.1.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-24.1.0.tgz", + "integrity": "sha512-ut5FthK5moxFKH2T1CUOC6ctR67rQRvvHdFLCD2Ql6KXmMuCrjsSsRI9UsLCm9M18BMwClv4pn327UvB7eeO1w==", + "license": "MIT", "dependencies": { - "undici-types": "~5.26.4" + "undici-types": "~7.8.0" } }, "node_modules/@types/node-fetch": { @@ -5510,9 +5514,10 @@ } }, "node_modules/undici-types": { - "version": "5.26.5", - "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", - "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==" + "version": "7.8.0", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.8.0.tgz", + "integrity": "sha512-9UJ2xGDvQ43tYyVMpuHlsgApydB8ZKfVYTsLDhXkFL/6gfkp+U8xTGdh8pMJv1SpZna0zxG1DwsKZsreLbXBxw==", + "license": "MIT" }, "node_modules/update-browserslist-db": { "version": "1.0.13", diff --git a/package.json b/package.json index 400a585cb..aafcde95d 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,9 @@ "private": true, "description": "setup java action", "main": "dist/setup/index.js", + "engines": { + "node": ">=24.0.0" + }, "scripts": { "build": "ncc build -o dist/setup src/setup-java.ts && ncc build -o dist/cleanup src/cleanup-java.ts", "format": "prettier --no-error-on-unmatched-pattern --config ./.prettierrc.js --write \"**/*.{ts,yml,yaml}\"", @@ -38,7 +41,7 @@ }, "devDependencies": { "@types/jest": "^29.5.14", - "@types/node": "^20.11.24", + "@types/node": "^24.1.0", "@types/semver": "^7.5.8", "@typescript-eslint/eslint-plugin": "^8.35.1", "@typescript-eslint/parser": "^8.35.1",