Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for adoptopenjdk binaries #67

Closed
wants to merge 14 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
68 changes: 62 additions & 6 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ jobs:
runs-on: ${{ matrix.operating-system }}
strategy:
matrix:
operating-system: [ubuntu-latest, windows-latest]
operating-system: [ubuntu-latest, windows-latest, macOS-latest]
steps:
- name: Checkout
uses: actions/checkout@v2
Expand All @@ -20,7 +20,34 @@ jobs:
- name: npm test
run: npm test

test:
testAdoptOpenJDK:
runs-on: ${{ matrix.operating-system }}
strategy:
matrix:
operating-system: [ubuntu-latest, windows-latest]
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Clear tool cache
if: runner.os != 'windows'
run: mv "${{ runner.tool_cache }}" "${{ runner.tool_cache }}.old"
- name: Clear tool cache (Windows)
if: runner.os == 'windows'
run: move "${{ runner.tool_cache }}" "${{ runner.tool_cache }}.old"
- name: Setup Java 13
id: setup-java-adopt
uses: ./
with:
java-version: 13.0.2
distro: adoptopenjdk
- name: Verify Java 13
if: runner.os != 'windows'
run: __tests__/verify-java.sh 13.0.2 "${{ steps.setup-java-adopt.outputs.path }}" "${{ steps.setup-java-adopt.outputs.version }}"
- name: Verify Java 13 (Windows)
if: runner.os == 'windows'
run: __tests__/verify-java.ps1 13.0.2 "${{ steps.setup-java-adopt.outputs.path }}" "${{ steps.setup-java-adopt.outputs.version }}"

testZulu:
runs-on: ${{ matrix.operating-system }}
strategy:
matrix:
Expand All @@ -35,18 +62,45 @@ jobs:
if: runner.os == 'windows'
run: move "${{ runner.tool_cache }}" "${{ runner.tool_cache }}.old"
- name: Setup Java 13
id: setup-java
id: setup-java-zulu
uses: ./
with:
java-version: 13.0.2
distro: zulu
- name: Verify Java 13
if: runner.os != 'windows'
run: __tests__/verify-java.sh 13.0.2 "${{ steps.setup-java.outputs.path }}" "${{ steps.setup-java.outputs.version }}"
run: __tests__/verify-java.sh 13.0.2 "${{ steps.setup-java-zulu.outputs.path }}" "${{ steps.setup-java-zulu.outputs.version }}"
- name: Verify Java 13 (Windows)
if: runner.os == 'windows'
run: __tests__/verify-java.ps1 13.0.2 "${{ steps.setup-java.outputs.path }}" "${{ steps.setup-java.outputs.version }}"
run: __tests__/verify-java.ps1 13.0.2 "${{ steps.setup-java-zulu.outputs.path }}" "${{ steps.setup-java-zulu.outputs.version }}"

test-proxy-adopt:
runs-on: ubuntu-latest
container:
image: ubuntu:latest
options: --dns 127.0.0.1
services:
squid-proxy:
image: datadog/squid:latest
ports:
- 3128:3128
env:
https_proxy: http://squid-proxy:3128
steps:
- uses: actions/checkout@v2
- name: Clear tool cache
run: rm -rf $RUNNER_TOOL_CACHE/*
- name: Setup Java 13
id: setup-java
uses: ./
with:
java-version: 13
distro: 'adoptopenjdk'
- name: Verify Java 13
run: __tests__/verify-java.sh 13.0.2 "${{ steps.setup-java.outputs.path }}" "${{ steps.setup-java.outputs.version }}"


test-proxy:
test-proxy-zulu:
runs-on: ubuntu-latest
container:
image: ubuntu:latest
Expand All @@ -67,6 +121,7 @@ jobs:
uses: ./
with:
java-version: 13.0.2
distro: zulu
- name: Verify Java 13
run: __tests__/verify-java.sh 13.0.2 "${{ steps.setup-java.outputs.path }}" "${{ steps.setup-java.outputs.version }}"

Expand All @@ -84,5 +139,6 @@ jobs:
uses: ./
with:
java-version: 13.0.2
distro: zulu
- name: Verify Java 13
run: __tests__/verify-java.sh 13.0.2 "${{ steps.setup-java.outputs.path }}" "${{ steps.setup-java.outputs.version }}"
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ steps:
- uses: actions/checkout@v2
- uses: actions/setup-java@v1
with:
java-version: '9.0.4' # The JDK version to make available on the path.
java-version: '11' # The JDK version to make available on the path.
vendor: adoptopenjdk # (adoptopenjdk or zulu) - defaults to adoptopenjdk
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like it should be distro instead of vendor?

java-package: jdk # (jre, jdk, or jdk+fx) - defaults to jdk
architecture: x64 # (x64 or x86) - defaults to x64
- run: java -cp java HelloWorldApp
Expand All @@ -29,14 +30,14 @@ Examples of version specifications that the java-version parameter will accept:
- A major Java version

e.g. ```6, 7, 8, 9, 10, 11, 12, 13, ...```

- A semver Java version specification

e.g. ```8.0.232, 7.0.181, 11.0.4```

e.g. ```8.0.x, >11.0.3, >=13.0.1, <8.0.212```

- An early access (EA) Java version
e.g. ```8.0.x, >11.0.3, >=13.0.1, <8.0.212``` (Zulu only)
- An early access (EA) Java version (Zulu only)

e.g. ```14-ea, 15-ea```

Expand All @@ -45,7 +46,7 @@ Examples of version specifications that the java-version parameter will accept:
e.g. ```14.0.0-ea.28, 15.0.0-ea.2``` (syntax for specifying an EA build number)

Note that, per semver rules, EA builds will be matched by explicit EA version specifications.

- 1.x syntax

e.g. ```1.8``` (same as ```8```)
Expand Down
99 changes: 80 additions & 19 deletions __tests__/installer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,15 @@ import * as installer from '../src/installer';

let javaFilePath = '';
let javaUrl = '';
let additionalPath = '';
if (process.platform === 'win32') {
javaFilePath = path.join(javaDir, 'java_win.zip');
javaUrl =
'https://download.java.net/java/GA/jdk12/33/GPL/openjdk-12_windows-x64_bin.zip';
} else if (process.platform === 'darwin') {
javaFilePath = path.join(javaDir, 'java_mac.tar.gz');
// macOS tarballs are in bundle format
additionalPath = '/Contents/Home';
javaUrl =
'https://download.java.net/java/GA/jdk12/33/GPL/openjdk-12_osx-x64_bin.tar.gz';
} else {
Expand Down Expand Up @@ -51,68 +54,125 @@ describe('installer tests', () => {
}
}, 100000);

it('Installs version of Java from jdkFile if no matching version is installed', async () => {
await installer.getJava('12', 'x64', javaFilePath, 'jdk');
it('Installs version of Java from jdkFile if no matching version is installed AdoptOpenJDK', async () => {
await installer.getJava('12', 'adoptopenjdk', 'x64', javaFilePath, 'jdk');
const JavaDir = path.join(toolDir, 'jdk', '12.0.0', 'x64');
expect(fs.existsSync(`${JavaDir}.complete`)).toBe(true);
expect(fs.existsSync(path.join(JavaDir, additionalPath, 'bin'))).toBe(true);
}, 100000);

it('Installs version of Java from jdkFile if no matching version is installed Zulu', async () => {
await installer.getJava('12', 'zulu', 'x64', javaFilePath, 'jdk');
const JavaDir = path.join(toolDir, 'jdk', '12.0.0', 'x64');
expect(fs.existsSync(`${JavaDir}.complete`)).toBe(true);
expect(fs.existsSync(path.join(JavaDir, 'bin'))).toBe(true);
expect(fs.existsSync(path.join(JavaDir, additionalPath, 'bin'))).toBe(true);
}, 100000);

it('Throws if invalid directory to jdk', async () => {
it('Throws if invalid directory to jdk AdoptOpenJDK', async () => {
let thrown = false;
try {
await installer.getJava('1000', 'x64', 'bad path', 'jdk');
await installer.getJava('1000', 'adoptopenjdk', 'x64', 'bad path', 'jdk');
} catch {
thrown = true;
}
expect(thrown).toBe(true);
});

it('Downloads java if no file given', async () => {
await installer.getJava('8.0.102', 'x64', '', 'jdk');
const JavaDir = path.join(toolDir, 'jdk', '8.0.102', 'x64');
it('Throws if invalid directory to jdk Zulu', async () => {
let thrown = false;
try {
await installer.getJava('1000', 'zulu', 'x64', 'bad path', 'jdk');
} catch {
thrown = true;
}
expect(thrown).toBe(true);
});

it('Downloads java if no file given AdoptOpenJDK', async () => {
await installer.getJava('8.0.252', 'adoptopenjdk', 'x64', '', 'jdk');
const JavaDir = path.join(toolDir, 'jdk', '8.0.252', 'x64');

expect(fs.existsSync(`${JavaDir}.complete`)).toBe(true);
expect(fs.existsSync(path.join(JavaDir, additionalPath, 'bin'))).toBe(true);
}, 100000);

it('Downloads java if no file given Zulu', async () => {
await installer.getJava('8.0.102', 'zulu', 'x64', '', 'jdk');
const JavaDir = path.join(toolDir, 'jdk', '8.0.102', 'x64');
expect(fs.existsSync(`${JavaDir}.complete`)).toBe(true);
expect(fs.existsSync(path.join(JavaDir, 'bin'))).toBe(true);
}, 100000);

it('Downloads java with 1.x syntax', async () => {
await installer.getJava('1.10', 'x64', '', 'jdk');
it('Downloads java with 1.x syntax AdoptOpenJDK', async () => {
await installer.getJava('1.13', 'adoptopenjdk', 'x64', '', 'jdk');
const JavaDir = path.join(toolDir, 'jdk', '13.0.2', 'x64');

expect(fs.existsSync(`${JavaDir}.complete`)).toBe(true);
expect(fs.existsSync(path.join(JavaDir, additionalPath, 'bin'))).toBe(true);
}, 100000);

it('Downloads java with 1.x syntax Zulu', async () => {
await installer.getJava('1.10', 'zulu', 'x64', '', 'jdk');
const JavaDir = path.join(toolDir, 'jdk', '10.0.2', 'x64');

expect(fs.existsSync(`${JavaDir}.complete`)).toBe(true);
expect(fs.existsSync(path.join(JavaDir, 'bin'))).toBe(true);
}, 100000);

it('Downloads java with normal semver syntax', async () => {
await installer.getJava('9.0.x', 'x64', '', 'jdk');
it('Downloads java with normal semver syntax AdoptOpenJDK', async () => {
await installer.getJava('13.0.x', 'adoptopenjdk', 'x64', '', 'jdk');
const JavaDir = path.join(toolDir, 'jdk', '13.0.2', 'x64');

expect(fs.existsSync(`${JavaDir}.complete`)).toBe(true);
expect(fs.existsSync(path.join(JavaDir, additionalPath, 'bin'))).toBe(true);
}, 100000);

it('Downloads java with normal semver syntax Zulu', async () => {
await installer.getJava('9.0.x', 'zulu', 'x64', '', 'jdk');
const JavaDir = path.join(toolDir, 'jdk', '9.0.7', 'x64');

expect(fs.existsSync(`${JavaDir}.complete`)).toBe(true);
expect(fs.existsSync(path.join(JavaDir, 'bin'))).toBe(true);
}, 100000);

it('Downloads java if package is jre', async () => {
await installer.getJava('8.0.222', 'x64', '', 'jre');
it('Downloads java if package is jre AdoptOpenJDK', async () => {
await installer.getJava('11.0.2', 'adoptopenjdk', 'x64', '', 'jre');
const JavaDir = path.join(toolDir, 'jre', '11.0.2', 'x64');

expect(fs.existsSync(`${JavaDir}.complete`)).toBe(true);
expect(fs.existsSync(path.join(JavaDir, additionalPath, 'bin'))).toBe(true);
}, 100000);

it('Downloads java if package is jre Zulu', async () => {
await installer.getJava('8.0.222', 'zulu', 'x64', '', 'jre');
const JavaDir = path.join(toolDir, 'jre', '8.0.222', 'x64');

expect(fs.existsSync(`${JavaDir}.complete`)).toBe(true);
expect(fs.existsSync(path.join(JavaDir, 'bin'))).toBe(true);
}, 100000);

it('Downloads java if package is jdk+fx', async () => {
await installer.getJava('8.0.222', 'x64', '', 'jdk+fx');
await installer.getJava('8.0.222', 'zulu', 'x64', '', 'jdk+fx');
const JavaDir = path.join(toolDir, 'jdk+fx', '8.0.222', 'x64');

expect(fs.existsSync(`${JavaDir}.complete`)).toBe(true);
expect(fs.existsSync(path.join(JavaDir, 'bin'))).toBe(true);
}, 100000);

it('Throws if invalid java package is specified', async () => {
it('Throws if invalid java package is specified AdoptOpenJDK', async () => {
let thrown = false;
try {
await installer.getJava('8', 'adoptopenjdk', 'x64', '', 'bad jdk');
} catch {
thrown = true;
}
expect(thrown).toBe(true);
});

it('Throws if invalid java package is specified Zulu', async () => {
let thrown = false;
try {
await installer.getJava('8.0.222', 'x64', '', 'bad jdk');
await installer.getJava('8.0.222', 'zulu', 'x64', '', 'bad jdk');
} catch {
thrown = true;
}
Expand All @@ -122,7 +182,7 @@ describe('installer tests', () => {
it('Throws if invalid directory to jdk', async () => {
let thrown = false;
try {
await installer.getJava('1000', 'x64', 'bad path', 'jdk');
await installer.getJava('1000', 'zulu', 'x64', 'bad path', 'jdk');
} catch {
thrown = true;
}
Expand All @@ -136,6 +196,7 @@ describe('installer tests', () => {
// This will throw if it doesn't find it in the cache (because no such version exists)
await installer.getJava(
'250',
'zulu',
'x64',
'path shouldnt matter, found in cache',
'jdk'
Expand All @@ -149,7 +210,7 @@ describe('installer tests', () => {
let thrown = false;
try {
// This will throw if it doesn't find it in the cache (because no such version exists)
await installer.getJava('251', 'x64', 'bad path', 'jdk');
await installer.getJava('251', 'zulu', 'x64', 'bad path', 'jdk');
} catch {
thrown = true;
}
Expand Down
5 changes: 5 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ inputs:
Early access versions can be specified in the form of e.g. 14-ea,
14.0.0-ea, or 14.0.0-ea.28'
required: true
distro:
description: 'The vendor to fetch the binary from (adoptopenjdk, zulu).
Defaults to adoptopenjdk'
required: false
default: 'adoptopenjdk'
java-package:
description: 'The package type (jre, jdk, jdk+fx)'
required: false
Expand Down
Loading