Compare commits

...

43 Commits

Author SHA1 Message Date
16cca5479d Merge pull request #346 from pjfanning/patch-1
sbt is a valid cache option value
2022-06-20 09:14:34 +02:00
7b469c48c4 sbt is a valid cache option value 2022-06-16 21:47:05 +01:00
2506d21b74 Merge pull request #332 from fmeriaux/sbt-exclude-some-files
sbt-cache: don't cache some files.
2022-06-15 11:20:20 +02:00
187f735c38 npm run format 2022-06-15 08:23:10 +02:00
48576e577e npm run release 2022-06-15 08:19:27 +02:00
fa01820a3b add documentation notes 2022-06-15 08:17:30 +02:00
62808131e1 Merge pull request #339 from starburstdata/pp/fix-arm64-architecture
Fix support for Zulu arm64 architecture
2022-06-10 09:44:45 +02:00
ddbbc2fff5 Merge pull request #342 from gdams/msft
msft: bump jdk17 to 17.0.3 and add aarch64 support to jdk11
2022-06-10 09:41:48 +02:00
4fba831118 fix test 2022-06-09 17:53:21 +01:00
11556068a2 msft: bump jdk17 to 17.0.3 and add aarch64 support to jdk11 2022-06-09 09:39:57 +01:00
ec303d3bdf Merge pull request #331 from AGulev/microsoft-11.0.15
Add Microsoft Java 11.0.15
2022-06-08 14:12:35 +02:00
1c449b9ad2 Fix support for Zulu arm64 architecture
Azul API stopped to support arm64 architecture, the only supported
option for ARM cpus is now 'arm'. This requires to set up hw_bitness
properly to get 64 bits version. 32 bits version can be obtained by
using 'arm' as an architecture.
2022-06-07 22:24:33 +02:00
3e3d8c490f sbt-cache: don't cache some files. 2022-05-25 11:39:10 +02:00
72dec17e4f index.js 2022-05-25 08:41:31 +02:00
e8f1c8b5ca Add Microsoft 11.0.15 2022-05-24 19:12:23 +02:00
05b9e395e1 Updates the sbt cache docs in the README (#327) 2022-05-09 09:30:21 +02:00
860f600565 Add Amazon Corretto example and fix links (#325) 2022-05-04 13:23:54 +02:00
bae3140877 Add Amazon Corretto distribution (#312) 2022-04-29 12:38:36 +02:00
dd80852400 Housekeeping: Update zeit/ncc to vercel/ncc (#270) 2022-04-26 15:44:58 +02:00
4fe61d24fe [README] Add sbt as supported package manager for caching (#322) 2022-04-26 09:35:00 +02:00
055250a105 Add CODE_OF_CONDUCT (#318) 2022-04-20 16:26:58 +02:00
0ed94a5678 Add SBT in cache managers. (#302) 2022-04-20 16:26:27 +02:00
9519cf1382 Merge pull request #317 from actions/t-dedah/updateCache
Updated @actions/cache
2022-04-11 19:06:07 +05:30
02c73de3fe Updated action version 2022-04-11 13:25:41 +00:00
fd3f6750a0 Updated package-lock.json 2022-04-11 13:08:18 +00:00
1aa8bf7608 Licensed 2022-04-11 09:39:09 +00:00
9c8c90e08c Updated @actions/cache 2022-04-11 07:36:42 +00:00
cd35109007 Bump actions to v3 (#314) 2022-04-07 12:25:49 +02:00
d2e3f417a9 Set output cache-hit to indicate if cache was hit (#275) 2022-04-07 10:58:22 +02:00
0aa6f2a84f Bump minimist from 1.2.5 to 1.2.6 (#303) 2022-04-01 09:57:27 +02:00
dc1a9f2791 Caching on GHES (#308)
* initial changes

* review comments

* updated with correct message

* linting

* update version

* updated version
2022-03-31 15:09:57 -04:00
e886040dc2 Update zulu-installer.test.ts (#310) 2022-03-31 18:33:52 +02:00
efbea1411b Update util.ts 2022-03-31 20:49:24 +05:30
c41070eda4 Update util.ts 2022-03-31 20:46:04 +05:30
f69f00b5e5 Update lockfileVersion (#293) 2022-02-24 14:42:37 +03:00
2e1dfa1fb4 Update Default runtime to node16 (#290) 2022-02-22 11:27:25 +03:00
a12e082d83 Merge pull request #224 from KengoTODA/remove-husky
Housekeeping: remove the config for husky
2021-12-29 14:46:32 +03:00
04d53533c2 Merge pull request #215 from beatngu13/update-readme-cache-key
Describe cache key format in readme
2021-12-29 14:27:51 +03:00
d8da887cad Merge pull request #196 from oscard0m/add-cache-to-node-workflows
ci(workflow): add cache to workflows using actions/setup-node
2021-12-29 14:12:29 +03:00
6df0b04fb5 build: remove the config for husky
husky has been removed by 980efe8 at 2019 Nov.
2021-09-10 07:53:56 +08:00
a1ad2000b3 Describe cache key format in readme 2021-08-31 21:42:01 +02:00
faa22ddfbc style(workflows): restore single quote strings 2021-08-22 15:51:45 +02:00
a388b3faf4 ci(workflow): add 'npm' cache for actions/setup-node in .github/workflows 2021-07-18 22:16:32 +02:00
45 changed files with 133221 additions and 122007 deletions

9
.github/workflows/build.yml vendored Executable file → Normal file
View File

@ -19,11 +19,12 @@ jobs:
matrix: matrix:
os: [ubuntu-latest, windows-latest, macos-latest] os: [ubuntu-latest, windows-latest, macos-latest]
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
- name: Setup Node.JS 12 - name: Setup Node.JS 16
uses: actions/setup-node@v2 uses: actions/setup-node@v3
with: with:
node-version: 12.x node-version: 16.x
cache: npm
- run: npm ci - run: npm ci
- run: npm run build - run: npm run build
- run: npm run format-check - run: npm run format-check

View File

@ -21,12 +21,13 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
- name: Set Node.js 12.x - name: Set Node.js 16.x
uses: actions/setup-node@v1 uses: actions/setup-node@v3
with: with:
node-version: 12.x node-version: 16.x
cache: npm
- name: Install dependencies - name: Install dependencies
run: npm ci run: npm ci
@ -44,7 +45,7 @@ jobs:
id: diff id: diff
# If index.js was different than expected, upload the expected version as an artifact # If index.js was different than expected, upload the expected version as an artifact
- uses: actions/upload-artifact@v2 - uses: actions/upload-artifact@v3
if: ${{ failure() && steps.diff.conclusion == 'failure' }} if: ${{ failure() && steps.diff.conclusion == 'failure' }}
with: with:
name: dist name: dist

View File

@ -23,7 +23,7 @@ jobs:
os: [macos-latest, windows-latest, ubuntu-latest] os: [macos-latest, windows-latest, ubuntu-latest]
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v3
- name: Run setup-java with the cache for gradle - name: Run setup-java with the cache for gradle
uses: ./ uses: ./
id: setup-java id: setup-java
@ -49,7 +49,7 @@ jobs:
needs: gradle-save needs: gradle-save
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v3
- name: Run setup-java with the cache for gradle - name: Run setup-java with the cache for gradle
uses: ./ uses: ./
id: setup-java id: setup-java
@ -72,7 +72,7 @@ jobs:
os: [macos-latest, windows-latest, ubuntu-latest] os: [macos-latest, windows-latest, ubuntu-latest]
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v3
- name: Run setup-java with the cache for maven - name: Run setup-java with the cache for maven
uses: ./ uses: ./
id: setup-java id: setup-java
@ -96,7 +96,7 @@ jobs:
needs: maven-save needs: maven-save
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v3
- name: Run setup-java with the cache for maven - name: Run setup-java with the cache for maven
uses: ./ uses: ./
id: setup-java id: setup-java
@ -111,3 +111,99 @@ jobs:
exit 1 exit 1
fi fi
ls ~/.m2/repository ls ~/.m2/repository
sbt-save:
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash
working-directory: __tests__/cache/sbt
strategy:
fail-fast: false
matrix:
os: [macos-latest, windows-latest, ubuntu-latest]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Run setup-java with the cache for sbt
uses: ./
id: setup-java
with:
distribution: 'adopt'
java-version: '11'
cache: sbt
- name: Create files to cache
run: sbt update
- name: Check files to cache on macos-latest
if: matrix.os == 'macos-latest'
run: |
if [ ! -d ~/Library/Caches/Coursier ]; then
echo "::error::The ~/Library/Caches/Coursier directory does not exist unexpectedly"
exit 1
fi
- name: Check files to cache on windows-latest
if: matrix.os == 'windows-latest'
run: |
if [ ! -d ~/AppData/Local/Coursier/Cache ]; then
echo "::error::The ~/AppData/Local/Coursier/Cache directory does not exist unexpectedly"
exit 1
fi
- name: Check files to cache on ubuntu-latest
if: matrix.os == 'ubuntu-latest'
run: |
if [ ! -d ~/.cache/coursier ]; then
echo "::error::The ~/.cache/coursier directory does not exist unexpectedly"
exit 1
fi
sbt-restore:
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash
working-directory: __tests__/cache/sbt
strategy:
fail-fast: false
matrix:
os: [macos-latest, windows-latest, ubuntu-latest]
needs: sbt-save
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Run setup-java with the cache for sbt
uses: ./
id: setup-java
with:
distribution: 'adopt'
java-version: '11'
cache: sbt
- name: Confirm that ~/Library/Caches/Coursier directory has been made
if: matrix.os == 'macos-latest'
run: |
if [ ! -d ~/Library/Caches/Coursier ]; then
echo "::error::The ~/Library/Caches/Coursier directory does not exist unexpectedly"
exit 1
fi
ls ~/Library/Caches/Coursier
- name: Confirm that ~/AppData/Local/Coursier/Cache directory has been made
if: matrix.os == 'windows-latest'
run: |
if [ ! -d ~/AppData/Local/Coursier/Cache ]; then
echo "::error::The ~/AppData/Local/Coursier/Cache directory does not exist unexpectedly"
exit 1
fi
ls ~/AppData/Local/Coursier/Cache
- name: Confirm that ~/.cache/coursier directory has been made
if: matrix.os == 'ubuntu-latest'
run: |
if [ ! -d ~/.cache/coursier ]; then
echo "::error::The ~/.cache/coursier directory does not exist unexpectedly"
exit 1
fi
ls ~/.cache/coursier

View File

@ -20,7 +20,7 @@ jobs:
os: [macos-latest, windows-latest, ubuntu-latest] os: [macos-latest, windows-latest, ubuntu-latest]
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v3
- name: Download Adopt OpenJDK file - name: Download Adopt OpenJDK file
run: | run: |
if ($IsLinux) { if ($IsLinux) {
@ -57,7 +57,7 @@ jobs:
os: [macos-latest, windows-latest, ubuntu-latest] os: [macos-latest, windows-latest, ubuntu-latest]
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v3
- name: Download Zulu OpenJDK file - name: Download Zulu OpenJDK file
run: | run: |
if ($IsLinux) { if ($IsLinux) {
@ -94,7 +94,7 @@ jobs:
os: [macos-latest, windows-latest, ubuntu-latest] os: [macos-latest, windows-latest, ubuntu-latest]
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v3
- name: Download Eclipse Temurin file - name: Download Eclipse Temurin file
run: | run: |
if ($IsLinux) { if ($IsLinux) {

View File

@ -24,7 +24,7 @@ jobs:
os: [macos-latest, windows-latest, ubuntu-latest] os: [macos-latest, windows-latest, ubuntu-latest]
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v3
- name: setup-java - name: setup-java
uses: ./ uses: ./
id: setup-java id: setup-java
@ -59,7 +59,7 @@ jobs:
os: [macos-latest, windows-latest, ubuntu-latest] os: [macos-latest, windows-latest, ubuntu-latest]
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v3
- name: Create fake settings.xml - name: Create fake settings.xml
run: | run: |
$xmlDirectory = Join-Path $HOME ".m2" $xmlDirectory = Join-Path $HOME ".m2"
@ -95,7 +95,7 @@ jobs:
os: [macos-latest, windows-latest, ubuntu-latest] os: [macos-latest, windows-latest, ubuntu-latest]
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v3
- name: Create fake settings.xml - name: Create fake settings.xml
run: | run: |
$xmlDirectory = Join-Path $HOME ".m2" $xmlDirectory = Join-Path $HOME ".m2"
@ -132,7 +132,7 @@ jobs:
os: [macos-latest, windows-latest, ubuntu-latest] os: [macos-latest, windows-latest, ubuntu-latest]
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v3
- name: setup-java - name: setup-java
uses: ./ uses: ./
id: setup-java id: setup-java

View File

@ -20,14 +20,14 @@ jobs:
fail-fast: false fail-fast: false
matrix: matrix:
os: [macos-latest, windows-latest, ubuntu-latest] os: [macos-latest, windows-latest, ubuntu-latest]
distribution: ['temurin', 'adopt', 'adopt-openj9', 'zulu', 'liberica', 'microsoft' ] # internally 'adopt-hotspot' is the same as 'adopt' distribution: ['temurin', 'adopt', 'adopt-openj9', 'zulu', 'liberica', 'microsoft', 'corretto' ] # internally 'adopt-hotspot' is the same as 'adopt'
version: ['8', '11', '16'] version: ['8', '11', '16']
exclude: exclude:
- distribution: microsoft - distribution: microsoft
version: 8 version: 8
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v3
- name: setup-java - name: setup-java
uses: ./ uses: ./
id: setup-java id: setup-java
@ -53,7 +53,7 @@ jobs:
- '16.0.2+7' - '16.0.2+7'
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v3
- name: setup-java - name: setup-java
uses: ./ uses: ./
id: setup-java id: setup-java
@ -75,7 +75,7 @@ jobs:
distribution: ['temurin', 'zulu', 'liberica'] distribution: ['temurin', 'zulu', 'liberica']
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v3
- name: setup-java - name: setup-java
uses: ./ uses: ./
id: setup-java id: setup-java
@ -98,7 +98,7 @@ jobs:
version: ['17-ea', '15.0.0-ea.14'] version: ['17-ea', '15.0.0-ea.14']
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v3
- name: setup-java - name: setup-java
uses: ./ uses: ./
id: setup-java id: setup-java
@ -120,7 +120,7 @@ jobs:
version: ['17-ea'] version: ['17-ea']
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v3
- name: setup-java - name: setup-java
uses: ./ uses: ./
id: setup-java id: setup-java
@ -141,7 +141,7 @@ jobs:
os: [macos-latest, windows-latest, ubuntu-latest] os: [macos-latest, windows-latest, ubuntu-latest]
distribution: ['temurin', 'zulu', 'liberica'] distribution: ['temurin', 'zulu', 'liberica']
java-package: ['jre'] java-package: ['jre']
version: ['16.0'] version: ['17.0']
include: include:
- distribution: 'zulu' - distribution: 'zulu'
java-package: jre+fx java-package: jre+fx
@ -159,13 +159,13 @@ jobs:
java-package: jre+fx java-package: jre+fx
version: '11' version: '11'
os: ubuntu-latest os: ubuntu-latest
exclude: - distribution: 'corretto'
# Eclipse Temurin currently doesn't publish JREs, only JDKs java-package: jre
- distribution: 'temurin' version: '8'
java-package: 'jre' os: windows-latest
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v3
- name: setup-java - name: setup-java
uses: ./ uses: ./
id: setup-java id: setup-java
@ -187,11 +187,11 @@ jobs:
matrix: matrix:
# x86 is not supported on macOS # x86 is not supported on macOS
os: [windows-latest, ubuntu-latest] os: [windows-latest, ubuntu-latest]
distribution: ['liberica', 'zulu'] distribution: ['liberica', 'zulu', 'corretto']
version: ['11'] version: ['11']
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v3
- name: setup-java - name: setup-java
uses: ./ uses: ./
id: setup-java id: setup-java

View File

@ -14,12 +14,12 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
name: Check licenses name: Check licenses
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
- run: npm ci - run: npm ci
- name: Install licensed - name: Install licensed
run: | run: |
cd $RUNNER_TEMP cd $RUNNER_TEMP
curl -Lfs -o licensed.tar.gz https://github.com/github/licensed/releases/download/3.3.1/licensed-3.3.1-linux-x64.tar.gz curl -Lfs -o licensed.tar.gz https://github.com/github/licensed/releases/download/3.4.4/licensed-3.4.4-linux-x64.tar.gz
sudo tar -xzf licensed.tar.gz sudo tar -xzf licensed.tar.gz
sudo mv licensed /usr/local/bin/licensed sudo mv licensed /usr/local/bin/licensed
- run: licensed status - run: licensed status

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

76
CODE_OF_CONDUCT.md Normal file
View File

@ -0,0 +1,76 @@
# Contributor Covenant Code of Conduct
## Our Pledge
In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to make participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, sex characteristics, gender identity and expression,
level of experience, education, socio-economic status, nationality, personal
appearance, race, religion, or sexual identity and orientation.
## Our Standards
Examples of behavior that contributes to creating a positive environment
include:
* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting
## Our Responsibilities
Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.
Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.
## Scope
This Code of Conduct applies within all project spaces, and it also applies when
an individual is representing the project or its community in public spaces.
Examples of representing a project or community include using an official
project e-mail address, posting via an official social media account, or acting
as an appointed representative at an online or offline event. Representation of
a project may be further defined and clarified by project maintainers.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at opensource+actions/setup-java@github.com. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.
Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
[homepage]: https://www.contributor-covenant.org
For answers to common questions about this code of conduct, see
https://www.contributor-covenant.org/faq

View File

@ -8,7 +8,7 @@
### NCC ### NCC
In order to avoid uploading `node_modules` to the repository, we use [zeit/ncc](https://github.com/zeit/ncc) to create multiple `index.js` files that gets saved under `dist/`. In order to avoid uploading `node_modules` to the repository, we use [vercel/ncc](https://github.com/vercel/ncc) to create multiple `index.js` files that gets saved under `dist/`.
There are two main files that get created There are two main files that get created
- `dist/setup/index.js` - `dist/setup/index.js`
- Core `setup-java` logic that downloads and installs an appropriate version of Java - Core `setup-java` logic that downloads and installs an appropriate version of Java

View File

@ -25,8 +25,8 @@ Inputs `java-version` and `distribution` are mandatory. See [Supported distribut
**Eclipse Temurin** **Eclipse Temurin**
```yaml ```yaml
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
- uses: actions/setup-java@v2 - uses: actions/setup-java@v3
with: with:
distribution: 'temurin' # See 'Supported distributions' for available options distribution: 'temurin' # See 'Supported distributions' for available options
java-version: '17' java-version: '17'
@ -36,8 +36,8 @@ steps:
**Zulu OpenJDK** **Zulu OpenJDK**
```yaml ```yaml
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
- uses: actions/setup-java@v2 - uses: actions/setup-java@v3
with: with:
distribution: 'zulu' # See 'Supported distributions' for available options distribution: 'zulu' # See 'Supported distributions' for available options
java-version: '11' java-version: '11'
@ -60,19 +60,29 @@ Currently, the following distributions are supported:
| `adopt-openj9` | Adopt OpenJDK OpenJ9 | [Link](https://adoptopenjdk.net/) | [Link](https://adoptopenjdk.net/about.html) | | `adopt-openj9` | Adopt OpenJDK OpenJ9 | [Link](https://adoptopenjdk.net/) | [Link](https://adoptopenjdk.net/about.html) |
| `liberica` | Liberica JDK | [Link](https://bell-sw.com/) | [Link](https://bell-sw.com/liberica_eula/) | | `liberica` | Liberica JDK | [Link](https://bell-sw.com/) | [Link](https://bell-sw.com/liberica_eula/) |
| `microsoft` | Microsoft Build of OpenJDK | [Link](https://www.microsoft.com/openjdk) | [Link](https://docs.microsoft.com/java/openjdk/faq) | `microsoft` | Microsoft Build of OpenJDK | [Link](https://www.microsoft.com/openjdk) | [Link](https://docs.microsoft.com/java/openjdk/faq)
| `corretto` | Amazon Corretto Build of OpenJDK | [Link](https://aws.amazon.com/corretto/) | [Link](https://aws.amazon.com/corretto/faqs/)
**NOTE:** The different distributors can provide discrepant list of available versions / supported configurations. Please refer to the official documentation to see the list of supported versions. **NOTE:** The different distributors can provide discrepant list of available versions / supported configurations. Please refer to the official documentation to see the list of supported versions.
**NOTE:** Adopt OpenJDK got moved to Eclipse Temurin and won't be updated anymore. It is highly recommended to migrate workflows from `adopt` to `temurin` to keep receiving software and security updates. See more details in the [Good-bye AdoptOpenJDK post](https://blog.adoptopenjdk.net/2021/08/goodbye-adoptopenjdk-hello-adoptium/). **NOTE:** Adopt OpenJDK got moved to Eclipse Temurin and won't be updated anymore. It is highly recommended to migrate workflows from `adopt` to `temurin` to keep receiving software and security updates. See more details in the [Good-bye AdoptOpenJDK post](https://blog.adoptopenjdk.net/2021/08/goodbye-adoptopenjdk-hello-adoptium/).
**NOTE:** For Zulu OpenJDK architectures x64 and arm64 are mapped to x86 / arm with proper hw_bitness.
### Caching packages dependencies ### Caching packages dependencies
The action has a built-in functionality for caching and restoring dependencies. It uses [actions/cache](https://github.com/actions/cache) under hood for caching dependencies but requires less configuration settings. Supported package managers are gradle and maven. The cache input is optional, and caching is turned off by default. The action has a built-in functionality for caching and restoring dependencies. It uses [actions/cache](https://github.com/actions/cache) under hood for caching dependencies but requires less configuration settings. Supported package managers are gradle, maven and sbt. The format of the used cache key is `setup-java-${{ platform }}-${{ packageManager }}-${{ fileHash }}`, where the hash is based on the following files:
- gradle: `**/*.gradle*`, `**/gradle-wrapper.properties`
- maven: `**/pom.xml`
- sbt: all sbt build definition files `**/*.sbt`, `**/project/build.properties`, `**/project/**.{scala,sbt}`
The workflow output `cache-hit` is set to indicate if an exact match was found for the key [as actions/cache does](https://github.com/actions/cache/tree/main#outputs).
The cache input is optional, and caching is turned off by default.
#### Caching gradle dependencies #### Caching gradle dependencies
```yaml ```yaml
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
- uses: actions/setup-java@v2 - uses: actions/setup-java@v3
with: with:
distribution: 'temurin' distribution: 'temurin'
java-version: '11' java-version: '11'
@ -83,8 +93,8 @@ steps:
#### Caching maven dependencies #### Caching maven dependencies
```yaml ```yaml
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
- uses: actions/setup-java@v2 - uses: actions/setup-java@v3
with: with:
distribution: 'temurin' distribution: 'temurin'
java-version: '11' java-version: '11'
@ -93,6 +103,19 @@ steps:
run: mvn -B package --file pom.xml run: mvn -B package --file pom.xml
``` ```
#### Caching sbt dependencies
```yaml
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '11'
cache: 'sbt'
- name: Build with SBT
run: sbt package
```
### 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.
@ -103,8 +126,8 @@ For Java distributions that are not cached on Hosted images, `check-latest` alwa
```yaml ```yaml
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
- uses: actions/setup-java@v2 - uses: actions/setup-java@v3
with: with:
distribution: 'adopt' distribution: 'adopt'
java-version: '11' java-version: '11'
@ -122,9 +145,9 @@ jobs:
java: [ '8', '11', '13', '15' ] java: [ '8', '11', '13', '15' ]
name: Java ${{ matrix.Java }} sample name: Java ${{ matrix.Java }} sample
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
- name: Setup java - name: Setup java
uses: actions/setup-java@v2 uses: actions/setup-java@v3
with: with:
distribution: '<distribution>' distribution: '<distribution>'
java-version: ${{ matrix.java }} java-version: ${{ matrix.java }}
@ -137,6 +160,8 @@ jobs:
- [Adopt](docs/advanced-usage.md#Adopt) - [Adopt](docs/advanced-usage.md#Adopt)
- [Zulu](docs/advanced-usage.md#Zulu) - [Zulu](docs/advanced-usage.md#Zulu)
- [Liberica](docs/advanced-usage.md#Liberica) - [Liberica](docs/advanced-usage.md#Liberica)
- [Microsoft](docs/advanced-usage.md#Microsoft)
- [Amazon Corretto](docs/advanced-usage.md#Amazon-Corretto)
- [Installing custom Java package type](docs/advanced-usage.md#Installing-custom-Java-package-type) - [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 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 custom Java distribution from local file](docs/advanced-usage.md#Installing-Java-from-local-file)

View File

@ -118,6 +118,23 @@ describe('dependency cache', () => {
expect(spyInfo).toBeCalledWith('gradle cache is not found'); expect(spyInfo).toBeCalledWith('gradle cache is not found');
}); });
}); });
describe('for sbt', () => {
it('throws error if no build.sbt found', async () => {
await expect(restore('sbt')).rejects.toThrowError(
`No file in ${projectRoot(
workspace
)} matched to [**/*.sbt,**/project/build.properties,**/project/**.{scala,sbt}], make sure you have checked out the target repository`
);
});
it('downloads cache', async () => {
createFile(join(workspace, 'build.sbt'));
await restore('sbt');
expect(spyCacheRestore).toBeCalled();
expect(spyWarning).not.toBeCalled();
expect(spyInfo).toBeCalledWith('sbt cache is not found');
});
});
}); });
describe('save', () => { describe('save', () => {
let spyCacheSave: jest.SpyInstance< let spyCacheSave: jest.SpyInstance<
@ -194,6 +211,30 @@ describe('dependency cache', () => {
expect(spyInfo).toBeCalledWith(expect.stringMatching(/^Cache saved with the key:.*/)); expect(spyInfo).toBeCalledWith(expect.stringMatching(/^Cache saved with the key:.*/));
}); });
}); });
describe('for sbt', () => {
it('uploads cache even if no build.sbt found', async () => {
createStateForMissingBuildFile();
await save('sbt');
expect(spyCacheSave).toBeCalled();
expect(spyWarning).not.toBeCalled();
});
it('does not upload cache if no restore run before', async () => {
createFile(join(workspace, 'build.sbt'));
await save('sbt');
expect(spyCacheSave).not.toBeCalled();
expect(spyWarning).toBeCalledWith('Error retrieving key from state.');
});
it('uploads cache', async () => {
createFile(join(workspace, 'build.sbt'));
createStateForSuccessfulRestore();
await save('sbt');
expect(spyCacheSave).toBeCalled();
expect(spyWarning).not.toBeCalled();
expect(spyInfo).toBeCalledWith(expect.stringMatching(/^Cache saved with the key:.*/));
});
});
}); });
}); });

1
__tests__/cache/sbt/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
target/

3
__tests__/cache/sbt/build.sbt vendored Normal file
View File

@ -0,0 +1,3 @@
ThisBuild / scalaVersion := "2.12.15"
libraryDependencies += "org.scala-lang.modules" %% "scala-parser-combinators" % "1.1.2"

View File

@ -0,0 +1 @@
sbt.version=1.6.2

1183
__tests__/data/corretto.json Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,152 @@
import { HttpClient } from '@actions/http-client';
import { JavaInstallerOptions } from '../../src/distributions/base-models';
import { CorrettoDistribution } from '../../src/distributions/corretto/installer';
import * as util from '../../src/util';
const manifestData = require('../data/corretto.json') as [];
describe('getAvailableVersions', () => {
let spyHttpClient: jest.SpyInstance;
let spyGetDownloadArchiveExtension: jest.SpyInstance;
beforeEach(() => {
spyHttpClient = jest.spyOn(HttpClient.prototype, 'getJson');
spyHttpClient.mockReturnValue({
statusCode: 200,
headers: {},
result: manifestData
});
spyGetDownloadArchiveExtension = jest.spyOn(util, 'getDownloadArchiveExtension');
});
afterEach(() => {
jest.resetAllMocks();
jest.clearAllMocks();
jest.restoreAllMocks();
});
describe('getAvailableVersions', () => {
it('load available versions', async () => {
const distribution = new CorrettoDistribution({
version: '11',
architecture: 'x64',
packageType: 'jdk',
checkLatest: false
});
mockPlatform(distribution, 'linux');
const availableVersions = await distribution['getAvailableVersions']();
expect(availableVersions).not.toBeNull();
expect(availableVersions.length).toBe(6);
});
it.each([
[{ version: '16', architecture: 'x64', packageType: 'jdk', checkLatest: false }, 'macos', 6],
[{ version: '16', architecture: 'x86', packageType: 'jdk', checkLatest: false }, 'macos', 0],
[{ version: '16', architecture: 'x64', packageType: 'jre', checkLatest: false }, 'macos', 0],
[{ version: '16', architecture: 'x64', packageType: 'jdk', checkLatest: false }, 'linux', 6],
[
{ version: '18', architecture: 'x64', packageType: 'jdk', checkLatest: false },
'windows',
6
],
[{ version: '18', architecture: 'x64', packageType: 'jre', checkLatest: false }, 'windows', 1]
])(
'fetch expected amount of available versions for %s',
async (
installerOptions: JavaInstallerOptions,
platform: string,
expectedAmountOfAvailableVersions
) => {
const distribution = new CorrettoDistribution(installerOptions);
mockPlatform(distribution, platform);
const availableVersions = await distribution['getAvailableVersions']();
expect(availableVersions).not.toBeNull();
expect(availableVersions.length).toBe(expectedAmountOfAvailableVersions);
}
);
});
describe('findPackageForDownload', () => {
it.each([
[
'macos',
'https://corretto.aws/downloads/resources/18.0.0.37.1/amazon-corretto-18.0.0.37.1-macosx-x64.tar.gz'
],
[
'windows',
'https://corretto.aws/downloads/resources/18.0.0.37.1/amazon-corretto-18.0.0.37.1-windows-x64-jdk.zip'
],
[
'linux',
'https://corretto.aws/downloads/resources/18.0.0.37.1/amazon-corretto-18.0.0.37.1-linux-x64.tar.gz'
]
])('for os: %s', async (platform: string, expectedLink: string) => {
const version = '18';
const distribution = new CorrettoDistribution({
version,
architecture: 'x64',
packageType: 'jdk',
checkLatest: false
});
mockPlatform(distribution, platform);
const availableVersion = await distribution['findPackageForDownload'](version);
expect(availableVersion).not.toBeNull();
expect(availableVersion.url).toBe(expectedLink);
});
it('with unstable version expect to throw not supported error', async () => {
const version = '18.0.1-ea';
const distribution = new CorrettoDistribution({
version,
architecture: 'x64',
packageType: 'jdk',
checkLatest: false
});
mockPlatform(distribution, 'linux');
await expect(distribution['findPackageForDownload'](version)).rejects.toThrowError(
'Early access versions are not supported'
);
});
it('with non major version expect to throw not supported error', async () => {
const version = '18.0.1';
const distribution = new CorrettoDistribution({
version,
architecture: 'x64',
packageType: 'jdk',
checkLatest: false
});
mockPlatform(distribution, 'linux');
await expect(distribution['findPackageForDownload'](version)).rejects.toThrowError(
'Only major versions are supported'
);
});
it('with unfound version throw could not find error', async () => {
const version = '4';
const distribution = new CorrettoDistribution({
version,
architecture: 'x64',
packageType: 'jdk',
checkLatest: false
});
mockPlatform(distribution, 'linux');
await expect(distribution['findPackageForDownload'](version)).rejects.toThrowError(
"Could not find satisfied version for SemVer '4'"
);
});
});
const mockPlatform = (distributon: CorrettoDistribution, platform: string) => {
distributon['getPlatformOption'] = () => platform;
const mockedExtension = platform === 'windows' ? 'zip' : 'tar.gz';
spyGetDownloadArchiveExtension.mockReturnValue(mockedExtension);
};
});

View File

@ -14,10 +14,15 @@ describe('findPackageForDownload', () => {
it.each([ it.each([
[ [
'17.x', '17.0.1',
'17.0.1', '17.0.1',
'https://aka.ms/download-jdk/microsoft-jdk-17.0.1.12.1-{{OS_TYPE}}-x64.{{ARCHIVE_TYPE}}' 'https://aka.ms/download-jdk/microsoft-jdk-17.0.1.12.1-{{OS_TYPE}}-x64.{{ARCHIVE_TYPE}}'
], ],
[
'17.x',
'17.0.3',
'https://aka.ms/download-jdk/microsoft-jdk-17.0.3-{{OS_TYPE}}-x64.{{ARCHIVE_TYPE}}'
],
[ [
'16.0.x', '16.0.x',
'16.0.2', '16.0.2',
@ -27,6 +32,11 @@ describe('findPackageForDownload', () => {
'11.0.13', '11.0.13',
'11.0.13', '11.0.13',
'https://aka.ms/download-jdk/microsoft-jdk-11.0.13.8.1-{{OS_TYPE}}-x64.{{ARCHIVE_TYPE}}' 'https://aka.ms/download-jdk/microsoft-jdk-11.0.13.8.1-{{OS_TYPE}}-x64.{{ARCHIVE_TYPE}}'
],
[
'11.0.15',
'11.0.15',
'https://aka.ms/download-jdk/microsoft-jdk-11.0.15-{{OS_TYPE}}-x64.{{ARCHIVE_TYPE}}'
] ]
])('version is %s -> %s', async (input, expectedVersion, expectedUrl) => { ])('version is %s -> %s', async (input, expectedVersion, expectedUrl) => {
const result = await distribution['findPackageForDownload'](input); const result = await distribution['findPackageForDownload'](input);

View File

@ -52,6 +52,14 @@ describe('getAvailableVersions', () => {
[ [
{ version: '8', architecture: 'x64', packageType: 'jre+fx', checkLatest: false }, { version: '8', architecture: 'x64', packageType: 'jre+fx', checkLatest: false },
'?os=macos&ext=tar.gz&bundle_type=jre&javafx=true&arch=x86&hw_bitness=64&release_status=ga&features=fx' '?os=macos&ext=tar.gz&bundle_type=jre&javafx=true&arch=x86&hw_bitness=64&release_status=ga&features=fx'
],
[
{ version: '11', architecture: 'arm64', packageType: 'jdk', checkLatest: false },
'?os=macos&ext=tar.gz&bundle_type=jdk&javafx=false&arch=arm&hw_bitness=64&release_status=ga'
],
[
{ version: '11', architecture: 'arm', packageType: 'jdk', checkLatest: false },
'?os=macos&ext=tar.gz&bundle_type=jdk&javafx=false&arch=arm&hw_bitness=&release_status=ga'
] ]
])('build correct url for %s -> %s', async (input, parsedUrl) => { ])('build correct url for %s -> %s', async (input, parsedUrl) => {
const distribution = new ZuluDistribution(input); const distribution = new ZuluDistribution(input);
@ -139,6 +147,7 @@ describe('findPackageForDownload', () => {
packageType: 'jdk', packageType: 'jdk',
checkLatest: false checkLatest: false
}); });
distribution['getAvailableVersions'] = async () => manifestData;
await expect( await expect(
distribution['findPackageForDownload'](distribution['version']) distribution['findPackageForDownload'](distribution['version'])
).rejects.toThrowError(/Could not find satisfied version for semver */); ).rejects.toThrowError(/Could not find satisfied version for semver */);

View File

@ -1,4 +1,9 @@
import { isVersionSatisfies } from '../src/util'; import * as cache from '@actions/cache';
import * as core from '@actions/core';
import { isVersionSatisfies, isCacheFeatureAvailable } from '../src/util';
jest.mock('@actions/cache');
jest.mock('@actions/core');
describe('isVersionSatisfies', () => { describe('isVersionSatisfies', () => {
it.each([ it.each([
@ -20,3 +25,38 @@ describe('isVersionSatisfies', () => {
expect(actual).toBe(expected); expect(actual).toBe(expected);
}); });
}); });
describe('isCacheFeatureAvailable', () => {
it('isCacheFeatureAvailable disabled on GHES', () => {
jest.spyOn(cache, 'isFeatureAvailable').mockImplementation(() => false);
try {
process.env['GITHUB_SERVER_URL'] = 'http://example.com';
isCacheFeatureAvailable();
} catch (error) {
expect(error).toHaveProperty(
'message',
'Caching is only supported on GHES version >= 3.5. If you are on a version >= 3.5, please check with your GHES admin if the Actions cache service is enabled or not.'
);
} finally {
delete process.env['GITHUB_SERVER_URL'];
}
});
it('isCacheFeatureAvailable disabled on dotcom', () => {
jest.spyOn(cache, 'isFeatureAvailable').mockImplementation(() => false);
const infoMock = jest.spyOn(core, 'warning');
const message = 'The runner was not able to contact the cache service. Caching will be skipped';
try {
process.env['GITHUB_SERVER_URL'] = 'http://github.com';
expect(isCacheFeatureAvailable()).toBe(false);
expect(infoMock).toHaveBeenCalledWith(message);
} finally {
delete process.env['GITHUB_SERVER_URL'];
}
});
it('isCacheFeatureAvailable is enabled', () => {
jest.spyOn(cache, 'isFeatureAvailable').mockImplementation(() => true);
expect(isCacheFeatureAvailable()).toBe(true);
});
});

View File

@ -54,7 +54,7 @@ inputs:
$GPG_PASSPHRASE.' $GPG_PASSPHRASE.'
required: false required: false
cache: cache:
description: 'Name of the build platform to cache dependencies. It can be "maven" or "gradle".' description: 'Name of the build platform to cache dependencies. It can be "maven", "gradle" or "sbt".'
required: false required: false
job-status: job-status:
description: 'Workaround to pass job status to post job step. This variable is not intended for manual setting' description: 'Workaround to pass job status to post job step. This variable is not intended for manual setting'
@ -67,6 +67,6 @@ outputs:
path: path:
description: 'Path to where the java environment has been installed (same as $JAVA_HOME)' description: 'Path to where the java environment has been installed (same as $JAVA_HOME)'
runs: runs:
using: 'node12' using: 'node16'
main: 'dist/setup/index.js' main: 'dist/setup/index.js'
post: 'dist/cleanup/index.js' post: 'dist/cleanup/index.js'

62693
dist/cleanup/index.js vendored

File diff suppressed because one or more lines are too long

183704
dist/setup/index.js vendored

File diff suppressed because one or more lines are too long

View File

@ -3,6 +3,9 @@
- [Eclipse Temurin](#Eclipse-Temurin) - [Eclipse Temurin](#Eclipse-Temurin)
- [Adopt](#Adopt) - [Adopt](#Adopt)
- [Zulu](#Zulu) - [Zulu](#Zulu)
- [Liberica](#Liberica)
- [Microsoft](#Microsoft)
- [Amazon Corretto](#Amazon-Corretto)
- [Installing custom Java package type](#Installing-custom-Java-package-type) - [Installing custom Java package type](#Installing-custom-Java-package-type)
- [Installing custom Java architecture](#Installing-custom-Java-architecture) - [Installing custom Java architecture](#Installing-custom-Java-architecture)
- [Installing custom Java distribution from local file](#Installing-Java-from-local-file) - [Installing custom Java distribution from local file](#Installing-Java-from-local-file)
@ -20,8 +23,8 @@ Inputs `java-version` and `distribution` are mandatory and needs to be provided.
### Eclipse Temurin ### Eclipse Temurin
```yaml ```yaml
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
- uses: actions/setup-java@v2 - uses: actions/setup-java@v3
with: with:
distribution: 'temurin' distribution: 'temurin'
java-version: '11' java-version: '11'
@ -33,8 +36,8 @@ steps:
```yaml ```yaml
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
- uses: actions/setup-java@v2 - uses: actions/setup-java@v3
with: with:
distribution: 'adopt-hotspot' distribution: 'adopt-hotspot'
java-version: '11' java-version: '11'
@ -44,8 +47,8 @@ steps:
### Zulu ### Zulu
```yaml ```yaml
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
- uses: actions/setup-java@v2 - uses: actions/setup-java@v3
with: with:
distribution: 'zulu' distribution: 'zulu'
java-version: '11' java-version: '11'
@ -56,8 +59,8 @@ steps:
### Liberica ### Liberica
```yaml ```yaml
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
- uses: actions/setup-java@v2 - uses: actions/setup-java@v3
with: with:
distribution: 'liberica' distribution: 'liberica'
java-version: '11' java-version: '11'
@ -68,19 +71,32 @@ steps:
### Microsoft ### Microsoft
```yaml ```yaml
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
- uses: actions/setup-java@v2 - uses: actions/setup-java@v3
with: with:
distribution: 'microsoft' distribution: 'microsoft'
java-version: '11' java-version: '11'
- run: java -cp java HelloWorldApp - run: java -cp java HelloWorldApp
``` ```
### Amazon Corretto
**NOTE:** Amazon Corretto only supports the major version specification.
```yaml
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
distribution: 'corretto'
java-version: '11'
- run: java -cp java HelloWorldApp
```
## Installing custom Java package type ## Installing custom Java package type
```yaml ```yaml
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
- uses: actions/setup-java@v2 - uses: actions/setup-java@v3
with: with:
distribution: '<distribution>' distribution: '<distribution>'
java-version: '11' java-version: '11'
@ -93,8 +109,8 @@ steps:
```yaml ```yaml
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
- uses: actions/setup-java@v2 - uses: actions/setup-java@v3
with: with:
distribution: '<distribution>' distribution: '<distribution>'
java-version: '11' java-version: '11'
@ -110,7 +126,7 @@ steps:
- run: | - run: |
download_url="https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.10%2B9/OpenJDK11U-jdk_x64_linux_hotspot_11.0.10_9.tar.gz" download_url="https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.10%2B9/OpenJDK11U-jdk_x64_linux_hotspot_11.0.10_9.tar.gz"
wget -O $RUNNER_TEMP/java_package.tar.gz $download_url wget -O $RUNNER_TEMP/java_package.tar.gz $download_url
- uses: actions/setup-java@v2 - uses: actions/setup-java@v3
with: with:
distribution: 'jdkfile' distribution: 'jdkfile'
jdkFile: ${{ runner.temp }}/java_package.tar.gz jdkFile: ${{ runner.temp }}/java_package.tar.gz
@ -132,9 +148,9 @@ jobs:
java: [ '8', '11' ] java: [ '8', '11' ]
name: Java ${{ matrix.Java }} (${{ matrix.distribution }}) sample name: Java ${{ matrix.Java }} (${{ matrix.distribution }}) sample
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
- name: Setup java - name: Setup java
uses: actions/setup-java@v2 uses: actions/setup-java@v3
with: with:
distribution: ${{ matrix.distribution }} distribution: ${{ matrix.distribution }}
java-version: ${{ matrix.java }} java-version: ${{ matrix.java }}
@ -152,9 +168,9 @@ jobs:
os: [ 'ubuntu-latest', 'macos-latest', 'windows-latest' ] os: [ 'ubuntu-latest', 'macos-latest', 'windows-latest' ]
name: Java ${{ matrix.Java }} (${{ matrix.os }}) sample name: Java ${{ matrix.Java }} (${{ matrix.os }}) sample
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
- name: Setup java - name: Setup java
uses: actions/setup-java@v2 uses: actions/setup-java@v3
with: with:
distribution: 'temurin' distribution: 'temurin'
java-version: ${{ matrix.java }} java-version: ${{ matrix.java }}
@ -169,9 +185,9 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
- name: Set up JDK 11 - name: Set up JDK 11
uses: actions/setup-java@v2 uses: actions/setup-java@v3
with: with:
distribution: '<distribution>' distribution: '<distribution>'
java-version: '11' java-version: '11'
@ -185,7 +201,7 @@ jobs:
GITHUB_TOKEN: ${{ github.token }} # GITHUB_TOKEN is the default env for the password GITHUB_TOKEN: ${{ github.token }} # GITHUB_TOKEN is the default env for the password
- name: Set up Apache Maven Central - name: Set up Apache Maven Central
uses: actions/setup-java@v2 uses: actions/setup-java@v3
with: # running setup-java again overwrites the settings.xml with: # running setup-java again overwrites the settings.xml
distribution: 'temurin' distribution: 'temurin'
java-version: '11' java-version: '11'
@ -280,9 +296,9 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
- name: Set up JDK 11 for Shared Runner - name: Set up JDK 11 for Shared Runner
uses: actions/setup-java@v2 uses: actions/setup-java@v3
with: with:
distribution: '<distribution>' distribution: '<distribution>'
java-version: '11' java-version: '11'
@ -306,10 +322,10 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
- name: Set up JDK 11 - name: Set up JDK 11
uses: actions/setup-java@v2 uses: actions/setup-java@v3
with: with:
distribution: '<distribution>' distribution: '<distribution>'
java-version: '11' java-version: '11'

6757
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
{ {
"name": "setup-java", "name": "setup-java",
"version": "2.0.0", "version": "3.1.1",
"private": true, "private": true,
"description": "setup java action", "description": "setup java action",
"main": "dist/setup/index.js", "main": "dist/setup/index.js",
@ -24,7 +24,7 @@
"author": "GitHub", "author": "GitHub",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@actions/cache": "^1.0.8", "@actions/cache": "^2.0.2",
"@actions/core": "^1.2.6", "@actions/core": "^1.2.6",
"@actions/exec": "^1.0.4", "@actions/exec": "^1.0.4",
"@actions/glob": "^0.2.0", "@actions/glob": "^0.2.0",
@ -36,19 +36,13 @@
}, },
"devDependencies": { "devDependencies": {
"@types/jest": "^27.0.2", "@types/jest": "^27.0.2",
"@types/node": "^12.19.13", "@types/node": "^16.11.25",
"@types/semver": "^7.3.4", "@types/semver": "^7.3.4",
"@zeit/ncc": "^0.20.5",
"jest": "^27.2.5", "jest": "^27.2.5",
"jest-circus": "^27.2.5", "jest-circus": "^27.2.5",
"@vercel/ncc": "^0.33.4",
"prettier": "^1.19.1", "prettier": "^1.19.1",
"ts-jest": "^27.0.5", "ts-jest": "^27.0.5",
"typescript": "^4.2.3" "typescript": "^4.2.3"
},
"husky": {
"skipCI": true,
"hooks": {
"pre-commit": "npm run build && npm run format"
}
} }
} }

View File

@ -13,7 +13,7 @@ const CACHE_MATCHED_KEY = 'cache-matched-key';
const CACHE_KEY_PREFIX = 'setup-java'; const CACHE_KEY_PREFIX = 'setup-java';
interface PackageManager { interface PackageManager {
id: 'maven' | 'gradle'; id: 'maven' | 'gradle' | 'sbt';
/** /**
* Paths of the file that specify the files to cache. * Paths of the file that specify the files to cache.
*/ */
@ -32,9 +32,28 @@ const supportedPackageManager: PackageManager[] = [
path: [join(os.homedir(), '.gradle', 'caches'), join(os.homedir(), '.gradle', 'wrapper')], path: [join(os.homedir(), '.gradle', 'caches'), join(os.homedir(), '.gradle', 'wrapper')],
// https://github.com/actions/cache/blob/0638051e9af2c23d10bb70fa9beffcad6cff9ce3/examples.md#java---gradle // https://github.com/actions/cache/blob/0638051e9af2c23d10bb70fa9beffcad6cff9ce3/examples.md#java---gradle
pattern: ['**/*.gradle*', '**/gradle-wrapper.properties'] pattern: ['**/*.gradle*', '**/gradle-wrapper.properties']
},
{
id: 'sbt',
path: [
join(os.homedir(), '.ivy2', 'cache'),
join(os.homedir(), '.sbt'),
getCoursierCachePath(),
// Some files should not be cached to avoid resolution problems.
// In particular the resolution of snapshots (ideological gap between maven/ivy).
'!' + join(os.homedir(), '.sbt', '*.lock'),
'!' + join(os.homedir(), '**', 'ivydata-*.properties')
],
pattern: ['**/*.sbt', '**/project/build.properties', '**/project/**.{scala,sbt}']
} }
]; ];
function getCoursierCachePath(): string {
if (os.type() === 'Linux') return join(os.homedir(), '.cache', 'coursier');
if (os.type() === 'Darwin') return join(os.homedir(), 'Library', 'Caches', 'Coursier');
return join(os.homedir(), 'AppData', 'Local', 'Coursier', 'Cache');
}
function findPackageManager(id: string): PackageManager { function findPackageManager(id: string): PackageManager {
const packageManager = supportedPackageManager.find(packageManager => packageManager.id === id); const packageManager = supportedPackageManager.find(packageManager => packageManager.id === id);
if (packageManager === undefined) { if (packageManager === undefined) {
@ -77,8 +96,10 @@ export async function restore(id: string) {
]); ]);
if (matchedKey) { if (matchedKey) {
core.saveState(CACHE_MATCHED_KEY, matchedKey); core.saveState(CACHE_MATCHED_KEY, matchedKey);
core.setOutput('cache-hit', matchedKey === primaryKey);
core.info(`Cache restored from key: ${matchedKey}`); core.info(`Cache restored from key: ${matchedKey}`);
} else { } else {
core.setOutput('cache-hit', false);
core.info(`${packageManager.id} cache is not found`); core.info(`${packageManager.id} cache is not found`);
} }
} }

View File

@ -4,7 +4,7 @@ import * as fs from 'fs';
import semver from 'semver'; import semver from 'semver';
import path from 'path'; import path from 'path';
import * as httpm from '@actions/http-client'; import * as httpm from '@actions/http-client';
import { getToolcachePath, getVersionFromToolcachePath, isVersionSatisfies } from '../util'; import { getToolcachePath, isVersionSatisfies } from '../util';
import { JavaDownloadRelease, JavaInstallerOptions, JavaInstallerResults } from './base-models'; import { JavaDownloadRelease, JavaInstallerOptions, JavaInstallerResults } from './base-models';
import { MACOS_JAVA_CONTENT_POSTFIX } from '../constants'; import { MACOS_JAVA_CONTENT_POSTFIX } from '../constants';

View File

@ -0,0 +1,155 @@
import * as core from '@actions/core';
import * as tc from '@actions/tool-cache';
import fs from 'fs';
import path from 'path';
import { extractJdkFile, getDownloadArchiveExtension } from '../../util';
import { JavaBase } from '../base-installer';
import { JavaDownloadRelease, JavaInstallerOptions, JavaInstallerResults } from '../base-models';
import { ICorrettoAllAvailableVersions, ICorettoAvailableVersions } from './models';
export class CorrettoDistribution extends JavaBase {
constructor(installerOptions: JavaInstallerOptions) {
super('Corretto', installerOptions);
}
protected async downloadTool(javaRelease: JavaDownloadRelease): Promise<JavaInstallerResults> {
core.info(
`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`
);
const javaArchivePath = await tc.downloadTool(javaRelease.url);
core.info(`Extracting Java archive...`);
const extractedJavaPath = await extractJdkFile(javaArchivePath, getDownloadArchiveExtension());
const archiveName = fs.readdirSync(extractedJavaPath)[0];
const archivePath = path.join(extractedJavaPath, archiveName);
const version = this.getToolcacheVersionName(javaRelease.version);
const javaPath = await tc.cacheDir(
archivePath,
this.toolcacheFolderName,
version,
this.architecture
);
return { version: javaRelease.version, path: javaPath };
}
protected async findPackageForDownload(version: string): Promise<JavaDownloadRelease> {
if (!this.stable) {
throw new Error('Early access versions are not supported');
}
if (version.includes('.')) {
throw new Error('Only major versions are supported');
}
const availableVersions = await this.getAvailableVersions();
const matchingVersions = availableVersions
.filter(item => item.version == version)
.map(item => {
return {
version: item.correttoVersion,
url: item.downloadLink
} as JavaDownloadRelease;
});
const resolvedVersion = matchingVersions.length > 0 ? matchingVersions[0] : null;
if (!resolvedVersion) {
const availableOptions = availableVersions.map(item => item.version).join(', ');
const availableOptionsMessage = availableOptions
? `\nAvailable versions: ${availableOptions}`
: '';
throw new Error(
`Could not find satisfied version for SemVer '${version}'. ${availableOptionsMessage}`
);
}
return resolvedVersion;
}
private async getAvailableVersions(): Promise<ICorettoAvailableVersions[]> {
const platform = this.getPlatformOption();
const arch = this.architecture;
const imageType = this.packageType;
console.time('coretto-retrieve-available-versions');
const availableVersionsUrl =
'https://corretto.github.io/corretto-downloads/latest_links/indexmap_with_checksum.json';
const fetchCurrentVersions = await this.http.getJson<ICorrettoAllAvailableVersions>(
availableVersionsUrl
);
const fetchedCurrentVersions = fetchCurrentVersions.result;
if (!fetchedCurrentVersions) {
throw Error(`Could not fetch latest corretto versions from ${availableVersionsUrl}`);
}
const eligbleVersions = fetchedCurrentVersions?.[platform]?.[arch]?.[imageType];
const availableVersions = this.getAvailableVersionsForPlatform(eligbleVersions);
if (core.isDebug()) {
this.printAvailableVersions(availableVersions);
}
return availableVersions;
}
private getAvailableVersionsForPlatform(
eligbleVersions: ICorrettoAllAvailableVersions['os']['arch']['imageType'] | undefined
): ICorettoAvailableVersions[] {
const availableVersions: ICorettoAvailableVersions[] = [];
for (const version in eligbleVersions) {
const availableVersion = eligbleVersions[version];
for (const fileType in availableVersion) {
const skipNonExtractableBinaries = fileType != getDownloadArchiveExtension();
if (skipNonExtractableBinaries) {
continue;
}
const availableVersionDetails = availableVersion[fileType];
const correttoVersion = this.getCorettoVersion(availableVersionDetails.resource);
availableVersions.push({
checksum: availableVersionDetails.checksum,
checksum_sha256: availableVersionDetails.checksum_sha256,
fileType,
resource: availableVersionDetails.resource,
downloadLink: `https://corretto.aws${availableVersionDetails.resource}`,
version: version,
correttoVersion
});
}
}
return availableVersions;
}
private printAvailableVersions(availableVersions: ICorettoAvailableVersions[]) {
core.startGroup('Print information about available versions');
console.timeEnd('coretto-retrieve-available-versions');
console.log(`Available versions: [${availableVersions.length}]`);
console.log(
availableVersions.map(item => `${item.version}: ${item.correttoVersion}`).join(', ')
);
core.endGroup();
}
private getPlatformOption(): string {
// Coretto has its own platform names so we need to map them
switch (process.platform) {
case 'darwin':
return 'macos';
case 'win32':
return 'windows';
default:
return process.platform;
}
}
private getCorettoVersion(resource: string): string {
const regex = /(\d+.+)\//;
const match = regex.exec(resource);
if (match === null) {
throw Error(`Could not parse corretto version from ${resource}`);
}
return match[1];
}
}

View File

@ -0,0 +1,25 @@
export interface ICorrettoAllAvailableVersions {
[os: string]: {
[arch: string]: {
[distributionType: string]: {
[version: string]: {
[fileType: string]: {
checksum: string;
checksum_sha256: string;
resource: string;
};
};
};
};
};
}
export interface ICorettoAvailableVersions {
version: string;
fileType: string;
checksum: string;
checksum_sha256: string;
resource: string;
downloadLink: string;
correttoVersion: string;
}

View File

@ -6,6 +6,7 @@ import { AdoptDistribution, AdoptImplementation } from './adopt/installer';
import { TemurinDistribution, TemurinImplementation } from './temurin/installer'; import { TemurinDistribution, TemurinImplementation } from './temurin/installer';
import { LibericaDistributions } from './liberica/installer'; import { LibericaDistributions } from './liberica/installer';
import { MicrosoftDistributions } from './microsoft/installer'; import { MicrosoftDistributions } from './microsoft/installer';
import { CorrettoDistribution } from './corretto/installer';
enum JavaDistribution { enum JavaDistribution {
Adopt = 'adopt', Adopt = 'adopt',
@ -15,7 +16,8 @@ enum JavaDistribution {
Zulu = 'zulu', Zulu = 'zulu',
Liberica = 'liberica', Liberica = 'liberica',
JdkFile = 'jdkfile', JdkFile = 'jdkfile',
Microsoft = 'microsoft' Microsoft = 'microsoft',
Corretto = 'corretto'
} }
export function getJavaDistribution( export function getJavaDistribution(
@ -39,6 +41,8 @@ export function getJavaDistribution(
return new LibericaDistributions(installerOptions); return new LibericaDistributions(installerOptions);
case JavaDistribution.Microsoft: case JavaDistribution.Microsoft:
return new MicrosoftDistributions(installerOptions); return new MicrosoftDistributions(installerOptions);
case JavaDistribution.Corretto:
return new CorrettoDistribution(installerOptions);
default: default:
return null; return null;
} }

View File

@ -80,11 +80,17 @@ export class MicrosoftDistributions extends JavaBase {
// TODO get these dynamically! // TODO get these dynamically!
// We will need Microsoft to add an endpoint where we can query for versions. // We will need Microsoft to add an endpoint where we can query for versions.
const jdkVersions = [ const jdkVersions = [
{
version: [17, 0, 3]
},
{ {
version: [17, 0, 1, 12, 1] version: [17, 0, 1, 12, 1]
}, },
{ {
version: [16, 0, 2, 7, 1] version: [16, 0, 2, 7, 1]
},
{
version: [11, 0, 15]
} }
]; ];

View File

@ -133,6 +133,8 @@ export class ZuluDistribution extends JavaBase {
return { arch: 'x86', hw_bitness: '64', abi: '' }; return { arch: 'x86', hw_bitness: '64', abi: '' };
} else if (this.architecture == 'x86') { } else if (this.architecture == 'x86') {
return { arch: 'x86', hw_bitness: '32', abi: '' }; return { arch: 'x86', hw_bitness: '32', abi: '' };
} else if (this.architecture == 'arm64') {
return { arch: 'arm', hw_bitness: '64', abi: '' };
} else { } else {
return { arch: this.architecture, hw_bitness: '', abi: '' }; return { arch: this.architecture, hw_bitness: '', abi: '' };
} }

View File

@ -1,6 +1,6 @@
import * as core from '@actions/core'; import * as core from '@actions/core';
import * as auth from './auth'; import * as auth from './auth';
import { getBooleanInput } from './util'; import { getBooleanInput, isCacheFeatureAvailable } from './util';
import * as constants from './constants'; import * as constants from './constants';
import { restore } from './cache'; import { restore } from './cache';
import * as path from 'path'; import * as path from 'path';
@ -42,7 +42,7 @@ async function run() {
core.info(`##[add-matcher]${path.join(matchersPath, 'java.json')}`); core.info(`##[add-matcher]${path.join(matchersPath, 'java.json')}`);
await auth.configureAuthentication(); await auth.configureAuthentication();
if (cache) { if (cache && isCacheFeatureAvailable()) {
await restore(cache); await restore(cache);
} }
} catch (error) { } catch (error) {

View File

@ -2,6 +2,7 @@ import os from 'os';
import path from 'path'; import path from 'path';
import * as fs from 'fs'; import * as fs from 'fs';
import * as semver from 'semver'; import * as semver from 'semver';
import * as cache from '@actions/cache';
import * as core from '@actions/core'; import * as core from '@actions/core';
import * as tc from '@actions/tool-cache'; import * as tc from '@actions/tool-cache';
@ -77,3 +78,24 @@ export function isJobStatusSuccess() {
return jobStatus === 'success'; return jobStatus === 'success';
} }
export function isGhes(): boolean {
const ghUrl = new URL(process.env['GITHUB_SERVER_URL'] || 'https://github.com');
return ghUrl.hostname.toUpperCase() !== 'GITHUB.COM';
}
export function isCacheFeatureAvailable(): boolean {
if (!cache.isFeatureAvailable()) {
if (isGhes()) {
throw new Error(
'Caching is only supported on GHES version >= 3.5. If you are on a version >= 3.5, please check with your GHES admin if the Actions cache service is enabled or not.'
);
} else {
core.warning('The runner was not able to contact the cache service. Caching will be skipped');
}
return false;
}
return true;
}