Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
b2da088
Implement support for custom vendors in setup-java
Mar 8, 2021
cfdcd68
minor improvements
Mar 8, 2021
1d25bcb
minor refactoring
Mar 8, 2021
330fe63
Add unit tests and e2e tests
Mar 8, 2021
ab1f15d
Update documentation for setup-java@v2 release
Mar 8, 2021
c65c532
minor improvements
Mar 8, 2021
9979ab3
regenerate dist
Mar 8, 2021
e6d2942
fix comments
Mar 9, 2021
f02cd99
Merge branch 'implement-v2-installers' into implement-v2-tests
Mar 9, 2021
87febe1
resolve comments
Mar 9, 2021
7006d0b
resolve comments
Mar 9, 2021
54adc86
fix tests
Mar 9, 2021
6738676
Update README.md
maxim-lobanov Mar 9, 2021
50ef02a
Apply suggestions from code review
maxim-lobanov Mar 9, 2021
fb17d02
fix minor nitpicks
Mar 10, 2021
408d6f3
handle 4th digit
Mar 10, 2021
793a1df
Merge branch 'implement-v2-installers' into implement-v2-tests
Mar 10, 2021
e9a0f2c
pull latest main
Mar 10, 2021
caf7917
Merge branch 'implement-v2-installers' into implement-v2-docs
Mar 10, 2021
f6c63d8
Update README.md
Mar 10, 2021
c94ef7c
rename adoptium to adopt
Mar 11, 2021
2ff07ea
Merge branch 'implement-v2-installers' into implement-v2-tests
Mar 11, 2021
491094c
rename adoptium to adopt
Mar 11, 2021
4423435
Merge branch 'implement-v2-installers' into implement-v2-docs
Mar 11, 2021
f761609
rename adoptium to adopt
Mar 11, 2021
03ecfa0
Update README.md
Mar 11, 2021
fde2f0f
make java-version and distribution required for action
Mar 12, 2021
0f6f6e1
Merge pull request #133 from actions/implement-v2-tests
maxim-lobanov Mar 15, 2021
20a04c5
Merge pull request #134 from actions/implement-v2-docs
maxim-lobanov Mar 15, 2021
fc17803
update readme
Mar 15, 2021
f20fd47
fix tests
Mar 15, 2021
f74bcbe
fix e2e tests
Mar 15, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
pull latest main
  • Loading branch information
Maxim Lobanov
Maxim Lobanov committed Mar 10, 2021
commit e9a0f2c6853ca6f4063f4bcae3630de6b0e62053
74 changes: 37 additions & 37 deletions .github/workflows/e2e-versions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ jobs:
id: setup-java
with:
java-version: ${{ matrix.version }}
java-package: 'jdk'
distribution: ${{ matrix.distribution }}
- name: Verify Java
run: bash __tests__/verify-java.sh "${{ matrix.version }}" "${{ steps.setup-java.outputs.path }}"
Expand All @@ -45,17 +44,19 @@ jobs:
os: [macos-latest, windows-latest, ubuntu-latest]
distribution: ['adoptium', 'zulu']
version:
- '8.0.282'
- '11.0'
- '11.0.10'
- '15.0'
exclude:
- os: windows-latest
distribution: 'zulu'
version: '8.0.282'
- os: windows-latest
distribution: 'zulu'
version: '11.0.10'
- '8.0.282'
- '11.0.2+7'
include:
- distribution: 'adoptium'
version: '12.0.2+10.1'
os: macos-latest
- distribution: 'adoptium'
version: '12.0.2+10.1'
os: windows-latest
- distribution: 'adoptium'
version: '12.0.2+10.1'
os: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
Expand All @@ -64,22 +65,39 @@ jobs:
id: setup-java
with:
java-version: ${{ matrix.version }}
java-package: jdk
distribution: ${{ matrix.distribution }}
- name: Verify Java
run: bash __tests__/verify-java.sh "${{ matrix.version }}" "${{ steps.setup-java.outputs.path }}"
shell: bash

setup-java-ea-versions-zulu:
name: zulu ${{ matrix.version }} (jdk-x64) - ${{ matrix.os }}
needs: setup-java-major-minor-versions
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [macos-latest, windows-latest, ubuntu-latest]
version: ['17-ea', '15.0.0-ea.14']
steps:
- name: Checkout
uses: actions/checkout@v2
- name: setup-java
uses: ./
id: setup-java
with:
java-version: ${{ matrix.version }}
distribution: zulu

setup-java-ea-versions:
name: ${{ matrix.distribution }} ${{ matrix.version }} (jdk-x64) - ${{ matrix.os }}
setup-java-ea-versions-adoptium:
name: adoptium ${{ matrix.version }} (jdk-x64) - ${{ matrix.os }}
needs: setup-java-major-minor-versions
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [macos-latest, windows-latest, ubuntu-latest]
distribution: ['adoptium', 'zulu']
version: ['14-ea', '15-ea']
version: ['17-ea', '15.0.0-ea.14.1.202003160455']
steps:
- name: Checkout
uses: actions/checkout@v2
Expand All @@ -88,11 +106,7 @@ jobs:
id: setup-java
with:
java-version: ${{ matrix.version }}
java-package: jdk
distribution: ${{ matrix.distribution }}
- name: Verify Java
run: bash __tests__/verify-java.sh "${{ matrix.version }}" "${{ steps.setup-java.outputs.path }}"
shell: bash
distribution: adoptium

setup-java-custom-package-type:
name: ${{ matrix.distribution }} ${{ matrix.version }} (${{ matrix.java-package }}-x64) - ${{ matrix.os }}
Expand All @@ -105,18 +119,7 @@ jobs:
distribution: ['adoptium', 'zulu']
java-package: ['jre']
version:
- '8.0.282'
- '11.0.10'
- '15.0'
exclude:
- os: windows-latest
distribution: 'zulu'
java-package: 'jre'
version: '8.0.282'
- os: windows-latest
java-package: 'jre'
distribution: 'zulu'
version: '11.0.10'
include:
- distribution: 'zulu'
java-package: jre+fx
Expand Down Expand Up @@ -150,7 +153,7 @@ jobs:
# Only Zulu provides x86 arch for now and only for windows / ubuntu
os: [windows-latest, ubuntu-latest]
distribution: ['zulu']
version: ['8', '11']
version: ['11']
steps:
- name: Checkout
uses: actions/checkout@v2
Expand All @@ -160,7 +163,4 @@ jobs:
with:
distribution: ${{ matrix.distribution }}
java-version: ${{ matrix.version }}
architecture: x86
- name: Verify Java
run: bash __tests__/verify-java.sh "${{ matrix.version }}" "${{ steps.setup-java.outputs.path }}"
shell: bash
architecture: x86
41 changes: 41 additions & 0 deletions __tests__/data/adoptium.json
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,47 @@
"semver": "12.0.2+10.2"
}
},
{
"binaries": [
{
"architecture": "x64",
"download_count": 24493,
"heap_size": "normal",
"image_type": "jdk",
"jvm_impl": "hotspot",
"os": "mac",
"package": {
"checksum": "9919eee037554d40c7d2f219bbd654f2bf119e16a2f4d284d8dedaf525ee59e6",
"checksum_link": "https://github.com/AdoptOpenJDK/openjdk12-binaries/releases/download/jdk-12.0.2%2B10/OpenJDK12U-jdk_x64_mac_hotspot_12.0.2_10.tar.gz.sha256.txt",
"download_count": 22907,
"link": "https://github.com/AdoptOpenJDK/openjdk12-binaries/releases/download/jdk-12.0.2%2B10/OpenJDK12U-jdk_x64_mac_hotspot_12.0.2_10.tar.gz",
"metadata_link": "https://github.com/AdoptOpenJDK/openjdk12-binaries/releases/download/jdk-12.0.2%2B10/OpenJDK12U-jdk_x64_mac_hotspot_12.0.2_10.tar.gz.json",
"name": "OpenJDK12U-jdk_x64_mac_hotspot_12.0.2_10.tar.gz",
"size": 198392994
},
"project": "jdk",
"scm_ref": "jdk-12.0.2+9_adopt",
"updated_at": "2019-07-18T20:27:24Z"
}
],
"download_count": 396318,
"id": "MDc6UmVsZWFzZTE4NzE2Mzk5.S/VUFSgnrVIv8A==",
"release_link": "https://github.com/AdoptOpenJDK/openjdk12-binaries/releases/tag/jdk-12.0.2%2B10",
"release_name": "jdk-12.0.2+9",
"release_type": "ga",
"timestamp": "2019-07-18T20:26:29Z",
"updated_at": "2019-07-18T20:26:29Z",
"vendor": "adoptopenjdk",
"version_data": {
"adopt_build_number": 1,
"build": 10,
"major": 12,
"minor": 0,
"openjdk_version": "12.0.2+9",
"security": 2,
"semver": "12.0.2+9.1"
}
},
{
"binaries": [
{
Expand Down
25 changes: 14 additions & 11 deletions __tests__/distributors/adoptium-installer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,18 @@ describe('findPackageForDownload', () => {
['15.0.1', '15.0.1+9.1'],
['11.x', '11.0.10+9'],
['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', '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) => {
const distribution = new AdoptiumDistribution({
version: '11',
arch: 'x64',
packageType: 'jdk'
});
distribution['getAvailableVersions'] = async () => manifestData;
const resolvedVersion = await distribution['findPackageForDownload'](new semver.Range(input));
const resolvedVersion = await distribution['findPackageForDownload'](input);
expect(resolvedVersion.version).toBe(expected);
});

Expand All @@ -115,9 +118,9 @@ describe('findPackageForDownload', () => {
packageType: 'jdk'
});
distribution['getAvailableVersions'] = async () => manifestData;
await expect(
distribution['findPackageForDownload'](new semver.Range('9.0.8'))
).rejects.toThrowError(/Could not find satisfied version for SemVer */);
await expect(distribution['findPackageForDownload']('9.0.8')).rejects.toThrowError(
/Could not find satisfied version for SemVer */
);
});

it('version is not found', async () => {
Expand All @@ -127,9 +130,9 @@ describe('findPackageForDownload', () => {
packageType: 'jdk'
});
distribution['getAvailableVersions'] = async () => manifestData;
await expect(
distribution['findPackageForDownload'](new semver.Range('7.x'))
).rejects.toThrowError(/Could not find satisfied version for SemVer */);
await expect(distribution['findPackageForDownload']('7.x')).rejects.toThrowError(
/Could not find satisfied version for SemVer */
);
});

it('version list is empty', async () => {
Expand All @@ -139,8 +142,8 @@ describe('findPackageForDownload', () => {
packageType: 'jdk'
});
distribution['getAvailableVersions'] = async () => [];
await expect(
distribution['findPackageForDownload'](new semver.Range('11'))
).rejects.toThrowError(/Could not find satisfied version for SemVer */);
await expect(distribution['findPackageForDownload']('11')).rejects.toThrowError(
/Could not find satisfied version for SemVer */
);
});
});
59 changes: 32 additions & 27 deletions __tests__/distributors/base-installer.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as tc from '@actions/tool-cache';
import * as core from '@actions/core';
import * as util from '../../src/util';

import path from 'path';
import * as semver from 'semver';
Expand All @@ -23,7 +24,7 @@ class EmptyJavaBase extends JavaBase {
};
}

protected async findPackageForDownload(range: semver.Range): Promise<JavaDownloadRelease> {
protected async findPackageForDownload(range: string): Promise<JavaDownloadRelease> {
const availableVersion = '11.0.8';
if (!semver.satisfies(availableVersion, range)) {
throw new Error('Available version not found');
Expand All @@ -41,11 +42,11 @@ describe('findInToolcache', () => {
const javaPath = path.join('Java_Empty_jdk', actualJavaVersion, 'x64');

let mockJavaBase: EmptyJavaBase;
let spyTcFind: jest.SpyInstance;
let spyGetToolcachePath: jest.SpyInstance;
let spyTcFindAllVersions: jest.SpyInstance;

beforeEach(() => {
spyTcFind = jest.spyOn(tc, 'find');
spyGetToolcachePath = jest.spyOn(util, 'getToolcachePath');
spyTcFindAllVersions = jest.spyOn(tc, 'findAllVersions');
});

Expand Down Expand Up @@ -74,15 +75,17 @@ describe('findInToolcache', () => {
[{ version: '11', arch: 'x86', packageType: 'jre' }, null]
])(`should find java for path %s -> %s`, (input, expected) => {
spyTcFindAllVersions.mockReturnValue([actualJavaVersion]);
spyTcFind.mockImplementation((toolname: string, javaVersion: string, architecture: string) => {
const semverVersion = new semver.Range(javaVersion);
spyGetToolcachePath.mockImplementation(
(toolname: string, javaVersion: string, architecture: string) => {
const semverVersion = new semver.Range(javaVersion);

if (path.basename(javaPath) !== architecture || !javaPath.includes(toolname)) {
return '';
}
if (path.basename(javaPath) !== architecture || !javaPath.includes(toolname)) {
return '';
}

return semver.satisfies(actualJavaVersion, semverVersion) ? javaPath : '';
});
return semver.satisfies(actualJavaVersion, semverVersion) ? javaPath : '';
}
);
mockJavaBase = new EmptyJavaBase(input);
expect(mockJavaBase['findInToolcache']()).toEqual(expected);
});
Expand All @@ -108,7 +111,7 @@ describe('findInToolcache', () => {
'11.3.2-ea',
'11.0.1'
]);
spyTcFind.mockImplementation(
spyGetToolcachePath.mockImplementation(
(toolname: string, javaVersion: string, architecture: string) =>
`/hostedtoolcache/${toolname}/${javaVersion}/${architecture}`
);
Expand All @@ -124,7 +127,7 @@ describe('setupJava', () => {

let mockJavaBase: EmptyJavaBase;

let spyTcFind: jest.SpyInstance;
let spyGetToolcachePath: jest.SpyInstance;
let spyTcFindAllVersions: jest.SpyInstance;
let spyCoreDebug: jest.SpyInstance;
let spyCoreInfo: jest.SpyInstance;
Expand All @@ -133,16 +136,18 @@ describe('setupJava', () => {
let spyCoreSetOutput: jest.SpyInstance;

beforeEach(() => {
spyTcFind = jest.spyOn(tc, 'find');
spyTcFind.mockImplementation((toolname: string, javaVersion: string, architecture: string) => {
const semverVersion = new semver.Range(javaVersion);
spyGetToolcachePath = jest.spyOn(util, 'getToolcachePath');
spyGetToolcachePath.mockImplementation(
(toolname: string, javaVersion: string, architecture: string) => {
const semverVersion = new semver.Range(javaVersion);

if (path.basename(javaPath) !== architecture || !javaPath.includes(toolname)) {
return '';
}
if (path.basename(javaPath) !== architecture || !javaPath.includes(toolname)) {
return '';
}

return semver.satisfies(actualJavaVersion, semverVersion) ? javaPath : '';
});
return semver.satisfies(actualJavaVersion, semverVersion) ? javaPath : '';
}
);

spyTcFindAllVersions = jest.spyOn(tc, 'findAllVersions');
spyTcFindAllVersions.mockReturnValue([actualJavaVersion]);
Expand Down Expand Up @@ -186,7 +191,7 @@ describe('setupJava', () => {
])('should find java locally for %s', (input, expected) => {
mockJavaBase = new EmptyJavaBase(input);
expect(mockJavaBase.setupJava()).resolves.toEqual(expected);
expect(spyTcFind).toHaveBeenCalled();
expect(spyGetToolcachePath).toHaveBeenCalled();
});

it.each([
Expand All @@ -205,7 +210,7 @@ describe('setupJava', () => {
])('download java with configuration %s', async (input, expected) => {
mockJavaBase = new EmptyJavaBase(input);
await expect(mockJavaBase.setupJava()).resolves.toEqual(expected);
expect(spyTcFind).toHaveBeenCalled();
expect(spyGetToolcachePath).toHaveBeenCalled();
expect(spyCoreAddPath).toHaveBeenCalled();
expect(spyCoreExportVariable).toHaveBeenCalled();
expect(spyCoreSetOutput).toHaveBeenCalled();
Expand All @@ -228,11 +233,11 @@ describe('normalizeVersion', () => {
const DummyJavaBase = JavaBase as any;

it.each([
['11', { version: new semver.Range('11'), stable: true }],
['11.0', { version: new semver.Range('11.0'), stable: true }],
['11.0.10', { version: new semver.Range('11.0.10'), stable: true }],
['11-ea', { version: new semver.Range('11'), stable: false }],
['11.0.2-ea', { version: new semver.Range('11.0.2'), stable: false }]
['11', { version: '11', stable: true }],
['11.0', { version: '11.0', stable: true }],
['11.0.10', { version: '11.0.10', stable: true }],
['11-ea', { version: '11', stable: false }],
['11.0.2-ea', { version: '11.0.2', stable: false }]
])('normalizeVersion from %s to %s', (input, expected) => {
expect(DummyJavaBase.prototype.normalizeVersion.call(null, input)).toEqual(expected);
});
Expand Down
Loading