mirror of
https://github.com/actions/setup-java.git
synced 2026-07-01 17:41:38 +00:00
Compare commits
5 Commits
2df4cee1ae
...
f9217513b1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f9217513b1 | ||
|
|
23f68c75ed | ||
|
|
bc5f1f4361 | ||
|
|
78078da0cd | ||
|
|
5caaba646e |
BIN
.licenses/npm/@actions/cache.dep.yml
generated
BIN
.licenses/npm/@actions/cache.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/@actions/http-client-2.2.0.dep.yml
generated
Normal file
BIN
.licenses/npm/@actions/http-client-2.2.0.dep.yml
generated
Normal file
Binary file not shown.
BIN
.licenses/npm/@azure/abort-controller.dep.yml
generated
BIN
.licenses/npm/@azure/abort-controller.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/@fastify/busboy.dep.yml
generated
Normal file
BIN
.licenses/npm/@fastify/busboy.dep.yml
generated
Normal file
Binary file not shown.
Binary file not shown.
BIN
.licenses/npm/psl.dep.yml
generated
BIN
.licenses/npm/psl.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/punycode.dep.yml
generated
BIN
.licenses/npm/punycode.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/semver-6.3.0.dep.yml
generated
BIN
.licenses/npm/semver-6.3.0.dep.yml
generated
Binary file not shown.
Binary file not shown.
BIN
.licenses/npm/tough-cookie.dep.yml
generated
BIN
.licenses/npm/tough-cookie.dep.yml
generated
Binary file not shown.
Binary file not shown.
16
README.md
16
README.md
@ -161,6 +161,22 @@ steps:
|
|||||||
run: sbt package
|
run: sbt package
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### Cache segment restore timeout
|
||||||
|
Usually, cache gets downloaded in multiple segments of fixed sizes. Sometimes, a segment download gets stuck, which causes the workflow job to be stuck. The cache segment download timeout [was introduced](https://github.com/actions/toolkit/tree/main/packages/cache#cache-segment-restore-timeout) to solve this issue as it allows the segment download to get aborted and hence allows the job to proceed with a cache miss. The default value of the cache segment download timeout is set to 10 minutes and can be customized by specifying an environment variable named `SEGMENT_DOWNLOAD_TIMEOUT_MINS` with a timeout value in minutes.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
env:
|
||||||
|
SEGMENT_DOWNLOAD_TIMEOUT_MINS: '5'
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- uses: actions/setup-java@v3
|
||||||
|
with:
|
||||||
|
distribution: 'temurin'
|
||||||
|
java-version: '17'
|
||||||
|
cache: 'gradle'
|
||||||
|
- run: ./gradlew build --no-daemon
|
||||||
|
```
|
||||||
|
|
||||||
### Check latest
|
### Check latest
|
||||||
|
|
||||||
In the basic examples above, the `check-latest` flag defaults to `false`. When set to `false`, the action tries to first resolve a version of Java from the local tool cache on the runner. If unable to find a specific version in the cache, the action will download a version of Java. Use the default or set `check-latest` to `false` if you prefer a faster more consistent setup experience that prioritizes trying to use the cached versions at the expense of newer versions sometimes being available for download.
|
In the basic examples above, the `check-latest` flag defaults to `false`. When set to `false`, the action tries to first resolve a version of Java from the local tool cache on the runner. If unable to find a specific version in the cache, the action will download a version of Java. Use the default or set `check-latest` to `false` if you prefer a faster more consistent setup experience that prioritizes trying to use the cached versions at the expense of newer versions sometimes being available for download.
|
||||||
|
|||||||
@ -1,4 +1,41 @@
|
|||||||
[
|
[
|
||||||
|
{
|
||||||
|
"version": "21.0.0",
|
||||||
|
"stable": true,
|
||||||
|
"release_url": "https://aka.ms/download-jdk",
|
||||||
|
"files": [
|
||||||
|
{
|
||||||
|
"filename": "microsoft-jdk-21.0.0-macos-x64.tar.gz",
|
||||||
|
"arch": "x64",
|
||||||
|
"platform": "darwin",
|
||||||
|
"download_url": "https://aka.ms/download-jdk/microsoft-jdk-21.0.0-macos-x64.tar.gz"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"filename": "microsoft-jdk-21.0.0-linux-x64.tar.gz",
|
||||||
|
"arch": "x64",
|
||||||
|
"platform": "linux",
|
||||||
|
"download_url": "https://aka.ms/download-jdk/microsoft-jdk-21.0.0-linux-x64.tar.gz"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"filename": "microsoft-jdk-21.0.0-windows-x64.zip",
|
||||||
|
"arch": "x64",
|
||||||
|
"platform": "win32",
|
||||||
|
"download_url": "https://aka.ms/download-jdk/microsoft-jdk-21.0.0-windows-x64.zip"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"filename": "microsoft-jdk-21.0.0-macos-aarch64.tar.gz",
|
||||||
|
"arch": "aarch64",
|
||||||
|
"platform": "darwin",
|
||||||
|
"download_url": "https://aka.ms/download-jdk/microsoft-jdk-21.0.0-macos-aarch64.tar.gz"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"filename": "microsoft-jdk-21.0.0-linux-aarch64.tar.gz",
|
||||||
|
"arch": "aarch64",
|
||||||
|
"platform": "linux",
|
||||||
|
"download_url": "https://aka.ms/download-jdk/microsoft-jdk-21.0.0-linux-aarch64.tar.gz"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"version": "17.0.7",
|
"version": "17.0.7",
|
||||||
"stable": true,
|
"stable": true,
|
||||||
|
|||||||
@ -7,6 +7,7 @@ import {JavaInstallerOptions} from '../../src/distributions/base-models';
|
|||||||
|
|
||||||
import os from 'os';
|
import os from 'os';
|
||||||
|
|
||||||
|
import temurinManifestData from '../data/temurin.json';
|
||||||
import manifestData from '../data/adopt.json';
|
import manifestData from '../data/adopt.json';
|
||||||
import {
|
import {
|
||||||
TemurinDistribution,
|
TemurinDistribution,
|
||||||
@ -18,7 +19,17 @@ describe('getAvailableVersions', () => {
|
|||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
spyHttpClient = jest.spyOn(HttpClient.prototype, 'getJson');
|
spyHttpClient = jest.spyOn(HttpClient.prototype, 'getJson');
|
||||||
spyHttpClient.mockReturnValue({
|
spyHttpClient
|
||||||
|
.mockImplementation((requestUrl, additionalHeaders) => {
|
||||||
|
if (requestUrl.startsWith('https://api.adoptium.net/')) {
|
||||||
|
return {
|
||||||
|
statusCode: 200,
|
||||||
|
headers: {},
|
||||||
|
result: []
|
||||||
|
} as any;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.mockReturnValue({
|
||||||
statusCode: 200,
|
statusCode: 200,
|
||||||
headers: {},
|
headers: {},
|
||||||
result: []
|
result: []
|
||||||
@ -135,6 +146,15 @@ describe('getAvailableVersions', () => {
|
|||||||
it('load available versions', async () => {
|
it('load available versions', async () => {
|
||||||
spyHttpClient = jest.spyOn(HttpClient.prototype, 'getJson');
|
spyHttpClient = jest.spyOn(HttpClient.prototype, 'getJson');
|
||||||
spyHttpClient
|
spyHttpClient
|
||||||
|
.mockImplementation((requestUrl, additionalHeaders) => {
|
||||||
|
if (requestUrl.startsWith('https://api.adoptium.net/')) {
|
||||||
|
return {
|
||||||
|
statusCode: 200,
|
||||||
|
headers: {},
|
||||||
|
result: []
|
||||||
|
} as any;
|
||||||
|
}
|
||||||
|
})
|
||||||
.mockReturnValueOnce({
|
.mockReturnValueOnce({
|
||||||
statusCode: 200,
|
statusCode: 200,
|
||||||
headers: {},
|
headers: {},
|
||||||
@ -236,6 +256,17 @@ describe('findPackageForDownload', () => {
|
|||||||
['15.0.1+9', '15.0.1+9'],
|
['15.0.1+9', '15.0.1+9'],
|
||||||
['15.0.1+9.1', '15.0.1+9.1']
|
['15.0.1+9.1', '15.0.1+9.1']
|
||||||
])('version is resolved correctly %s -> %s', async (input, expected) => {
|
])('version is resolved correctly %s -> %s', async (input, expected) => {
|
||||||
|
const temurinDistribution = new TemurinDistribution(
|
||||||
|
{
|
||||||
|
version: '11',
|
||||||
|
architecture: 'x64',
|
||||||
|
packageType: 'jdk',
|
||||||
|
checkLatest: false
|
||||||
|
},
|
||||||
|
TemurinImplementation.Hotspot
|
||||||
|
);
|
||||||
|
temurinDistribution['getAvailableVersions'] = async () => [] as any;
|
||||||
|
|
||||||
const distribution = new AdoptDistribution(
|
const distribution = new AdoptDistribution(
|
||||||
{
|
{
|
||||||
version: '11',
|
version: '11',
|
||||||
@ -243,26 +274,23 @@ describe('findPackageForDownload', () => {
|
|||||||
packageType: 'jdk',
|
packageType: 'jdk',
|
||||||
checkLatest: false
|
checkLatest: false
|
||||||
},
|
},
|
||||||
AdoptImplementation.Hotspot
|
AdoptImplementation.Hotspot,
|
||||||
|
temurinDistribution
|
||||||
);
|
);
|
||||||
distribution['getAvailableVersions'] = async () => manifestData as any;
|
distribution['getAvailableVersions'] = async () => manifestData as any;
|
||||||
|
|
||||||
const resolvedVersion = await distribution['findPackageForDownload'](input);
|
const resolvedVersion = await distribution['findPackageForDownload'](input);
|
||||||
expect(resolvedVersion.version).toBe(expected);
|
expect(resolvedVersion.version).toBe(expected);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('delegates to Temurin', () => {
|
describe('delegates to Temurin', () => {
|
||||||
it.each([
|
it.each([
|
||||||
['9', '9.0.7+10'],
|
['8', '8.0.302+8'],
|
||||||
['15', '15.0.2+7'],
|
['16', '16.0.2+7'],
|
||||||
['15.0', '15.0.2+7'],
|
['16.0', '16.0.2+7'],
|
||||||
['15.0.2', '15.0.2+7'],
|
['16.0.2', '16.0.2+7'],
|
||||||
['15.0.1', '15.0.1+9.1'],
|
['8.x', '8.0.302+8'],
|
||||||
['11.x', '11.0.10+9'],
|
['x', '16.0.2+7']
|
||||||
['x', '15.0.2+7'],
|
|
||||||
['12', '12.0.2+10.3'], // make sure that '12.0.2+10.1', '12.0.2+10.3', '12.0.2+10.2' are sorted correctly
|
|
||||||
['12.0.2+10.1', '12.0.2+10.1'],
|
|
||||||
['15.0.1+9', '15.0.1+9'],
|
|
||||||
['15.0.1+9.1', '15.0.1+9.1']
|
|
||||||
])('version is resolved correctly %s -> %s', async (input, expected) => {
|
])('version is resolved correctly %s -> %s', async (input, expected) => {
|
||||||
const temurinDistribution = new TemurinDistribution(
|
const temurinDistribution = new TemurinDistribution(
|
||||||
{
|
{
|
||||||
@ -273,6 +301,8 @@ describe('findPackageForDownload', () => {
|
|||||||
},
|
},
|
||||||
TemurinImplementation.Hotspot
|
TemurinImplementation.Hotspot
|
||||||
);
|
);
|
||||||
|
temurinDistribution['getAvailableVersions'] = async () =>
|
||||||
|
temurinManifestData as any;
|
||||||
|
|
||||||
const distribution = new AdoptDistribution(
|
const distribution = new AdoptDistribution(
|
||||||
{
|
{
|
||||||
@ -285,11 +315,13 @@ describe('findPackageForDownload', () => {
|
|||||||
temurinDistribution
|
temurinDistribution
|
||||||
);
|
);
|
||||||
|
|
||||||
temurinDistribution['getAvailableVersions'] = async () =>
|
distribution['findPackageForDownload'] = async () => {
|
||||||
manifestData as any;
|
throw new Error(`Could not find satisfied version`);
|
||||||
const resolvedVersion = await distribution['findPackageForDownload'](
|
};
|
||||||
input
|
|
||||||
);
|
const resolvedVersion = await temurinDistribution[
|
||||||
|
'findPackageForDownload'
|
||||||
|
](input);
|
||||||
expect(resolvedVersion.version).toBe(expected);
|
expect(resolvedVersion.version).toBe(expected);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -334,6 +366,16 @@ describe('findPackageForDownload', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('version is found but binaries list is empty', async () => {
|
it('version is found but binaries list is empty', async () => {
|
||||||
|
const temurinDistribution = new TemurinDistribution(
|
||||||
|
{
|
||||||
|
version: '11',
|
||||||
|
architecture: 'x64',
|
||||||
|
packageType: 'jdk',
|
||||||
|
checkLatest: false
|
||||||
|
},
|
||||||
|
TemurinImplementation.Hotspot
|
||||||
|
);
|
||||||
|
temurinDistribution['getAvailableVersions'] = async () => [] as any;
|
||||||
const distribution = new AdoptDistribution(
|
const distribution = new AdoptDistribution(
|
||||||
{
|
{
|
||||||
version: '11',
|
version: '11',
|
||||||
@ -341,13 +383,24 @@ describe('findPackageForDownload', () => {
|
|||||||
packageType: 'jdk',
|
packageType: 'jdk',
|
||||||
checkLatest: false
|
checkLatest: false
|
||||||
},
|
},
|
||||||
AdoptImplementation.Hotspot
|
AdoptImplementation.Hotspot,
|
||||||
|
temurinDistribution
|
||||||
);
|
);
|
||||||
distribution['getAvailableVersions'] = async () => manifestData as any;
|
distribution['getAvailableVersions'] = async () => manifestData as any;
|
||||||
await expect(
|
await expect(
|
||||||
distribution['findPackageForDownload']('9.0.8')
|
distribution['findPackageForDownload']('9.0.8')
|
||||||
).rejects.toThrow(/Could not find satisfied version for SemVer */);
|
).rejects.toThrow(/Could not find satisfied version for SemVer */);
|
||||||
});
|
});
|
||||||
|
const temurinDistribution = new TemurinDistribution(
|
||||||
|
{
|
||||||
|
version: '11',
|
||||||
|
architecture: 'x64',
|
||||||
|
packageType: 'jdk',
|
||||||
|
checkLatest: false
|
||||||
|
},
|
||||||
|
TemurinImplementation.Hotspot
|
||||||
|
);
|
||||||
|
temurinDistribution['getAvailableVersions'] = async () => [] as any;
|
||||||
|
|
||||||
it('version is not found', async () => {
|
it('version is not found', async () => {
|
||||||
const distribution = new AdoptDistribution(
|
const distribution = new AdoptDistribution(
|
||||||
@ -357,7 +410,8 @@ describe('findPackageForDownload', () => {
|
|||||||
packageType: 'jdk',
|
packageType: 'jdk',
|
||||||
checkLatest: false
|
checkLatest: false
|
||||||
},
|
},
|
||||||
AdoptImplementation.Hotspot
|
AdoptImplementation.Hotspot,
|
||||||
|
temurinDistribution
|
||||||
);
|
);
|
||||||
distribution['getAvailableVersions'] = async () => manifestData as any;
|
distribution['getAvailableVersions'] = async () => manifestData as any;
|
||||||
await expect(distribution['findPackageForDownload']('7.x')).rejects.toThrow(
|
await expect(distribution['findPackageForDownload']('7.x')).rejects.toThrow(
|
||||||
@ -366,6 +420,23 @@ describe('findPackageForDownload', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('version list is empty', async () => {
|
it('version list is empty', async () => {
|
||||||
|
let spyHttpClient = jest.spyOn(HttpClient.prototype, 'getJson');
|
||||||
|
|
||||||
|
spyHttpClient.mockImplementation((requestUrl, additionalHeaders) => {
|
||||||
|
if (requestUrl.startsWith('https://api.adoptium.net/')) {
|
||||||
|
return {
|
||||||
|
statusCode: 200,
|
||||||
|
headers: {},
|
||||||
|
result: []
|
||||||
|
} as any;
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
statusCode: 200,
|
||||||
|
headers: {},
|
||||||
|
result: manifestData as any
|
||||||
|
} as any;
|
||||||
|
});
|
||||||
|
|
||||||
const distribution = new AdoptDistribution(
|
const distribution = new AdoptDistribution(
|
||||||
{
|
{
|
||||||
version: '11',
|
version: '11',
|
||||||
|
|||||||
@ -29,6 +29,11 @@ describe('findPackageForDownload', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it.each([
|
it.each([
|
||||||
|
[
|
||||||
|
'21.x',
|
||||||
|
'21.0.0',
|
||||||
|
'https://aka.ms/download-jdk/microsoft-jdk-21.0.0-{{OS_TYPE}}-x64.{{ARCHIVE_TYPE}}'
|
||||||
|
],
|
||||||
[
|
[
|
||||||
'17.0.1',
|
'17.0.1',
|
||||||
'17.0.1+12.1',
|
'17.0.1+12.1',
|
||||||
|
|||||||
4197
dist/cleanup/index.js
vendored
4197
dist/cleanup/index.js
vendored
File diff suppressed because one or more lines are too long
4232
dist/setup/index.js
vendored
4232
dist/setup/index.js
vendored
File diff suppressed because one or more lines are too long
2912
package-lock.json
generated
2912
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -47,8 +47,8 @@
|
|||||||
"eslint-config-prettier": "^8.6.0",
|
"eslint-config-prettier": "^8.6.0",
|
||||||
"eslint-plugin-jest": "^27.2.1",
|
"eslint-plugin-jest": "^27.2.1",
|
||||||
"eslint-plugin-node": "^11.1.0",
|
"eslint-plugin-node": "^11.1.0",
|
||||||
"jest": "^27.2.5",
|
"jest": "^27.5.1",
|
||||||
"jest-circus": "^27.2.5",
|
"jest-circus": "^27.5.1",
|
||||||
"prettier": "^2.8.4",
|
"prettier": "^2.8.4",
|
||||||
"ts-jest": "^27.0.5",
|
"ts-jest": "^27.0.5",
|
||||||
"typescript": "^4.2.3"
|
"typescript": "^4.2.3"
|
||||||
|
|||||||
@ -1,4 +1,41 @@
|
|||||||
[
|
[
|
||||||
|
{
|
||||||
|
"version": "21.0.0",
|
||||||
|
"stable": true,
|
||||||
|
"release_url": "https://aka.ms/download-jdk",
|
||||||
|
"files": [
|
||||||
|
{
|
||||||
|
"filename": "microsoft-jdk-21.0.0-macos-x64.tar.gz",
|
||||||
|
"arch": "x64",
|
||||||
|
"platform": "darwin",
|
||||||
|
"download_url": "https://aka.ms/download-jdk/microsoft-jdk-21.0.0-macos-x64.tar.gz"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"filename": "microsoft-jdk-21.0.0-linux-x64.tar.gz",
|
||||||
|
"arch": "x64",
|
||||||
|
"platform": "linux",
|
||||||
|
"download_url": "https://aka.ms/download-jdk/microsoft-jdk-21.0.0-linux-x64.tar.gz"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"filename": "microsoft-jdk-21.0.0-windows-x64.zip",
|
||||||
|
"arch": "x64",
|
||||||
|
"platform": "win32",
|
||||||
|
"download_url": "https://aka.ms/download-jdk/microsoft-jdk-21.0.0-windows-x64.zip"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"filename": "microsoft-jdk-21.0.0-macos-aarch64.tar.gz",
|
||||||
|
"arch": "aarch64",
|
||||||
|
"platform": "darwin",
|
||||||
|
"download_url": "https://aka.ms/download-jdk/microsoft-jdk-21.0.0-macos-aarch64.tar.gz"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"filename": "microsoft-jdk-21.0.0-linux-aarch64.tar.gz",
|
||||||
|
"arch": "aarch64",
|
||||||
|
"platform": "linux",
|
||||||
|
"download_url": "https://aka.ms/download-jdk/microsoft-jdk-21.0.0-linux-aarch64.tar.gz"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"version": "17.0.7",
|
"version": "17.0.7",
|
||||||
"stable": true,
|
"stable": true,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user