Skip to content

Commit

Permalink
Add support for http url in jdkFile
Browse files Browse the repository at this point in the history
  • Loading branch information
mdvorak committed Mar 16, 2022
1 parent f69f00b commit ebc13aa
Show file tree
Hide file tree
Showing 8 changed files with 2,186 additions and 2,136 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/e2e-local-file.yml
Expand Up @@ -121,3 +121,39 @@ jobs:
- name: Verify Java version
run: bash __tests__/verify-java.sh "11.0.12" "${{ steps.setup-java.outputs.path }}"
shell: bash

setup-java-remote-file-temurin:
name: Validate download from remote file Eclipse Temurin
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [macos-latest, windows-latest, ubuntu-latest]
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Download Eclipse Temurin file
run: |
if ($IsLinux) {
$downloadUrl = "https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.12%2B7/OpenJDK11U-jdk_x64_linux_hotspot_11.0.12_7.tar.gz"
$localFilename = "java_package.tar.gz"
} elseif ($IsMacOS) {
$downloadUrl = "https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.12%2B7/OpenJDK11U-jdk_x64_mac_hotspot_11.0.12_7.tar.gz"
$localFilename = "java_package.tar.gz"
} elseif ($IsWindows) {
$downloadUrl = "https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.12%2B7/OpenJDK11U-jdk_x64_windows_hotspot_11.0.12_7.zip"
$localFilename = "java_package.zip"
}
echo "DownloadUrl=$downloadUrl" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
shell: pwsh
- name: setup-java
uses: ./
id: setup-java
with:
distribution: 'jdkfile'
jdkFile: ${{ env.DownloadUrl }}
java-version: '11.0.0-ea'
architecture: x64
- name: Verify Java version
run: bash __tests__/verify-java.sh "11.0.12" "${{ steps.setup-java.outputs.path }}"
shell: bash
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -144,6 +144,7 @@ jobs:
- [Installing custom Java package type](docs/advanced-usage.md#Installing-custom-Java-package-type)
- [Installing custom Java architecture](docs/advanced-usage.md#Installing-custom-Java-architecture)
- [Installing custom Java distribution from local file](docs/advanced-usage.md#Installing-Java-from-local-file)
- [Installing Java from remote archive](docs/advanced-usage.md#Installing-Java-from-remote-archive)
- [Testing against different Java distributions](docs/advanced-usage.md#Testing-against-different-Java-distributions)
- [Testing against different platforms](docs/advanced-usage.md#Testing-against-different-platforms)
- [Publishing using Apache Maven](docs/advanced-usage.md#Publishing-using-Apache-Maven)
Expand Down
30 changes: 30 additions & 0 deletions __tests__/distributors/local-installer.test.ts
Expand Up @@ -161,6 +161,36 @@ describe('setupJava', () => {
);
});

it('java is downloaded from remote jdkfile', async () => {
const inputs = {
version: '11.0.289',
architecture: 'x86',
packageType: 'jdk',
checkLatest: false
};
const expected = {
version: '11.0.289',
path: path.join('Java_jdkfile_jdk', inputs.version, inputs.architecture)
};

const jdkFile = 'https://example.com/jdk.tar.gz';

const spyTcDownloadTool = jest.spyOn(tc, 'downloadTool');
spyTcDownloadTool.mockReturnValue(Promise.resolve(expectedJdkFile));

mockJavaBase = new LocalDistribution(inputs, jdkFile);
await expect(mockJavaBase.setupJava()).resolves.toEqual(expected);
expect(spyTcFindAllVersions).toHaveBeenCalled();
expect(spyTcDownloadTool).toHaveBeenCalledWith(jdkFile);
expect(spyCoreInfo).not.toHaveBeenCalledWith(
`Resolved Java ${actualJavaVersion} from tool-cache`
);
expect(spyCoreInfo).toHaveBeenCalledWith(`Extracting Java from '${expectedJdkFile}'`);
expect(spyCoreInfo).toHaveBeenCalledWith(
`Java ${inputs.version} was not found in tool-cache. Trying to unpack JDK file...`
);
});

it('jdk file is not found', async () => {
const inputs = {
version: '11.0.289',
Expand Down
2 changes: 1 addition & 1 deletion action.yml
Expand Up @@ -18,7 +18,7 @@ inputs:
required: false
default: 'x64'
jdkFile:
description: 'Path to where the compressed JDK is located'
description: 'Path to where the compressed JDK is located, or URL where it should be downloaded from'
required: false
check-latest:
description: 'Set this option if you want the action to check for the latest available version that satisfies the version spec'
Expand Down

0 comments on commit ebc13aa

Please sign in to comment.