Compare commits

...

183 Commits
v2.5.1 ... main

Author SHA1 Message Date
mahabaleshwars a1c6c9c867
Updated advanced-usage.md (#622)
* Update advanced-usage.md

* Update advanced-usage.md

* Update advanced-usage.md

* Update README.md

* Update advanced-usage.md
2024-05-03 08:29:31 -05:00
mahabaleshwars 99b8673ff6
Patch for java version file (#610)
* patch to extract file from other location

* patch to extract filename from other directories

* removed code failing checks

* changed the validation for .java-version type
2024-03-14 09:12:58 -05:00
mahabaleshwars 5896cecc08
Added .tool-versions file support (#606)
* added support for tool version file

* testing with one regex

* working regex

* Checked for the file extension

* added e2e checks for tool version

* removed error warning

* updated regex to support early version

* updated regex for early version support

* updated regex for early version

* updated regex to accept early versions

* added coreinfo to analyze

* updated the regex

* updated regex

* new regex for early version

* updated regex to match the new version file format

* new regex

* changed the regex

* redex updated

* used java version regex

* regex updated

* regex modified

* regex updated

* regex updated

* regex updated

* updated regex to support early versions

* Regex updated to support all java versions

* Documentation updated to add tool version description

* Documentation updated for the tool version file

* update the advanced doc and readme file to specify tool version changes
2024-03-12 08:45:42 -05:00
HarithaVattikuti 80ae3c2885
Update httpclient version and other dependencies (#607)
* test

* fixed license issues

* fix audit issue

* fix license
2024-03-08 10:25:58 -06:00
mahabaleshwars 9704b39bf2
Added Windows Arm64 Support for Windows Arm64 Runners (#595)
* Added Windows Arm64 Support for Windows Arm64 Runners

* microsoft test file update and tool-version test file

* Delete .DS_Store

* added test cases for windows and linux for zulu, liberica and microsoft

* adding different data files for each OS

* added changes to distribution files

* added more version support for microsoft
2024-02-27 23:11:33 -06:00
Michael Keppler 7a445ee88d
Fix typo in configuration example (#572) 2023-12-21 10:03:21 +01:00
Julien Dubois 3232623d9c
Oracle JDK 21 support (#538)
* Allow Oracle JDK 21 usage

* Fix tests

* Add Java 21 support in the documentation

---------

Co-authored-by: Ivan Zosimov <ivanzosimov@github.com>
2023-12-14 14:46:05 +01:00
Ivan c0660d8edc
docs: add note about maven-gpg-plugin version (#570) 2023-12-14 14:28:01 +01:00
Nikolas Grottendieck 2f7af1b9c5
make it clear that Java 21 is supported (#566)
Update examples and references to Java where older Java versions are used to
highlight the support of Java 21.

Specific provider examples are only updated where they support Java 21.

Fixes #557
2023-12-14 14:27:46 +01:00
Peter Murray 16ef37f8dd
HTTP errors when the token is undefined (#556)
* Fixing issues with the handling of the token and avoiding error on when the token is undefined

* chore: rebuild action

---------

Co-authored-by: Ivan Zosimov <ivanzosimov@github.com>
2023-12-01 14:55:03 +01:00
K.B.Dharun Krishna a2374547df
feat: bump actions/checkout and actions/setup-java to v4 (#533)
* eat: bump to use node20 runtime, actions/checkout to v4

* docs: update version of setup-java in documentation and e2e tests

---------

Co-authored-by: Ivan Zosimov <ivanzosimov@github.com>
2023-12-01 11:16:32 +01:00
aparnajyothi-y 387ac29b30
Upgrade Node to v20 (#558)
* Build changes

* 4.0.0

* node version update

* changes

* upgrade to v20

* Removing conflicts

* Upgrade to v20 in the reusable workflows

* Rebased index.js

* Removing conflicts

* Resolving conflicts

* Fomat check

* failed checks fix
2023-11-29 15:11:46 +01:00
itchyny 9eda6b51cc
feat: implement cache-dependency-path option to control caching dependency (#499) 2023-11-22 16:43:14 +01:00
Ivan 78078da0cd
Update @actions/cache dependency and documentation (#549)
* deps: Update actions/cache dep, rebuild solution, update docs

* docs: fix typo

* deps: update jest dependencies and licenses

* deps: fix vulnerable dependencies, rebuild solution

* licenses: update
2023-10-17 11:09:10 +02:00
Ralf Stuckert 5caaba646e
add support for microsoft openjdk 21.0.0 (#546)
* support for microsoft openjdk 21.0.0

* support for microsoft openjdk 21.0.0
2023-10-17 10:19:17 +02:00
Accelerator1996 0ab4596768
add support for dragonwell (#532)
* add support for dragonwell

* fix: update logic of parsing json file, refactor code

* build: rebuild action

* chore: update error message

* build: rebuild action

* tests: fix unit tests, add e2e tests

* chore: prettier, lint and rebuild solution

* feat: add check for the package type, update unit tests

* tests: update e2e tests

* tests: remove excess entries from e2e tests

* feat: update logic of getting json file

* feat: add logic for backuping getting json

* chore: update wordings

* chore: fix typos, add additional logs

* fix: fix review points

* chore: rebuild solution

* chore: update wordings

* chore: refactor code

---------

Co-authored-by: Ivan Zosimov <ivanzosimov@github.com>
Co-authored-by: Ivan <98037481+IvanZosimov@users.noreply.github.com>
2023-09-20 13:22:11 +02:00
Marko Zivic 4075bfc1b5
Merge pull request #503 from gnodet/fix-xml-namespaces
Fix XML namespaces wrongly using https
2023-08-31 06:15:25 +02:00
Orleando Dassi 5b86b67f5b
Fixed usage link within the README.md file (#525) 2023-08-16 01:01:53 +02:00
CyberFlame b943a4ed87
fix typo and remove unintentional(?) word (#518)
* fix typo and remove unintentional(?) word

* docs: fix typo in the Readme.md

---------

Co-authored-by: Ivan Zosimov <ivanzosimov@github.com>
2023-07-31 11:29:53 +02:00
dependabot[bot] c16064d22c
Bump word-wrap from 1.2.3 to 1.2.4 (#516)
Bumps [word-wrap](https://github.com/jonschlinkert/word-wrap) from 1.2.3 to 1.2.4.
- [Release notes](https://github.com/jonschlinkert/word-wrap/releases)
- [Commits](https://github.com/jonschlinkert/word-wrap/compare/1.2.3...1.2.4)

---
updated-dependencies:
- dependency-name: word-wrap
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-07-27 13:48:48 +02:00
Endi327 cd89f46ac9
Add versions properties to cache (#280)
* Add versions properties to cache

* lint fix

npm run format change

* [FIX] unit test

* docs: fix typo in the Readme.md

* docs: update link to the toolkit/cache package

---------

Co-authored-by: Ivan Zosimov <ivan.zosimov@Ivans-MacBook-Pro.local>
2023-07-21 13:38:46 +02:00
Nikolai Laevskii 4fb397523b
Merge pull request #507 from akv-platform/update-oracle-jdk-url-calculation
Update Oracle JDK download URL calculation
2023-07-18 11:04:49 +02:00
Nikolai Laevskii 33b10b64eb Use archive as fallback only when dealing with major version 2023-07-18 09:28:12 +02:00
Ivan 75c6561172
Update dependencies (#511)
* chore: update dependencies, rebuild action

* chore: update licenses

* chore: rebuild action on linux
2023-07-10 17:20:15 +02:00
Nikolai Laevskii ebe05e0f88 Update build 2023-07-05 09:34:35 +02:00
Nikolai Laevskii 46099e1f14 Build 2023-07-05 09:34:34 +02:00
Nikolai Laevskii 1a3cd386c6 Update Oracle JDK URL calculation 2023-07-05 09:34:34 +02:00
Guillaume Nodet 91f49aa1b0 Fix XML namespaces wrongly using https 2023-06-28 11:24:07 +02:00
ragsmpl 1f2faad7e0
Instruction to download custom distribution JDK and install (#500) 2023-06-20 16:41:21 +02:00
Dmitry Shibanov 45058d7f99
Update xml2js (#484) 2023-06-15 17:41:12 +02:00
Nikolai Laevskii 87c1c7064c
Merge pull request #494 from akv-platform/remove-implicit-dependencies
Remove implicit dependencies
2023-06-08 11:53:50 +02:00
Nikolai Laevskii 5e4a7c3698 Move eslint-plugin-node to dev dependencies 2023-06-08 11:46:31 +02:00
Nikolai Laevskii f4213ceea0 Install eslint-plugin-node 2023-06-08 11:46:31 +02:00
github-actions[bot] ba4a2dd11d Update configuration files 2023-06-08 11:46:30 +02:00
Nikolai Laevskii 01a228c633
Merge pull request #498 from akv-platform/update-mocks
Update mocks
2023-06-08 11:44:43 +02:00
Nikolai Laevskii 07b6c30c67 Add mocks for oracle installer 2023-06-08 11:00:37 +02:00
Nikolai Laevskii c19d52bc93 Add mock data for microsoft-installer 2023-06-08 11:00:37 +02:00
Nikolai Laevskii 3927f47357
Merge pull request #489 from anishi1222/main
Update versions of Oracle JDK and Microsoft Build of OpenJDK
2023-06-08 10:58:50 +02:00
Akihiro Nishikawa cb77eb7f64
Merge pull request #1 from anishi1222/anishi1222-patch-1
Anishi1222 patch 1
2023-05-09 20:24:39 -07:00
Akihiro Nishikawa 9ff43a1ebe
Update microsoft-installer.test.ts 2023-05-10 12:20:09 +09:00
Akihiro Nishikawa 575d86297c
Update microsoft-openjdk-versions.json
Following Ivan's comment, versions of JDK are added.
2023-05-10 12:13:53 +09:00
Akihiro Nishikawa d70493eaf0
Update e2e-versions.yml 2023-05-08 18:48:02 +09:00
Akihiro Nishikawa 088a9ed5f6 Version updated for Oracle JDK 2023-05-06 18:54:05 +09:00
Akihiro Nishikawa 8d9836d093 Update versions 2023-05-06 18:41:28 +09:00
Akihiro Nishikawa 9f75459cbe Revert "Versions updated."
This reverts commit 827f99856d.

revert
2023-05-06 18:20:59 +09:00
Akihiro Nishikawa 827f99856d Versions updated. 2023-05-06 18:18:14 +09:00
Akihiro Nishikawa 27bb911606
Update microsoft-openjdk-versions.json 2023-05-06 18:00:17 +09:00
Ivan ddb82ce8a6
Corretto toolcache folder name fix (#480) 2023-04-10 10:29:19 +02:00
Doğaç Eldenk 404e5db3a1
fix sbt/scala cache key (#478) 2023-04-10 09:56:26 +02:00
Erwin Morrhey 191ba8c6ba
always check postfix "Contents/Home" on macOS (#397) 2023-04-04 11:40:40 +02:00
Ivan e42168ca1a
Fix glob bug in package.json scripts section (#475) 2023-04-03 12:48:27 +02:00
Jordie 5ffc13f417
IBM Semeru (OpenJ9) Support (#289) 2023-03-21 10:32:38 +01:00
github-actions[bot] 669e0727d8
Update configuration files (#464)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-03-15 00:34:22 +01:00
Marko Zivic 888b4006f3
Merge pull request #463 from akv-platform/reusable-workflow
Turn on automatic update of ESLint and Prettier configuration files
2023-03-10 10:56:11 +01:00
IvanZosimov 676c490d4c Add update-config-files.yml 2023-03-09 13:55:42 +01:00
Ivan 0de5c66fc0
Add and configure ESLint and update configuration for Prettier (#458)
* Add ESLint config and update Prettier

* Update test files

* Rebuild action

* Update docs

* Update licenses

* Update tsconfig

* Rebuild action

* Update tsconfig.json

* Fix console.time calls

* Rebuild action

* Rebuild action on Linux
2023-03-09 14:49:35 +02:00
Benoit ea15b3b99c
Update advanced-usage.md (#436)
change to be consistent with https://github.com/actions/setup-java#usage
2023-02-08 10:47:39 +01:00
Dmitry Shibanov 14d87b223c
Add link to the Oracle distribution (#451) 2023-02-08 10:35:35 +01:00
Dmitry Shibanov 3f07048e3d
Revert "Revert "Add support for Oracle JDK (#401)" (#421)" (#450)
This reverts commit c3ac5dd0ed.
2023-02-07 16:29:21 +01:00
Ivan 9b86bbe88a
Update workflow badges (#449) 2023-01-31 08:48:23 +02:00
Piyush 8f12c5c4d1
Updated readme file (#446) 2023-01-19 13:22:11 +01:00
MaksimZhukov e11351903a
Update release-new-action-version.yml (#442) 2023-01-12 13:51:18 +01:00
dependabot[bot] 285fb318c5
Bump json5 from 2.2.0 to 2.2.3 (#439) 2023-01-09 09:54:28 +01:00
Marko Zivic 308abcba03
Merge pull request #437 from actions/update-code-owners
Update CODEOWNERS
2022-12-27 09:28:56 +01:00
Evgenii Korolevskii 03d1057e7d
Update CODEOWNERS 2022-12-26 09:43:06 +01:00
Marko Zivic d401f0c450
Merge pull request #435 from actions/update-codeowners
Update CODEOWNERS
2022-12-23 08:25:00 +01:00
Evgenii Korolevskii 5e1c7d44c8
update codeowners 2022-12-23 00:05:13 +01:00
Evgenii Korolevskii bf3c595741
Update CODEOWNERS 2022-12-23 00:04:11 +01:00
Ivan 35e7c82cf7
Merge pull request #433 from akv-platform/apply-reusable-workflows
Update action to use reusable workflows
2022-12-22 10:46:06 +02:00
IvanZosimov 5bbbb020e8 Fix review points 2022-12-20 15:38:24 +01:00
IvanZosimov 007465e618 Update action to use reusable-workflows repo 2022-12-19 13:38:39 +01:00
IvanZosimov 8a24ed99d8 Merge branch 'main' of https://github.com/akv-platform/setup-java into apply-reusable-workflows 2022-12-19 13:37:02 +01:00
IvanZosimov 3dc9295fa8 Updae codeql.yml 2022-12-16 17:07:00 +01:00
IvanZosimov 81f1f778b7 Update codeql.yml 2022-12-16 16:51:33 +01:00
Milos Pantic 06db6c25b8
Update architecture docs (#425) 2022-12-16 15:07:31 +01:00
Jongwoo Han 545223a83e
refactor: Use early return pattern to avoid nested conditions (#428) 2022-12-16 15:04:57 +01:00
IvanZosimov a3c7fb1220 Add links to reusable workflows 2022-12-15 16:41:32 +01:00
IvanZosimov 1eb7169fc2 Update workflows 2022-12-15 16:10:53 +01:00
IvanZosimov caaa9d738f Update workflows to use reusable-workflows 2022-12-14 14:53:47 +01:00
Evgenii Korolevskii 1df8dbefe2
Add support for java.version file (#426) 2022-12-13 12:45:14 +01:00
Dmitry Shibanov c3ac5dd0ed
Revert "Add support for Oracle JDK (#401)" (#421)
This reverts commit 6cdf39a6b6.

Co-authored-by: Brian Cristante <33549821+brcrista@users.noreply.github.com>
2022-12-05 17:45:21 +01:00
Ashley dcd29da2fa
Fix typo in README.md (#419)
`diractory` -> `directory`
2022-12-05 10:25:33 +01:00
James M. Greene 19eeec562b
Update to latest `actions/publish-action` (#411) 2022-11-23 17:28:23 +01:00
Dmitry Shibanov bd7e5d28eb
Update minimatch to 3.1.2 (#413) 2022-11-23 15:24:31 +01:00
Fabio Niephaus 6cdf39a6b6
Add support for Oracle JDK (#401) 2022-11-23 13:28:51 +01:00
Lorenzo Bettini 7db6b4554c
Eclipse Temurin instead of Adopt OpenJDK (#398) 2022-11-18 09:35:24 +01:00
Dmitry Shibanov bf2f02c4a7
Pass the token input through on GHES for Microsoft Build of OpenJDK (#395) 2022-11-18 09:33:59 +01:00
Kengo TODA de1bb2b0c5
feat: support Gradle version catalog (#394) 2022-10-17 18:34:41 +02:00
Sankalp Kotewar 2c53c1a588
Update actions/cache to 3.0.4 version (#392) 2022-10-17 12:12:57 +02:00
Wes Morgan 3617c43588
Default to runner architecture (#376) 2022-10-11 01:47:17 +02:00
Marcell Harmaci a82e6d0020
Update README.md (#391) 2022-10-10 15:28:56 +02:00
Marko Zivic fbb269240e
Merge pull request #390 from rentziass/rentziass/update-actions-core
Update @actions/core to 1.10.0
2022-10-07 13:50:24 +02:00
Francesco Renzi dfcd06a4b9 Update @actions/core to 1.10.0 2022-10-06 12:11:13 +01:00
Marko Zivic e150063ee4
Merge pull request #282 from Okeanos/maven-toolchains-support
Add Maven Toolchains Declaration (#276)
2022-09-28 15:22:23 +02:00
Nikolas Grottendieck eb1418aa81
Add Maven Toolchains Declaration (#276)
* Add (optional) Maven Toolchains Declaration after JDK is installed
* Extract common/shared Maven constants

Resolves #276
2022-09-27 17:25:52 +02:00
Marko Zivic 499ae9c28b
Merge pull request #387 from akv-platform/v-sdolin/issue-382-docs2
Add inputs documentation to README
2022-09-27 09:25:48 +02:00
Dmitry Shibanov a18c333f3f
Add versions-manifest.json for Microsoft Build of OpenJDK (#383) 2022-09-23 14:47:30 +02:00
Dmitry Shibanov 26eeac8c9e
Add json for Microsoft Build of OpenJDK (#386) 2022-09-22 16:10:29 +02:00
Sergey Dolin cdc5f296eb Fix cross-refernces 2022-09-22 15:55:15 +02:00
Sergey Dolin b80173ab1e Add inputs documentation to README 2022-09-22 09:11:29 +02:00
Dmitry Shibanov a96c2ca6ae
improve documentation and more emphasis to Java 17 (#379) 2022-09-09 14:49:09 +02:00
qhy040404 7bbeb80d24
Fix typo (#380) 2022-09-09 13:35:58 +02:00
Dmitry Shibanov d854b6da19
Add support for multiple jdks (#368) 2022-09-08 15:26:54 +02:00
ansraliant 749e4491fa
Add Cache Hit Output (#373) 2022-09-07 12:34:51 +02:00
Milos Pantic aa53851224
Update actions version in package json (#377) 2022-09-05 13:22:12 +02:00
Marko Zivic 5b36705a13
Merge pull request #364 from e-korolevskii/main
Update contributors guide
2022-08-10 16:44:08 +02:00
Evgenii Korolevskii 4656cbcede
Merge branch 'actions:main' into main 2022-08-10 16:38:09 +02:00
Marko Zivic ef96bec0e4
Merge pull request #274 from schuenadel/include-buildSrc-in-cache-key
Include *.kt files in buildSrc in cache key
2022-08-10 10:10:46 +02:00
Evgenii Korolevskii 8e8bf44561
Update docs/contributors.md
Co-authored-by: Ivan <98037481+IvanZosimov@users.noreply.github.com>
2022-08-09 23:55:25 +02:00
Evgenii Korolevskii 40dd195c45 rephased documents 2022-08-03 19:22:03 +02:00
Evgenii Korolevskii 858120d4a8 formating 2022-08-01 01:37:40 +02:00
Evgenii Korolevskii ad9cecf99b update contributors guide 2022-08-01 01:36:24 +02:00
Marko Zivic 8048bbee47
Merge pull request #352 from julienrf/patch-1
Make it clearer that the action supports Scala
2022-07-21 10:39:18 +02:00
Marko Zivic 9e9f60b996
Merge pull request #285 from schuenadel/suggest-clear-cache-after-dependency-update
Remove `restoreKeys` to clear cache after update
2022-07-15 09:21:07 +02:00
Marko Zivic 46f0194a3b
Merge pull request #351 from akv-platform/v-sdolin/issue-44
Add "Install multiple JDKs" README section
2022-07-15 09:18:12 +02:00
Sergey Dolin c69efbe773 Add distribution input 2022-07-15 09:14:25 +02:00
Sergey Dolin 3c69e15101 use @v3 version 2022-07-14 09:22:10 +02:00
Julien Richard-Foy bf1c35bd9d
Make it clearer that the action supports Scala 2022-07-07 09:29:35 +02:00
Sergey Dolin 66a84830d9 Remove unessary steps from the step 2022-07-07 09:11:25 +02:00
Sergey Dolin 8ac768a2cf Add "Install multiple JDKs" README section 2022-07-07 06:44:16 +02:00
Marko Zivic 2c7a4878f5
Merge pull request #350 from e-korolevskii/Add-tests-for-updated-cachetool-ver-(347)
test(cache): Add test for cachetool v 3.0
2022-07-06 14:44:41 +02:00
Evgenii Korolevskii e2f30c1450 test(cache): Add test for cachetool v 3.0
Not to fail workflow on cache service errors
2022-07-04 22:48:10 +02:00
Marko Zivic 2dfaeac2db
Merge pull request #347 from e-korolevskii/CacheVersionUpdateTo3
build(cache): Update cache tool version
2022-07-04 08:19:35 +02:00
Dmitry Shibanov aa24fa78d2 regenerate dist 2022-06-24 16:18:43 +02:00
Evgenii Korolevskii 25d94e7786 add build 2022-06-24 16:05:43 +02:00
Evgenii Korolevskii 2fc49d780a remove old build 2022-06-24 16:03:07 +02:00
Evgenii Korolevskii e6a4b93088 update licenses 2022-06-24 15:56:27 +02:00
Evgenii Korolevskii 821cc3dbd1 Merge branch 'CacheVersionUpdateTo3' of https://github.com/e-korolevskii/setup-java into CacheVersionUpdateTo3 2022-06-24 15:52:39 +02:00
Evgenii Korolevskii 4903eafcd7 update licenses 2022-06-24 15:52:29 +02:00
Evgenii Korolevskii a0500669b7 Merge branch 'main' into CacheVersionUpdateTo3 2022-06-24 15:42:06 +02:00
Evgenii Korolevskii d397c16c56 build(cache): Update cache tool version
Graceful handling of error (non-validation one)
2022-06-24 15:32:10 +02:00
Marko Zivic 16cca5479d
Merge pull request #346 from pjfanning/patch-1
sbt is a valid cache option value
2022-06-20 09:14:34 +02:00
PJ Fanning 7b469c48c4
sbt is a valid cache option value 2022-06-16 21:47:05 +01:00
Marko Zivic 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
Florian Meriaux 187f735c38
npm run format 2022-06-15 08:23:10 +02:00
Florian Meriaux 48576e577e
npm run release 2022-06-15 08:19:27 +02:00
Florian Meriaux fa01820a3b
add documentation notes 2022-06-15 08:17:30 +02:00
Marko Zivic 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
Marko Zivic 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
George Adams 4fba831118
fix test 2022-06-09 17:53:21 +01:00
George Adams 11556068a2
msft: bump jdk17 to 17.0.3 and add aarch64 support to jdk11 2022-06-09 09:39:57 +01:00
Marko Zivic 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
Pawel Palucha 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
Florian Meriaux 3e3d8c490f
sbt-cache: don't cache some files. 2022-05-25 11:39:10 +02:00
AGulev 72dec17e4f index.js 2022-05-25 08:41:31 +02:00
AGulev e8f1c8b5ca Add Microsoft 11.0.15 2022-05-24 19:12:23 +02:00
Adam Fisher 05b9e395e1
Updates the sbt cache docs in the README (#327) 2022-05-09 09:30:21 +02:00
Dmitry Shibanov 860f600565
Add Amazon Corretto example and fix links (#325) 2022-05-04 13:23:54 +02:00
Manuel bae3140877
Add Amazon Corretto distribution (#312) 2022-04-29 12:38:36 +02:00
Mario Schünadel fa0272551b Merge remote-tracking branch 'upstream/main' into suggest-clear-cache-after-dependency-update 2022-04-28 16:16:25 +02:00
Mario Schünadel 30cdb8c7dd upstream with main v3.2.0 2022-04-28 15:55:20 +02:00
Kengo TODA dd80852400
Housekeeping: Update zeit/ncc to vercel/ncc (#270) 2022-04-26 15:44:58 +02:00
IKEDA Sho 4fe61d24fe
[README] Add sbt as supported package manager for caching (#322) 2022-04-26 09:35:00 +02:00
Mario Schünadel 45b7b136cf only Versions.kt and Dependencies.kt as cache key 2022-04-25 13:40:12 +02:00
Mario Schünadel f56009127d fix dist/* 2022-04-25 13:13:12 +02:00
Mario Schünadel fa513641c0 Merge remote-tracking branch 'git@github.com-actions/setup-java.git/main' into include-buildSrc-in-cache-key 2022-04-25 12:43:44 +02:00
Dmitry Shibanov 055250a105
Add CODE_OF_CONDUCT (#318) 2022-04-20 16:26:58 +02:00
Florian Meriaux 0ed94a5678
Add SBT in cache managers. (#302) 2022-04-20 16:26:27 +02:00
Mario Schünadel 83b77aa58b
Merge branch 'actions:main' into suggest-clear-cache-after-dependency-update 2022-04-19 12:45:13 +02:00
Deepak Dahiya 9519cf1382
Merge pull request #317 from actions/t-dedah/updateCache
Updated @actions/cache
2022-04-11 19:06:07 +05:30
Deepak Dahiya 02c73de3fe Updated action version 2022-04-11 13:25:41 +00:00
Deepak Dahiya fd3f6750a0 Updated package-lock.json 2022-04-11 13:08:18 +00:00
Deepak Dahiya 1aa8bf7608 Licensed 2022-04-11 09:39:09 +00:00
Deepak Dahiya 9c8c90e08c Updated @actions/cache 2022-04-11 07:36:42 +00:00
Dmitry Shibanov cd35109007
Bump actions to v3 (#314) 2022-04-07 12:25:49 +02:00
Mario Schünadel d2e3f417a9
Set output `cache-hit` to indicate if cache was hit (#275) 2022-04-07 10:58:22 +02:00
dependabot[bot] 0aa6f2a84f
Bump minimist from 1.2.5 to 1.2.6 (#303) 2022-04-01 09:57:27 +02:00
Shubham Tiwari 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
Shubham Tiwari e886040dc2
Update zulu-installer.test.ts (#310) 2022-03-31 18:33:52 +02:00
Shubham Tiwari efbea1411b
Update util.ts 2022-03-31 20:49:24 +05:30
Shubham Tiwari c41070eda4
Update util.ts 2022-03-31 20:46:04 +05:30
Dmitry Shibanov f69f00b5e5
Update lockfileVersion (#293) 2022-02-24 14:42:37 +03:00
Thomas Boop 2e1dfa1fb4
Update Default runtime to node16 (#290) 2022-02-22 11:27:25 +03:00
Mario Schünadel efcb607a6b remove "restoreKeys" to clear cache after update 2022-01-25 15:35:45 +01:00
Mario Schünadel ca584e7011
Merge pull request #1 from schuenadel/include-buildSrc-in-cache-key
Include *.kt files in buildSrc in cache key
2022-01-13 14:16:30 +01:00
Mario Schünadel 69e93308b0 Include *.kt files in buildSrc in cache key 2022-01-13 13:46:49 +01:00
MaksimZhukov a12e082d83
Merge pull request #224 from KengoTODA/remove-husky
Housekeeping: remove the config for husky
2021-12-29 14:46:32 +03:00
MaksimZhukov 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
MaksimZhukov 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
Kengo TODA 6df0b04fb5 build: remove the config for husky
husky has been removed by 980efe8 at 2019 Nov.
2021-09-10 07:53:56 +08:00
Daniel Kraus a1ad2000b3 Describe cache key format in readme 2021-08-31 21:42:01 +02:00
Oscar Dominguez faa22ddfbc
style(workflows): restore single quote strings 2021-08-22 15:51:45 +02:00
Oscar Dominguez a388b3faf4 ci(workflow): add 'npm' cache for actions/setup-node in .github/workflows 2021-07-18 22:16:32 +02:00
139 changed files with 194240 additions and 129051 deletions

6
.eslintignore Normal file
View File

@ -0,0 +1,6 @@
# Ignore list
/*
# Do not ignore these folders:
!__tests__/
!src/

51
.eslintrc.js Normal file
View File

@ -0,0 +1,51 @@
// This is a reusable configuration file copied from https://github.com/actions/reusable-workflows/tree/main/reusable-configurations. Please don't make changes to this file as it's the subject of an automatic update.
module.exports = {
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:eslint-plugin-jest/recommended',
'eslint-config-prettier'
],
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint', 'eslint-plugin-node', 'eslint-plugin-jest'],
rules: {
'@typescript-eslint/no-require-imports': 'error',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/ban-ts-comment': [
'error',
{
'ts-ignore': 'allow-with-description'
}
],
'no-console': 'error',
'yoda': 'error',
'prefer-const': [
'error',
{
destructuring: 'all'
}
],
'no-control-regex': 'off',
'no-constant-condition': ['error', {checkLoops: false}],
'node/no-extraneous-import': 'error'
},
overrides: [
{
files: ['**/*{test,spec}.ts'],
rules: {
'@typescript-eslint/no-unused-vars': 'off',
'jest/no-standalone-expect': 'off',
'jest/no-conditional-expect': 'off',
'no-console': 'off',
}
}
],
env: {
node: true,
es6: true,
'jest/globals': true
}
};

1
.gitattributes vendored
View File

@ -1,3 +1,4 @@
* text=auto eol=lf
dist/index.js -diff -merge
dist/index.js linguist-generated=true
.licenses/** -diff linguist-generated=true

3
.github/CODEOWNERS vendored
View File

@ -1,2 +1 @@
* @actions/actions-service
* @actions/virtual-environments-owners
* @actions/setup-actions-team

View File

@ -1 +1 @@
blank_issues_enabled: false
blank_issues_enabled: false

19
.github/workflows/basic-validation.yml vendored Normal file
View File

@ -0,0 +1,19 @@
name: Basic validation
on:
push:
branches:
- main
- releases/*
paths-ignore:
- '**.md'
pull_request:
paths-ignore:
- '**.md'
jobs:
call-basic-validation:
name: Basic validation
uses: actions/reusable-workflows/.github/workflows/basic-validation.yml@main
with:
node-version: '20.x'

View File

@ -1,30 +0,0 @@
name: Build Action
on:
push:
branches:
- main
- releases/*
paths-ignore:
- '**.md'
pull_request:
paths-ignore:
- '**.md'
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- uses: actions/checkout@v2
- name: Setup Node.JS 12
uses: actions/setup-node@v2
with:
node-version: 12.x
- run: npm ci
- run: npm run build
- run: npm run format-check
- run: npm test

View File

@ -1,8 +1,3 @@
# `dist/index.js` is a special file in Actions.
# When you reference an action with `uses:` in a workflow,
# `index.js` is the code that will run.
# For our project, we generate this file through a build process from other source files.
# We need to make sure the checked-in `index.js` actually matches what we expect it to be.
name: Check dist/
on:
@ -17,35 +12,8 @@ on:
workflow_dispatch:
jobs:
check-dist:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set Node.js 12.x
uses: actions/setup-node@v1
with:
node-version: 12.x
- name: Install dependencies
run: npm ci
- name: Rebuild the dist/ directory
run: npm run build
- name: Compare the expected and actual dist/ directories
run: |
if [ "$(git diff --ignore-space-at-eol dist/ | wc -l)" -gt "0" ]; then
echo "Detected uncommitted changes after build. See status below:"
git diff
exit 1
fi
id: diff
# If index.js was different than expected, upload the expected version as an artifact
- uses: actions/upload-artifact@v2
if: ${{ failure() && steps.diff.conclusion == 'failure' }}
with:
name: dist
path: dist/
call-check-dist:
name: Check dist/
uses: actions/reusable-workflows/.github/workflows/check-dist.yml@main
with:
node-version: '20.x'

14
.github/workflows/codeql-analysis.yml vendored Normal file
View File

@ -0,0 +1,14 @@
name: CodeQL analysis
on:
push:
branches: [main]
pull_request:
branches: [main]
schedule:
- cron: '0 3 * * 0'
jobs:
call-codeQL-analysis:
name: CodeQL analysis
uses: actions/reusable-workflows/.github/workflows/codeql-analysis.yml@main

View File

@ -0,0 +1,93 @@
name: Validate cache with cache-dependency-path option
on:
push:
branches:
- main
- releases/*
paths-ignore:
- '**.md'
pull_request:
paths-ignore:
- '**.md'
defaults:
run:
shell: bash
jobs:
gradle1-save:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [macos-latest, windows-latest, ubuntu-latest]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Run setup-java with the cache for gradle
uses: ./
id: setup-java
with:
distribution: 'adopt'
java-version: '11'
cache: gradle
cache-dependency-path: __tests__/cache/gradle1/*.gradle*
- name: Create files to cache
# Need to avoid using Gradle daemon to stabilize the save process on Windows
# https://github.com/actions/cache/issues/454#issuecomment-840493935
run: |
gradle downloadDependencies --no-daemon -p __tests__/cache/gradle1
if [ ! -d ~/.gradle/caches ]; then
echo "::error::The ~/.gradle/caches directory does not exist unexpectedly"
exit 1
fi
gradle1-restore:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [macos-latest, windows-latest, ubuntu-latest]
needs: gradle1-save
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Run setup-java with the cache for gradle
uses: ./
id: setup-java
with:
distribution: 'adopt'
java-version: '11'
cache: gradle
cache-dependency-path: __tests__/cache/gradle1/*.gradle*
- name: Confirm that ~/.gradle/caches directory has been made
run: |
if [ ! -d ~/.gradle/caches ]; then
echo "::error::The ~/.gradle/caches directory does not exist unexpectedly"
exit 1
fi
ls ~/.gradle/caches/
gradle2-restore:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [macos-latest, windows-latest, ubuntu-latest]
needs: gradle1-save
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Run setup-java with the cache for gradle
uses: ./
id: setup-java
with:
distribution: 'adopt'
java-version: '11'
cache: gradle
cache-dependency-path: __tests__/cache/gradle2/*.gradle*
- name: Confirm that ~/.gradle/caches directory has not been made
run: |
if [ -d ~/.gradle/caches ]; then
echo "::error::The ~/.gradle/caches directory exists unexpectedly"
exit 1
fi

View File

@ -1,4 +1,5 @@
name: Validate cache
on:
push:
branches:
@ -23,7 +24,7 @@ jobs:
os: [macos-latest, windows-latest, ubuntu-latest]
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Run setup-java with the cache for gradle
uses: ./
id: setup-java
@ -35,7 +36,7 @@ jobs:
# Need to avoid using Gradle daemon to stabilize the save process on Windows
# https://github.com/actions/cache/issues/454#issuecomment-840493935
run: |
gradle downloadDependencies --no-daemon -p __tests__/cache/gradle
gradle downloadDependencies --no-daemon -p __tests__/cache/gradle1
if [ ! -d ~/.gradle/caches ]; then
echo "::error::The ~/.gradle/caches directory does not exist unexpectedly"
exit 1
@ -49,7 +50,7 @@ jobs:
needs: gradle-save
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Run setup-java with the cache for gradle
uses: ./
id: setup-java
@ -72,7 +73,7 @@ jobs:
os: [macos-latest, windows-latest, ubuntu-latest]
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Run setup-java with the cache for maven
uses: ./
id: setup-java
@ -96,7 +97,7 @@ jobs:
needs: maven-save
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Run setup-java with the cache for maven
uses: ./
id: setup-java
@ -111,3 +112,98 @@ jobs:
exit 1
fi
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@v4
- 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@v4
- 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

@ -1,4 +1,5 @@
name: Validate local file
on:
push:
branches:
@ -20,7 +21,7 @@ jobs:
os: [macos-latest, windows-latest, ubuntu-latest]
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Download Adopt OpenJDK file
run: |
if ($IsLinux) {
@ -57,7 +58,7 @@ jobs:
os: [macos-latest, windows-latest, ubuntu-latest]
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Download Zulu OpenJDK file
run: |
if ($IsLinux) {
@ -94,7 +95,7 @@ jobs:
os: [macos-latest, windows-latest, ubuntu-latest]
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Download Eclipse Temurin file
run: |
if ($IsLinux) {

View File

@ -1,4 +1,5 @@
name: Validate publishing functionality
on:
push:
branches:
@ -24,7 +25,7 @@ jobs:
os: [macos-latest, windows-latest, ubuntu-latest]
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: setup-java
uses: ./
id: setup-java
@ -59,7 +60,7 @@ jobs:
os: [macos-latest, windows-latest, ubuntu-latest]
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Create fake settings.xml
run: |
$xmlDirectory = Join-Path $HOME ".m2"
@ -85,7 +86,7 @@ jobs:
if ($content -notlike '*maven*') {
throw "settings.xml file is not overwritten"
}
test-publishing-skip-overwrite:
name: settings.xml is not overwritten if flag is false
runs-on: ${{ matrix.os }}
@ -95,7 +96,7 @@ jobs:
os: [macos-latest, windows-latest, ubuntu-latest]
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Create fake settings.xml
run: |
$xmlDirectory = Join-Path $HOME ".m2"
@ -132,7 +133,7 @@ jobs:
os: [macos-latest, windows-latest, ubuntu-latest]
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: setup-java
uses: ./
id: setup-java
@ -149,4 +150,4 @@ jobs:
$path = Join-Path $env:RUNNER_TEMP "settings.xml"
if (-not (Test-Path $path)) {
throw "settings.xml file is not found in expected location"
}
}

View File

@ -1,4 +1,5 @@
name: Validate Java e2e
on:
push:
branches:
@ -10,7 +11,7 @@ on:
paths-ignore:
- '**.md'
schedule:
- cron: '0 */12 * * *'
- cron: '0 */12 * * *'
workflow_dispatch:
jobs:
setup-java-major-versions:
@ -20,14 +21,37 @@ jobs:
fail-fast: false
matrix:
os: [macos-latest, windows-latest, ubuntu-latest]
distribution: ['temurin', 'adopt', 'adopt-openj9', 'zulu', 'liberica', 'microsoft' ] # internally 'adopt-hotspot' is the same as 'adopt'
version: ['8', '11', '16']
distribution: [
'temurin',
'adopt',
'adopt-openj9',
'zulu',
'liberica',
'microsoft',
'semeru',
'corretto',
'dragonwell'
] # internally 'adopt-hotspot' is the same as 'adopt'
version: ['8', '11', '17']
exclude:
- distribution: microsoft
version: 8
- distribution: microsoft
version: 8
- distribution: dragonwell
os: macos-latest
include:
- distribution: oracle
os: macos-latest
version: 17
- distribution: oracle
os: windows-latest
version: 20
- distribution: oracle
os: ubuntu-latest
version: 20
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: setup-java
uses: ./
id: setup-java
@ -48,12 +72,22 @@ jobs:
os: [macos-latest, windows-latest, ubuntu-latest]
distribution: ['temurin', 'zulu', 'liberica']
version:
- '11.0'
- '8.0.302'
- '16.0.2+7'
- '11.0'
- '8.0.302'
- '17.0.7+7'
include:
- distribution: oracle
os: ubuntu-latest
version: '20.0.1'
- distribution: dragonwell
os: ubuntu-latest
version: '11.0'
- distribution: dragonwell
os: ubuntu-latest
version: '11.0.13+9'
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: setup-java
uses: ./
id: setup-java
@ -72,10 +106,13 @@ jobs:
fail-fast: false
matrix:
os: [macos-latest, windows-latest, ubuntu-latest]
distribution: ['temurin', 'zulu', 'liberica']
distribution: ['temurin', 'zulu', 'liberica', 'dragonwell']
exclude:
- distribution: dragonwell
os: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: setup-java
uses: ./
id: setup-java
@ -87,6 +124,46 @@ jobs:
run: bash __tests__/verify-java.sh "11" "${{ steps.setup-java.outputs.path }}"
shell: bash
setup-java-multiple-jdks:
name: ${{ matrix.distribution }} ${{ matrix.version }} - multiple jdks - ${{ matrix.os }}
needs: setup-java-major-versions
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [macos-latest, windows-latest, ubuntu-latest]
distribution: ['temurin', 'zulu', 'liberica', 'dragonwell']
exclude:
- distribution: dragonwell
os: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: setup-java
uses: ./
id: setup-java
with:
distribution: ${{ matrix.distribution }}
java-version: |
11
17
- name: Verify Java env variables
run: |
$versionsArr = "11","17"
foreach ($version in $versionsArr)
{
$envName = "JAVA_HOME_${version}_${env:RUNNER_ARCH}"
$JavaVersionPath = [Environment]::GetEnvironmentVariable($envName)
if (-not (Test-Path "$JavaVersionPath")) {
Write-Host "$envName is not found"
exit 1
}
}
shell: pwsh
- name: Verify Java
run: bash __tests__/verify-java.sh "17" "${{ 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
@ -98,7 +175,7 @@ jobs:
version: ['17-ea', '15.0.0-ea.14']
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: setup-java
uses: ./
id: setup-java
@ -120,7 +197,7 @@ jobs:
version: ['17-ea']
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: setup-java
uses: ./
id: setup-java
@ -139,9 +216,9 @@ jobs:
fail-fast: false
matrix:
os: [macos-latest, windows-latest, ubuntu-latest]
distribution: ['temurin', 'zulu', 'liberica']
distribution: ['temurin', 'zulu', 'liberica', 'semeru']
java-package: ['jre']
version: ['16.0']
version: ['17.0']
include:
- distribution: 'zulu'
java-package: jre+fx
@ -159,13 +236,13 @@ jobs:
java-package: jre+fx
version: '11'
os: ubuntu-latest
exclude:
# Eclipse Temurin currently doesn't publish JREs, only JDKs
- distribution: 'temurin'
java-package: 'jre'
- distribution: 'corretto'
java-package: jre
version: '8'
os: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: setup-java
uses: ./
id: setup-java
@ -187,11 +264,11 @@ jobs:
matrix:
# x86 is not supported on macOS
os: [windows-latest, ubuntu-latest]
distribution: ['liberica', 'zulu']
distribution: ['liberica', 'zulu', 'corretto']
version: ['11']
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: setup-java
uses: ./
id: setup-java
@ -203,4 +280,115 @@ jobs:
run: bash __tests__/verify-java.sh "${{ matrix.version }}" "${{ steps.setup-java.outputs.path }}"
shell: bash
# Only Microsoft provides AArch64. However, GitHub-hosted runners do not support this architecture.
setup-java-version-both-version-inputs-presents:
name: ${{ matrix.distribution }} version (should be from input) - ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [macos-latest, windows-latest, ubuntu-latest]
distribution: ['temurin', 'microsoft', 'corretto']
java-version-file: ['.java-version', '.tool-versions']
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Create .java-version file
shell: bash
run: echo "8" > .java-version
- name: Create .tool-versions file
shell: bash
run: echo "java 8" > .tool-versions
- name: setup-java
uses: ./
id: setup-java
with:
distribution: ${{ matrix.distribution }}
java-version: 11
java-version-file: ${{matrix.java-version-file }}
- name: Verify Java
run: bash __tests__/verify-java.sh "11" "${{ steps.setup-java.outputs.path }}"
shell: bash
setup-java-version-from-file-major-notation:
name: ${{ matrix.distribution }} version from file X - ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [macos-latest, windows-latest, ubuntu-latest]
distribution: ['temurin', 'zulu', 'liberica', 'microsoft', 'corretto']
java-version-file: ['.java-version', '.tool-versions']
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Create .java-version file
shell: bash
run: echo "11" > .java-version
- name: Create .tool-versions file
shell: bash
run: echo "java 11" > .tool-versions
- name: setup-java
uses: ./
id: setup-java
with:
distribution: ${{ matrix.distribution }}
java-version-file: ${{matrix.java-version-file }}
- name: Verify Java
run: bash __tests__/verify-java.sh "11" "${{ steps.setup-java.outputs.path }}"
shell: bash
setup-java-version-from-file-major-minor-patch-notation:
name: ${{ matrix.distribution }} version from file X.Y.Z - ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [macos-latest, windows-latest, ubuntu-latest]
distribution: ['adopt', 'adopt-openj9', 'zulu']
java-version-file: ['.java-version', '.tool-versions']
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Create .java-version file
shell: bash
run: echo "11.0.2" > .java-version
- name: Create .tool-versions file
shell: bash
run: echo "java 11.0.2" > .tool-versions
- name: setup-java
uses: ./
id: setup-java
with:
distribution: ${{ matrix.distribution }}
java-version-file: ${{matrix.java-version-file }}
- name: Verify Java
run: bash __tests__/verify-java.sh "11.0.2" "${{ steps.setup-java.outputs.path }}"
shell: bash
setup-java-version-from-file-major-minor-patch-with-dist:
name: ${{ matrix.distribution }} version from file 'openjdk64-11.0.2' - ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [macos-latest, windows-latest, ubuntu-latest]
distribution: ['adopt', 'zulu', 'liberica']
java-version-file: ['.java-version', '.tool-versions']
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Create .java-version file
shell: bash
run: echo "openjdk64-11.0.2" > .java-version
- name: Create .tool-versions file
shell: bash
run: echo "java openjdk64-11.0.2" > .tool-versions
- name: setup-java
uses: ./
id: setup-java
with:
distribution: ${{ matrix.distribution }}
java-version-file: ${{matrix.java-version-file }}
- name: Verify Java
run: bash __tests__/verify-java.sh "11.0.2" "${{ steps.setup-java.outputs.path }}"
shell: bash

View File

@ -10,16 +10,6 @@ on:
workflow_dispatch:
jobs:
test:
runs-on: ubuntu-latest
name: Check licenses
steps:
- uses: actions/checkout@v2
- run: npm ci
- name: Install licensed
run: |
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
sudo tar -xzf licensed.tar.gz
sudo mv licensed /usr/local/bin/licensed
- run: licensed status
call-licensed:
name: Licensed
uses: actions/reusable-workflows/.github/workflows/licensed.yml@main

View File

@ -1,4 +1,5 @@
name: Release new action version
on:
release:
types: [released]
@ -20,9 +21,9 @@ jobs:
name: releaseNewActionVersion
runs-on: ubuntu-latest
steps:
- name: Update the ${{ env.TAG_NAME }} tag
id: update-major-tag
uses: actions/publish-action@v0.1.0
with:
source-tag: ${{ env.TAG_NAME }}
slack-webhook: ${{ secrets.SLACK_WEBHOOK }}
- name: Update the ${{ env.TAG_NAME }} tag
id: update-major-tag
uses: actions/publish-action@v0.2.2
with:
source-tag: ${{ env.TAG_NAME }}
slack-webhook: ${{ secrets.SLACK_WEBHOOK }}

View File

@ -0,0 +1,11 @@
name: Update configuration files
on:
schedule:
- cron: '0 3 * * 0'
workflow_dispatch:
jobs:
call-update-configuration-files:
name: Update configuration files
uses: actions/reusable-workflows/.github/workflows/update-config-files.yml@main

3
.gitignore vendored
View File

@ -94,3 +94,6 @@ typings/
# DynamoDB Local files
.dynamodb/
.vscode/
# IntelliJ / WebStorm
/.idea/

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.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
.licenses/npm/@fastify/busboy.dep.yml generated Normal file

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.

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.

BIN
.licenses/npm/tslib-2.6.2.dep.yml generated Normal file

Binary file not shown.

BIN
.licenses/npm/undici-types.dep.yml generated Normal file

Binary file not shown.

BIN
.licenses/npm/undici.dep.yml generated Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

7
.prettierignore Normal file
View File

@ -0,0 +1,7 @@
# Ignore list
/*
# Do not ignore these folders:
!__tests__/
!.github/
!src/

11
.prettierrc.js Normal file
View File

@ -0,0 +1,11 @@
// This is a reusable configuration file copied from https://github.com/actions/reusable-workflows/tree/main/reusable-configurations. Please don't make changes to this file as it's the subject of an automatic update.
module.exports = {
printWidth: 80,
tabWidth: 2,
useTabs: false,
semi: true,
singleQuote: true,
trailingComma: 'none',
bracketSpacing: false,
arrowParens: 'avoid'
};

View File

@ -1,11 +0,0 @@
{
"printWidth": 100,
"tabWidth": 2,
"useTabs": false,
"semi": true,
"singleQuote": true,
"trailingComma": "none",
"bracketSpacing": true,
"arrowParens": "avoid",
"parser": "typescript"
}

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

@ -1,38 +0,0 @@
# Contributors
### Checkin
- Do checkin source (src)
- Do checkin a single index.js file after running `ncc`
- Do not checking node_modules
### 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/`.
There are two main files that get created
- `dist/setup/index.js`
- Core `setup-java` logic that downloads and installs an appropriate version of Java
- Handling creating a `settings.xml` file to make it easier to publish packages
- `dist/cleanup/index/js`
- Extra cleanup script that is used to remove GPG keys (needed for certain self-hosted runner scenarios)
If you're developing locally, after doing `npm install`, you can use the following commands
```yaml
npm run build # runs tsc along with ncc
npm run format # runs prettier --write
npm run format-check # runs prettier --check
npm run test # runs jest
npm run release # add all the necessary ncc files under dist/* to the git staging area
```
Any files generated using `tsc` will be added to `lib/*`, however those files also are not uploaded to the repository and are excluded using `.gitignore`.
### Testing
Tests are included under `_tests_/*` and can be run using `npm run-script test`.
We ask that you include a link to a successful run that utilizes the changes you are working on. For example, if your changes are in the branch `newAwesomeFeature`, then show an example run that uses `setup-python@newAwesomeFeature` or `my-fork@newAwesomeFeature`. This will help speed up testing and help us confirm that there are no breaking changes or bugs.
### Licensed
This repository uses a tool called [Licensed](https://github.com/github/licensed) to verify third party dependencies. You may need to locally install licensed and run `licensed cache` to update the dependency cache if you install or update a production dependency. If licensed cache is unable to determine the dependency, you may need to modify the cache file yourself to put the correct license. You should still verify the dependency, licensed is a tool to help, but is not a substitute for human review of dependencies.

228
README.md
View File

@ -1,115 +1,212 @@
# setup-java
# Setup Java
<p align="left">
<a href="https://github.com/actions/setup-java"><img alt="GitHub Actions status" src="https://github.com/actions/setup-java/workflows/Main%20workflow/badge.svg"></a>
</p>
[![Basic validation](https://github.com/actions/setup-java/actions/workflows/basic-validation.yml/badge.svg?branch=main)](https://github.com/actions/setup-java/actions/workflows/basic-validation.yml)
[![Validate Java e2e](https://github.com/actions/setup-java/actions/workflows/e2e-versions.yml/badge.svg?branch=main)](https://github.com/actions/setup-java/actions/workflows/e2e-versions.yml)
[![Validate cache](https://github.com/actions/setup-java/actions/workflows/e2e-cache.yml/badge.svg?branch=main)](https://github.com/actions/setup-java/actions/workflows/e2e-cache.yml)
This action provides the following functionality for GitHub Actions runners:
- Downloading and setting up a requested version of Java. See [Usage](#Usage) for a list of supported distributions
- Extracting and caching custom version of Java from a local file
- Configuring runner for publishing using Apache Maven
- Configuring runner for publishing using Gradle
- Configuring runner for using GPG private key
- Registering problem matchers for error output
- Caching dependencies managed by Apache Maven
- Caching dependencies managed by Gradle
The `setup-java` action provides the following functionality for GitHub Actions runners:
- Downloading and setting up a requested version of Java. See [Usage](#usage) for a list of supported distributions.
- Extracting and caching custom version of Java from a local file.
- Configuring runner for publishing using Apache Maven.
- Configuring runner for publishing using Gradle.
- Configuring runner for using GPG private key.
- Registering problem matchers for error output.
- Caching dependencies managed by Apache Maven.
- Caching dependencies managed by Gradle.
- Caching dependencies managed by sbt.
- [Maven Toolchains declaration](https://maven.apache.org/guides/mini/guide-using-toolchains.html) for specified JDK versions.
This action allows you to work with Java and Scala projects.
## V2 vs V1
- V2 supports custom distributions and provides support for Zulu OpenJDK, Eclipse Temurin and Adopt OpenJDK out of the box. V1 supports only Zulu OpenJDK
- V2 requires you to specify distribution along with the version. V1 defaults to Zulu OpenJDK, only version input is required. Follow [the migration guide](docs/switching-to-v2.md) to switch from V1 to V2
- V2 supports custom distributions and provides support for Azul Zulu OpenJDK, Eclipse Temurin and AdoptOpenJDK out of the box. V1 supports only Azul Zulu OpenJDK.
- V2 requires you to specify distribution along with the version. V1 defaults to Azul Zulu OpenJDK, only version input is required. Follow [the migration guide](docs/switching-to-v2.md) to switch from V1 to V2.
## Usage
Inputs `java-version` and `distribution` are mandatory. See [Supported distributions](#supported-distributions) section for a list of available options.
### Basic
**Eclipse Temurin**
- `java-version`: The Java version that is going to be set up. Takes a whole or [semver](#supported-version-syntax) Java version. If not specified, the action will expect `java-version-file` input to be specified.
- `java-version-file`: The path to a file containing java version. Supported file types are `.java-version` and `.tool-versions`. See more details in [about .java-version-file](docs/advanced-usage.md#Java-version-file).
- `distribution`: _(required)_ Java [distribution](#supported-distributions).
- `java-package`: The packaging variant of the chosen distribution. Possible values: `jdk`, `jre`, `jdk+fx`, `jre+fx`. Default value: `jdk`.
- `architecture`: The target architecture of the package. Possible values: `x86`, `x64`, `armv7`, `aarch64`, `ppc64le`. Default value: Derived from the runner machine.
- `jdkFile`: If a use-case requires a custom distribution setup-java uses the compressed JDK from the location pointed by this input and will take care of the installation and caching on the VM.
- `check-latest`: Setting this option makes the action to check for the latest available version for the version spec.
- `cache`: Quick [setup caching](#caching-packages-dependencies) for the dependencies managed through one of the predefined package managers. It can be one of "maven", "gradle" or "sbt".
- `cache-dependency-path`: The path to a dependency file: pom.xml, build.gradle, build.sbt, etc. This option can be used with the `cache` option. If this option is omitted, the action searches for the dependency file in the entire repository. This option supports wildcards and a list of file names for caching multiple dependencies.
#### Maven options
The action has a bunch of inputs to generate maven's [settings.xml](https://maven.apache.org/settings.html) on the fly and pass the values to Apache Maven GPG Plugin as well as Apache Maven Toolchains. See [advanced usage](docs/advanced-usage.md) for more.
- `overwrite-settings`: By default action overwrites the settings.xml. In order to skip generation of file if it exists, set this to `false`.
- `server-id`: ID of the distributionManagement repository in the pom.xml file. Default is `github`.
- `server-username`: Environment variable name for the username for authentication to the Apache Maven repository. Default is GITHUB_ACTOR.
- `server-password`: Environment variable name for password or token for authentication to the Apache Maven repository. Default is GITHUB_TOKEN.
- `settings-path`: Maven related setting to point to the directory where the settings.xml file will be written. Default is ~/.m2.
- `gpg-private-key`: GPG private key to import. Default is empty string.
- `gpg-passphrase`: Environment variable name for the GPG private key passphrase. Default is GPG_PASSPHRASE.
- `mvn-toolchain-id`: Name of Maven Toolchain ID if the default name of `${distribution}_${java-version}` is not wanted.
- `mvn-toolchain-vendor`: Name of Maven Toolchain Vendor if the default name of `${distribution}` is not wanted.
### Basic Configuration
#### Eclipse Temurin
```yaml
steps:
- uses: actions/checkout@v2
- uses: actions/setup-java@v2
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: 'temurin' # See 'Supported distributions' for available options
java-version: '17'
- run: java -cp java HelloWorldApp
java-version: '21'
- run: java HelloWorldApp.java
```
**Zulu OpenJDK**
#### Azul Zulu OpenJDK
```yaml
steps:
- uses: actions/checkout@v2
- uses: actions/setup-java@v2
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: 'zulu' # See 'Supported distributions' for available options
java-version: '11'
- run: java -cp java HelloWorldApp
java-version: '21'
- run: java HelloWorldApp.java
```
#### Supported version syntax
The `java-version` input supports an exact version or a version range using [SemVer](https://semver.org/) notation:
- major versions: `8`, `11`, `16`, `17`
- more specific versions: `17.0`, `11.0`, `11.0.4`, `8.0.232`, `8.0.282+8`
- early access (EA) versions: `15-ea`, `15.0.0-ea`, `15.0.0-ea.2`, `15.0.0+2-ea`
- major versions: `8`, `11`, `16`, `17`, `21`
- more specific versions: `8.0.282+8`, `8.0.232`, `11.0`, `11.0.4`, `17.0`
- early access (EA) versions: `15-ea`, `15.0.0-ea`
#### Supported distributions
Currently, the following distributions are supported:
| Keyword | Distribution | Official site | License
|-|-|-|-|
| `temurin` | Eclipse Temurin | [Link](https://adoptium.net/) | [Link](https://adoptium.net/about.html)
| `zulu` | Zulu OpenJDK | [Link](https://www.azul.com/downloads/zulu-community/?package=jdk) | [Link](https://www.azul.com/products/zulu-and-zulu-enterprise/zulu-terms-of-use/) |
| `adopt` or `adopt-hotspot` | Adopt OpenJDK Hotspot | [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) |
| `zulu` | Azul Zulu OpenJDK | [Link](https://www.azul.com/downloads/zulu-community/?package=jdk) | [Link](https://www.azul.com/products/zulu-and-zulu-enterprise/zulu-terms-of-use/) |
| `adopt` or `adopt-hotspot` | AdoptOpenJDK Hotspot | [Link](https://adoptopenjdk.net/) | [Link](https://adoptopenjdk.net/about.html) |
| `adopt-openj9` | AdoptOpenJDK 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/) |
| `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/)
| `semeru` | IBM Semeru Runtime Open Edition | [Link](https://developer.ibm.com/languages/java/semeru-runtimes/downloads/) | [Link](https://openjdk.java.net/legal/gplv2+ce.html) |
| `oracle` | Oracle JDK | [Link](https://www.oracle.com/java/technologies/downloads/) | [Link](https://java.com/freeuselicense)
| `dragonwell` | Alibaba Dragonwell JDK | [Link](https://dragonwell-jdk.io/) | [Link](https://www.aliyun.com/product/dragonwell/)
**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:** AdoptOpenJDK got moved to Eclipse Temurin and won't be updated anymore. It is highly recommended to migrate workflows from `adopt` and `adopt-openj9`, to `temurin` and `semeru` respectively, 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 Azul Zulu OpenJDK architectures x64 and arm64 are mapped to x86 / arm with proper hw_bitness.
### 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 [toolkit/cache](https://github.com/actions/toolkit/tree/main/packages/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`, `buildSrc/**/Versions.kt`, `buildSrc/**/Dependencies.kt`, `gradle/*.versions.toml`, and `**/versions.properties`
- maven: `**/pom.xml`
- sbt: all sbt build definition files `**/*.sbt`, `**/project/build.properties`, `**/project/**.scala`, `**/project/**.sbt`
When the option `cache-dependency-path` is specified, the hash is based on the matching file. This option supports wildcards and a list of file names, and is especially useful for monorepos.
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
```yaml
steps:
- uses: actions/checkout@v2
- uses: actions/setup-java@v2
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '11'
java-version: '21'
cache: 'gradle'
cache-dependency-path: | # optional
sub-project/*.gradle*
sub-project/**/gradle-wrapper.properties
- run: ./gradlew build --no-daemon
```
#### Caching maven dependencies
```yaml
steps:
- uses: actions/checkout@v2
- uses: actions/setup-java@v2
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '11'
java-version: '21'
cache: 'maven'
cache-dependency-path: 'sub-project/pom.xml' # optional
- name: Build with Maven
run: mvn -B package --file pom.xml
```
#### Caching sbt dependencies
```yaml
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '21'
cache: 'sbt'
cache-dependency-path: | # optional
sub-project/build.sbt
sub-project/project/build.properties
- name: Build with SBT
run: sbt package
```
#### Cache segment restore timeout
Usually, cache gets downloaded in multiple segments of fixed sizes. Sometimes, a segment download gets stuck, which causes the workflow job to be stuck. The cache segment download timeout [was introduced](https://github.com/actions/toolkit/tree/main/packages/cache#cache-segment-restore-timeout) to solve this issue as it allows the segment download to get aborted and hence allows the job to proceed with a cache miss. The default value of the cache segment download timeout is set to 10 minutes and can be customized by specifying an environment variable named `SEGMENT_DOWNLOAD_TIMEOUT_MINS` with a timeout value in minutes.
```yaml
env:
SEGMENT_DOWNLOAD_TIMEOUT_MINS: '5'
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '21'
cache: 'gradle'
- run: ./gradlew build --no-daemon
```
### 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.
If `check-latest` is set to `true`, the action first checks if the cached version is the latest one. If the locally cached version is not the most up-to-date, the latest version of Java will be downloaded. Set `check-latest` to `true` if you want the most up-to-date version of Java to always be used. Setting `check-latest` to `true` has performance implications as downloading versions of Java is slower than using cached versions.
For Java distributions that are not cached on Hosted images, `check-latest` always behaves as `true` and downloads Java on-flight. Check out [Hosted Tool Cache](docs/advanced-usage.md#Hosted-Tool-Cache) for more details about pre-cached Java versions.
For Java distributions that are not cached on Hosted images, `check-latest` always behaves as `true` and downloads Java on-flight. Check out [Hosted Tool Cache](docs/advanced-usage.md#Hosted-Tool-Cache) for more details about pre-cached Java versions.
```yaml
steps:
- uses: actions/checkout@v2
- uses: actions/setup-java@v2
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: 'adopt'
java-version: '11'
distribution: 'temurin'
java-version: '21'
check-latest: true
- run: java -cp java HelloWorldApp
- run: java HelloWorldApp.java
```
### Testing against different Java versions
@ -119,24 +216,47 @@ jobs:
runs-on: ubuntu-20.04
strategy:
matrix:
java: [ '8', '11', '13', '15' ]
java: [ '8', '11', '17', '21' ]
name: Java ${{ matrix.Java }} sample
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Setup java
uses: actions/setup-java@v2
uses: actions/setup-java@v4
with:
distribution: '<distribution>'
java-version: ${{ matrix.java }}
- run: java -cp java HelloWorldApp
- run: java HelloWorldApp.java
```
### Advanced
### Install multiple JDKs
All versions are added to the PATH. The last version will be used and available globally. Other Java versions can be accessed through env variables with such specification as 'JAVA_HOME_{{ MAJOR_VERSION }}_{{ ARCHITECTURE }}'.
```yaml
steps:
- uses: actions/setup-java@v4
with:
distribution: '<distribution>'
java-version: |
8
11
15
```
### Using Maven Toolchains
In the example above multiple JDKs are installed for the same job. The result after the last JDK is installed is a Maven Toolchains declaration containing references to all three JDKs. The values for `id`, `version`, and `vendor` of the individual Toolchain entries are the given input values for `distribution` and `java-version` (`vendor` being the combination of `${distribution}_${java-version}`) by default.
### Advanced Configuration
- [Selecting a Java distribution](docs/advanced-usage.md#Selecting-a-Java-distribution)
- [Eclipse Temurin](docs/advanced-usage.md#Eclipse-Temurin)
- [Adopt](docs/advanced-usage.md#Adopt)
- [Zulu](docs/advanced-usage.md#Zulu)
- [Liberica](docs/advanced-usage.md#Liberica)
- [Microsoft](docs/advanced-usage.md#Microsoft)
- [Amazon Corretto](docs/advanced-usage.md#Amazon-Corretto)
- [Oracle](docs/advanced-usage.md#Oracle)
- [Alibaba Dragonwell](docs/advanced-usage.md#Alibaba-Dragonwell)
- [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)
@ -145,6 +265,8 @@ jobs:
- [Publishing using Apache Maven](docs/advanced-usage.md#Publishing-using-Apache-Maven)
- [Publishing using Gradle](docs/advanced-usage.md#Publishing-using-Gradle)
- [Hosted Tool Cache](docs/advanced-usage.md#Hosted-Tool-Cache)
- [Modifying Maven Toolchains](docs/advanced-usage.md#Modifying-Maven-Toolchains)
- [Java Version File](docs/advanced-usage.md#Java-version-file)
## License
@ -152,4 +274,4 @@ The scripts and documentation in this project are released under the [MIT Licens
## Contributions
Contributions are welcome! See [Contributor's Guide](CONTRIBUTING.md)
Contributions are welcome! See [Contributor's Guide](docs/contributors.md)

View File

@ -1,13 +1,14 @@
import io = require('@actions/io');
import fs = require('fs');
import path = require('path');
import * as io from '@actions/io';
import * as core from '@actions/core';
import * as fs from 'fs';
import * as path from 'path';
import os from 'os';
import * as auth from '../src/auth';
import {M2_DIR, MVN_SETTINGS_FILE} from '../src/constants';
const m2Dir = path.join(__dirname, auth.M2_DIR);
const settingsFile = path.join(m2Dir, auth.SETTINGS_FILE);
const m2Dir = path.join(__dirname, M2_DIR);
const settingsFile = path.join(m2Dir, MVN_SETTINGS_FILE);
describe('auth tests', () => {
let spyOSHomedir: jest.SpyInstance;
@ -38,10 +39,16 @@ describe('auth tests', () => {
const password = 'TOLKIEN';
const altHome = path.join(__dirname, 'runner', 'settings');
const altSettingsFile = path.join(altHome, auth.SETTINGS_FILE);
const altSettingsFile = path.join(altHome, MVN_SETTINGS_FILE);
await io.rmRF(altHome); // ensure it doesn't already exist
await auth.createAuthenticationSettings(id, username, password, altHome, true);
await auth.createAuthenticationSettings(
id,
username,
password,
altHome,
true
);
expect(fs.existsSync(m2Dir)).toBe(false);
expect(fs.existsSync(settingsFile)).toBe(false);
@ -60,11 +67,19 @@ describe('auth tests', () => {
const username = 'UNAME';
const password = 'TOKEN';
await auth.createAuthenticationSettings(id, username, password, m2Dir, true);
await auth.createAuthenticationSettings(
id,
username,
password,
m2Dir,
true
);
expect(fs.existsSync(m2Dir)).toBe(true);
expect(fs.existsSync(settingsFile)).toBe(true);
expect(fs.readFileSync(settingsFile, 'utf-8')).toEqual(auth.generate(id, username, password));
expect(fs.readFileSync(settingsFile, 'utf-8')).toEqual(
auth.generate(id, username, password)
);
}, 100000);
it('creates settings.xml with additional configuration', async () => {
@ -73,7 +88,14 @@ describe('auth tests', () => {
const password = 'TOKEN';
const gpgPassphrase = 'GPG';
await auth.createAuthenticationSettings(id, username, password, m2Dir, true, gpgPassphrase);
await auth.createAuthenticationSettings(
id,
username,
password,
m2Dir,
true,
gpgPassphrase
);
expect(fs.existsSync(m2Dir)).toBe(true);
expect(fs.existsSync(settingsFile)).toBe(true);
@ -87,16 +109,24 @@ describe('auth tests', () => {
const username = 'USERNAME';
const password = 'PASSWORD';
fs.mkdirSync(m2Dir, { recursive: true });
fs.mkdirSync(m2Dir, {recursive: true});
fs.writeFileSync(settingsFile, 'FAKE FILE');
expect(fs.existsSync(m2Dir)).toBe(true);
expect(fs.existsSync(settingsFile)).toBe(true);
await auth.createAuthenticationSettings(id, username, password, m2Dir, true);
await auth.createAuthenticationSettings(
id,
username,
password,
m2Dir,
true
);
expect(fs.existsSync(m2Dir)).toBe(true);
expect(fs.existsSync(settingsFile)).toBe(true);
expect(fs.readFileSync(settingsFile, 'utf-8')).toEqual(auth.generate(id, username, password));
expect(fs.readFileSync(settingsFile, 'utf-8')).toEqual(
auth.generate(id, username, password)
);
}, 100000);
it('does not overwrite existing settings.xml files', async () => {
@ -104,12 +134,18 @@ describe('auth tests', () => {
const username = 'USERNAME';
const password = 'PASSWORD';
fs.mkdirSync(m2Dir, { recursive: true });
fs.mkdirSync(m2Dir, {recursive: true});
fs.writeFileSync(settingsFile, 'FAKE FILE');
expect(fs.existsSync(m2Dir)).toBe(true);
expect(fs.existsSync(settingsFile)).toBe(true);
await auth.createAuthenticationSettings(id, username, password, m2Dir, false);
await auth.createAuthenticationSettings(
id,
username,
password,
m2Dir,
false
);
expect(fs.existsSync(m2Dir)).toBe(true);
expect(fs.existsSync(settingsFile)).toBe(true);
@ -158,6 +194,8 @@ describe('auth tests', () => {
</servers>
</settings>`;
expect(auth.generate(id, username, password, gpgPassphrase)).toEqual(expectedSettings);
expect(auth.generate(id, username, password, gpgPassphrase)).toEqual(
expectedSettings
);
});
});

View File

@ -1,11 +1,12 @@
import { mkdtempSync } from 'fs';
import { tmpdir } from 'os';
import { join } from 'path';
import { restore, save } from '../src/cache';
import {mkdtempSync} from 'fs';
import {tmpdir} from 'os';
import {join} from 'path';
import {restore, save} from '../src/cache';
import * as fs from 'fs';
import * as os from 'os';
import * as core from '@actions/core';
import * as cache from '@actions/cache';
import * as glob from '@actions/glob';
describe('dependency cache', () => {
const ORIGINAL_RUNNER_OS = process.env['RUNNER_OS'];
@ -64,21 +65,30 @@ describe('dependency cache', () => {
ReturnType<typeof cache.restoreCache>,
Parameters<typeof cache.restoreCache>
>;
let spyGlobHashFiles: jest.SpyInstance<
ReturnType<typeof glob.hashFiles>,
Parameters<typeof glob.hashFiles>
>;
beforeEach(() => {
spyCacheRestore = jest
.spyOn(cache, 'restoreCache')
.mockImplementation((paths: string[], primaryKey: string) => Promise.resolve(undefined));
.mockImplementation((paths: string[], primaryKey: string) =>
Promise.resolve(undefined)
);
spyGlobHashFiles = jest.spyOn(glob, 'hashFiles');
spyWarning.mockImplementation(() => null);
});
it('throws error if unsupported package manager specified', () => {
return expect(restore('ant')).rejects.toThrowError('unknown package manager specified: ant');
return expect(restore('ant', '')).rejects.toThrow(
'unknown package manager specified: ant'
);
});
describe('for maven', () => {
it('throws error if no pom.xml found', async () => {
await expect(restore('maven')).rejects.toThrowError(
await expect(restore('maven', '')).rejects.toThrow(
`No file in ${projectRoot(
workspace
)} matched to [**/pom.xml], make sure you have checked out the target repository`
@ -87,35 +97,160 @@ describe('dependency cache', () => {
it('downloads cache', async () => {
createFile(join(workspace, 'pom.xml'));
await restore('maven');
expect(spyCacheRestore).toBeCalled();
expect(spyWarning).not.toBeCalled();
expect(spyInfo).toBeCalledWith('maven cache is not found');
await restore('maven', '');
expect(spyCacheRestore).toHaveBeenCalled();
expect(spyGlobHashFiles).toHaveBeenCalledWith('**/pom.xml');
expect(spyWarning).not.toHaveBeenCalled();
expect(spyInfo).toHaveBeenCalledWith('maven cache is not found');
});
});
describe('for gradle', () => {
it('throws error if no build.gradle found', async () => {
await expect(restore('gradle')).rejects.toThrowError(
await expect(restore('gradle', '')).rejects.toThrow(
`No file in ${projectRoot(
workspace
)} matched to [**/*.gradle*,**/gradle-wrapper.properties], make sure you have checked out the target repository`
)} matched to [**/*.gradle*,**/gradle-wrapper.properties,buildSrc/**/Versions.kt,buildSrc/**/Dependencies.kt,gradle/*.versions.toml,**/versions.properties], make sure you have checked out the target repository`
);
});
it('downloads cache based on build.gradle', async () => {
createFile(join(workspace, 'build.gradle'));
await restore('gradle');
expect(spyCacheRestore).toBeCalled();
expect(spyWarning).not.toBeCalled();
expect(spyInfo).toBeCalledWith('gradle cache is not found');
await restore('gradle', '');
expect(spyCacheRestore).toHaveBeenCalled();
expect(spyGlobHashFiles).toHaveBeenCalledWith(
'**/*.gradle*\n**/gradle-wrapper.properties\nbuildSrc/**/Versions.kt\nbuildSrc/**/Dependencies.kt\ngradle/*.versions.toml\n**/versions.properties'
);
expect(spyWarning).not.toHaveBeenCalled();
expect(spyInfo).toHaveBeenCalledWith('gradle cache is not found');
});
it('downloads cache based on build.gradle.kts', async () => {
createFile(join(workspace, 'build.gradle.kts'));
await restore('gradle');
expect(spyCacheRestore).toBeCalled();
expect(spyWarning).not.toBeCalled();
expect(spyInfo).toBeCalledWith('gradle cache is not found');
await restore('gradle', '');
expect(spyCacheRestore).toHaveBeenCalled();
expect(spyGlobHashFiles).toHaveBeenCalledWith(
'**/*.gradle*\n**/gradle-wrapper.properties\nbuildSrc/**/Versions.kt\nbuildSrc/**/Dependencies.kt\ngradle/*.versions.toml\n**/versions.properties'
);
expect(spyWarning).not.toHaveBeenCalled();
expect(spyInfo).toHaveBeenCalledWith('gradle cache is not found');
});
it('downloads cache based on libs.versions.toml', async () => {
createDirectory(join(workspace, 'gradle'));
createFile(join(workspace, 'gradle', 'libs.versions.toml'));
await restore('gradle', '');
expect(spyCacheRestore).toHaveBeenCalled();
expect(spyGlobHashFiles).toHaveBeenCalledWith(
'**/*.gradle*\n**/gradle-wrapper.properties\nbuildSrc/**/Versions.kt\nbuildSrc/**/Dependencies.kt\ngradle/*.versions.toml\n**/versions.properties'
);
expect(spyWarning).not.toHaveBeenCalled();
expect(spyInfo).toHaveBeenCalledWith('gradle cache is not found');
});
it('downloads cache based on buildSrc/Versions.kt', async () => {
createDirectory(join(workspace, 'buildSrc'));
createFile(join(workspace, 'buildSrc', 'Versions.kt'));
await restore('gradle', '');
expect(spyCacheRestore).toHaveBeenCalled();
expect(spyGlobHashFiles).toHaveBeenCalledWith(
'**/*.gradle*\n**/gradle-wrapper.properties\nbuildSrc/**/Versions.kt\nbuildSrc/**/Dependencies.kt\ngradle/*.versions.toml\n**/versions.properties'
);
expect(spyWarning).not.toHaveBeenCalled();
expect(spyInfo).toHaveBeenCalledWith('gradle cache is not found');
});
});
describe('for sbt', () => {
it('throws error if no build.sbt found', async () => {
await expect(restore('sbt', '')).rejects.toThrow(
`No file in ${projectRoot(
workspace
)} matched to [**/*.sbt,**/project/build.properties,**/project/**.scala,**/project/**.sbt], make sure you have checked out the target repository`
);
});
it('downloads cache', async () => {
createFile(join(workspace, 'build.sbt'));
await restore('sbt', '');
expect(spyCacheRestore).toHaveBeenCalled();
expect(spyGlobHashFiles).toHaveBeenCalledWith(
'**/*.sbt\n**/project/build.properties\n**/project/**.scala\n**/project/**.sbt'
);
expect(spyWarning).not.toHaveBeenCalled();
expect(spyInfo).toHaveBeenCalledWith('sbt cache is not found');
});
it('detects scala and sbt changes under **/project/ folder', async () => {
createFile(join(workspace, 'build.sbt'));
createDirectory(join(workspace, 'project'));
createFile(join(workspace, 'project/DependenciesV1.scala'));
await restore('sbt', '');
const firstCall = spySaveState.mock.calls.toString();
spySaveState.mockClear();
await restore('sbt', '');
const secondCall = spySaveState.mock.calls.toString();
// Make sure multiple restores produce the same cache
expect(firstCall).toBe(secondCall);
spySaveState.mockClear();
createFile(join(workspace, 'project/DependenciesV2.scala'));
await restore('sbt', '');
const thirdCall = spySaveState.mock.calls.toString();
expect(firstCall).not.toBe(thirdCall);
});
});
it('downloads cache based on versions.properties', async () => {
createFile(join(workspace, 'versions.properties'));
await restore('gradle', '');
expect(spyCacheRestore).toHaveBeenCalled();
expect(spyGlobHashFiles).toHaveBeenCalledWith(
'**/*.gradle*\n**/gradle-wrapper.properties\nbuildSrc/**/Versions.kt\nbuildSrc/**/Dependencies.kt\ngradle/*.versions.toml\n**/versions.properties'
);
expect(spyWarning).not.toHaveBeenCalled();
expect(spyInfo).toHaveBeenCalledWith('gradle cache is not found');
});
describe('cache-dependency-path', () => {
it('throws error if no matching dependency file found', async () => {
createFile(join(workspace, 'build.gradle.kts'));
await expect(
restore('gradle', 'sub-project/**/build.gradle.kts')
).rejects.toThrow(
`No file in ${projectRoot(
workspace
)} matched to [sub-project/**/build.gradle.kts], make sure you have checked out the target repository`
);
});
it('downloads cache based on the specified pattern', async () => {
createFile(join(workspace, 'build.gradle.kts'));
createDirectory(join(workspace, 'sub-project1'));
createFile(join(workspace, 'sub-project1', 'build.gradle.kts'));
createDirectory(join(workspace, 'sub-project2'));
createFile(join(workspace, 'sub-project2', 'build.gradle.kts'));
await restore('gradle', 'build.gradle.kts');
expect(spyCacheRestore).toHaveBeenCalled();
expect(spyGlobHashFiles).toHaveBeenCalledWith('build.gradle.kts');
expect(spyWarning).not.toHaveBeenCalled();
expect(spyInfo).toHaveBeenCalledWith('gradle cache is not found');
await restore('gradle', 'sub-project1/**/*.gradle*\n');
expect(spyCacheRestore).toHaveBeenCalled();
expect(spyGlobHashFiles).toHaveBeenCalledWith(
'sub-project1/**/*.gradle*'
);
expect(spyWarning).not.toHaveBeenCalled();
expect(spyInfo).toHaveBeenCalledWith('gradle cache is not found');
await restore('gradle', '*.gradle*\nsub-project2/**/*.gradle*\n');
expect(spyCacheRestore).toHaveBeenCalled();
expect(spyGlobHashFiles).toHaveBeenCalledWith(
'*.gradle*\nsub-project2/**/*.gradle*'
);
expect(spyWarning).not.toHaveBeenCalled();
expect(spyInfo).toHaveBeenCalledWith('gradle cache is not found');
});
});
});
@ -128,36 +263,69 @@ describe('dependency cache', () => {
beforeEach(() => {
spyCacheSave = jest
.spyOn(cache, 'saveCache')
.mockImplementation((paths: string[], key: string) => Promise.resolve(0));
.mockImplementation((paths: string[], key: string) =>
Promise.resolve(0)
);
spyWarning.mockImplementation(() => null);
});
it('throws error if unsupported package manager specified', () => {
return expect(save('ant')).rejects.toThrowError('unknown package manager specified: ant');
return expect(save('ant')).rejects.toThrow(
'unknown package manager specified: ant'
);
});
it('save with -1 cacheId , should not fail workflow', async () => {
spyCacheSave.mockImplementation(() => Promise.resolve(-1));
createStateForMissingBuildFile();
await save('maven');
expect(spyCacheSave).toHaveBeenCalled();
expect(spyWarning).not.toHaveBeenCalled();
expect(spyInfo).toHaveBeenCalled();
expect(spyInfo).toHaveBeenCalledWith(
expect.stringMatching(/^Cache saved with the key:.*/)
);
});
it('saves with error from toolkit, should fail workflow', async () => {
spyCacheSave.mockImplementation(() =>
Promise.reject(new cache.ValidationError('Validation failed'))
);
createStateForMissingBuildFile();
expect.assertions(1);
await expect(save('maven')).rejects.toEqual(
new cache.ValidationError('Validation failed')
);
});
describe('for maven', () => {
it('uploads cache even if no pom.xml found', async () => {
createStateForMissingBuildFile();
await save('maven');
expect(spyCacheSave).toBeCalled();
expect(spyWarning).not.toBeCalled();
expect(spyCacheSave).toHaveBeenCalled();
expect(spyWarning).not.toHaveBeenCalled();
});
it('does not upload cache if no restore run before', async () => {
createFile(join(workspace, 'pom.xml'));
await save('maven');
expect(spyCacheSave).not.toBeCalled();
expect(spyWarning).toBeCalledWith('Error retrieving key from state.');
expect(spyCacheSave).not.toHaveBeenCalled();
expect(spyWarning).toHaveBeenCalledWith(
'Error retrieving key from state.'
);
});
it('uploads cache', async () => {
createFile(join(workspace, 'pom.xml'));
createStateForSuccessfulRestore();
await save('maven');
expect(spyCacheSave).toBeCalled();
expect(spyWarning).not.toBeCalled();
expect(spyInfo).toBeCalledWith(expect.stringMatching(/^Cache saved with the key:.*/));
expect(spyCacheSave).toHaveBeenCalled();
expect(spyWarning).not.toHaveBeenCalled();
expect(spyInfo).toHaveBeenCalledWith(
expect.stringMatching(/^Cache saved with the key:.*/)
);
});
});
describe('for gradle', () => {
@ -165,33 +333,90 @@ describe('dependency cache', () => {
createStateForMissingBuildFile();
await save('gradle');
expect(spyCacheSave).toBeCalled();
expect(spyWarning).not.toBeCalled();
expect(spyCacheSave).toHaveBeenCalled();
expect(spyWarning).not.toHaveBeenCalled();
});
it('does not upload cache if no restore run before', async () => {
createFile(join(workspace, 'build.gradle'));
await save('gradle');
expect(spyCacheSave).not.toBeCalled();
expect(spyWarning).toBeCalledWith('Error retrieving key from state.');
expect(spyCacheSave).not.toHaveBeenCalled();
expect(spyWarning).toHaveBeenCalledWith(
'Error retrieving key from state.'
);
});
it('uploads cache based on build.gradle', async () => {
createFile(join(workspace, 'build.gradle'));
createStateForSuccessfulRestore();
await save('gradle');
expect(spyCacheSave).toBeCalled();
expect(spyWarning).not.toBeCalled();
expect(spyInfo).toBeCalledWith(expect.stringMatching(/^Cache saved with the key:.*/));
expect(spyCacheSave).toHaveBeenCalled();
expect(spyWarning).not.toHaveBeenCalled();
expect(spyInfo).toHaveBeenCalledWith(
expect.stringMatching(/^Cache saved with the key:.*/)
);
});
it('uploads cache based on build.gradle.kts', async () => {
createFile(join(workspace, 'build.gradle.kts'));
createStateForSuccessfulRestore();
await save('gradle');
expect(spyCacheSave).toBeCalled();
expect(spyWarning).not.toBeCalled();
expect(spyInfo).toBeCalledWith(expect.stringMatching(/^Cache saved with the key:.*/));
expect(spyCacheSave).toHaveBeenCalled();
expect(spyWarning).not.toHaveBeenCalled();
expect(spyInfo).toHaveBeenCalledWith(
expect.stringMatching(/^Cache saved with the key:.*/)
);
});
it('uploads cache based on buildSrc/Versions.kt', async () => {
createDirectory(join(workspace, 'buildSrc'));
createFile(join(workspace, 'buildSrc', 'Versions.kt'));
createStateForSuccessfulRestore();
await save('gradle');
expect(spyCacheSave).toHaveBeenCalled();
expect(spyWarning).not.toHaveBeenCalled();
expect(spyInfo).toHaveBeenCalledWith(
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).toHaveBeenCalled();
expect(spyWarning).not.toHaveBeenCalled();
});
it('does not upload cache if no restore run before', async () => {
createFile(join(workspace, 'build.sbt'));
await save('sbt');
expect(spyCacheSave).not.toHaveBeenCalled();
expect(spyWarning).toHaveBeenCalledWith(
'Error retrieving key from state.'
);
});
it('uploads cache', async () => {
createFile(join(workspace, 'build.sbt'));
createStateForSuccessfulRestore();
await save('sbt');
expect(spyCacheSave).toHaveBeenCalled();
expect(spyWarning).not.toHaveBeenCalled();
expect(spyInfo).toHaveBeenCalledWith(
expect.stringMatching(/^Cache saved with the key:.*/)
);
});
it('uploads cache based on versions.properties', async () => {
createFile(join(workspace, 'versions.properties'));
createStateForSuccessfulRestore();
await save('gradle');
expect(spyCacheSave).toHaveBeenCalled();
expect(spyWarning).not.toHaveBeenCalled();
expect(spyInfo).toHaveBeenCalledWith(
expect.stringMatching(/^Cache saved with the key:.*/)
);
});
});
});
@ -236,6 +461,11 @@ function createFile(path: string) {
fs.writeFileSync(path, '');
}
function createDirectory(path: string) {
core.info(`created a directory at ${path}`);
fs.mkdirSync(path);
}
function projectRoot(workspace: string): string {
if (os.platform() === 'darwin') {
return `/private${workspace}`;

12
__tests__/cache/gradle2/.gitignore vendored Normal file
View File

@ -0,0 +1,12 @@
.gradle
**/build/
!src/**/build/
# Ignore Gradle GUI config
gradle-app.setting
# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
!gradle-wrapper.jar
# Cache of project
.gradletasknamecache

17
__tests__/cache/gradle2/build.gradle vendored Normal file
View File

@ -0,0 +1,17 @@
plugins {
id 'java'
}
repositories {
mavenCentral()
}
dependencies {
implementation 'org.junit.jupiter:junit-jupiter-api:5.7.2'
}
tasks.register('downloadDependencies') {
doLast {
def total = configurations.compileClasspath.inject (0) { sum, file ->
sum + file.length()
}
println total
}
}

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

View File

@ -1,4 +1,4 @@
import { run as cleanup } from '../src/cleanup-java';
import {run as cleanup} from '../src/cleanup-java';
import * as core from '@actions/core';
import * as cache from '@actions/cache';
import * as util from '../src/util';
@ -26,7 +26,7 @@ describe('cleanup', () => {
resetState();
});
it('does not fail nor warn even when the save provess throws a ReserveCacheError', async () => {
it('does not fail nor warn even when the save process throws a ReserveCacheError', async () => {
spyCacheSave.mockImplementation((paths: string[], key: string) =>
Promise.reject(
new cache.ReserveCacheError(
@ -38,8 +38,8 @@ describe('cleanup', () => {
return name === 'cache' ? 'gradle' : '';
});
await cleanup();
expect(spyCacheSave).toBeCalled();
expect(spyWarning).not.toBeCalled();
expect(spyCacheSave).toHaveBeenCalled();
expect(spyWarning).not.toHaveBeenCalled();
});
it('does not fail even though the save process throws error', async () => {
@ -50,7 +50,7 @@ describe('cleanup', () => {
return name === 'cache' ? 'gradle' : '';
});
await cleanup();
expect(spyCacheSave).toBeCalled();
expect(spyCacheSave).toHaveBeenCalled();
});
});

1183
__tests__/data/corretto.json Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,443 @@
[
{
"buildVersion": 36,
"updateVersion": 0,
"patchVersion": 0,
"downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/14+36/bellsoft-jdk14+36-linux-amd64.zip",
"interimVersion": 0,
"version": "14+36",
"featureVersion": 14
},
{
"buildVersion": 9,
"updateVersion": 11,
"patchVersion": 0,
"downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/11.0.11+9/bellsoft-jdk11.0.11+9-linux-amd64.zip",
"interimVersion": 0,
"version": "11.0.11+9",
"featureVersion": 11
},
{
"buildVersion": 8,
"updateVersion": 1,
"patchVersion": 0,
"downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/14.0.1+8/bellsoft-jdk14.0.1+8-linux-amd64.zip",
"interimVersion": 0,
"version": "14.0.1+8",
"featureVersion": 14
},
{
"buildVersion": 10,
"updateVersion": 262,
"patchVersion": 0,
"downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/8u262+10/bellsoft-jdk8u262+10-linux-amd64.zip",
"interimVersion": 0,
"version": "8u262+10",
"featureVersion": 8
},
{
"buildVersion": 1,
"updateVersion": 275,
"patchVersion": 0,
"downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/8u275+1/bellsoft-jdk8u275+1-linux-amd64.zip",
"interimVersion": 0,
"version": "8u275+1",
"featureVersion": 8
},
{
"buildVersion": 1,
"updateVersion": 9,
"patchVersion": 1,
"downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/11.0.9.1+1/bellsoft-jdk11.0.9.1+1-linux-amd64.zip",
"interimVersion": 0,
"version": "11.0.9.1+1",
"featureVersion": 11
},
{
"buildVersion": 8,
"updateVersion": 202,
"patchVersion": 0,
"downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/8u202/bellsoft-jdk8u202-linux-amd64.zip",
"interimVersion": 0,
"version": "8u202+8",
"featureVersion": 8
},
{
"buildVersion": 33,
"updateVersion": 0,
"patchVersion": 0,
"downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/12/bellsoft-jdk12-linux-amd64.zip",
"interimVersion": 0,
"version": "12+33",
"featureVersion": 12
},
{
"buildVersion": 8,
"updateVersion": 282,
"patchVersion": 0,
"downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/8u282+8/bellsoft-jdk8u282+8-linux-amd64.zip",
"interimVersion": 0,
"version": "8u282+8",
"featureVersion": 8
},
{
"buildVersion": 11,
"updateVersion": 9,
"patchVersion": 0,
"downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/11.0.9+11/bellsoft-jdk11.0.9+11-linux-amd64.zip",
"interimVersion": 0,
"version": "11.0.9+11",
"featureVersion": 11
},
{
"buildVersion": 33,
"updateVersion": 0,
"patchVersion": 0,
"downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/13/bellsoft-jdk13-linux-amd64.zip",
"interimVersion": 0,
"version": "13+33",
"featureVersion": 13
},
{
"buildVersion": 12,
"updateVersion": 9,
"patchVersion": 0,
"downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/11.0.9+12/bellsoft-jdk11.0.9+12-linux-amd64.zip",
"interimVersion": 0,
"version": "11.0.9+12",
"featureVersion": 11
},
{
"buildVersion": 7,
"updateVersion": 242,
"patchVersion": 0,
"downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/8u242+7/bellsoft-jdk8u242+7-linux-amd64.zip",
"interimVersion": 0,
"version": "8u242+7",
"featureVersion": 8
},
{
"buildVersion": 9,
"updateVersion": 2,
"patchVersion": 0,
"downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/13.0.2+9/bellsoft-jdk13.0.2+9-linux-amd64.zip",
"interimVersion": 0,
"version": "13.0.2+9",
"featureVersion": 13
},
{
"buildVersion": 9,
"updateVersion": 1,
"patchVersion": 0,
"downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/13.0.1/bellsoft-jdk13.0.1-linux-amd64.zip",
"interimVersion": 0,
"version": "13.0.1+9",
"featureVersion": 13
},
{
"buildVersion": 1,
"updateVersion": 265,
"patchVersion": 0,
"downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/8u265+1/bellsoft-jdk8u265+1-linux-amd64.zip",
"interimVersion": 0,
"version": "8u265+1",
"featureVersion": 8
},
{
"buildVersion": 9,
"updateVersion": 1,
"patchVersion": 0,
"downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/15.0.1+9/bellsoft-jdk15.0.1+9-linux-amd64.zip",
"interimVersion": 0,
"version": "15.0.1+9",
"featureVersion": 15
},
{
"buildVersion": 10,
"updateVersion": 272,
"patchVersion": 0,
"downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/8u272+10/bellsoft-jdk8u272+10-linux-amd64.zip",
"interimVersion": 0,
"version": "8u272+10",
"featureVersion": 8
},
{
"buildVersion": 7,
"updateVersion": 2,
"patchVersion": 0,
"downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/16.0.2+7/bellsoft-jdk16.0.2+7-linux-amd64.zip",
"interimVersion": 0,
"version": "16.0.2+7",
"featureVersion": 16
},
{
"buildVersion": 10,
"updateVersion": 6,
"patchVersion": 0,
"downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/11.0.6+10/bellsoft-jdk11.0.6+10-linux-amd64.zip",
"interimVersion": 0,
"version": "11.0.6+10",
"featureVersion": 11
},
{
"buildVersion": 9,
"updateVersion": 252,
"patchVersion": 0,
"downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/8u252+9/bellsoft-jdk8u252+9-linux-amd64.zip",
"interimVersion": 0,
"version": "8u252+9",
"featureVersion": 8
},
{
"buildVersion": 12,
"updateVersion": 212,
"patchVersion": 0,
"downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/8u212/bellsoft-jdk8u212-linux-amd64.zip",
"interimVersion": 0,
"version": "8u212+12",
"featureVersion": 8
},
{
"buildVersion": 10,
"updateVersion": 2,
"patchVersion": 0,
"downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/15.0.2+10/bellsoft-jdk15.0.2+10-linux-amd64.zip",
"interimVersion": 0,
"version": "15.0.2+10",
"featureVersion": 15
},
{
"buildVersion": 9,
"updateVersion": 10,
"patchVersion": 0,
"downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/11.0.10+9/bellsoft-jdk11.0.10+9-linux-amd64.zip",
"interimVersion": 0,
"version": "11.0.10+9",
"featureVersion": 11
},
{
"buildVersion": 0,
"updateVersion": 1,
"patchVersion": 0,
"downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/11.0.1/bellsoft-jdk11.0.1-linux-amd64.tar.gz",
"interimVersion": 0,
"version": "11.0.1+0",
"featureVersion": 11
},
{
"buildVersion": 7,
"updateVersion": 12,
"patchVersion": 0,
"downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/11.0.12+7/bellsoft-jdk11.0.12+7-linux-amd64.zip",
"interimVersion": 0,
"version": "11.0.12+7",
"featureVersion": 11
},
{
"buildVersion": 36,
"updateVersion": 0,
"patchVersion": 0,
"downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/16+36/bellsoft-jdk16+36-linux-amd64.zip",
"interimVersion": 0,
"version": "16+36",
"featureVersion": 16
},
{
"buildVersion": 12,
"updateVersion": 3,
"patchVersion": 0,
"downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/11.0.3/bellsoft-jdk11.0.3-linux-amd64.zip",
"interimVersion": 0,
"version": "11.0.3+12",
"featureVersion": 11
},
{
"buildVersion": 10,
"updateVersion": 8,
"patchVersion": 0,
"downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/11.0.8+10/bellsoft-jdk11.0.8+10-linux-amd64.zip",
"interimVersion": 0,
"version": "11.0.8+10",
"featureVersion": 11
},
{
"buildVersion": 7,
"updateVersion": 2,
"patchVersion": 0,
"downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/11.0.2/bellsoft-jdk11.0.2-linux-amd64.zip",
"interimVersion": 0,
"version": "11.0.2+7",
"featureVersion": 11
},
{
"buildVersion": 10,
"updateVersion": 5,
"patchVersion": 0,
"downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/11.0.5/bellsoft-jdk11.0.5-linux-amd64.zip",
"interimVersion": 0,
"version": "11.0.5+10",
"featureVersion": 11
},
{
"buildVersion": 10,
"updateVersion": 4,
"patchVersion": 0,
"downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/11.0.4/bellsoft-jdk11.0.4-linux-amd64.zip",
"interimVersion": 0,
"version": "11.0.4+10",
"featureVersion": 11
},
{
"buildVersion": 10,
"updateVersion": 2,
"patchVersion": 0,
"downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/12.0.2/bellsoft-jdk12.0.2-linux-amd64.zip",
"interimVersion": 0,
"version": "12.0.2+10",
"featureVersion": 12
},
{
"buildVersion": 12,
"updateVersion": 1,
"patchVersion": 0,
"downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/12.0.1/bellsoft-jdk12.0.1-linux-amd64.zip",
"interimVersion": 0,
"version": "12.0.1+12",
"featureVersion": 12
},
{
"buildVersion": 10,
"updateVersion": 1,
"patchVersion": 0,
"downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/13.0.1+10/bellsoft-jdk13.0.1+10-linux-amd64.zip",
"interimVersion": 0,
"version": "13.0.1+10",
"featureVersion": 13
},
{
"buildVersion": 11,
"updateVersion": 5,
"patchVersion": 0,
"downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/11.0.5+11/bellsoft-jdk11.0.5+11-linux-amd64.tar.gz",
"interimVersion": 0,
"version": "11.0.5+11",
"featureVersion": 11
},
{
"buildVersion": 11,
"updateVersion": 5,
"patchVersion": 0,
"downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/11.0.5+11/bellsoft-jdk11.0.5+11-linux-amd64.zip",
"interimVersion": 0,
"version": "11.0.5+11",
"featureVersion": 11
},
{
"buildVersion": 10,
"updateVersion": 292,
"patchVersion": 0,
"downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/8u292+10/bellsoft-jdk8u292+10-linux-amd64.zip",
"interimVersion": 0,
"version": "8u292+10",
"featureVersion": 8
},
{
"buildVersion": 11,
"updateVersion": 222,
"patchVersion": 0,
"downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/8u222/bellsoft-jdk8u222-linux-amd64.zip",
"interimVersion": 0,
"version": "8u222+11",
"featureVersion": 8
},
{
"buildVersion": 36,
"updateVersion": 0,
"patchVersion": 0,
"downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/15+36/bellsoft-jdk15+36-linux-amd64.zip",
"interimVersion": 0,
"version": "15+36",
"featureVersion": 15
},
{
"buildVersion": 10,
"updateVersion": 7,
"patchVersion": 0,
"downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/11.0.7+10/bellsoft-jdk11.0.7+10-linux-amd64.zip",
"interimVersion": 0,
"version": "11.0.7+10",
"featureVersion": 11
},
{
"buildVersion": 10,
"updateVersion": 232,
"patchVersion": 0,
"downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/8u232+10/bellsoft-jdk8u232+10-linux-amd64.zip",
"interimVersion": 0,
"version": "8u232+10",
"featureVersion": 8
},
{
"buildVersion": 8,
"updateVersion": 2,
"patchVersion": 0,
"downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/15.0.2+8/bellsoft-jdk15.0.2+8-linux-amd64.zip",
"interimVersion": 0,
"version": "15.0.2+8",
"featureVersion": 15
},
{
"buildVersion": 8,
"updateVersion": 302,
"patchVersion": 0,
"downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/8u302+8/bellsoft-jdk8u302+8-linux-amd64.zip",
"interimVersion": 0,
"version": "8u302+8",
"featureVersion": 8
},
{
"buildVersion": 12,
"updateVersion": 192,
"patchVersion": 0,
"downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/8u192.all/bellsoft-jdk1.8.0-linux-amd64.tar.gz",
"interimVersion": 0,
"version": "8u192+12",
"featureVersion": 8
},
{
"buildVersion": 13,
"updateVersion": 2,
"patchVersion": 0,
"downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/14.0.2+13/bellsoft-jdk14.0.2+13-linux-amd64.zip",
"interimVersion": 0,
"version": "14.0.2+13",
"featureVersion": 14
},
{
"buildVersion": 9,
"updateVersion": 1,
"patchVersion": 0,
"downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/16.0.1+9/bellsoft-jdk16.0.1+9-linux-amd64.zip",
"interimVersion": 0,
"version": "16.0.1+9",
"featureVersion": 16
},
{
"buildVersion": 9,
"updateVersion": 232,
"patchVersion": 0,
"downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/8u232/bellsoft-jdk8u232-linux-amd64.zip",
"interimVersion": 0,
"version": "8u232+9",
"featureVersion": 8
},
{
"buildVersion": 13,
"updateVersion": 10,
"patchVersion": 0,
"downloadUrl":"https://download.bell-sw.com/java/17.0.10+13/bellsoft-jdk17.0.10+13-linux-amd64.tar.gz",
"interimVersion": 0,
"version": "17.0.10+13",
"featureVersion": 17
}
]

View File

@ -0,0 +1,452 @@
[
{
"buildVersion": 36,
"updateVersion": 0,
"patchVersion": 0,
"downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/14+36/bellsoft-jdk14+36-windows-amd64.zip",
"interimVersion": 0,
"version": "14+36",
"featureVersion": 14
},
{
"buildVersion": 9,
"updateVersion": 11,
"patchVersion": 0,
"downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/11.0.11+9/bellsoft-jdk11.0.11+9-windows-amd64.zip",
"interimVersion": 0,
"version": "11.0.11+9",
"featureVersion": 11
},
{
"buildVersion": 8,
"updateVersion": 1,
"patchVersion": 0,
"downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/14.0.1+8/bellsoft-jdk14.0.1+8-windows-amd64.zip",
"interimVersion": 0,
"version": "14.0.1+8",
"featureVersion": 14
},
{
"buildVersion": 10,
"updateVersion": 262,
"patchVersion": 0,
"downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/8u262+10/bellsoft-jdk8u262+10-windows-amd64.zip",
"interimVersion": 0,
"version": "8u262+10",
"featureVersion": 8
},
{
"buildVersion": 1,
"updateVersion": 275,
"patchVersion": 0,
"downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/8u275+1/bellsoft-jdk8u275+1-windows-amd64.zip",
"interimVersion": 0,
"version": "8u275+1",
"featureVersion": 8
},
{
"buildVersion": 1,
"updateVersion": 9,
"patchVersion": 1,
"downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/11.0.9.1+1/bellsoft-jdk11.0.9.1+1-windows-amd64.zip",
"interimVersion": 0,
"version": "11.0.9.1+1",
"featureVersion": 11
},
{
"buildVersion": 8,
"updateVersion": 202,
"patchVersion": 0,
"downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/8u202/bellsoft-jdk8u202-windows-amd64.zip",
"interimVersion": 0,
"version": "8u202+8",
"featureVersion": 8
},
{
"buildVersion": 33,
"updateVersion": 0,
"patchVersion": 0,
"downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/12/bellsoft-jdk12-windows-amd64.zip",
"interimVersion": 0,
"version": "12+33",
"featureVersion": 12
},
{
"buildVersion": 8,
"updateVersion": 282,
"patchVersion": 0,
"downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/8u282+8/bellsoft-jdk8u282+8-windows-amd64.zip",
"interimVersion": 0,
"version": "8u282+8",
"featureVersion": 8
},
{
"buildVersion": 11,
"updateVersion": 9,
"patchVersion": 0,
"downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/11.0.9+11/bellsoft-jdk11.0.9+11-windows-amd64.zip",
"interimVersion": 0,
"version": "11.0.9+11",
"featureVersion": 11
},
{
"buildVersion": 33,
"updateVersion": 0,
"patchVersion": 0,
"downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/13/bellsoft-jdk13-windows-amd64.zip",
"interimVersion": 0,
"version": "13+33",
"featureVersion": 13
},
{
"buildVersion": 12,
"updateVersion": 9,
"patchVersion": 0,
"downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/11.0.9+12/bellsoft-jdk11.0.9+12-windows-amd64.zip",
"interimVersion": 0,
"version": "11.0.9+12",
"featureVersion": 11
},
{
"buildVersion": 7,
"updateVersion": 242,
"patchVersion": 0,
"downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/8u242+7/bellsoft-jdk8u242+7-windows-amd64.zip",
"interimVersion": 0,
"version": "8u242+7",
"featureVersion": 8
},
{
"buildVersion": 9,
"updateVersion": 2,
"patchVersion": 0,
"downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/13.0.2+9/bellsoft-jdk13.0.2+9-windows-amd64.zip",
"interimVersion": 0,
"version": "13.0.2+9",
"featureVersion": 13
},
{
"buildVersion": 9,
"updateVersion": 1,
"patchVersion": 0,
"downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/13.0.1/bellsoft-jdk13.0.1-windows-amd64.zip",
"interimVersion": 0,
"version": "13.0.1+9",
"featureVersion": 13
},
{
"buildVersion": 1,
"updateVersion": 265,
"patchVersion": 0,
"downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/8u265+1/bellsoft-jdk8u265+1-windows-amd64.zip",
"interimVersion": 0,
"version": "8u265+1",
"featureVersion": 8
},
{
"buildVersion": 9,
"updateVersion": 1,
"patchVersion": 0,
"downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/15.0.1+9/bellsoft-jdk15.0.1+9-windows-amd64.zip",
"interimVersion": 0,
"version": "15.0.1+9",
"featureVersion": 15
},
{
"buildVersion": 10,
"updateVersion": 272,
"patchVersion": 0,
"downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/8u272+10/bellsoft-jdk8u272+10-windows-amd64.zip",
"interimVersion": 0,
"version": "8u272+10",
"featureVersion": 8
},
{
"buildVersion": 7,
"updateVersion": 2,
"patchVersion": 0,
"downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/16.0.2+7/bellsoft-jdk16.0.2+7-windows-amd64.zip",
"interimVersion": 0,
"version": "16.0.2+7",
"featureVersion": 16
},
{
"buildVersion": 10,
"updateVersion": 6,
"patchVersion": 0,
"downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/11.0.6+10/bellsoft-jdk11.0.6+10-windows-amd64.zip",
"interimVersion": 0,
"version": "11.0.6+10",
"featureVersion": 11
},
{
"buildVersion": 9,
"updateVersion": 252,
"patchVersion": 0,
"downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/8u252+9/bellsoft-jdk8u252+9-windows-amd64.zip",
"interimVersion": 0,
"version": "8u252+9",
"featureVersion": 8
},
{
"buildVersion": 12,
"updateVersion": 212,
"patchVersion": 0,
"downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/8u212/bellsoft-jdk8u212-windows-amd64.zip",
"interimVersion": 0,
"version": "8u212+12",
"featureVersion": 8
},
{
"buildVersion": 10,
"updateVersion": 2,
"patchVersion": 0,
"downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/15.0.2+10/bellsoft-jdk15.0.2+10-windows-amd64.zip",
"interimVersion": 0,
"version": "15.0.2+10",
"featureVersion": 15
},
{
"buildVersion": 9,
"updateVersion": 10,
"patchVersion": 0,
"downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/11.0.10+9/bellsoft-jdk11.0.10+9-windows-amd64.zip",
"interimVersion": 0,
"version": "11.0.10+9",
"featureVersion": 11
},
{
"buildVersion": 0,
"updateVersion": 1,
"patchVersion": 0,
"downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/11.0.1/bellsoft-jdk11.0.1-windows-amd64.tar.gz",
"interimVersion": 0,
"version": "11.0.1+0",
"featureVersion": 11
},
{
"buildVersion": 7,
"updateVersion": 12,
"patchVersion": 0,
"downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/11.0.12+7/bellsoft-jdk11.0.12+7-windows-amd64.zip",
"interimVersion": 0,
"version": "11.0.12+7",
"featureVersion": 11
},
{
"buildVersion": 36,
"updateVersion": 0,
"patchVersion": 0,
"downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/16+36/bellsoft-jdk16+36-windows-amd64.zip",
"interimVersion": 0,
"version": "16+36",
"featureVersion": 16
},
{
"buildVersion": 12,
"updateVersion": 3,
"patchVersion": 0,
"downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/11.0.3/bellsoft-jdk11.0.3-windows-amd64.zip",
"interimVersion": 0,
"version": "11.0.3+12",
"featureVersion": 11
},
{
"buildVersion": 10,
"updateVersion": 8,
"patchVersion": 0,
"downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/11.0.8+10/bellsoft-jdk11.0.8+10-windows-amd64.zip",
"interimVersion": 0,
"version": "11.0.8+10",
"featureVersion": 11
},
{
"buildVersion": 7,
"updateVersion": 2,
"patchVersion": 0,
"downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/11.0.2/bellsoft-jdk11.0.2-windows-amd64.zip",
"interimVersion": 0,
"version": "11.0.2+7",
"featureVersion": 11
},
{
"buildVersion": 10,
"updateVersion": 5,
"patchVersion": 0,
"downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/11.0.5/bellsoft-jdk11.0.5-windows-amd64.zip",
"interimVersion": 0,
"version": "11.0.5+10",
"featureVersion": 11
},
{
"buildVersion": 10,
"updateVersion": 4,
"patchVersion": 0,
"downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/11.0.4/bellsoft-jdk11.0.4-windows-amd64.zip",
"interimVersion": 0,
"version": "11.0.4+10",
"featureVersion": 11
},
{
"buildVersion": 10,
"updateVersion": 2,
"patchVersion": 0,
"downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/12.0.2/bellsoft-jdk12.0.2-windows-amd64.zip",
"interimVersion": 0,
"version": "12.0.2+10",
"featureVersion": 12
},
{
"buildVersion": 12,
"updateVersion": 1,
"patchVersion": 0,
"downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/12.0.1/bellsoft-jdk12.0.1-windows-amd64.zip",
"interimVersion": 0,
"version": "12.0.1+12",
"featureVersion": 12
},
{
"buildVersion": 10,
"updateVersion": 1,
"patchVersion": 0,
"downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/13.0.1+10/bellsoft-jdk13.0.1+10-windows-amd64.zip",
"interimVersion": 0,
"version": "13.0.1+10",
"featureVersion": 13
},
{
"buildVersion": 11,
"updateVersion": 5,
"patchVersion": 0,
"downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/11.0.5+11/bellsoft-jdk11.0.5+11-windows-amd64.tar.gz",
"interimVersion": 0,
"version": "11.0.5+11",
"featureVersion": 11
},
{
"buildVersion": 11,
"updateVersion": 5,
"patchVersion": 0,
"downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/11.0.5+11/bellsoft-jdk11.0.5+11-windows-amd64.zip",
"interimVersion": 0,
"version": "11.0.5+11",
"featureVersion": 11
},
{
"buildVersion": 10,
"updateVersion": 292,
"patchVersion": 0,
"downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/8u292+10/bellsoft-jdk8u292+10-windows-amd64.zip",
"interimVersion": 0,
"version": "8u292+10",
"featureVersion": 8
},
{
"buildVersion": 11,
"updateVersion": 222,
"patchVersion": 0,
"downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/8u222/bellsoft-jdk8u222-windows-amd64.zip",
"interimVersion": 0,
"version": "8u222+11",
"featureVersion": 8
},
{
"buildVersion": 36,
"updateVersion": 0,
"patchVersion": 0,
"downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/15+36/bellsoft-jdk15+36-windows-amd64.zip",
"interimVersion": 0,
"version": "15+36",
"featureVersion": 15
},
{
"buildVersion": 10,
"updateVersion": 7,
"patchVersion": 0,
"downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/11.0.7+10/bellsoft-jdk11.0.7+10-windows-amd64.zip",
"interimVersion": 0,
"version": "11.0.7+10",
"featureVersion": 11
},
{
"buildVersion": 10,
"updateVersion": 232,
"patchVersion": 0,
"downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/8u232+10/bellsoft-jdk8u232+10-windows-amd64.zip",
"interimVersion": 0,
"version": "8u232+10",
"featureVersion": 8
},
{
"buildVersion": 8,
"updateVersion": 2,
"patchVersion": 0,
"downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/15.0.2+8/bellsoft-jdk15.0.2+8-windows-amd64.zip",
"interimVersion": 0,
"version": "15.0.2+8",
"featureVersion": 15
},
{
"buildVersion": 8,
"updateVersion": 302,
"patchVersion": 0,
"downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/8u302+8/bellsoft-jdk8u302+8-windows-amd64.zip",
"interimVersion": 0,
"version": "8u302+8",
"featureVersion": 8
},
{
"buildVersion": 12,
"updateVersion": 192,
"patchVersion": 0,
"downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/8u192.all/bellsoft-jdk1.8.0-windows-amd64.tar.gz",
"interimVersion": 0,
"version": "8u192+12",
"featureVersion": 8
},
{
"buildVersion": 13,
"updateVersion": 2,
"patchVersion": 0,
"downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/14.0.2+13/bellsoft-jdk14.0.2+13-windows-amd64.zip",
"interimVersion": 0,
"version": "14.0.2+13",
"featureVersion": 14
},
{
"buildVersion": 9,
"updateVersion": 1,
"patchVersion": 0,
"downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/16.0.1+9/bellsoft-jdk16.0.1+9-windows-amd64.zip",
"interimVersion": 0,
"version": "16.0.1+9",
"featureVersion": 16
},
{
"buildVersion": 9,
"updateVersion": 232,
"patchVersion": 0,
"downloadUrl": "https://github.com/bell-sw/Liberica/releases/download/8u232/bellsoft-jdk8u232-windows-amd64.zip",
"interimVersion": 0,
"version": "8u232+9",
"featureVersion": 8
},
{
"buildVersion": 14,
"updateVersion": 2,
"patchVersion": 0,
"downloadUrl": "https://download.bell-sw.com/java/21.0.2+14/bellsoft-jdk21.0.2+14-windows-aarch64.zip",
"interimVersion": 0,
"version": "21.0.2+14",
"featureVersion": 21
},
{
"buildVersion": 13,
"updateVersion": 10,
"patchVersion": 0,
"downloadUrl": "https://download.bell-sw.com/java/17.0.10+13/bellsoft-jdk17.0.10+13-windows-aarch64.zip",
"interimVersion": 0,
"version": "17.0.10+13",
"featureVersion": 17
}
]

View File

@ -0,0 +1,261 @@
[
{
"version": "21.0.0",
"stable": true,
"release_url": "https://aka.ms/download-jdk",
"files": [
{
"filename": "microsoft-jdk-21.0.0-macos-x64.tar.gz",
"arch": "x64",
"platform": "darwin",
"download_url": "https://aka.ms/download-jdk/microsoft-jdk-21.0.0-macos-x64.tar.gz"
},
{
"filename": "microsoft-jdk-21.0.0-linux-x64.tar.gz",
"arch": "x64",
"platform": "linux",
"download_url": "https://aka.ms/download-jdk/microsoft-jdk-21.0.0-linux-x64.tar.gz"
},
{
"filename": "microsoft-jdk-21.0.0-windows-x64.zip",
"arch": "x64",
"platform": "win32",
"download_url": "https://aka.ms/download-jdk/microsoft-jdk-21.0.0-windows-x64.zip"
},
{
"filename": "microsoft-jdk-21.0.0-macos-aarch64.tar.gz",
"arch": "aarch64",
"platform": "darwin",
"download_url": "https://aka.ms/download-jdk/microsoft-jdk-21.0.0-macos-aarch64.tar.gz"
},
{
"filename": "microsoft-jdk-21.0.0-linux-aarch64.tar.gz",
"arch": "aarch64",
"platform": "linux",
"download_url": "https://aka.ms/download-jdk/microsoft-jdk-21.0.0-linux-aarch64.tar.gz"
}
]
},
{
"version": "17.0.7",
"stable": true,
"release_url": "https://aka.ms/download-jdk",
"files": [
{
"filename": "microsoft-jdk-17.0.7-macos-x64.tar.gz",
"arch": "x64",
"platform": "darwin",
"download_url": "https://aka.ms/download-jdk/microsoft-jdk-17.0.7-macos-x64.tar.gz"
},
{
"filename": "microsoft-jdk-17.0.7-linux-x64.tar.gz",
"arch": "x64",
"platform": "linux",
"download_url": "https://aka.ms/download-jdk/microsoft-jdk-17.0.7-linux-x64.tar.gz"
},
{
"filename": "microsoft-jdk-17.0.7-windows-x64.zip",
"arch": "x64",
"platform": "win32",
"download_url": "https://aka.ms/download-jdk/microsoft-jdk-17.0.7-windows-x64.zip"
},
{
"filename": "microsoft-jdk-17.0.7-macos-aarch64.tar.gz",
"arch": "aarch64",
"platform": "darwin",
"download_url": "https://aka.ms/download-jdk/microsoft-jdk-17.0.7-macos-aarch64.tar.gz"
},
{
"filename": "microsoft-jdk-17.0.7-linux-aarch64.tar.gz",
"arch": "aarch64",
"platform": "linux",
"download_url": "https://aka.ms/download-jdk/microsoft-jdk-17.0.7-linux-aarch64.tar.gz"
},
{
"filename": "microsoft-jdk-17.0.7-windows-aarch64.zip",
"arch": "aarch64",
"platform": "win32",
"download_url": "https://aka.ms/download-jdk/microsoft-jdk-17.0.7-windows-aarch64.zip"
}
]
},
{
"version": "17.0.1+12.1",
"stable": true,
"release_url": "https://aka.ms/download-jdk",
"files": [
{
"filename": "microsoft-jdk-17.0.1.12.1-macos-x64.tar.gz",
"arch": "x64",
"platform": "darwin",
"download_url": "https://aka.ms/download-jdk/microsoft-jdk-17.0.1.12.1-macos-x64.tar.gz"
},
{
"filename": "microsoft-jdk-17.0.1.12.1-linux-x64.tar.gz",
"arch": "x64",
"platform": "linux",
"download_url": "https://aka.ms/download-jdk/microsoft-jdk-17.0.1.12.1-linux-x64.tar.gz"
},
{
"filename": "microsoft-jdk-17.0.1.12.1-windows-x64.zip",
"arch": "x64",
"platform": "win32",
"download_url": "https://aka.ms/download-jdk/microsoft-jdk-17.0.1.12.1-windows-x64.zip"
},
{
"filename": "microsoft-jdk-17.0.1.12.1-macos-aarch64.tar.gz",
"arch": "aarch64",
"platform": "darwin",
"download_url": "https://aka.ms/download-jdk/microsoft-jdk-17.0.1.12.1-macos-aarch64.tar.gz"
},
{
"filename": "microsoft-jdk-17.0.1.12.1-linux-aarch64.tar.gz",
"arch": "aarch64",
"platform": "linux",
"download_url": "https://aka.ms/download-jdk/microsoft-jdk-17.0.1.12.1-linux-aarch64.tar.gz"
}
]
},
{
"version": "16.0.2+7.1",
"stable": true,
"release_url": "https://aka.ms/download-jdk",
"files": [
{
"filename": "microsoft-jdk-16.0.2.7.1-macos-x64.tar.gz",
"arch": "x64",
"platform": "darwin",
"download_url": "https://aka.ms/download-jdk/microsoft-jdk-16.0.2.7.1-macos-x64.tar.gz"
},
{
"filename": "microsoft-jdk-16.0.2.7.1-linux-x64.tar.gz",
"arch": "x64",
"platform": "linux",
"download_url": "https://aka.ms/download-jdk/microsoft-jdk-16.0.2.7.1-linux-x64.tar.gz"
},
{
"filename": "microsoft-jdk-16.0.2.7.1-windows-x64.zip",
"arch": "x64",
"platform": "win32",
"download_url": "https://aka.ms/download-jdk/microsoft-jdk-16.0.2.7.1-windows-x64.zip"
},
{
"filename": "microsoft-jdk-16.0.2.7.1-macos-aarch64.tar.gz",
"arch": "aarch64",
"platform": "darwin",
"download_url": "https://aka.ms/download-jdk/microsoft-jdk-16.0.2.7.1-macos-aarch64.tar.gz"
},
{
"filename": "microsoft-jdk-16.0.2.7.1-linux-aarch64.tar.gz",
"arch": "aarch64",
"platform": "linux",
"download_url": "https://aka.ms/download-jdk/microsoft-jdk-16.0.2.7.1-linux-aarch64.tar.gz"
}
]
},
{
"version": "11.0.19",
"stable": true,
"release_url": "https://aka.ms/download-jdk",
"files": [
{
"filename": "microsoft-jdk-11.0.19-macos-x64.tar.gz",
"arch": "x64",
"platform": "darwin",
"download_url": "https://aka.ms/download-jdk/microsoft-jdk-11.0.19-macos-x64.tar.gz"
},
{
"filename": "microsoft-jdk-11.0.19-linux-x64.tar.gz",
"arch": "x64",
"platform": "linux",
"download_url": "https://aka.ms/download-jdk/microsoft-jdk-11.0.19-linux-x64.tar.gz"
},
{
"filename": "microsoft-jdk-11.0.19-windows-x64.zip",
"arch": "x64",
"platform": "win32",
"download_url": "https://aka.ms/download-jdk/microsoft-jdk-11.0.19-windows-x64.zip"
},
{
"filename": "microsoft-jdk-11.0.19-macos-aarch64.tar.gz",
"arch": "aarch64",
"platform": "darwin",
"download_url": "https://aka.ms/download-jdk/microsoft-jdk-11.0.19-macos-aarch64.tar.gz"
},
{
"filename": "microsoft-jdk-11.0.19-linux-aarch64.tar.gz",
"arch": "aarch64",
"platform": "linux",
"download_url": "https://aka.ms/download-jdk/microsoft-jdk-11.0.19-linux-aarch64.tar.gz"
}
]
},
{
"version": "11.0.15",
"stable": true,
"release_url": "https://aka.ms/download-jdk",
"files": [
{
"filename": "microsoft-jdk-11.0.15-macos-x64.tar.gz",
"arch": "x64",
"platform": "darwin",
"download_url": "https://aka.ms/download-jdk/microsoft-jdk-11.0.15-macos-x64.tar.gz"
},
{
"filename": "microsoft-jdk-11.0.15-linux-x64.tar.gz",
"arch": "x64",
"platform": "linux",
"download_url": "https://aka.ms/download-jdk/microsoft-jdk-11.0.15-linux-x64.tar.gz"
},
{
"filename": "microsoft-jdk-11.0.15-windows-x64.zip",
"arch": "x64",
"platform": "win32",
"download_url": "https://aka.ms/download-jdk/microsoft-jdk-11.0.15-windows-x64.zip"
},
{
"filename": "microsoft-jdk-11.0.15-macos-aarch64.tar.gz",
"arch": "aarch64",
"platform": "darwin",
"download_url": "https://aka.ms/download-jdk/microsoft-jdk-11.0.15-macos-aarch64.tar.gz"
},
{
"filename": "microsoft-jdk-11.0.15-linux-aarch64.tar.gz",
"arch": "aarch64",
"platform": "linux",
"download_url": "https://aka.ms/download-jdk/microsoft-jdk-11.0.15-linux-aarch64.tar.gz"
}
]
},
{
"version": "11.0.13+8.1",
"stable": true,
"release_url": "https://aka.ms/download-jdk",
"files": [
{
"filename": "microsoft-jdk-11.0.13.8.1-macos-x64.tar.gz",
"arch": "x64",
"platform": "darwin",
"download_url": "https://aka.ms/download-jdk/microsoft-jdk-11.0.13.8.1-macos-x64.tar.gz"
},
{
"filename": "microsoft-jdk-11.0.13.8.1-linux-x64.tar.gz",
"arch": "x64",
"platform": "linux",
"download_url": "https://aka.ms/download-jdk/microsoft-jdk-11.0.13.8.1-linux-x64.tar.gz"
},
{
"filename": "microsoft-jdk-11.0.13.8.1-windows-x64.zip",
"arch": "x64",
"platform": "win32",
"download_url": "https://aka.ms/download-jdk/microsoft-jdk-11.0.13.8.1-windows-x64.zip"
},
{
"filename": "microsoft-jdk-11.0.13.8.1-linux-aarch64.tar.gz",
"arch": "aarch64",
"platform": "linux",
"download_url": "https://aka.ms/download-jdk/microsoft-jdk-11.0.13.8.1-linux-aarch64.tar.gz"
}
]
}
]

2168
__tests__/data/semeru.json Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,254 @@
[
{
"id": 10996,
"url": "https://cdn.azul.com/zulu/bin/zulu1.8.0_05-8.1.0.10-linux.tar.gz",
"name": "zulu1.8.0_05-8.1.0.10-linux.tar.gz",
"zulu_version": [8, 1, 0, 10],
"jdk_version": [8, 0, 5, 13]
},
{
"id": 10997,
"url": "https://cdn.azul.com/zulu/bin/zulu1.8.0_11-8.2.0.1-linux.tar.gz",
"name": "zulu1.8.0_11-8.2.0.1-linux.tar.gz",
"zulu_version": [8, 2, 0, 1],
"jdk_version": [8, 0, 11, 12]
},
{
"id": 10346,
"url": "https://cdn.azul.com/zulu/bin/zulu8.21.0.1-jdk8.0.131-linux_x64.tar.gz",
"name": "zulu8.21.0.1-jdk8.0.131-linux_x64.tar.gz",
"zulu_version": [8, 21, 0, 1],
"jdk_version": [8, 0, 131, 11]
},
{
"id": 10362,
"url": "https://cdn.azul.com/zulu/bin/zulu8.23.0.3-jdk8.0.144-linux_x64.tar.gz",
"name": "zulu8.23.0.3-jdk8.0.144-linux_x64.tar.gz",
"zulu_version": [8, 23, 0, 3],
"jdk_version": [8, 0, 144, 1]
},
{
"id": 10399,
"url": "https://cdn.azul.com/zulu/bin/zulu8.25.0.1-jdk8.0.152-linux_x64.tar.gz",
"name": "zulu8.25.0.1-jdk8.0.152-linux_x64.tar.gz",
"zulu_version": [8, 25, 0, 1],
"jdk_version": [8, 0, 152, 16]
},
{
"id": 11355,
"url": "https://cdn.azul.com/zulu/bin/zulu8.46.0.19-ca-jdk8.0.252-linux_x64.tar.gz",
"name": "zulu8.46.0.19-ca-jdk8.0.252-linux_x64.tar.gz",
"zulu_version": [8, 46, 0, 19],
"jdk_version": [8, 0, 252, 14]
},
{
"id": 11481,
"url": "https://cdn.azul.com/zulu/bin/zulu8.48.0.47-ca-jdk8.0.262-linux_x64.tar.gz",
"name": "zulu8.48.0.47-ca-jdk8.0.262-linux_x64.tar.gz",
"zulu_version": [8, 48, 0, 47],
"jdk_version": [8, 0, 262, 17]
},
{
"id": 11622,
"url": "https://cdn.azul.com/zulu/bin/zulu8.48.0.51-ca-jdk8.0.262-linux_x64.tar.gz",
"name": "zulu8.48.0.51-ca-jdk8.0.262-linux_x64.tar.gz",
"zulu_version": [8, 48, 0, 51],
"jdk_version": [8, 0, 262, 19]
},
{
"id": 11535,
"url": "https://cdn.azul.com/zulu/bin/zulu8.48.0.49-ca-jdk8.0.262-linux_x64.tar.gz",
"name": "zulu8.48.0.49-ca-jdk8.0.262-linux_x64.tar.gz",
"zulu_version": [8, 48, 0, 49],
"jdk_version": [8, 0, 262, 18]
},
{
"id": 12424,
"url": "https://cdn.azul.com/zulu/bin/zulu8.52.0.23-ca-jdk8.0.282-linux_x64.tar.gz",
"name": "zulu8.52.0.23-ca-jdk8.0.282-linux_x64.tar.gz",
"zulu_version": [8, 52, 0, 23],
"jdk_version": [8, 0, 282, 8]
},
{
"id": 10383,
"url": "https://cdn.azul.com/zulu/bin/zulu9.0.0.15-jdk9.0.0-linux_x64.tar.gz",
"name": "zulu9.0.0.15-jdk9.0.0-linux_x64.tar.gz",
"zulu_version": [9, 0, 0, 15],
"jdk_version": [9, 0, 0, 0]
},
{
"id": 10413,
"url": "https://cdn.azul.com/zulu/bin/zulu9.0.1.3-jdk9.0.1-linux_x64.tar.gz",
"name": "zulu9.0.1.3-jdk9.0.1-linux_x64.tar.gz",
"zulu_version": [9, 0, 1, 3],
"jdk_version": [9, 0, 1, 0]
},
{
"id": 10503,
"url": "https://cdn.azul.com/zulu/bin/zulu10.2+3-jdk10.0.1-linux_x64.tar.gz",
"name": "zulu10.2+3-jdk10.0.1-linux_x64.tar.gz",
"zulu_version": [10, 2, 3, 0],
"jdk_version": [10, 0, 1, 9]
},
{
"id": 10541,
"url": "https://cdn.azul.com/zulu/bin/zulu10.3+5-jdk10.0.2-linux_x64.tar.gz",
"name": "zulu10.3+5-jdk10.0.2-linux_x64.tar.gz",
"zulu_version": [10, 3, 5, 0],
"jdk_version": [10, 0, 2, 13]
},
{
"id": 10576,
"url": "https://cdn.azul.com/zulu/bin/zulu11.2.3-jdk11.0.1-linux_x64.tar.gz",
"name": "zulu11.2.3-jdk11.0.1-linux_x64.tar.gz",
"zulu_version": [11, 2, 3, 0],
"jdk_version": [11, 0, 1, 13]
},
{
"id": 10604,
"url": "https://cdn.azul.com/zulu/bin/zulu11.29.3-ca-jdk11.0.2-linux_x64.tar.gz",
"name": "zulu11.29.3-ca-jdk11.0.2-linux_x64.tar.gz",
"zulu_version": [11, 29, 3, 0],
"jdk_version": [11, 0, 2, 7]
},
{
"id": 10687,
"url": "https://cdn.azul.com/zulu/bin/zulu11.31.11-ca-jdk11.0.3-linux_x64.tar.gz",
"name": "zulu11.31.11-ca-jdk11.0.3-linux_x64.tar.gz",
"zulu_version": [11, 31, 11, 0],
"jdk_version": [11, 0, 3, 7]
},
{
"id": 10856,
"url": "https://cdn.azul.com/zulu/bin/zulu11.35.13-ca-jdk11.0.5-linux_x64.tar.gz",
"name": "zulu11.35.13-ca-jdk11.0.5-linux_x64.tar.gz",
"zulu_version": [11, 35, 13, 0],
"jdk_version": [11, 0, 5, 10]
},
{
"id": 10933,
"url": "https://cdn.azul.com/zulu/bin/zulu11.35.15-ca-jdk11.0.5-linux_x64.tar.gz",
"name": "zulu11.35.15-ca-jdk11.0.5-linux_x64.tar.gz",
"zulu_version": [11, 35, 15, 0],
"jdk_version": [11, 0, 5, 10]
},
{
"id": 10933,
"url": "https://cdn.azul.com/zulu/bin/zulu11.35.11-ca-jdk11.0.5-linux_x64.tar.gz",
"name": "zulu11.35.15-ca-jdk11.0.5-linux_x64.tar.gz",
"zulu_version": [11, 35, 11, 0],
"jdk_version": [11, 0, 5, 10]
},
{
"id": 12397,
"url": "https://cdn.azul.com/zulu/bin/zulu11.45.27-ca-jdk11.0.10-linux_x64.tar.gz",
"name": "zulu11.45.27-ca-jdk11.0.10-linux_x64.tar.gz",
"zulu_version": [11, 45, 27, 0],
"jdk_version": [11, 0, 10, 9]
},
{
"id": 10667,
"url": "https://cdn.azul.com/zulu/bin/zulu12.1.3-ca-jdk12.0.0-linux_x64.tar.gz",
"name": "zulu12.1.3-ca-jdk12.0.0-linux_x64.tar.gz",
"zulu_version": [12, 1, 3, 0],
"jdk_version": [12, 0, 0, 33]
},
{
"id": 10710,
"url": "https://cdn.azul.com/zulu/bin/zulu12.2.3-ca-jdk12.0.1-linux_x64.tar.gz",
"name": "zulu12.2.3-ca-jdk12.0.1-linux_x64.tar.gz",
"zulu_version": [12, 2, 3, 0],
"jdk_version": [12, 0, 1, 12]
},
{
"id": 10780,
"url": "https://cdn.azul.com/zulu/bin/zulu12.3.11-ca-jdk12.0.2-linux_x64.tar.gz",
"name": "zulu12.3.11-ca-jdk12.0.2-linux_x64.tar.gz",
"zulu_version": [12, 3, 11, 0],
"jdk_version": [12, 0, 2, 3]
},
{
"id": 10846,
"url": "https://cdn.azul.com/zulu/bin/zulu13.27.9-ca-jdk13.0.0-linux_x64.tar.gz",
"name": "zulu13.27.9-ca-jdk13.0.0-linux_x64.tar.gz",
"zulu_version": [13, 27, 9, 0],
"jdk_version": [13, 0, 0, 33]
},
{
"id": 10888,
"url": "https://cdn.azul.com/zulu/bin/zulu13.28.11-ca-jdk13.0.1-linux_x64.tar.gz",
"name": "zulu13.28.11-ca-jdk13.0.1-linux_x64.tar.gz",
"zulu_version": [13, 28, 11, 0],
"jdk_version": [13, 0, 1, 10]
},
{
"id": 11073,
"url": "https://cdn.azul.com/zulu/bin/zulu13.29.9-ca-jdk13.0.2-linux_x64.tar.gz",
"name": "zulu13.29.9-ca-jdk13.0.2-linux_x64.tar.gz",
"zulu_version": [13, 29, 9, 0],
"jdk_version": [13, 0, 2, 6]
},
{
"id": 12408,
"url": "https://cdn.azul.com/zulu/bin/zulu13.37.21-ca-jdk13.0.6-linux_x64.tar.gz",
"name": "zulu13.37.21-ca-jdk13.0.6-linux_x64.tar.gz",
"zulu_version": [13, 37, 21, 0],
"jdk_version": [13, 0, 6, 5]
},
{
"id": 11236,
"url": "https://cdn.azul.com/zulu/bin/zulu14.27.1-ca-jdk14.0.0-linux_x64.tar.gz",
"name": "zulu14.27.1-ca-jdk14.0.0-linux_x64.tar.gz",
"zulu_version": [14, 27, 1, 0],
"jdk_version": [14, 0, 0, 36]
},
{
"id": 11349,
"url": "https://cdn.azul.com/zulu/bin/zulu14.28.21-ca-jdk14.0.1-linux_x64.tar.gz",
"name": "zulu14.28.21-ca-jdk14.0.1-linux_x64.tar.gz",
"zulu_version": [14, 28, 21, 0],
"jdk_version": [14, 0, 1, 8]
},
{
"id": 11513,
"url": "https://cdn.azul.com/zulu/bin/zulu14.29.23-ca-jdk14.0.2-linux_x64.tar.gz",
"name": "zulu14.29.23-ca-jdk14.0.2-linux_x64.tar.gz",
"zulu_version": [14, 29, 23, 0],
"jdk_version": [14, 0, 2, 12]
},
{
"id": 11780,
"url": "https://cdn.azul.com/zulu/bin/zulu15.27.17-ca-jdk15.0.0-linux_x64.tar.gz",
"name": "zulu15.27.17-ca-jdk15.0.0-linux_x64.tar.gz",
"zulu_version": [15, 27, 17, 0],
"jdk_version": [15, 0, 0, 36]
},
{
"id": 11924,
"url": "https://cdn.azul.com/zulu/bin/zulu15.28.13-ca-jdk15.0.1-linux_x64.tar.gz",
"name": "zulu15.28.13-ca-jdk15.0.1-linux_x64.tar.gz",
"zulu_version": [15, 28, 13, 0],
"jdk_version": [15, 0, 1, 8]
},
{
"id": 12101,
"url": "https://cdn.azul.com/zulu/bin/zulu15.28.51-ca-jdk15.0.1-linux_x64.tar.gz",
"name": "zulu15.28.51-ca-jdk15.0.1-linux_x64.tar.gz",
"zulu_version": [15, 28, 51, 0],
"jdk_version": [15, 0, 1, 9]
},
{
"id": 12445,
"url": "https://cdn.azul.com/zulu/bin/zulu15.29.15-ca-jdk15.0.2-linux_x64.tar.gz",
"name": "zulu15.29.15-ca-jdk15.0.2-linux_x64.tar.gz",
"zulu_version": [15, 29, 15, 0],
"jdk_version": [15, 0, 2, 7]
},
{
"id": 12447,
"url": "https://cdn.azul.com/zulu/bin/zulu21.32.17-ca-jdk21.0.2-linux_aarch64.tar.gz",
"name": "zulu21.32.17-ca-jdk21.0.2-linux_aarch64.tar.gz",
"zulu_version": [21, 32, 17, 0],
"jdk_version": [21, 0, 2, 6]
}
]

View File

@ -0,0 +1,254 @@
[
{
"id": 10996,
"url": "https://cdn.azul.com/zulu/bin/zulu1.8.0_05-8.1.0.10-windows.tar.gz",
"name": "zulu1.8.0_05-8.1.0.10-windows.tar.gz",
"zulu_version": [8, 1, 0, 10],
"jdk_version": [8, 0, 5, 13]
},
{
"id": 10997,
"url": "https://cdn.azul.com/zulu/bin/zulu1.8.0_11-8.2.0.1-windows.tar.gz",
"name": "zulu1.8.0_11-8.2.0.1-windows.tar.gz",
"zulu_version": [8, 2, 0, 1],
"jdk_version": [8, 0, 11, 12]
},
{
"id": 10346,
"url": "https://cdn.azul.com/zulu/bin/zulu8.21.0.1-jdk8.0.131-windows_x64.tar.gz",
"name": "zulu8.21.0.1-jdk8.0.131-windows_x64.tar.gz",
"zulu_version": [8, 21, 0, 1],
"jdk_version": [8, 0, 131, 11]
},
{
"id": 10362,
"url": "https://cdn.azul.com/zulu/bin/zulu8.23.0.3-jdk8.0.144-windows_x64.tar.gz",
"name": "zulu8.23.0.3-jdk8.0.144-windows_x64.tar.gz",
"zulu_version": [8, 23, 0, 3],
"jdk_version": [8, 0, 144, 1]
},
{
"id": 10399,
"url": "https://cdn.azul.com/zulu/bin/zulu8.25.0.1-jdk8.0.152-windows_x64.tar.gz",
"name": "zulu8.25.0.1-jdk8.0.152-windows_x64.tar.gz",
"zulu_version": [8, 25, 0, 1],
"jdk_version": [8, 0, 152, 16]
},
{
"id": 11355,
"url": "https://cdn.azul.com/zulu/bin/zulu8.46.0.19-ca-jdk8.0.252-windows_x64.tar.gz",
"name": "zulu8.46.0.19-ca-jdk8.0.252-windows_x64.tar.gz",
"zulu_version": [8, 46, 0, 19],
"jdk_version": [8, 0, 252, 14]
},
{
"id": 11481,
"url": "https://cdn.azul.com/zulu/bin/zulu8.48.0.47-ca-jdk8.0.262-windows_x64.tar.gz",
"name": "zulu8.48.0.47-ca-jdk8.0.262-windows_x64.tar.gz",
"zulu_version": [8, 48, 0, 47],
"jdk_version": [8, 0, 262, 17]
},
{
"id": 11622,
"url": "https://cdn.azul.com/zulu/bin/zulu8.48.0.51-ca-jdk8.0.262-windows_x64.tar.gz",
"name": "zulu8.48.0.51-ca-jdk8.0.262-windows_x64.tar.gz",
"zulu_version": [8, 48, 0, 51],
"jdk_version": [8, 0, 262, 19]
},
{
"id": 11535,
"url": "https://cdn.azul.com/zulu/bin/zulu8.48.0.49-ca-jdk8.0.262-windows_x64.tar.gz",
"name": "zulu8.48.0.49-ca-jdk8.0.262-windows_x64.tar.gz",
"zulu_version": [8, 48, 0, 49],
"jdk_version": [8, 0, 262, 18]
},
{
"id": 12424,
"url": "https://cdn.azul.com/zulu/bin/zulu8.52.0.23-ca-jdk8.0.282-windows_x64.tar.gz",
"name": "zulu8.52.0.23-ca-jdk8.0.282-windows_x64.tar.gz",
"zulu_version": [8, 52, 0, 23],
"jdk_version": [8, 0, 282, 8]
},
{
"id": 10383,
"url": "https://cdn.azul.com/zulu/bin/zulu9.0.0.15-jdk9.0.0-windows_x64.tar.gz",
"name": "zulu9.0.0.15-jdk9.0.0-windows_x64.tar.gz",
"zulu_version": [9, 0, 0, 15],
"jdk_version": [9, 0, 0, 0]
},
{
"id": 10413,
"url": "https://cdn.azul.com/zulu/bin/zulu9.0.1.3-jdk9.0.1-windows_x64.tar.gz",
"name": "zulu9.0.1.3-jdk9.0.1-windows_x64.tar.gz",
"zulu_version": [9, 0, 1, 3],
"jdk_version": [9, 0, 1, 0]
},
{
"id": 10503,
"url": "https://cdn.azul.com/zulu/bin/zulu10.2+3-jdk10.0.1-windows_x64.tar.gz",
"name": "zulu10.2+3-jdk10.0.1-windows_x64.tar.gz",
"zulu_version": [10, 2, 3, 0],
"jdk_version": [10, 0, 1, 9]
},
{
"id": 10541,
"url": "https://cdn.azul.com/zulu/bin/zulu10.3+5-jdk10.0.2-windows_x64.tar.gz",
"name": "zulu10.3+5-jdk10.0.2-windows_x64.tar.gz",
"zulu_version": [10, 3, 5, 0],
"jdk_version": [10, 0, 2, 13]
},
{
"id": 10576,
"url": "https://cdn.azul.com/zulu/bin/zulu11.2.3-jdk11.0.1-windows_x64.tar.gz",
"name": "zulu11.2.3-jdk11.0.1-windows_x64.tar.gz",
"zulu_version": [11, 2, 3, 0],
"jdk_version": [11, 0, 1, 13]
},
{
"id": 10604,
"url": "https://cdn.azul.com/zulu/bin/zulu11.29.3-ca-jdk11.0.2-windows_x64.tar.gz",
"name": "zulu11.29.3-ca-jdk11.0.2-windows_x64.tar.gz",
"zulu_version": [11, 29, 3, 0],
"jdk_version": [11, 0, 2, 7]
},
{
"id": 10687,
"url": "https://cdn.azul.com/zulu/bin/zulu11.31.11-ca-jdk11.0.3-windows_x64.tar.gz",
"name": "zulu11.31.11-ca-jdk11.0.3-windows_x64.tar.gz",
"zulu_version": [11, 31, 11, 0],
"jdk_version": [11, 0, 3, 7]
},
{
"id": 10856,
"url": "https://cdn.azul.com/zulu/bin/zulu11.35.13-ca-jdk11.0.5-windows_x64.tar.gz",
"name": "zulu11.35.13-ca-jdk11.0.5-windows_x64.tar.gz",
"zulu_version": [11, 35, 13, 0],
"jdk_version": [11, 0, 5, 10]
},
{
"id": 10933,
"url": "https://cdn.azul.com/zulu/bin/zulu11.35.15-ca-jdk11.0.5-windows_x64.tar.gz",
"name": "zulu11.35.15-ca-jdk11.0.5-windows_x64.tar.gz",
"zulu_version": [11, 35, 15, 0],
"jdk_version": [11, 0, 5, 10]
},
{
"id": 10933,
"url": "https://cdn.azul.com/zulu/bin/zulu11.35.11-ca-jdk11.0.5-windows_x64.tar.gz",
"name": "zulu11.35.15-ca-jdk11.0.5-windows_x64.tar.gz",
"zulu_version": [11, 35, 11, 0],
"jdk_version": [11, 0, 5, 10]
},
{
"id": 12397,
"url": "https://cdn.azul.com/zulu/bin/zulu11.45.27-ca-jdk11.0.10-windows_x64.tar.gz",
"name": "zulu11.45.27-ca-jdk11.0.10-windows_x64.tar.gz",
"zulu_version": [11, 45, 27, 0],
"jdk_version": [11, 0, 10, 9]
},
{
"id": 10667,
"url": "https://cdn.azul.com/zulu/bin/zulu12.1.3-ca-jdk12.0.0-windows_x64.tar.gz",
"name": "zulu12.1.3-ca-jdk12.0.0-windows_x64.tar.gz",
"zulu_version": [12, 1, 3, 0],
"jdk_version": [12, 0, 0, 33]
},
{
"id": 10710,
"url": "https://cdn.azul.com/zulu/bin/zulu12.2.3-ca-jdk12.0.1-windows_x64.tar.gz",
"name": "zulu12.2.3-ca-jdk12.0.1-windows_x64.tar.gz",
"zulu_version": [12, 2, 3, 0],
"jdk_version": [12, 0, 1, 12]
},
{
"id": 10780,
"url": "https://cdn.azul.com/zulu/bin/zulu12.3.11-ca-jdk12.0.2-windows_x64.tar.gz",
"name": "zulu12.3.11-ca-jdk12.0.2-windows_x64.tar.gz",
"zulu_version": [12, 3, 11, 0],
"jdk_version": [12, 0, 2, 3]
},
{
"id": 10846,
"url": "https://cdn.azul.com/zulu/bin/zulu13.27.9-ca-jdk13.0.0-windows_x64.tar.gz",
"name": "zulu13.27.9-ca-jdk13.0.0-windows_x64.tar.gz",
"zulu_version": [13, 27, 9, 0],
"jdk_version": [13, 0, 0, 33]
},
{
"id": 10888,
"url": "https://cdn.azul.com/zulu/bin/zulu13.28.11-ca-jdk13.0.1-windows_x64.tar.gz",
"name": "zulu13.28.11-ca-jdk13.0.1-windows_x64.tar.gz",
"zulu_version": [13, 28, 11, 0],
"jdk_version": [13, 0, 1, 10]
},
{
"id": 11073,
"url": "https://cdn.azul.com/zulu/bin/zulu13.29.9-ca-jdk13.0.2-windows_x64.tar.gz",
"name": "zulu13.29.9-ca-jdk13.0.2-windows_x64.tar.gz",
"zulu_version": [13, 29, 9, 0],
"jdk_version": [13, 0, 2, 6]
},
{
"id": 12408,
"url": "https://cdn.azul.com/zulu/bin/zulu13.37.21-ca-jdk13.0.6-windows_x64.tar.gz",
"name": "zulu13.37.21-ca-jdk13.0.6-windows_x64.tar.gz",
"zulu_version": [13, 37, 21, 0],
"jdk_version": [13, 0, 6, 5]
},
{
"id": 11236,
"url": "https://cdn.azul.com/zulu/bin/zulu14.27.1-ca-jdk14.0.0-windows_x64.tar.gz",
"name": "zulu14.27.1-ca-jdk14.0.0-windows_x64.tar.gz",
"zulu_version": [14, 27, 1, 0],
"jdk_version": [14, 0, 0, 36]
},
{
"id": 11349,
"url": "https://cdn.azul.com/zulu/bin/zulu14.28.21-ca-jdk14.0.1-windows_x64.tar.gz",
"name": "zulu14.28.21-ca-jdk14.0.1-windows_x64.tar.gz",
"zulu_version": [14, 28, 21, 0],
"jdk_version": [14, 0, 1, 8]
},
{
"id": 11513,
"url": "https://cdn.azul.com/zulu/bin/zulu14.29.23-ca-jdk14.0.2-windows_x64.tar.gz",
"name": "zulu14.29.23-ca-jdk14.0.2-windows_x64.tar.gz",
"zulu_version": [14, 29, 23, 0],
"jdk_version": [14, 0, 2, 12]
},
{
"id": 11780,
"url": "https://cdn.azul.com/zulu/bin/zulu15.27.17-ca-jdk15.0.0-windows_x64.tar.gz",
"name": "zulu15.27.17-ca-jdk15.0.0-windows_x64.tar.gz",
"zulu_version": [15, 27, 17, 0],
"jdk_version": [15, 0, 0, 36]
},
{
"id": 11924,
"url": "https://cdn.azul.com/zulu/bin/zulu15.28.13-ca-jdk15.0.1-windows_x64.tar.gz",
"name": "zulu15.28.13-ca-jdk15.0.1-windows_x64.tar.gz",
"zulu_version": [15, 28, 13, 0],
"jdk_version": [15, 0, 1, 8]
},
{
"id": 12101,
"url": "https://cdn.azul.com/zulu/bin/zulu15.28.51-ca-jdk15.0.1-windows_x64.tar.gz",
"name": "zulu15.28.51-ca-jdk15.0.1-windows_x64.tar.gz",
"zulu_version": [15, 28, 51, 0],
"jdk_version": [15, 0, 1, 9]
},
{
"id": 12445,
"url": "https://cdn.azul.com/zulu/bin/zulu15.29.15-ca-jdk15.0.2-windows_x64.tar.gz",
"name": "zulu15.29.15-ca-jdk15.0.2-windows_x64.tar.gz",
"zulu_version": [15, 29, 15, 0],
"jdk_version": [15, 0, 2, 7]
},
{
"id": 12446,
"url": "https://cdn.azul.com/zulu/bin/zulu17.48.15-ca-jdk17.0.10-windows_aarch64.zip",
"name": "zulu17.48.15-ca-jdk17.0.10-win_aarhc4.zip",
"zulu_version": [17, 48, 15, 0],
"jdk_version": [17, 0, 10, 7]
}
]

View File

@ -1,9 +1,14 @@
import { HttpClient } from '@actions/http-client';
import {HttpClient} from '@actions/http-client';
import {IAdoptAvailableVersions} from '../../src/distributions/adopt/models';
import {
AdoptDistribution,
AdoptImplementation
} from '../../src/distributions/adopt/installer';
import {JavaInstallerOptions} from '../../src/distributions/base-models';
import { AdoptDistribution, AdoptImplementation } from '../../src/distributions/adopt/installer';
import { JavaInstallerOptions } from '../../src/distributions/base-models';
import os from 'os';
let manifestData = require('../data/adopt.json') as [];
import manifestData from '../data/adopt.json';
describe('getAvailableVersions', () => {
let spyHttpClient: jest.SpyInstance;
@ -25,42 +30,82 @@ describe('getAvailableVersions', () => {
it.each([
[
{ version: '11', architecture: 'x64', packageType: 'jdk', checkLatest: false },
{
version: '11',
architecture: 'x64',
packageType: 'jdk',
checkLatest: false
},
AdoptImplementation.Hotspot,
'os=mac&architecture=x64&image_type=jdk&release_type=ga&jvm_impl=hotspot&page_size=20&page=0'
],
[
{ version: '11', architecture: 'x86', packageType: 'jdk', checkLatest: false },
{
version: '11',
architecture: 'x86',
packageType: 'jdk',
checkLatest: false
},
AdoptImplementation.Hotspot,
'os=mac&architecture=x86&image_type=jdk&release_type=ga&jvm_impl=hotspot&page_size=20&page=0'
],
[
{ version: '11', architecture: 'x64', packageType: 'jre', checkLatest: false },
{
version: '11',
architecture: 'x64',
packageType: 'jre',
checkLatest: false
},
AdoptImplementation.Hotspot,
'os=mac&architecture=x64&image_type=jre&release_type=ga&jvm_impl=hotspot&page_size=20&page=0'
],
[
{ version: '11-ea', architecture: 'x64', packageType: 'jdk', checkLatest: false },
{
version: '11-ea',
architecture: 'x64',
packageType: 'jdk',
checkLatest: false
},
AdoptImplementation.Hotspot,
'os=mac&architecture=x64&image_type=jdk&release_type=ea&jvm_impl=hotspot&page_size=20&page=0'
],
[
{ version: '11', architecture: 'x64', packageType: 'jdk', checkLatest: false },
{
version: '11',
architecture: 'x64',
packageType: 'jdk',
checkLatest: false
},
AdoptImplementation.OpenJ9,
'os=mac&architecture=x64&image_type=jdk&release_type=ga&jvm_impl=openj9&page_size=20&page=0'
],
[
{ version: '11', architecture: 'x86', packageType: 'jdk', checkLatest: false },
{
version: '11',
architecture: 'x86',
packageType: 'jdk',
checkLatest: false
},
AdoptImplementation.OpenJ9,
'os=mac&architecture=x86&image_type=jdk&release_type=ga&jvm_impl=openj9&page_size=20&page=0'
],
[
{ version: '11', architecture: 'x64', packageType: 'jre', checkLatest: false },
{
version: '11',
architecture: 'x64',
packageType: 'jre',
checkLatest: false
},
AdoptImplementation.OpenJ9,
'os=mac&architecture=x64&image_type=jre&release_type=ga&jvm_impl=openj9&page_size=20&page=0'
],
[
{ version: '11-ea', architecture: 'x64', packageType: 'jdk', checkLatest: false },
{
version: '11-ea',
architecture: 'x64',
packageType: 'jdk',
checkLatest: false
},
AdoptImplementation.OpenJ9,
'os=mac&architecture=x64&image_type=jdk&release_type=ea&jvm_impl=openj9&page_size=20&page=0'
]
@ -72,7 +117,8 @@ describe('getAvailableVersions', () => {
expectedParameters
) => {
const distribution = new AdoptDistribution(installerOptions, impl);
const baseUrl = 'https://api.adoptopenjdk.net/v3/assets/version/%5B1.0,100.0%5D';
const baseUrl =
'https://api.adoptopenjdk.net/v3/assets/version/%5B1.0,100.0%5D';
const expectedUrl = `${baseUrl}?project=jdk&vendor=adoptopenjdk&heap_size=normal&sort_method=DEFAULT&sort_order=DESC&${expectedParameters}`;
distribution['getPlatformOption'] = () => 'mac';
@ -89,12 +135,12 @@ describe('getAvailableVersions', () => {
.mockReturnValueOnce({
statusCode: 200,
headers: {},
result: manifestData
result: manifestData as any
})
.mockReturnValueOnce({
statusCode: 200,
headers: {},
result: manifestData
result: manifestData as any
})
.mockReturnValueOnce({
statusCode: 200,
@ -103,7 +149,12 @@ describe('getAvailableVersions', () => {
});
const distribution = new AdoptDistribution(
{ version: '11', architecture: 'x64', packageType: 'jdk', checkLatest: false },
{
version: '11',
architecture: 'x64',
packageType: 'jdk',
checkLatest: false
},
AdoptImplementation.Hotspot
);
const availableVersions = await distribution['getAvailableVersions']();
@ -120,7 +171,12 @@ describe('getAvailableVersions', () => {
'find right toolchain folder',
(impl: AdoptImplementation, packageType: string, expected: string) => {
const distribution = new AdoptDistribution(
{ version: '11', architecture: 'x64', packageType: packageType, checkLatest: false },
{
version: '11',
architecture: 'x64',
packageType: packageType,
checkLatest: false
},
impl
);
@ -128,6 +184,39 @@ describe('getAvailableVersions', () => {
expect(distribution.toolcacheFolderName).toBe(expected);
}
);
it.each([
['amd64', 'x64'],
['arm64', 'aarch64']
])(
'defaults to os.arch(): %s mapped to distro arch: %s',
async (osArch: string, distroArch: string) => {
jest.spyOn(os, 'arch').mockReturnValue(osArch);
const installerOptions: JavaInstallerOptions = {
version: '17',
architecture: '', // to get default value
packageType: 'jdk',
checkLatest: false
};
const expectedParameters = `os=mac&architecture=${distroArch}&image_type=jdk&release_type=ga&jvm_impl=hotspot&page_size=20&page=0`;
const distribution = new AdoptDistribution(
installerOptions,
AdoptImplementation.Hotspot
);
const baseUrl =
'https://api.adoptopenjdk.net/v3/assets/version/%5B1.0,100.0%5D';
const expectedUrl = `${baseUrl}?project=jdk&vendor=adoptopenjdk&heap_size=normal&sort_method=DEFAULT&sort_order=DESC&${expectedParameters}`;
distribution['getPlatformOption'] = () => 'mac';
await distribution['getAvailableVersions']();
expect(spyHttpClient.mock.calls).toHaveLength(1);
expect(spyHttpClient.mock.calls[0][0]).toBe(expectedUrl);
}
);
});
describe('findPackageForDownload', () => {
@ -145,43 +234,63 @@ describe('findPackageForDownload', () => {
['15.0.1+9.1', '15.0.1+9.1']
])('version is resolved correctly %s -> %s', async (input, expected) => {
const distribution = new AdoptDistribution(
{ version: '11', architecture: 'x64', packageType: 'jdk', checkLatest: false },
{
version: '11',
architecture: 'x64',
packageType: 'jdk',
checkLatest: false
},
AdoptImplementation.Hotspot
);
distribution['getAvailableVersions'] = async () => manifestData;
distribution['getAvailableVersions'] = async () => manifestData as any;
const resolvedVersion = await distribution['findPackageForDownload'](input);
expect(resolvedVersion.version).toBe(expected);
});
it('version is found but binaries list is empty', async () => {
const distribution = new AdoptDistribution(
{ version: '11', architecture: 'x64', packageType: 'jdk', checkLatest: false },
{
version: '11',
architecture: 'x64',
packageType: 'jdk',
checkLatest: false
},
AdoptImplementation.Hotspot
);
distribution['getAvailableVersions'] = async () => manifestData;
await expect(distribution['findPackageForDownload']('9.0.8')).rejects.toThrowError(
/Could not find satisfied version for SemVer */
);
distribution['getAvailableVersions'] = async () => manifestData as any;
await expect(
distribution['findPackageForDownload']('9.0.8')
).rejects.toThrow(/Could not find satisfied version for SemVer */);
});
it('version is not found', async () => {
const distribution = new AdoptDistribution(
{ version: '11', architecture: 'x64', packageType: 'jdk', checkLatest: false },
{
version: '11',
architecture: 'x64',
packageType: 'jdk',
checkLatest: false
},
AdoptImplementation.Hotspot
);
distribution['getAvailableVersions'] = async () => manifestData;
await expect(distribution['findPackageForDownload']('7.x')).rejects.toThrowError(
distribution['getAvailableVersions'] = async () => manifestData as any;
await expect(distribution['findPackageForDownload']('7.x')).rejects.toThrow(
/Could not find satisfied version for SemVer */
);
});
it('version list is empty', async () => {
const distribution = new AdoptDistribution(
{ version: '11', architecture: 'x64', packageType: 'jdk', checkLatest: false },
{
version: '11',
architecture: 'x64',
packageType: 'jdk',
checkLatest: false
},
AdoptImplementation.Hotspot
);
distribution['getAvailableVersions'] = async () => [];
await expect(distribution['findPackageForDownload']('11')).rejects.toThrowError(
await expect(distribution['findPackageForDownload']('11')).rejects.toThrow(
/Could not find satisfied version for SemVer */
);
});

View File

@ -5,26 +5,37 @@ import * as util from '../../src/util';
import path from 'path';
import * as semver from 'semver';
import { JavaBase } from '../../src/distributions/base-installer';
import {JavaBase} from '../../src/distributions/base-installer';
import {
JavaDownloadRelease,
JavaInstallerOptions,
JavaInstallerResults
} from '../../src/distributions/base-models';
import os from 'os';
class EmptyJavaBase extends JavaBase {
constructor(installerOptions: JavaInstallerOptions) {
super('Empty', installerOptions);
}
protected async downloadTool(javaRelease: JavaDownloadRelease): Promise<JavaInstallerResults> {
protected async downloadTool(
javaRelease: JavaDownloadRelease
): Promise<JavaInstallerResults> {
return {
version: '11.0.9',
path: path.join('toolcache', this.toolcacheFolderName, '11.0.9', this.architecture)
path: path.join(
'toolcache',
this.toolcacheFolderName,
'11.0.9',
this.architecture
)
};
}
protected async findPackageForDownload(range: string): Promise<JavaDownloadRelease> {
protected async findPackageForDownload(
range: string
): Promise<JavaDownloadRelease> {
const availableVersion = '11.0.9';
if (!semver.satisfies(availableVersion, range)) {
throw new Error('Available version not found');
@ -58,44 +69,111 @@ describe('findInToolcache', () => {
it.each([
[
{ version: '11', architecture: 'x64', packageType: 'jdk', checkLatest: false },
{ version: actualJavaVersion, path: javaPath }
{
version: '11',
architecture: 'x64',
packageType: 'jdk',
checkLatest: false
},
{version: actualJavaVersion, path: javaPath}
],
[
{ version: '11.0', architecture: 'x64', packageType: 'jdk', checkLatest: false },
{ version: actualJavaVersion, path: javaPath }
{
version: '11.0',
architecture: 'x64',
packageType: 'jdk',
checkLatest: false
},
{version: actualJavaVersion, path: javaPath}
],
[
{ version: '11.0.8', architecture: 'x64', packageType: 'jdk', checkLatest: false },
{ version: actualJavaVersion, path: javaPath }
{
version: '11.0.8',
architecture: 'x64',
packageType: 'jdk',
checkLatest: false
},
{version: actualJavaVersion, path: javaPath}
],
[
{ version: '11', architecture: 'x64', packageType: 'jdk', checkLatest: true },
{ version: actualJavaVersion, path: javaPath }
{
version: '11',
architecture: 'x64',
packageType: 'jdk',
checkLatest: true
},
{version: actualJavaVersion, path: javaPath}
],
[
{ version: '11.0', architecture: 'x64', packageType: 'jdk', checkLatest: true },
{ version: actualJavaVersion, path: javaPath }
{
version: '11.0',
architecture: 'x64',
packageType: 'jdk',
checkLatest: true
},
{version: actualJavaVersion, path: javaPath}
],
[
{ version: '11.0.8', architecture: 'x64', packageType: 'jdk', checkLatest: true },
{ version: actualJavaVersion, path: javaPath }
{
version: '11.0.8',
architecture: 'x64',
packageType: 'jdk',
checkLatest: true
},
{version: actualJavaVersion, path: javaPath}
],
[{ version: '11', architecture: 'x64', packageType: 'jre', checkLatest: false }, null],
[{ version: '8', architecture: 'x64', packageType: 'jdk', checkLatest: false }, null],
[{ version: '11', architecture: 'x86', packageType: 'jdk', checkLatest: false }, null],
[{ version: '11', architecture: 'x86', packageType: 'jre', checkLatest: false }, null]
[
{
version: '11',
architecture: 'x64',
packageType: 'jre',
checkLatest: false
},
null
],
[
{
version: '8',
architecture: 'x64',
packageType: 'jdk',
checkLatest: false
},
null
],
[
{
version: '11',
architecture: 'x86',
packageType: 'jdk',
checkLatest: false
},
null
],
[
{
version: '11',
architecture: 'x86',
packageType: 'jre',
checkLatest: false
},
null
]
])(`should find java for path %s -> %s`, (input, expected) => {
spyTcFindAllVersions.mockReturnValue([actualJavaVersion]);
spyGetToolcachePath.mockImplementation(
(toolname: string, javaVersion: string, architecture: string) => {
const semverVersion = new semver.Range(javaVersion);
if (path.basename(javaPath) !== architecture || !javaPath.includes(toolname)) {
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);
@ -103,52 +181,63 @@ describe('findInToolcache', () => {
});
it.each([
['11', { version: '11.0.3+2', versionInPath: '11.0.3-2' }],
['11.0', { version: '11.0.3+2', versionInPath: '11.0.3-2' }],
['11.0.1', { version: '11.0.1', versionInPath: '11.0.1' }],
['11.0.3', { version: '11.0.3+2', versionInPath: '11.0.3-2' }],
['15', { version: '15.0.2+4', versionInPath: '15.0.2-4' }],
['x', { version: '15.0.2+4', versionInPath: '15.0.2-4' }],
['x-ea', { version: '17.4.4', versionInPath: '17.4.4-ea' }],
['11-ea', { version: '11.3.3+5.2.1231421', versionInPath: '11.3.3-ea.5.2.1231421' }],
['11.2-ea', { version: '11.2.1', versionInPath: '11.2.1-ea' }],
['11.2.1-ea', { version: '11.2.1', versionInPath: '11.2.1-ea' }]
])('should choose correct java from tool-cache for input %s', (input, expected) => {
spyTcFindAllVersions.mockReturnValue([
'17.4.4-ea',
'11.0.2',
'15.0.2-4',
'11.0.3-2',
'11.2.1-ea',
'11.3.2-ea',
'11.3.2-ea.5',
'11.3.3-ea.5.2.1231421',
'12.3.2-0',
'11.0.1'
]);
spyGetToolcachePath.mockImplementation(
(toolname: string, javaVersion: string, architecture: string) =>
`/hostedtoolcache/${toolname}/${javaVersion}/${architecture}`
);
mockJavaBase = new EmptyJavaBase({
version: input,
architecture: 'x64',
packageType: 'jdk',
checkLatest: false
});
const foundVersion = mockJavaBase['findInToolcache']();
expect(foundVersion).toEqual({
version: expected.version,
path: `/hostedtoolcache/Java_Empty_jdk/${expected.versionInPath}/x64`
});
});
['11', {version: '11.0.3+2', versionInPath: '11.0.3-2'}],
['11.0', {version: '11.0.3+2', versionInPath: '11.0.3-2'}],
['11.0.1', {version: '11.0.1', versionInPath: '11.0.1'}],
['11.0.3', {version: '11.0.3+2', versionInPath: '11.0.3-2'}],
['15', {version: '15.0.2+4', versionInPath: '15.0.2-4'}],
['x', {version: '15.0.2+4', versionInPath: '15.0.2-4'}],
['x-ea', {version: '17.4.4', versionInPath: '17.4.4-ea'}],
[
'11-ea',
{version: '11.3.3+5.2.1231421', versionInPath: '11.3.3-ea.5.2.1231421'}
],
['11.2-ea', {version: '11.2.1', versionInPath: '11.2.1-ea'}],
['11.2.1-ea', {version: '11.2.1', versionInPath: '11.2.1-ea'}]
])(
'should choose correct java from tool-cache for input %s',
(input, expected) => {
spyTcFindAllVersions.mockReturnValue([
'17.4.4-ea',
'11.0.2',
'15.0.2-4',
'11.0.3-2',
'11.2.1-ea',
'11.3.2-ea',
'11.3.2-ea.5',
'11.3.3-ea.5.2.1231421',
'12.3.2-0',
'11.0.1'
]);
spyGetToolcachePath.mockImplementation(
(toolname: string, javaVersion: string, architecture: string) =>
`/hostedtoolcache/${toolname}/${javaVersion}/${architecture}`
);
mockJavaBase = new EmptyJavaBase({
version: input,
architecture: 'x64',
packageType: 'jdk',
checkLatest: false
});
const foundVersion = mockJavaBase['findInToolcache']();
expect(foundVersion).toEqual({
version: expected.version,
path: `/hostedtoolcache/Java_Empty_jdk/${expected.versionInPath}/x64`
});
}
);
});
describe('setupJava', () => {
const actualJavaVersion = '11.0.9';
const installedJavaVersion = '11.0.8';
const javaPath = path.join('Java_Empty_jdk', installedJavaVersion, 'x86');
const javaPathInstalled = path.join('toolcache', 'Java_Empty_jdk', actualJavaVersion, 'x86');
const javaPathInstalled = path.join(
'toolcache',
'Java_Empty_jdk',
actualJavaVersion,
'x86'
);
let mockJavaBase: EmptyJavaBase;
@ -166,11 +255,16 @@ describe('setupJava', () => {
(toolname: string, javaVersion: string, architecture: string) => {
const semverVersion = new semver.Range(javaVersion);
if (path.basename(javaPath) !== architecture || !javaPath.includes(toolname)) {
if (
path.basename(javaPath) !== architecture ||
!javaPath.includes(toolname)
) {
return '';
}
return semver.satisfies(installedJavaVersion, semverVersion) ? javaPath : '';
return semver.satisfies(installedJavaVersion, semverVersion)
? javaPath
: '';
}
);
@ -192,6 +286,8 @@ describe('setupJava', () => {
spyCoreSetOutput = jest.spyOn(core, 'setOutput');
spyCoreSetOutput.mockImplementation(() => undefined);
jest.spyOn(os, 'arch').mockReturnValue('x86');
});
afterEach(() => {
@ -202,23 +298,46 @@ describe('setupJava', () => {
it.each([
[
{ version: '11', architecture: 'x86', packageType: 'jdk', checkLatest: false },
{ version: installedJavaVersion, path: javaPath }
{
version: '11',
architecture: 'x86',
packageType: 'jdk',
checkLatest: false
},
{version: installedJavaVersion, path: javaPath}
],
[
{ version: '11.0', architecture: 'x86', packageType: 'jdk', checkLatest: false },
{ version: installedJavaVersion, path: javaPath }
{
version: '11.0',
architecture: 'x86',
packageType: 'jdk',
checkLatest: false
},
{version: installedJavaVersion, path: javaPath}
],
[
{ version: '11.0.8', architecture: 'x86', packageType: 'jdk', checkLatest: false },
{ version: installedJavaVersion, path: javaPath }
{
version: '11.0.8',
architecture: 'x86',
packageType: 'jdk',
checkLatest: false
},
{version: installedJavaVersion, path: javaPath}
],
[
{version: '11', architecture: '', packageType: 'jdk', checkLatest: false},
{version: installedJavaVersion, path: javaPath}
]
])('should find java locally for %s', (input, expected) => {
])('should find java locally for %s', async (input, expected) => {
mockJavaBase = new EmptyJavaBase(input);
expect(mockJavaBase.setupJava()).resolves.toEqual(expected);
await expect(mockJavaBase.setupJava()).resolves.toEqual(expected);
expect(spyGetToolcachePath).toHaveBeenCalled();
expect(spyCoreInfo).toHaveBeenCalledWith(`Resolved Java ${expected.version} from tool-cache`);
expect(spyCoreInfo).toHaveBeenCalledWith(`Setting Java ${expected.version} as the default`);
expect(spyCoreInfo).toHaveBeenCalledWith(
`Resolved Java ${expected.version} from tool-cache`
);
expect(spyCoreInfo).toHaveBeenCalledWith(
`Setting Java ${expected.version} as the default`
);
expect(spyCoreInfo).not.toHaveBeenCalledWith(
'Trying to resolve the latest version from remote'
);
@ -227,16 +346,47 @@ describe('setupJava', () => {
it.each([
[
{ version: '11', architecture: 'x86', packageType: 'jre', checkLatest: false },
{ path: path.join('toolcache', 'Java_Empty_jre', '11.0.9', 'x86'), version: '11.0.9' }
{
version: '11',
architecture: 'x86',
packageType: 'jre',
checkLatest: false
},
{
path: path.join('toolcache', 'Java_Empty_jre', '11.0.9', 'x86'),
version: '11.0.9'
}
],
[
{ version: '11', architecture: 'x64', packageType: 'jdk', checkLatest: false },
{ path: path.join('toolcache', 'Java_Empty_jdk', '11.0.9', 'x64'), version: '11.0.9' }
{
version: '11',
architecture: 'x64',
packageType: 'jdk',
checkLatest: false
},
{
path: path.join('toolcache', 'Java_Empty_jdk', '11.0.9', 'x64'),
version: '11.0.9'
}
],
[
{ version: '11', architecture: 'x64', packageType: 'jre', checkLatest: false },
{ path: path.join('toolcache', 'Java_Empty_jre', '11.0.9', 'x64'), version: '11.0.9' }
{
version: '11',
architecture: 'x64',
packageType: 'jre',
checkLatest: false
},
{
path: path.join('toolcache', 'Java_Empty_jre', '11.0.9', 'x64'),
version: '11.0.9'
}
],
[
{version: '11', architecture: '', packageType: 'jre', checkLatest: false},
{
path: path.join('toolcache', 'Java_Empty_jre', '11.0.9', 'x86'),
version: '11.0.9'
}
]
])('download java with configuration %s', async (input, expected) => {
mockJavaBase = new EmptyJavaBase(input);
@ -244,82 +394,177 @@ describe('setupJava', () => {
expect(spyGetToolcachePath).toHaveBeenCalled();
expect(spyCoreAddPath).toHaveBeenCalled();
expect(spyCoreExportVariable).toHaveBeenCalled();
expect(spyCoreExportVariable).toHaveBeenCalledWith(
`JAVA_HOME_${input.version}_${(
input.architecture || 'x86'
).toLocaleUpperCase()}`,
expected.path
);
expect(spyCoreSetOutput).toHaveBeenCalled();
expect(spyCoreInfo).toHaveBeenCalledWith('Trying to resolve the latest version from remote');
expect(spyCoreInfo).toHaveBeenCalledWith(`Resolved latest version as ${expected.version}`);
expect(spyCoreInfo).toHaveBeenCalledWith(
'Trying to resolve the latest version from remote'
);
expect(spyCoreInfo).toHaveBeenCalledWith(
`Resolved latest version as ${expected.version}`
);
expect(spyCoreInfo).toHaveBeenCalledWith('Trying to download...');
expect(spyCoreInfo).toHaveBeenCalledWith(`Java ${expected.version} was downloaded`);
expect(spyCoreInfo).toHaveBeenCalledWith(`Setting Java ${expected.version} as the default`);
expect(spyCoreInfo).toHaveBeenCalledWith(
`Java ${expected.version} was downloaded`
);
expect(spyCoreInfo).toHaveBeenCalledWith(
`Setting Java ${expected.version} as the default`
);
});
it.each([
[
{ version: '11.0.9', architecture: 'x86', packageType: 'jdk', checkLatest: true },
{ version: '11.0.9', path: javaPathInstalled }
]
])('should check the latest java version for %s and resolve locally', async (input, expected) => {
mockJavaBase = new EmptyJavaBase(input);
mockJavaBase['findInToolcache'] = () => ({ version: '11.0.9', path: expected.path });
await expect(mockJavaBase.setupJava()).resolves.toEqual(expected);
expect(spyCoreInfo).toHaveBeenCalledWith('Trying to resolve the latest version from remote');
expect(spyCoreInfo).toHaveBeenCalledWith(`Resolved latest version as ${expected.version}`);
expect(spyCoreInfo).toHaveBeenCalledWith(`Resolved Java ${expected.version} from tool-cache`);
expect(spyCoreInfo).toHaveBeenCalledWith(`Setting Java ${expected.version} as the default`);
});
it.each([
[
{ version: '11', architecture: 'x86', packageType: 'jdk', checkLatest: true },
{ version: actualJavaVersion, path: javaPathInstalled }
{
version: '11.0.9',
architecture: 'x86',
packageType: 'jdk',
checkLatest: true
},
{version: '11.0.9', path: javaPathInstalled}
],
[
{ version: '11.0', architecture: 'x86', packageType: 'jdk', checkLatest: true },
{ version: actualJavaVersion, path: javaPathInstalled }
],
[
{ version: '11.0.x', architecture: 'x86', packageType: 'jdk', checkLatest: true },
{ version: actualJavaVersion, path: javaPathInstalled }
{
version: '11.0.9',
architecture: '',
packageType: 'jdk',
checkLatest: true
},
{version: '11.0.9', path: javaPathInstalled}
]
])('should check the latest java version for %s and download', async (input, expected) => {
mockJavaBase = new EmptyJavaBase(input);
await expect(mockJavaBase.setupJava()).resolves.toEqual(expected);
expect(spyGetToolcachePath).toHaveBeenCalled();
expect(spyCoreInfo).toHaveBeenCalledWith('Trying to resolve the latest version from remote');
expect(spyCoreInfo).toHaveBeenCalledWith(`Resolved latest version as ${actualJavaVersion}`);
expect(spyCoreInfo).toHaveBeenCalledWith('Trying to download...');
expect(spyCoreInfo).toHaveBeenCalledWith(`Java ${actualJavaVersion} was downloaded`);
expect(spyCoreInfo).toHaveBeenCalledWith(`Setting Java ${expected.version} as the default`);
});
])(
'should check the latest java version for %s and resolve locally',
async (input, expected) => {
mockJavaBase = new EmptyJavaBase(input);
mockJavaBase['findInToolcache'] = () => ({
version: '11.0.9',
path: expected.path
});
await expect(mockJavaBase.setupJava()).resolves.toEqual(expected);
expect(spyCoreInfo).toHaveBeenCalledWith(
'Trying to resolve the latest version from remote'
);
expect(spyCoreInfo).toHaveBeenCalledWith(
`Resolved latest version as ${expected.version}`
);
expect(spyCoreInfo).toHaveBeenCalledWith(
`Resolved Java ${expected.version} from tool-cache`
);
expect(spyCoreInfo).toHaveBeenCalledWith(
`Setting Java ${expected.version} as the default`
);
}
);
it.each([
[{ version: '15', architecture: 'x86', packageType: 'jre', checkLatest: false }],
[{ version: '11.0.7', architecture: 'x64', packageType: 'jre', checkLatest: false }]
])('should throw an error for Available version not found for %s', async input => {
mockJavaBase = new EmptyJavaBase(input);
await expect(mockJavaBase.setupJava()).rejects.toThrowError('Available version not found');
expect(spyTcFindAllVersions).toHaveBeenCalled();
expect(spyCoreAddPath).not.toHaveBeenCalled();
expect(spyCoreExportVariable).not.toHaveBeenCalled();
expect(spyCoreSetOutput).not.toHaveBeenCalled();
});
[
{
version: '11',
architecture: 'x86',
packageType: 'jdk',
checkLatest: true
},
{version: actualJavaVersion, path: javaPathInstalled}
],
[
{
version: '11.0',
architecture: 'x86',
packageType: 'jdk',
checkLatest: true
},
{version: actualJavaVersion, path: javaPathInstalled}
],
[
{
version: '11.0.x',
architecture: 'x86',
packageType: 'jdk',
checkLatest: true
},
{version: actualJavaVersion, path: javaPathInstalled}
],
[
{version: '11', architecture: '', packageType: 'jdk', checkLatest: true},
{version: actualJavaVersion, path: javaPathInstalled}
]
])(
'should check the latest java version for %s and download',
async (input, expected) => {
mockJavaBase = new EmptyJavaBase(input);
await expect(mockJavaBase.setupJava()).resolves.toEqual(expected);
expect(spyGetToolcachePath).toHaveBeenCalled();
expect(spyCoreInfo).toHaveBeenCalledWith(
'Trying to resolve the latest version from remote'
);
expect(spyCoreInfo).toHaveBeenCalledWith(
`Resolved latest version as ${actualJavaVersion}`
);
expect(spyCoreInfo).toHaveBeenCalledWith('Trying to download...');
expect(spyCoreInfo).toHaveBeenCalledWith(
`Java ${actualJavaVersion} was downloaded`
);
expect(spyCoreInfo).toHaveBeenCalledWith(
`Setting Java ${expected.version} as the default`
);
}
);
it.each([
[
{
version: '15',
architecture: 'x86',
packageType: 'jre',
checkLatest: false
}
],
[
{
version: '11.0.7',
architecture: 'x64',
packageType: 'jre',
checkLatest: false
}
]
])(
'should throw an error for Available version not found for %s',
async input => {
mockJavaBase = new EmptyJavaBase(input);
await expect(mockJavaBase.setupJava()).rejects.toThrow(
'Available version not found'
);
expect(spyTcFindAllVersions).toHaveBeenCalled();
expect(spyCoreAddPath).not.toHaveBeenCalled();
expect(spyCoreExportVariable).not.toHaveBeenCalled();
expect(spyCoreSetOutput).not.toHaveBeenCalled();
}
);
});
describe('normalizeVersion', () => {
const DummyJavaBase = JavaBase as any;
it.each([
['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 }]
['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);
expect(DummyJavaBase.prototype.normalizeVersion.call(null, input)).toEqual(
expected
);
});
it('normalizeVersion should throw an error for non semver', () => {
const version = '11g';
expect(DummyJavaBase.prototype.normalizeVersion.bind(null, version)).toThrowError(
expect(
DummyJavaBase.prototype.normalizeVersion.bind(null, version)
).toThrow(
`The string '${version}' is not valid SemVer notation for a Java version. Please check README file for code snippets and more detailed information`
);
});
@ -329,14 +574,14 @@ describe('getToolcacheVersionName', () => {
const DummyJavaBase = JavaBase as any;
it.each([
[{ version: '11', stable: true }, '11'],
[{ version: '11.0.2', stable: true }, '11.0.2'],
[{ version: '11.0.2+4', stable: true }, '11.0.2-4'],
[{ version: '11.0.2+4.1.2563234', stable: true }, '11.0.2-4.1.2563234'],
[{ version: '11.0', stable: false }, '11.0-ea'],
[{ version: '11.0.3', stable: false }, '11.0.3-ea'],
[{ version: '11.0.3+4', stable: false }, '11.0.3-ea.4'],
[{ version: '11.0.3+4.2.256', stable: false }, '11.0.3-ea.4.2.256']
[{version: '11', stable: true}, '11'],
[{version: '11.0.2', stable: true}, '11.0.2'],
[{version: '11.0.2+4', stable: true}, '11.0.2-4'],
[{version: '11.0.2+4.1.2563234', stable: true}, '11.0.2-4.1.2563234'],
[{version: '11.0', stable: false}, '11.0-ea'],
[{version: '11.0.3', stable: false}, '11.0.3-ea'],
[{version: '11.0.3+4', stable: false}, '11.0.3-ea.4'],
[{version: '11.0.3+4.2.256', stable: false}, '11.0.3-ea.4.2.256']
])('returns correct version name for %s', (input, expected) => {
const inputVersion = input.stable ? '11' : '11-ea';
const mockJavaBase = new EmptyJavaBase({

View File

@ -0,0 +1,243 @@
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';
import os from 'os';
import {isGeneratorFunction} from 'util/types';
import manifestData from '../data/corretto.json';
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.toThrow('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.toThrow('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.toThrow("Could not find satisfied version for SemVer '4'");
});
it.each([
['arm64', 'aarch64'],
['amd64', 'x64']
])(
'defaults to os.arch(): %s mapped to distro arch: %s',
async (osArch: string, distroArch: string) => {
jest.spyOn(os, 'arch').mockReturnValue(osArch);
const version = '17';
const installerOptions: JavaInstallerOptions = {
version,
architecture: '', // to get default value
packageType: 'jdk',
checkLatest: false
};
const distribution = new CorrettoDistribution(installerOptions);
mockPlatform(distribution, 'macos');
const expectedLink = `https://corretto.aws/downloads/resources/17.0.2.8.1/amazon-corretto-17.0.2.8.1-macosx-${distroArch}.tar.gz`;
const availableVersion = await distribution['findPackageForDownload'](
version
);
expect(availableVersion).not.toBeNull();
expect(availableVersion.url).toBe(expectedLink);
}
);
});
const mockPlatform = (
distribution: CorrettoDistribution,
platform: string
) => {
distribution['getPlatformOption'] = () => platform;
const mockedExtension = platform === 'windows' ? 'zip' : 'tar.gz';
spyGetDownloadArchiveExtension.mockReturnValue(mockedExtension);
};
});

View File

@ -0,0 +1,226 @@
import {HttpClient} from '@actions/http-client';
import {DragonwellDistribution} from '../../src/distributions/dragonwell/installer';
import * as utils from '../../src/util';
import manifestData from '../data/dragonwell.json';
describe('getAvailableVersions', () => {
let spyHttpClient: jest.SpyInstance;
let spyUtilGetDownloadArchiveExtension: jest.SpyInstance;
beforeEach(() => {
spyHttpClient = jest.spyOn(HttpClient.prototype, 'getJson');
spyHttpClient.mockReturnValue({
statusCode: 200,
headers: {},
result: manifestData
});
spyUtilGetDownloadArchiveExtension = jest.spyOn(
utils,
'getDownloadArchiveExtension'
);
spyUtilGetDownloadArchiveExtension.mockReturnValue('tar.gz');
});
afterEach(() => {
jest.resetAllMocks();
jest.clearAllMocks();
jest.restoreAllMocks();
});
const mockPlatform = (
distribution: DragonwellDistribution,
platform: string
) => {
distribution['getPlatformOption'] = () => platform;
const mockedExtension = platform == 'windows' ? 'zip' : 'tar.gz';
spyUtilGetDownloadArchiveExtension.mockReturnValue(mockedExtension);
};
describe('getAvailableVersions', () => {
it.each([
['8', 'x86', 'linux', 0],
['8', 'aarch64', 'linux', 24],
['8.6.6', 'x64', 'linux', 27],
['8', 'x86', 'anolis', 0],
['8', 'x86', 'windows', 0],
['8', 'x86', 'mac', 0],
['11', 'x64', 'linux', 27],
['11', 'aarch64', 'linux', 24],
['17', 'riscv', 'linux', 0],
['16.0.1', 'x64', 'linux', 27]
])(
'should get right number of available versions from JSON',
async (
jdkVersion: string,
arch: string,
platform: string,
len: number
) => {
const distribution = new DragonwellDistribution({
version: jdkVersion,
architecture: arch,
packageType: 'jdk',
checkLatest: false
});
mockPlatform(distribution, platform);
const availableVersions = await distribution['getAvailableVersions']();
expect(availableVersions).not.toBeNull();
expect(availableVersions.length).toBe(len);
}
);
});
describe('findPackageForDownload', () => {
it.each([
[
'8',
'linux',
'x64',
'https://github.com/alibaba/dragonwell8/releases/download/dragonwell-extended-8.13.14_jdk8u352-ga/Alibaba_Dragonwell_Extended_8.13.14_x64_linux.tar.gz'
],
[
'8',
'linux',
'aarch64',
'https://github.com/alibaba/dragonwell8/releases/download/dragonwell-extended-8.13.14_jdk8u352-ga/Alibaba_Dragonwell_Extended_8.13.14_aarch64_linux.tar.gz'
],
[
'8',
'windows',
'x64',
'https://github.com/alibaba/dragonwell8/releases/download/dragonwell-extended-8.13.14_jdk8u352-ga/Alibaba_Dragonwell_Extended_8.13.14_x64_windows.zip'
],
[
'8.13.14',
'linux',
'x64',
'https://github.com/alibaba/dragonwell8/releases/download/dragonwell-extended-8.13.14_jdk8u352-ga/Alibaba_Dragonwell_Extended_8.13.14_x64_linux.tar.gz'
],
[
'11',
'linux',
'x64',
'https://github.com/alibaba/dragonwell11/releases/download/dragonwell-extended-11.0.17.13_jdk-11.0.17-ga/Alibaba_Dragonwell_Extended_11.0.17.13.8_x64_linux.tar.gz'
],
[
'11',
'linux',
'aarch64',
'https://github.com/alibaba/dragonwell11/releases/download/dragonwell-extended-11.0.17.13_jdk-11.0.17-ga/Alibaba_Dragonwell_Extended_11.0.17.13.8_aarch64_linux.tar.gz'
],
[
'11',
'windows',
'x64',
'https://github.com/alibaba/dragonwell11/releases/download/dragonwell-extended-11.0.17.13_jdk-11.0.17-ga/Alibaba_Dragonwell_Extended_11.0.17.13.8_x64_windows.zip'
],
[
'11',
'alpine-linux',
'x64',
'https://github.com/alibaba/dragonwell11/releases/download/dragonwell-extended-11.0.17.13_jdk-11.0.17-ga/Alibaba_Dragonwell_Extended_11.0.17.13.8_x64_alpine-linux.tar.gz'
],
[
'11.0.17',
'linux',
'x64',
'https://github.com/alibaba/dragonwell11/releases/download/dragonwell-extended-11.0.17.13_jdk-11.0.17-ga/Alibaba_Dragonwell_Extended_11.0.17.13.8_x64_linux.tar.gz'
],
[
'17',
'linux',
'x64',
'https://github.com/alibaba/dragonwell17/releases/download/dragonwell-standard-17.0.5.0.5%2B8_jdk-17.0.5-ga/Alibaba_Dragonwell_Standard_17.0.5.0.5.8_x64_linux.tar.gz'
],
[
'17',
'linux',
'aarch64',
'https://github.com/alibaba/dragonwell17/releases/download/dragonwell-standard-17.0.5.0.5%2B8_jdk-17.0.5-ga/Alibaba_Dragonwell_Standard_17.0.5.0.5.8_aarch64_linux.tar.gz'
],
[
'17',
'windows',
'x64',
'https://github.com/alibaba/dragonwell17/releases/download/dragonwell-standard-17.0.5.0.5%2B8_jdk-17.0.5-ga/Alibaba_Dragonwell_Standard_17.0.5.0.5.8_x64_windows.zip'
],
[
'17',
'alpine-linux',
'x64',
'https://github.com/alibaba/dragonwell17/releases/download/dragonwell-standard-17.0.5.0.5%2B8_jdk-17.0.5-ga/Alibaba_Dragonwell_Standard_17.0.5.0.5.8_x64_alpine-linux.tar.gz'
],
[
'17.0.4',
'linux',
'x64',
'https://github.com/alibaba/dragonwell17/releases/download/dragonwell-standard-17.0.4.0.4%2B8_jdk-17.0.4-ga/Alibaba_Dragonwell_Standard_17.0.4.0.4%2B8_x64_linux.tar.gz'
]
])(
'should return proper link according to the specified java-version, platform and arch',
async (
jdkVersion: string,
platform: string,
arch: string,
expectedLink: string
) => {
const distribution = new DragonwellDistribution({
version: jdkVersion,
architecture: arch,
packageType: 'jdk',
checkLatest: false
});
mockPlatform(distribution, platform);
const availableVersion = await distribution['findPackageForDownload'](
jdkVersion
);
expect(availableVersion).not.toBeNull();
expect(availableVersion.url).toBe(expectedLink);
}
);
it.each([
['8', 'alpine-linux', 'x64'],
['8', 'macos', 'aarch64'],
['11', 'macos', 'aarch64'],
['17', 'linux', 'riscv']
])(
'should throw when required version of JDK can not be found in the JSON',
async (jdkVersion: string, platform: string, arch: string) => {
const distribution = new DragonwellDistribution({
version: jdkVersion,
architecture: arch,
packageType: 'jdk',
checkLatest: false
});
mockPlatform(distribution, platform);
await expect(
distribution['findPackageForDownload'](jdkVersion)
).rejects.toThrow(
`Couldn't find any satisfied version for the specified java-version: "${jdkVersion}" and architecture: "${arch}".`
);
}
);
it('should throw when required package type is not jdk', async () => {
const jdkVersion = '17';
const arch = 'x64';
const platform = 'linux';
const distribution = new DragonwellDistribution({
version: jdkVersion,
architecture: arch,
packageType: 'jre',
checkLatest: false
});
mockPlatform(distribution, platform);
await expect(
distribution['findPackageForDownload'](jdkVersion)
).rejects.toThrow('Dragonwell provides only the `jdk` package type');
});
});
});

View File

@ -1,8 +1,12 @@
import { LibericaDistributions } from '../../src/distributions/liberica/installer';
import { ArchitectureOptions, LibericaVersion } from '../../src/distributions/liberica/models';
import { HttpClient } from '@actions/http-client';
import {LibericaDistributions} from '../../src/distributions/liberica/installer';
import {
ArchitectureOptions,
LibericaVersion
} from '../../src/distributions/liberica/models';
import {HttpClient} from '@actions/http-client';
import os from 'os';
const manifestData = require('../data/liberica.json') as LibericaVersion[];
import manifestData from '../data/liberica.json';
describe('getAvailableVersions', () => {
let spyHttpClient: jest.SpyInstance;
@ -12,7 +16,7 @@ describe('getAvailableVersions', () => {
spyHttpClient.mockReturnValue({
statusCode: 200,
headers: {},
result: manifestData
result: manifestData as LibericaVersion[]
});
});
@ -24,27 +28,57 @@ describe('getAvailableVersions', () => {
it.each([
[
{ version: '11.x', architecture: 'x86', packageType: 'jdk', checkLatest: false },
{
version: '11.x',
architecture: 'x86',
packageType: 'jdk',
checkLatest: false
},
'bundle-type=jdk&bitness=32&arch=x86&build-type=all'
],
[
{ version: '11-ea', architecture: 'x86', packageType: 'jdk', checkLatest: false },
{
version: '11-ea',
architecture: 'x86',
packageType: 'jdk',
checkLatest: false
},
'bundle-type=jdk&bitness=32&arch=x86&build-type=ea'
],
[
{ version: '16.0.2', architecture: 'x64', packageType: 'jdk', checkLatest: false },
{
version: '16.0.2',
architecture: 'x64',
packageType: 'jdk',
checkLatest: false
},
'bundle-type=jdk&bitness=64&arch=x86&build-type=all'
],
[
{ version: '16.0.2', architecture: 'x64', packageType: 'jre', checkLatest: false },
{
version: '16.0.2',
architecture: 'x64',
packageType: 'jre',
checkLatest: false
},
'bundle-type=jre&bitness=64&arch=x86&build-type=all'
],
[
{ version: '8', architecture: 'armv7', packageType: 'jdk+fx', checkLatest: false },
{
version: '8',
architecture: 'armv7',
packageType: 'jdk+fx',
checkLatest: false
},
'bundle-type=jdk-full&bitness=32&arch=arm&build-type=all'
],
[
{ version: '8', architecture: 'aarch64', packageType: 'jre+fx', checkLatest: false },
{
version: '8',
architecture: 'aarch64',
packageType: 'jre+fx',
checkLatest: false
},
'bundle-type=jre-full&bitness=64&arch=arm&build-type=all'
]
])('build correct url for %s -> %s', async (input, urlParams) => {
@ -61,6 +95,39 @@ describe('getAvailableVersions', () => {
expect(spyHttpClient.mock.calls[0][0]).toBe(buildUrl);
});
type DistroArch = {
bitness: string;
arch: string;
};
it.each([
['amd64', {bitness: '64', arch: 'x86'}],
['arm64', {bitness: '64', arch: 'arm'}]
])(
'defaults to os.arch(): %s mapped to distro arch: %s',
async (osArch: string, distroArch: DistroArch) => {
jest.spyOn(os, 'arch').mockReturnValue(osArch);
const distribution = new LibericaDistributions({
version: '17',
architecture: '', // to get default value
packageType: 'jdk',
checkLatest: false
});
const additionalParams =
'&installation-type=archive&fields=downloadUrl%2Cversion%2CfeatureVersion%2CinterimVersion%2C' +
'updateVersion%2CbuildVersion';
distribution['getPlatformOption'] = () => 'macos';
const buildUrl = `https://api.bell-sw.com/v1/liberica/releases?os=macos&bundle-type=jdk&bitness=${distroArch.bitness}&arch=${distroArch.arch}&build-type=all${additionalParams}`;
await distribution['getAvailableVersions']();
expect(spyHttpClient.mock.calls).toHaveLength(1);
expect(spyHttpClient.mock.calls[0][0]).toBe(buildUrl);
}
);
it('load available versions', async () => {
const distribution = new LibericaDistributions({
version: '11',
@ -75,21 +142,24 @@ describe('getAvailableVersions', () => {
describe('getArchitectureOptions', () => {
it.each([
['x86', { bitness: '32', arch: 'x86' }],
['x64', { bitness: '64', arch: 'x86' }],
['armv7', { bitness: '32', arch: 'arm' }],
['aarch64', { bitness: '64', arch: 'arm' }],
['ppc64le', { bitness: '64', arch: 'ppc' }]
] as [string, ArchitectureOptions][])('parse architecture %s -> %s', (input, expected) => {
const distributions = new LibericaDistributions({
architecture: input,
checkLatest: false,
packageType: '',
version: ''
});
['x86', {bitness: '32', arch: 'x86'}],
['x64', {bitness: '64', arch: 'x86'}],
['armv7', {bitness: '32', arch: 'arm'}],
['aarch64', {bitness: '64', arch: 'arm'}],
['ppc64le', {bitness: '64', arch: 'ppc'}]
] as [string, ArchitectureOptions][])(
'parse architecture %s -> %s',
(input, expected) => {
const distributions = new LibericaDistributions({
architecture: input,
checkLatest: false,
packageType: '',
version: ''
});
expect(distributions['getArchitectureOptions']()).toEqual(expected);
});
expect(distributions['getArchitectureOptions']()).toEqual(expected);
}
);
it.each(['armv6', 's390x'])('not support architecture %s', input => {
const distributions = new LibericaDistributions({
@ -165,9 +235,9 @@ describe('getPlatformOption', () => {
it.each(['aix', 'android', 'freebsd', 'openbsd', 'netbsd'])(
'not support os version %s',
input => {
expect(() => distributions['getPlatformOption'](input as NodeJS.Platform)).toThrow(
/Platform '\w+' is not supported\. Supported platforms: .+/
);
expect(() =>
distributions['getPlatformOption'](input as NodeJS.Platform)
).toThrow(/Platform '\w+' is not supported\. Supported platforms: .+/);
}
);
});
@ -181,9 +251,33 @@ describe('convertVersionToSemver', () => {
});
it.each([
[{ featureVersion: 11, interimVersion: 0, updateVersion: 12, buildVersion: 7 }, '11.0.12+7'],
[{ featureVersion: 11, interimVersion: 0, updateVersion: 12, buildVersion: 0 }, '11.0.12'],
[{ featureVersion: 11, interimVersion: 0, updateVersion: 0, buildVersion: 13 }, '11.0.0+13']
[
{
featureVersion: 11,
interimVersion: 0,
updateVersion: 12,
buildVersion: 7
},
'11.0.12+7'
],
[
{
featureVersion: 11,
interimVersion: 0,
updateVersion: 12,
buildVersion: 0
},
'11.0.12'
],
[
{
featureVersion: 11,
interimVersion: 0,
updateVersion: 0,
buildVersion: 13
},
'11.0.0+13'
]
])('%s -> %s', (input, expected) => {
const actual = distributions['convertVersionToSemver']({
downloadUrl: '',

View File

@ -0,0 +1,290 @@
import {LibericaDistributions} from '../../src/distributions/liberica/installer';
import {
ArchitectureOptions,
LibericaVersion
} from '../../src/distributions/liberica/models';
import {HttpClient} from '@actions/http-client';
import os from 'os';
import manifestData from '../data/liberica-linux.json';
describe('getAvailableVersions', () => {
let spyHttpClient: jest.SpyInstance;
beforeEach(() => {
spyHttpClient = jest.spyOn(HttpClient.prototype, 'getJson');
spyHttpClient.mockReturnValue({
statusCode: 200,
headers: {},
result: manifestData as LibericaVersion[]
});
});
afterEach(() => {
jest.resetAllMocks();
jest.clearAllMocks();
jest.restoreAllMocks();
});
it.each([
[
{
version: '11.x',
architecture: 'x86',
packageType: 'jdk',
checkLatest: false
},
'bundle-type=jdk&bitness=32&arch=x86&build-type=all'
],
[
{
version: '11-ea',
architecture: 'x86',
packageType: 'jdk',
checkLatest: false
},
'bundle-type=jdk&bitness=32&arch=x86&build-type=ea'
],
[
{
version: '16.0.2',
architecture: 'x64',
packageType: 'jdk',
checkLatest: false
},
'bundle-type=jdk&bitness=64&arch=x86&build-type=all'
],
[
{
version: '16.0.2',
architecture: 'x64',
packageType: 'jre',
checkLatest: false
},
'bundle-type=jre&bitness=64&arch=x86&build-type=all'
],
[
{
version: '8',
architecture: 'armv7',
packageType: 'jdk+fx',
checkLatest: false
},
'bundle-type=jdk-full&bitness=32&arch=arm&build-type=all'
],
[
{
version: '8',
architecture: 'aarch64',
packageType: 'jre+fx',
checkLatest: false
},
'bundle-type=jre-full&bitness=64&arch=arm&build-type=all'
]
])('build correct url for %s -> %s', async (input, urlParams) => {
const additionalParams =
'&installation-type=archive&fields=downloadUrl%2Cversion%2CfeatureVersion%2CinterimVersion%2C' +
'updateVersion%2CbuildVersion';
const distribution = new LibericaDistributions(input);
distribution['getPlatformOption'] = () => 'linux';
const buildUrl = `https://api.bell-sw.com/v1/liberica/releases?os=linux&${urlParams}${additionalParams}`;
await distribution['getAvailableVersions']();
expect(spyHttpClient.mock.calls).toHaveLength(1);
expect(spyHttpClient.mock.calls[0][0]).toBe(buildUrl);
});
type DistroArch = {
bitness: string;
arch: string;
};
it.each([
['amd64', {bitness: '64', arch: 'x86'}],
['arm64', {bitness: '64', arch: 'arm'}]
])(
'defaults to os.arch(): %s mapped to distro arch: %s',
async (osArch: string, distroArch: DistroArch) => {
jest.spyOn(os, 'arch').mockReturnValue(osArch);
const distribution = new LibericaDistributions({
version: '17',
architecture: '', // to get default value
packageType: 'jdk',
checkLatest: false
});
const additionalParams =
'&installation-type=archive&fields=downloadUrl%2Cversion%2CfeatureVersion%2CinterimVersion%2C' +
'updateVersion%2CbuildVersion';
distribution['getPlatformOption'] = () => 'linux';
const buildUrl = `https://api.bell-sw.com/v1/liberica/releases?os=linux&bundle-type=jdk&bitness=${distroArch.bitness}&arch=${distroArch.arch}&build-type=all${additionalParams}`;
await distribution['getAvailableVersions']();
expect(spyHttpClient.mock.calls).toHaveLength(1);
expect(spyHttpClient.mock.calls[0][0]).toBe(buildUrl);
}
);
it('load available versions', async () => {
const distribution = new LibericaDistributions({
version: '11',
architecture: 'x64',
packageType: 'jdk',
checkLatest: false
});
const availableVersions = await distribution['getAvailableVersions']();
expect(availableVersions).toEqual(manifestData);
});
});
describe('getArchitectureOptions', () => {
it.each([
['x86', {bitness: '32', arch: 'x86'}],
['x64', {bitness: '64', arch: 'x86'}],
['armv7', {bitness: '32', arch: 'arm'}],
['aarch64', {bitness: '64', arch: 'arm'}],
['ppc64le', {bitness: '64', arch: 'ppc'}]
] as [string, ArchitectureOptions][])(
'parse architecture %s -> %s',
(input, expected) => {
const distributions = new LibericaDistributions({
architecture: input,
checkLatest: false,
packageType: '',
version: ''
});
expect(distributions['getArchitectureOptions']()).toEqual(expected);
}
);
it.each(['armv6', 's390x'])('not support architecture %s', input => {
const distributions = new LibericaDistributions({
architecture: input,
checkLatest: false,
packageType: '',
version: ''
});
expect(() => distributions['getArchitectureOptions']()).toThrow(
/Architecture '\w+' is not supported\. Supported architectures: .*/
);
});
});
describe('findPackageForDownload', () => {
let distribution: LibericaDistributions;
beforeEach(() => {
distribution = new LibericaDistributions({
version: '',
architecture: 'x64',
packageType: 'jdk',
checkLatest: false
});
distribution['getAvailableVersions'] = async () => manifestData;
});
it.each([
['8', '8.0.302+8'],
['11.x', '11.0.12+7'],
['8.0', '8.0.302+8'],
['11.0.x', '11.0.12+7'],
['15', '15.0.2+10'],
['15.0', '15.0.2+10'],
['15.0.0', '15.0.0+36'],
['8.0.232', '8.0.232+10'],
['8.0.232+9', '8.0.232+9'],
['15.0.2+8', '15.0.2+8'],
['15.0.2+10', '15.0.2+10']
])('version is %s -> %s', async (input, expected) => {
const result = await distribution['findPackageForDownload'](input);
expect(result.version).toBe(expected);
});
it('should throw an error', async () => {
await expect(distribution['findPackageForDownload']('18')).rejects.toThrow(
/Could not find satisfied version for semver */
);
});
});
describe('getPlatformOption', () => {
const distributions = new LibericaDistributions({
architecture: 'x64',
version: '11',
packageType: 'jdk',
checkLatest: false
});
it.each([
['linux', 'linux'],
['darwin', 'macos'],
['win32', 'windows'],
['cygwin', 'windows'],
['sunos', 'solaris']
])('os version %s -> %s', (input, expected) => {
const actual = distributions['getPlatformOption'](input as NodeJS.Platform);
expect(actual).toEqual(expected);
});
it.each(['aix', 'android', 'freebsd', 'openbsd', 'netbsd'])(
'not support os version %s',
input => {
expect(() =>
distributions['getPlatformOption'](input as NodeJS.Platform)
).toThrow(/Platform '\w+' is not supported\. Supported platforms: .+/);
}
);
});
describe('convertVersionToSemver', () => {
const distributions = new LibericaDistributions({
architecture: 'x64',
version: '11',
packageType: 'jdk',
checkLatest: false
});
it.each([
[
{
featureVersion: 11,
interimVersion: 0,
updateVersion: 12,
buildVersion: 7
},
'11.0.12+7'
],
[
{
featureVersion: 11,
interimVersion: 0,
updateVersion: 12,
buildVersion: 0
},
'11.0.12'
],
[
{
featureVersion: 11,
interimVersion: 0,
updateVersion: 0,
buildVersion: 13
},
'11.0.0+13'
]
])('%s -> %s', (input, expected) => {
const actual = distributions['convertVersionToSemver']({
downloadUrl: '',
version: '',
...input
});
expect(actual).toEqual(expected);
});
});

View File

@ -0,0 +1,290 @@
import {LibericaDistributions} from '../../src/distributions/liberica/installer';
import {
ArchitectureOptions,
LibericaVersion
} from '../../src/distributions/liberica/models';
import {HttpClient} from '@actions/http-client';
import os from 'os';
import manifestData from '../data/liberica-windows.json';
describe('getAvailableVersions', () => {
let spyHttpClient: jest.SpyInstance;
beforeEach(() => {
spyHttpClient = jest.spyOn(HttpClient.prototype, 'getJson');
spyHttpClient.mockReturnValue({
statusCode: 200,
headers: {},
result: manifestData as LibericaVersion[]
});
});
afterEach(() => {
jest.resetAllMocks();
jest.clearAllMocks();
jest.restoreAllMocks();
});
it.each([
[
{
version: '11.x',
architecture: 'x86',
packageType: 'jdk',
checkLatest: false
},
'bundle-type=jdk&bitness=32&arch=x86&build-type=all'
],
[
{
version: '11-ea',
architecture: 'x86',
packageType: 'jdk',
checkLatest: false
},
'bundle-type=jdk&bitness=32&arch=x86&build-type=ea'
],
[
{
version: '16.0.2',
architecture: 'x64',
packageType: 'jdk',
checkLatest: false
},
'bundle-type=jdk&bitness=64&arch=x86&build-type=all'
],
[
{
version: '16.0.2',
architecture: 'x64',
packageType: 'jre',
checkLatest: false
},
'bundle-type=jre&bitness=64&arch=x86&build-type=all'
],
[
{
version: '8',
architecture: 'armv7',
packageType: 'jdk+fx',
checkLatest: false
},
'bundle-type=jdk-full&bitness=32&arch=arm&build-type=all'
],
[
{
version: '8',
architecture: 'aarch64',
packageType: 'jre+fx',
checkLatest: false
},
'bundle-type=jre-full&bitness=64&arch=arm&build-type=all'
]
])('build correct url for %s -> %s', async (input, urlParams) => {
const additionalParams =
'&installation-type=archive&fields=downloadUrl%2Cversion%2CfeatureVersion%2CinterimVersion%2C' +
'updateVersion%2CbuildVersion';
const distribution = new LibericaDistributions(input);
distribution['getPlatformOption'] = () => 'windows';
const buildUrl = `https://api.bell-sw.com/v1/liberica/releases?os=windows&${urlParams}${additionalParams}`;
await distribution['getAvailableVersions']();
expect(spyHttpClient.mock.calls).toHaveLength(1);
expect(spyHttpClient.mock.calls[0][0]).toBe(buildUrl);
});
type DistroArch = {
bitness: string;
arch: string;
};
it.each([
['amd64', {bitness: '64', arch: 'x86'}],
['arm64', {bitness: '64', arch: 'arm'}]
])(
'defaults to os.arch(): %s mapped to distro arch: %s',
async (osArch: string, distroArch: DistroArch) => {
jest.spyOn(os, 'arch').mockReturnValue(osArch);
const distribution = new LibericaDistributions({
version: '17',
architecture: '', // to get default value
packageType: 'jdk',
checkLatest: false
});
const additionalParams =
'&installation-type=archive&fields=downloadUrl%2Cversion%2CfeatureVersion%2CinterimVersion%2C' +
'updateVersion%2CbuildVersion';
distribution['getPlatformOption'] = () => 'windows';
const buildUrl = `https://api.bell-sw.com/v1/liberica/releases?os=windows&bundle-type=jdk&bitness=${distroArch.bitness}&arch=${distroArch.arch}&build-type=all${additionalParams}`;
await distribution['getAvailableVersions']();
expect(spyHttpClient.mock.calls).toHaveLength(1);
expect(spyHttpClient.mock.calls[0][0]).toBe(buildUrl);
}
);
it('load available versions', async () => {
const distribution = new LibericaDistributions({
version: '11',
architecture: 'x64',
packageType: 'jdk',
checkLatest: false
});
const availableVersions = await distribution['getAvailableVersions']();
expect(availableVersions).toEqual(manifestData);
});
});
describe('getArchitectureOptions', () => {
it.each([
['x86', {bitness: '32', arch: 'x86'}],
['x64', {bitness: '64', arch: 'x86'}],
['armv7', {bitness: '32', arch: 'arm'}],
['aarch64', {bitness: '64', arch: 'arm'}],
['ppc64le', {bitness: '64', arch: 'ppc'}]
] as [string, ArchitectureOptions][])(
'parse architecture %s -> %s',
(input, expected) => {
const distributions = new LibericaDistributions({
architecture: input,
checkLatest: false,
packageType: '',
version: ''
});
expect(distributions['getArchitectureOptions']()).toEqual(expected);
}
);
it.each(['armv6', 's390x'])('not support architecture %s', input => {
const distributions = new LibericaDistributions({
architecture: input,
checkLatest: false,
packageType: '',
version: ''
});
expect(() => distributions['getArchitectureOptions']()).toThrow(
/Architecture '\w+' is not supported\. Supported architectures: .*/
);
});
});
describe('findPackageForDownload', () => {
let distribution: LibericaDistributions;
beforeEach(() => {
distribution = new LibericaDistributions({
version: '',
architecture: 'x64',
packageType: 'jdk',
checkLatest: false
});
distribution['getAvailableVersions'] = async () => manifestData;
});
it.each([
['8', '8.0.302+8'],
['11.x', '11.0.12+7'],
['8.0', '8.0.302+8'],
['11.0.x', '11.0.12+7'],
['15', '15.0.2+10'],
['15.0', '15.0.2+10'],
['15.0.0', '15.0.0+36'],
['8.0.232', '8.0.232+10'],
['8.0.232+9', '8.0.232+9'],
['15.0.2+8', '15.0.2+8'],
['15.0.2+10', '15.0.2+10']
])('version is %s -> %s', async (input, expected) => {
const result = await distribution['findPackageForDownload'](input);
expect(result.version).toBe(expected);
});
it('should throw an error', async () => {
await expect(distribution['findPackageForDownload']('18')).rejects.toThrow(
/Could not find satisfied version for semver */
);
});
});
describe('getPlatformOption', () => {
const distributions = new LibericaDistributions({
architecture: 'x64',
version: '11',
packageType: 'jdk',
checkLatest: false
});
it.each([
['linux', 'linux'],
['darwin', 'macos'],
['win32', 'windows'],
['cygwin', 'windows'],
['sunos', 'solaris']
])('os version %s -> %s', (input, expected) => {
const actual = distributions['getPlatformOption'](input as NodeJS.Platform);
expect(actual).toEqual(expected);
});
it.each(['aix', 'android', 'freebsd', 'openbsd', 'netbsd'])(
'not support os version %s',
input => {
expect(() =>
distributions['getPlatformOption'](input as NodeJS.Platform)
).toThrow(/Platform '\w+' is not supported\. Supported platforms: .+/);
}
);
});
describe('convertVersionToSemver', () => {
const distributions = new LibericaDistributions({
architecture: 'x64',
version: '11',
packageType: 'jdk',
checkLatest: false
});
it.each([
[
{
featureVersion: 11,
interimVersion: 0,
updateVersion: 12,
buildVersion: 7
},
'11.0.12+7'
],
[
{
featureVersion: 11,
interimVersion: 0,
updateVersion: 12,
buildVersion: 0
},
'11.0.12'
],
[
{
featureVersion: 11,
interimVersion: 0,
updateVersion: 0,
buildVersion: 13
},
'11.0.0+13'
]
])('%s -> %s', (input, expected) => {
const actual = distributions['convertVersionToSemver']({
downloadUrl: '',
version: '',
...input
});
expect(actual).toEqual(expected);
});
});

View File

@ -7,7 +7,7 @@ import path from 'path';
import * as semver from 'semver';
import * as util from '../../src/util';
import { LocalDistribution } from '../../src/distributions/local/installer';
import {LocalDistribution} from '../../src/distributions/local/installer';
describe('setupJava', () => {
const actualJavaVersion = '11.1.10';
@ -27,7 +27,7 @@ describe('setupJava', () => {
let spyFsReadDir: jest.SpyInstance;
let spyUtilsExtractJdkFile: jest.SpyInstance;
let spyPathResolve: jest.SpyInstance;
let expectedJdkFile = 'JavaLocalJdkFile';
const expectedJdkFile = 'JavaLocalJdkFile';
beforeEach(() => {
spyGetToolcachePath = jest.spyOn(util, 'getToolcachePath');
@ -35,18 +35,27 @@ describe('setupJava', () => {
(toolname: string, javaVersion: string, architecture: string) => {
const semverVersion = new semver.Range(javaVersion);
if (path.basename(javaPath) !== architecture || !javaPath.includes(toolname)) {
if (
path.basename(javaPath) !== architecture ||
!javaPath.includes(toolname)
) {
return '';
}
return semver.satisfies(actualJavaVersion, semverVersion) ? javaPath : '';
return semver.satisfies(actualJavaVersion, semverVersion)
? javaPath
: '';
}
);
spyTcCacheDir = jest.spyOn(tc, 'cacheDir');
spyTcCacheDir.mockImplementation(
(archivePath: string, toolcacheFolderName: string, version: string, architecture: string) =>
path.join(toolcacheFolderName, version, architecture)
(
archivePath: string,
toolcacheFolderName: string,
version: string,
architecture: string
) => path.join(toolcacheFolderName, version, architecture)
);
spyTcFindAllVersions = jest.spyOn(tc, 'findAllVersions');
@ -74,7 +83,7 @@ describe('setupJava', () => {
spyFsStat = jest.spyOn(fs, 'statSync');
spyFsStat.mockImplementation((file: string) => {
return { isFile: () => file === expectedJdkFile };
return {isFile: () => file === expectedJdkFile};
});
// Spy on util methods
@ -108,7 +117,9 @@ describe('setupJava', () => {
mockJavaBase = new LocalDistribution(inputs, jdkFile);
await expect(mockJavaBase.setupJava()).resolves.toEqual(expected);
expect(spyGetToolcachePath).toHaveBeenCalled();
expect(spyCoreInfo).toHaveBeenCalledWith(`Resolved Java ${actualJavaVersion} from tool-cache`);
expect(spyCoreInfo).toHaveBeenCalledWith(
`Resolved Java ${actualJavaVersion} from tool-cache`
);
expect(spyCoreInfo).not.toHaveBeenCalledWith(
`Java ${inputs.version} was not found in tool-cache. Trying to unpack JDK file...`
);
@ -130,7 +141,9 @@ describe('setupJava', () => {
mockJavaBase = new LocalDistribution(inputs, jdkFile);
await expect(mockJavaBase.setupJava()).resolves.toEqual(expected);
expect(spyGetToolcachePath).toHaveBeenCalled();
expect(spyCoreInfo).toHaveBeenCalledWith(`Resolved Java ${actualJavaVersion} from tool-cache`);
expect(spyCoreInfo).toHaveBeenCalledWith(
`Resolved Java ${actualJavaVersion} from tool-cache`
);
expect(spyCoreInfo).not.toHaveBeenCalledWith(
`Java ${inputs.version} was not found in tool-cache. Trying to unpack JDK file...`
);
@ -155,7 +168,9 @@ describe('setupJava', () => {
expect(spyCoreInfo).not.toHaveBeenCalledWith(
`Resolved Java ${actualJavaVersion} from tool-cache`
);
expect(spyCoreInfo).toHaveBeenCalledWith(`Extracting Java from '${jdkFile}'`);
expect(spyCoreInfo).toHaveBeenCalledWith(
`Extracting Java from '${jdkFile}'`
);
expect(spyCoreInfo).toHaveBeenCalledWith(
`Java ${inputs.version} was not found in tool-cache. Trying to unpack JDK file...`
);
@ -171,46 +186,163 @@ describe('setupJava', () => {
const jdkFile = 'not_existing_one';
const expected = {
javaVersion: '11.0.289',
javaPath: path.join('Java_jdkfile_jdk', inputs.version, inputs.architecture)
javaPath: path.join(
'Java_jdkfile_jdk',
inputs.version,
inputs.architecture
)
};
mockJavaBase = new LocalDistribution(inputs, jdkFile);
expected.javaPath = path.join('Java_jdkfile_jdk', inputs.version, inputs.architecture);
await expect(mockJavaBase.setupJava()).rejects.toThrowError(
expected.javaPath = path.join(
'Java_jdkfile_jdk',
inputs.version,
inputs.architecture
);
await expect(mockJavaBase.setupJava()).rejects.toThrow(
"JDK file was not found in path 'not_existing_one'"
);
expect(spyTcFindAllVersions).toHaveBeenCalled();
expect(spyCoreInfo).not.toHaveBeenCalledWith(
`Resolved Java ${actualJavaVersion} from tool-cache`
);
expect(spyCoreInfo).not.toHaveBeenCalledWith(`Extracting Java from '${jdkFile}'`);
expect(spyCoreInfo).not.toHaveBeenCalledWith(
`Extracting Java from '${jdkFile}'`
);
expect(spyCoreInfo).toHaveBeenCalledWith(
`Java ${inputs.version} was not found in tool-cache. Trying to unpack JDK file...`
);
});
it('java is resolved from toolcache including Contents/Home on MacOS', async () => {
const inputs = {
version: actualJavaVersion,
architecture: 'x86',
packageType: 'jdk',
checkLatest: false
};
const jdkFile = 'not_existing_one';
const expected = {
version: actualJavaVersion,
path: path.join(
'Java_jdkfile_jdk',
inputs.version,
inputs.architecture,
'Contents',
'Home'
)
};
const originalPlatform = process.platform;
Object.defineProperty(process, 'platform', {
value: 'darwin'
});
spyFsStat = jest.spyOn(fs, 'existsSync');
spyFsStat.mockImplementation((file: string) => {
return file.endsWith('Home');
});
mockJavaBase = new LocalDistribution(inputs, jdkFile);
await expect(mockJavaBase.setupJava()).resolves.toEqual(expected);
expect(spyGetToolcachePath).toHaveBeenCalled();
expect(spyCoreInfo).toHaveBeenCalledWith(
`Resolved Java ${actualJavaVersion} from tool-cache`
);
expect(spyCoreInfo).not.toHaveBeenCalledWith(
`Java ${inputs.version} was not found in tool-cache. Trying to unpack JDK file...`
);
Object.defineProperty(process, 'platform', {
value: originalPlatform
});
});
it('java is unpacked from jdkfile including Contents/Home on MacOS', async () => {
const inputs = {
version: '11.0.289',
architecture: 'x86',
packageType: 'jdk',
checkLatest: false
};
const jdkFile = expectedJdkFile;
const expected = {
version: '11.0.289',
path: path.join(
'Java_jdkfile_jdk',
inputs.version,
inputs.architecture,
'Contents',
'Home'
)
};
const originalPlatform = process.platform;
Object.defineProperty(process, 'platform', {
value: 'darwin'
});
spyFsStat = jest.spyOn(fs, 'existsSync');
spyFsStat.mockImplementation((file: string) => {
return file.endsWith('Home');
});
mockJavaBase = new LocalDistribution(inputs, jdkFile);
await expect(mockJavaBase.setupJava()).resolves.toEqual(expected);
expect(spyTcFindAllVersions).toHaveBeenCalled();
expect(spyCoreInfo).not.toHaveBeenCalledWith(
`Resolved Java ${actualJavaVersion} from tool-cache`
);
expect(spyCoreInfo).toHaveBeenCalledWith(
`Extracting Java from '${jdkFile}'`
);
expect(spyCoreInfo).toHaveBeenCalledWith(
`Java ${inputs.version} was not found in tool-cache. Trying to unpack JDK file...`
);
Object.defineProperty(process, 'platform', {
value: originalPlatform
});
});
it.each([
[
{ version: '8.0.289', architecture: 'x64', packageType: 'jdk', checkLatest: false },
{
version: '8.0.289',
architecture: 'x64',
packageType: 'jdk',
checkLatest: false
},
'otherJdkFile'
],
[
{ version: '11.0.289', architecture: 'x64', packageType: 'jdk', checkLatest: false },
{
version: '11.0.289',
architecture: 'x64',
packageType: 'jdk',
checkLatest: false
},
'otherJdkFile'
],
[
{ version: '12.0.289', architecture: 'x64', packageType: 'jdk', checkLatest: false },
{
version: '12.0.289',
architecture: 'x64',
packageType: 'jdk',
checkLatest: false
},
'otherJdkFile'
],
[
{ version: '11.1.11', architecture: 'x64', packageType: 'jdk', checkLatest: false },
{
version: '11.1.11',
architecture: 'x64',
packageType: 'jdk',
checkLatest: false
},
'not_existing_one'
]
])(
`Throw an error if jdkfile has wrong path, inputs %s, jdkfile %s, real name ${expectedJdkFile}`,
async (inputs, jdkFile) => {
mockJavaBase = new LocalDistribution(inputs, jdkFile);
await expect(mockJavaBase.setupJava()).rejects.toThrowError(
await expect(mockJavaBase.setupJava()).rejects.toThrow(
/JDK file was not found in path */
);
expect(spyTcFindAllVersions).toHaveBeenCalled();
@ -218,18 +350,41 @@ describe('setupJava', () => {
);
it.each([
[{ version: '8.0.289', architecture: 'x64', packageType: 'jdk', checkLatest: false }, ''],
[
{ version: '7.0.289', architecture: 'x64', packageType: 'jdk', checkLatest: false },
{
version: '8.0.289',
architecture: 'x64',
packageType: 'jdk',
checkLatest: false
},
''
],
[
{
version: '7.0.289',
architecture: 'x64',
packageType: 'jdk',
checkLatest: false
},
undefined
],
[
{ version: '11.0.289', architecture: 'x64', packageType: 'jdk', checkLatest: false },
{
version: '11.0.289',
architecture: 'x64',
packageType: 'jdk',
checkLatest: false
},
undefined
]
])('Throw an error if jdkfile is not specified, inputs %s', async (inputs, jdkFile) => {
mockJavaBase = new LocalDistribution(inputs, jdkFile);
await expect(mockJavaBase.setupJava()).rejects.toThrowError("'jdkFile' is not specified");
expect(spyTcFindAllVersions).toHaveBeenCalled();
});
])(
'Throw an error if jdkfile is not specified, inputs %s',
async (inputs, jdkFile) => {
mockJavaBase = new LocalDistribution(inputs, jdkFile);
await expect(mockJavaBase.setupJava()).rejects.toThrow(
"'jdkFile' is not specified"
);
expect(spyTcFindAllVersions).toHaveBeenCalled();
}
);
});

View File

@ -1,7 +1,13 @@
import { MicrosoftDistributions } from '../../src/distributions/microsoft/installer';
import {MicrosoftDistributions} from '../../src/distributions/microsoft/installer';
import os from 'os';
import data from '../data/microsoft.json';
import * as httpm from '@actions/http-client';
import * as core from '@actions/core';
describe('findPackageForDownload', () => {
let distribution: MicrosoftDistributions;
let spyGetManifestFromRepo: jest.SpyInstance;
let spyDebug: jest.SpyInstance;
beforeEach(() => {
distribution = new MicrosoftDistributions({
@ -10,23 +16,53 @@ describe('findPackageForDownload', () => {
packageType: 'jdk',
checkLatest: false
});
spyGetManifestFromRepo = jest.spyOn(httpm.HttpClient.prototype, 'getJson');
spyGetManifestFromRepo.mockReturnValue({
result: data,
statusCode: 200,
headers: {}
});
spyDebug = jest.spyOn(core, 'debug');
spyDebug.mockImplementation(() => {});
});
it.each([
[
'17.x',
'21.x',
'21.0.0',
'https://aka.ms/download-jdk/microsoft-jdk-21.0.0-{{OS_TYPE}}-x64.{{ARCHIVE_TYPE}}'
],
[
'17.0.1',
'17.0.1+12.1',
'https://aka.ms/download-jdk/microsoft-jdk-17.0.1.12.1-{{OS_TYPE}}-x64.{{ARCHIVE_TYPE}}'
],
[
'17.x',
'17.0.7',
'https://aka.ms/download-jdk/microsoft-jdk-17.0.7-{{OS_TYPE}}-x64.{{ARCHIVE_TYPE}}'
],
[
'16.0.x',
'16.0.2',
'16.0.2+7.1',
'https://aka.ms/download-jdk/microsoft-jdk-16.0.2.7.1-{{OS_TYPE}}-x64.{{ARCHIVE_TYPE}}'
],
[
'11.0.13',
'11.0.13',
'11.0.13+8.1',
'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}}'
],
[
'11.x',
'11.0.19',
'https://aka.ms/download-jdk/microsoft-jdk-11.0.19-{{OS_TYPE}}-x64.{{ARCHIVE_TYPE}}'
]
])('version is %s -> %s', async (input, expectedVersion, expectedUrl) => {
const result = await distribution['findPackageForDownload'](input);
@ -47,42 +83,87 @@ describe('findPackageForDownload', () => {
archive = 'tar.gz';
break;
}
const url = expectedUrl.replace('{{OS_TYPE}}', os).replace('{{ARCHIVE_TYPE}}', archive);
const url = expectedUrl
.replace('{{OS_TYPE}}', os)
.replace('{{ARCHIVE_TYPE}}', archive);
expect(result.url).toBe(url);
});
it.each([
['amd64', 'x64'],
['arm64', 'aarch64']
])(
'defaults to os.arch(): %s mapped to distro arch: %s',
async (osArch: string, distroArch: string) => {
jest.spyOn(os, 'arch').mockReturnValue(osArch);
jest.spyOn(os, 'platform').mockReturnValue('darwin');
const version = '17';
const distro = new MicrosoftDistributions({
version,
architecture: '', // to get default value
packageType: 'jdk',
checkLatest: false
});
const result = await distro['findPackageForDownload'](version);
const expectedUrl = `https://aka.ms/download-jdk/microsoft-jdk-17.0.7-macos-${distroArch}.tar.gz`;
expect(result.url).toBe(expectedUrl);
}
);
it.each([
['amd64', 'x64'],
['arm64', 'aarch64']
])(
'defaults to os.arch(): %s mapped to distro arch: %s',
async (osArch: string, distroArch: string) => {
jest.spyOn(os, 'arch').mockReturnValue(osArch);
jest.spyOn(os, 'platform').mockReturnValue('linux');
const version = '17';
const distro = new MicrosoftDistributions({
version,
architecture: '', // to get default value
packageType: 'jdk',
checkLatest: false
});
const result = await distro['findPackageForDownload'](version);
const expectedUrl = `https://aka.ms/download-jdk/microsoft-jdk-17.0.7-linux-${distroArch}.tar.gz`;
expect(result.url).toBe(expectedUrl);
}
);
it.each([
['amd64', 'x64'],
['arm64', 'aarch64']
])(
'defaults to os.arch(): %s mapped to distro arch: %s',
async (osArch: string, distroArch: string) => {
jest.spyOn(os, 'arch').mockReturnValue(osArch);
jest.spyOn(os, 'platform').mockReturnValue('win32');
const version = '17';
const distro = new MicrosoftDistributions({
version,
architecture: '', // to get default value
packageType: 'jdk',
checkLatest: false
});
const result = await distro['findPackageForDownload'](version);
const expectedUrl = `https://aka.ms/download-jdk/microsoft-jdk-17.0.7-windows-${distroArch}.zip`;
expect(result.url).toBe(expectedUrl);
}
);
it('should throw an error', async () => {
await expect(distribution['findPackageForDownload']('8')).rejects.toThrow(
/Could not find satisfied version for SemVer */
);
});
});
describe('getPlatformOption', () => {
const distributions = new MicrosoftDistributions({
architecture: 'x64',
version: '11',
packageType: 'jdk',
checkLatest: false
});
it.each([
['linux', 'tar.gz', 'linux'],
['darwin', 'tar.gz', 'macos'],
['win32', 'zip', 'windows']
])('os version %s -> %s', (input, expectedArchive, expectedOs) => {
const actual = distributions['getPlatformOption'](input as NodeJS.Platform);
expect(actual.archive).toEqual(expectedArchive);
expect(actual.os).toEqual(expectedOs);
});
it.each(['aix', 'android', 'freebsd', 'openbsd', 'netbsd', 'solaris', 'cygwin'])(
'not support os version %s',
input => {
expect(() => distributions['getPlatformOption'](input as NodeJS.Platform)).toThrow(
/Platform '\w+' is not supported\. Supported platforms: .+/
);
}
);
});

View File

@ -0,0 +1,129 @@
import {OracleDistribution} from '../../src/distributions/oracle/installer';
import os from 'os';
import * as core from '@actions/core';
import {getDownloadArchiveExtension} from '../../src/util';
import {HttpClient} from '@actions/http-client';
describe('findPackageForDownload', () => {
let distribution: OracleDistribution;
let spyDebug: jest.SpyInstance;
let spyHttpClient: jest.SpyInstance;
beforeEach(() => {
distribution = new OracleDistribution({
version: '',
architecture: 'x64',
packageType: 'jdk',
checkLatest: false
});
spyDebug = jest.spyOn(core, 'debug');
spyDebug.mockImplementation(() => {});
});
it.each([
[
'21',
'21',
'https://download.oracle.com/java/21/latest/jdk-21_{{OS_TYPE}}-x64_bin.{{ARCHIVE_TYPE}}'
],
[
'20',
'20',
'https://download.oracle.com/java/20/latest/jdk-20_{{OS_TYPE}}-x64_bin.{{ARCHIVE_TYPE}}'
],
[
'18',
'18',
'https://download.oracle.com/java/18/archive/jdk-18_{{OS_TYPE}}-x64_bin.{{ARCHIVE_TYPE}}'
],
[
'20.0.1',
'20.0.1',
'https://download.oracle.com/java/20/archive/jdk-20.0.1_{{OS_TYPE}}-x64_bin.{{ARCHIVE_TYPE}}'
],
[
'17',
'17',
'https://download.oracle.com/java/17/latest/jdk-17_{{OS_TYPE}}-x64_bin.{{ARCHIVE_TYPE}}'
],
[
'17.0.1',
'17.0.1',
'https://download.oracle.com/java/17/archive/jdk-17.0.1_{{OS_TYPE}}-x64_bin.{{ARCHIVE_TYPE}}'
]
])('version is %s -> %s', async (input, expectedVersion, expectedUrl) => {
/* Needed only for this particular test because some urls might change */
spyHttpClient = jest.spyOn(HttpClient.prototype, 'head');
spyHttpClient.mockReturnValue(
Promise.resolve({
message: {
statusCode: 200
}
})
);
/**
* NOTE - Should fail to retrieve 18 from latest and check archive instead
*/
if (input === '18') {
spyHttpClient.mockReturnValueOnce(
Promise.resolve({
message: {
statusCode: 404
}
})
);
}
const result = await distribution['findPackageForDownload'](input);
jest.restoreAllMocks();
expect(result.version).toBe(expectedVersion);
const osType = distribution.getPlatform();
const archiveType = getDownloadArchiveExtension();
const url = expectedUrl
.replace('{{OS_TYPE}}', osType)
.replace('{{ARCHIVE_TYPE}}', archiveType);
expect(result.url).toBe(url);
});
it.each([
['amd64', 'x64'],
['arm64', 'aarch64']
])(
'defaults to os.arch(): %s mapped to distro arch: %s',
async (osArch: string, distroArch: string) => {
jest.spyOn(os, 'arch').mockReturnValue(osArch);
jest.spyOn(os, 'platform').mockReturnValue('linux');
const version = '18';
const distro = new OracleDistribution({
version,
architecture: '', // to get default value
packageType: 'jdk',
checkLatest: false
});
const osType = distribution.getPlatform();
if (osType === 'windows' && distroArch == 'aarch64') {
return; // skip, aarch64 is not available for Windows
}
const archiveType = getDownloadArchiveExtension();
const result = await distro['findPackageForDownload'](version);
const expectedUrl = `https://download.oracle.com/java/18/archive/jdk-18_${osType}-${distroArch}_bin.${archiveType}`;
expect(result.url).toBe(expectedUrl);
}
);
it('should throw an error', async () => {
await expect(distribution['findPackageForDownload']('8')).rejects.toThrow(
/Oracle JDK is only supported for JDK 17 and later/
);
await expect(distribution['findPackageForDownload']('11')).rejects.toThrow(
/Oracle JDK is only supported for JDK 17 and later/
);
});
});

View File

@ -0,0 +1,287 @@
import {HttpClient} from '@actions/http-client';
import {JavaInstallerOptions} from '../../src/distributions/base-models';
import {SemeruDistribution} from '../../src/distributions/semeru/installer';
import manifestData from '../data/semeru.json';
describe('getAvailableVersions', () => {
let spyHttpClient: jest.SpyInstance;
beforeEach(() => {
spyHttpClient = jest.spyOn(HttpClient.prototype, 'getJson');
spyHttpClient.mockReturnValue({
statusCode: 200,
headers: {},
result: []
});
});
afterEach(() => {
jest.resetAllMocks();
jest.clearAllMocks();
jest.restoreAllMocks();
});
it.each([
[
{
version: '16',
architecture: 'x64',
packageType: 'jdk',
checkLatest: false
},
'os=mac&architecture=x64&image_type=jdk&release_type=ga&jvm_impl=openj9&page_size=20&page=0'
],
[
{
version: '16',
architecture: 'x86',
packageType: 'jdk',
checkLatest: false
},
'os=mac&architecture=x86&image_type=jdk&release_type=ga&jvm_impl=openj9&page_size=20&page=0'
],
[
{
version: '16',
architecture: 'x64',
packageType: 'jre',
checkLatest: false
},
'os=mac&architecture=x64&image_type=jre&release_type=ga&jvm_impl=openj9&page_size=20&page=0'
],
[
{
version: '16',
architecture: 'x64',
packageType: 'jdk',
checkLatest: false
},
'os=mac&architecture=x64&image_type=jdk&release_type=ga&jvm_impl=openj9&page_size=20&page=0'
]
])(
'build correct url for %s',
async (installerOptions: JavaInstallerOptions, expectedParameters) => {
const distribution = new SemeruDistribution(installerOptions);
const baseUrl =
'https://api.adoptopenjdk.net/v3/assets/version/%5B1.0,100.0%5D';
const expectedUrl = `${baseUrl}?project=jdk&vendor=ibm&heap_size=normal&sort_method=DEFAULT&sort_order=DESC&${expectedParameters}`;
distribution['getPlatformOption'] = () => 'mac';
await distribution['getAvailableVersions']();
expect(spyHttpClient.mock.calls).toHaveLength(1);
expect(spyHttpClient.mock.calls[0][0]).toBe(expectedUrl);
}
);
it('load available versions', async () => {
spyHttpClient = jest.spyOn(HttpClient.prototype, 'getJson');
spyHttpClient
.mockReturnValueOnce({
statusCode: 200,
headers: {},
result: manifestData as any
})
.mockReturnValueOnce({
statusCode: 200,
headers: {},
result: manifestData as any
})
.mockReturnValueOnce({
statusCode: 200,
headers: {},
result: []
});
const distribution = new SemeruDistribution({
version: '8',
architecture: 'x64',
packageType: 'jdk',
checkLatest: false
});
const availableVersions = await distribution['getAvailableVersions']();
expect(availableVersions).not.toBeNull();
expect(availableVersions.length).toBe(manifestData.length * 2);
});
it.each([
['jdk', 'Java_IBM_Semeru_jdk'],
['jre', 'Java_IBM_Semeru_jre']
])('find right toolchain folder', (packageType: string, expected: string) => {
const distribution = new SemeruDistribution({
version: '8',
architecture: 'x64',
packageType: packageType,
checkLatest: false
});
// @ts-ignore - because it is protected
expect(distribution.toolcacheFolderName).toBe(expected);
});
});
describe('findPackageForDownload', () => {
it.each([
['8', '8.0.322+6'],
['16', '16.0.2+7'],
['16.0', '16.0.2+7'],
['16.0.2', '16.0.2+7'],
['8.x', '8.0.322+6'],
['x', '17.0.2+8']
])('version is resolved correctly %s -> %s', async (input, expected) => {
const distribution = new SemeruDistribution({
version: '8',
architecture: 'x64',
packageType: 'jdk',
checkLatest: false
});
distribution['getAvailableVersions'] = async () => manifestData as any;
const resolvedVersion = await distribution['findPackageForDownload'](input);
expect(resolvedVersion.version).toBe(expected);
});
it('version is found but binaries list is empty', async () => {
const distribution = new SemeruDistribution({
version: '9.0.8',
architecture: 'x64',
packageType: 'jdk',
checkLatest: false
});
distribution['getAvailableVersions'] = async () => manifestData as any;
await expect(
distribution['findPackageForDownload']('9.0.8')
).rejects.toThrow(/Could not find satisfied version for SemVer */);
});
it('version is not found', async () => {
const distribution = new SemeruDistribution({
version: '7.x',
architecture: 'x64',
packageType: 'jdk',
checkLatest: false
});
distribution['getAvailableVersions'] = async () => manifestData as any;
await expect(distribution['findPackageForDownload']('7.x')).rejects.toThrow(
/Could not find satisfied version for SemVer */
);
});
it('version list is empty', async () => {
const distribution = new SemeruDistribution({
version: '8',
architecture: 'x64',
packageType: 'jdk',
checkLatest: false
});
distribution['getAvailableVersions'] = async () => [];
await expect(distribution['findPackageForDownload']('8')).rejects.toThrow(
/Could not find satisfied version for SemVer */
);
});
it.each(['x64', 'x86', 'ppc64le', 'ppc64', 's390x', 'aarch64'])(
'correct Semeru `%s` architecture resolves',
async (arch: string) => {
const distribution = new SemeruDistribution({
version: '8',
architecture: arch,
packageType: 'jdk',
checkLatest: false
});
distribution['getAvailableVersions'] = async () => manifestData as any;
const resolvedVersion = await distribution['findPackageForDownload']('8');
expect(resolvedVersion.version).not.toBeNull();
}
);
it.each(['zos', 'z/OS', 'z/os', 'test0987654321=', '++=++', 'myArch'])(
'incorrect Semeru `%s` architecture throws',
async (arch: string) => {
const distribution = new SemeruDistribution({
version: '8',
architecture: arch,
packageType: 'jdk',
checkLatest: false
});
distribution['getAvailableVersions'] = async () => [];
await expect(distribution['findPackageForDownload']('8')).rejects.toThrow(
`Unsupported architecture for IBM Semeru: ${arch}, the following are supported: x64, x86, ppc64le, ppc64, s390x, aarch64`
);
}
);
it.each(['9-ea', '17-ea', '8-ea', '4-ea'])(
'early access version are illegal for Semeru (%s)',
async (version: string) => {
const distribution = new SemeruDistribution({
version: version,
architecture: 'x64',
packageType: 'jdk',
checkLatest: false
});
distribution['getAvailableVersions'] = async () => manifestData as any;
await expect(
distribution['findPackageForDownload'](version)
).rejects.toThrow(
'IBM Semeru does not provide builds for early access versions'
);
}
);
it.each([
'jdk+fx',
'jre+fx',
'test',
'test2',
'jdk-fx',
'javafx',
'jdk-javafx',
'ibm',
' '
])(
'rejects incorrect `%s` Semeru package type',
async (packageType: string) => {
const distribution = new SemeruDistribution({
version: '8',
architecture: 'x64',
packageType: packageType,
checkLatest: false
});
distribution['getAvailableVersions'] = async () => manifestData as any;
await expect(distribution['findPackageForDownload']('8')).rejects.toThrow(
'IBM Semeru only provide `jdk` and `jre` package types'
);
}
);
it.each(['jdk', 'jre'])(
'accepts correct `%s` Semeru package type',
async (packageType: string) => {
const distribution = new SemeruDistribution({
version: '8',
architecture: 'x64',
packageType: packageType,
checkLatest: false
});
distribution['getAvailableVersions'] = async () => manifestData as any;
const resolvedVersion = await distribution['findPackageForDownload']('8');
await expect(resolvedVersion.version).toMatch(/8[0-9.]+/);
}
);
it('fails when long release name is used', async () => {
expect(
() =>
new SemeruDistribution({
version: 'jdk-16.0.2+7_openj9-0.27.1',
architecture: 'x64',
packageType: 'jdk',
checkLatest: false
})
).toThrow(
"The string 'jdk-16.0.2+7_openj9-0.27.1' is not valid SemVer notation for a Java version. Please check README file for code snippets and more detailed information"
);
});
});

View File

@ -1,12 +1,12 @@
import { HttpClient } from '@actions/http-client';
import {HttpClient} from '@actions/http-client';
import os from 'os';
import {
TemurinDistribution,
TemurinImplementation
} from '../../src/distributions/temurin/installer';
import { JavaInstallerOptions } from '../../src/distributions/base-models';
import {JavaInstallerOptions} from '../../src/distributions/base-models';
let manifestData = require('../data/temurin.json') as [];
import manifestData from '../data/temurin.json';
describe('getAvailableVersions', () => {
let spyHttpClient: jest.SpyInstance;
@ -28,22 +28,42 @@ describe('getAvailableVersions', () => {
it.each([
[
{ version: '16', architecture: 'x64', packageType: 'jdk', checkLatest: false },
{
version: '16',
architecture: 'x64',
packageType: 'jdk',
checkLatest: false
},
TemurinImplementation.Hotspot,
'os=mac&architecture=x64&image_type=jdk&release_type=ga&jvm_impl=hotspot&page_size=20&page=0'
],
[
{ version: '16', architecture: 'x86', packageType: 'jdk', checkLatest: false },
{
version: '16',
architecture: 'x86',
packageType: 'jdk',
checkLatest: false
},
TemurinImplementation.Hotspot,
'os=mac&architecture=x86&image_type=jdk&release_type=ga&jvm_impl=hotspot&page_size=20&page=0'
],
[
{ version: '16', architecture: 'x64', packageType: 'jre', checkLatest: false },
{
version: '16',
architecture: 'x64',
packageType: 'jre',
checkLatest: false
},
TemurinImplementation.Hotspot,
'os=mac&architecture=x64&image_type=jre&release_type=ga&jvm_impl=hotspot&page_size=20&page=0'
],
[
{ version: '16-ea', architecture: 'x64', packageType: 'jdk', checkLatest: false },
{
version: '16-ea',
architecture: 'x64',
packageType: 'jdk',
checkLatest: false
},
TemurinImplementation.Hotspot,
'os=mac&architecture=x64&image_type=jdk&release_type=ea&jvm_impl=hotspot&page_size=20&page=0'
]
@ -55,7 +75,8 @@ describe('getAvailableVersions', () => {
expectedParameters
) => {
const distribution = new TemurinDistribution(installerOptions, impl);
const baseUrl = 'https://api.adoptium.net/v3/assets/version/%5B1.0,100.0%5D';
const baseUrl =
'https://api.adoptium.net/v3/assets/version/%5B1.0,100.0%5D';
const expectedUrl = `${baseUrl}?project=jdk&vendor=adoptium&heap_size=normal&sort_method=DEFAULT&sort_order=DESC&${expectedParameters}`;
distribution['getPlatformOption'] = () => 'mac';
@ -72,12 +93,12 @@ describe('getAvailableVersions', () => {
.mockReturnValueOnce({
statusCode: 200,
headers: {},
result: manifestData
result: manifestData as any
})
.mockReturnValueOnce({
statusCode: 200,
headers: {},
result: manifestData
result: manifestData as any
})
.mockReturnValueOnce({
statusCode: 200,
@ -86,7 +107,12 @@ describe('getAvailableVersions', () => {
});
const distribution = new TemurinDistribution(
{ version: '8', architecture: 'x64', packageType: 'jdk', checkLatest: false },
{
version: '8',
architecture: 'x64',
packageType: 'jdk',
checkLatest: false
},
TemurinImplementation.Hotspot
);
const availableVersions = await distribution['getAvailableVersions']();
@ -101,7 +127,12 @@ describe('getAvailableVersions', () => {
'find right toolchain folder',
(impl: TemurinImplementation, packageType: string, expected: string) => {
const distribution = new TemurinDistribution(
{ version: '8', architecture: 'x64', packageType: packageType, checkLatest: false },
{
version: '8',
architecture: 'x64',
packageType: packageType,
checkLatest: false
},
impl
);
@ -109,6 +140,39 @@ describe('getAvailableVersions', () => {
expect(distribution.toolcacheFolderName).toBe(expected);
}
);
it.each([
['amd64', 'x64'],
['arm64', 'aarch64']
])(
'defaults to os.arch(): %s mapped to distro arch: %s',
async (osArch: string, distroArch: string) => {
jest.spyOn(os, 'arch').mockReturnValue(distroArch);
const installerOptions: JavaInstallerOptions = {
version: '17',
architecture: '',
packageType: 'jdk',
checkLatest: false
};
const expectedParameters = `os=mac&architecture=${distroArch}&image_type=jdk&release_type=ga&jvm_impl=hotspot&page_size=20&page=0`;
const distribution = new TemurinDistribution(
installerOptions,
TemurinImplementation.Hotspot
);
const baseUrl =
'https://api.adoptium.net/v3/assets/version/%5B1.0,100.0%5D';
const expectedUrl = `${baseUrl}?project=jdk&vendor=adoptium&heap_size=normal&sort_method=DEFAULT&sort_order=DESC&${expectedParameters}`;
distribution['getPlatformOption'] = () => 'mac';
await distribution['getAvailableVersions']();
expect(spyHttpClient.mock.calls).toHaveLength(1);
expect(spyHttpClient.mock.calls[0][0]).toBe(expectedUrl);
}
);
});
describe('findPackageForDownload', () => {
@ -121,43 +185,63 @@ describe('findPackageForDownload', () => {
['x', '16.0.2+7']
])('version is resolved correctly %s -> %s', async (input, expected) => {
const distribution = new TemurinDistribution(
{ version: '8', architecture: 'x64', packageType: 'jdk', checkLatest: false },
{
version: '8',
architecture: 'x64',
packageType: 'jdk',
checkLatest: false
},
TemurinImplementation.Hotspot
);
distribution['getAvailableVersions'] = async () => manifestData;
distribution['getAvailableVersions'] = async () => manifestData as any;
const resolvedVersion = await distribution['findPackageForDownload'](input);
expect(resolvedVersion.version).toBe(expected);
});
it('version is found but binaries list is empty', async () => {
const distribution = new TemurinDistribution(
{ version: '9.0.8', architecture: 'x64', packageType: 'jdk', checkLatest: false },
{
version: '9.0.8',
architecture: 'x64',
packageType: 'jdk',
checkLatest: false
},
TemurinImplementation.Hotspot
);
distribution['getAvailableVersions'] = async () => manifestData;
await expect(distribution['findPackageForDownload']('9.0.8')).rejects.toThrowError(
/Could not find satisfied version for SemVer */
);
distribution['getAvailableVersions'] = async () => manifestData as any;
await expect(
distribution['findPackageForDownload']('9.0.8')
).rejects.toThrow(/Could not find satisfied version for SemVer */);
});
it('version is not found', async () => {
const distribution = new TemurinDistribution(
{ version: '7.x', architecture: 'x64', packageType: 'jdk', checkLatest: false },
{
version: '7.x',
architecture: 'x64',
packageType: 'jdk',
checkLatest: false
},
TemurinImplementation.Hotspot
);
distribution['getAvailableVersions'] = async () => manifestData;
await expect(distribution['findPackageForDownload']('7.x')).rejects.toThrowError(
distribution['getAvailableVersions'] = async () => manifestData as any;
await expect(distribution['findPackageForDownload']('7.x')).rejects.toThrow(
/Could not find satisfied version for SemVer */
);
});
it('version list is empty', async () => {
const distribution = new TemurinDistribution(
{ version: '8', architecture: 'x64', packageType: 'jdk', checkLatest: false },
{
version: '8',
architecture: 'x64',
packageType: 'jdk',
checkLatest: false
},
TemurinImplementation.Hotspot
);
distribution['getAvailableVersions'] = async () => [];
await expect(distribution['findPackageForDownload']('8')).rejects.toThrowError(
await expect(distribution['findPackageForDownload']('8')).rejects.toThrow(
/Could not find satisfied version for SemVer */
);
});

View File

@ -1,10 +1,11 @@
import { HttpClient } from '@actions/http-client';
import {HttpClient} from '@actions/http-client';
import * as semver from 'semver';
import { ZuluDistribution } from '../../src/distributions/zulu/installer';
import { IZuluVersions } from '../../src/distributions/zulu/models';
import {ZuluDistribution} from '../../src/distributions/zulu/installer';
import {IZuluVersions} from '../../src/distributions/zulu/models';
import * as utils from '../../src/util';
import os from 'os';
const manifestData = require('../data/zulu-releases-default.json') as [];
import manifestData from '../data/zulu-releases-default.json';
describe('getAvailableVersions', () => {
let spyHttpClient: jest.SpyInstance;
@ -18,7 +19,10 @@ describe('getAvailableVersions', () => {
result: manifestData as IZuluVersions[]
});
spyUtilGetDownloadArchiveExtension = jest.spyOn(utils, 'getDownloadArchiveExtension');
spyUtilGetDownloadArchiveExtension = jest.spyOn(
utils,
'getDownloadArchiveExtension'
);
spyUtilGetDownloadArchiveExtension.mockReturnValue('tar.gz');
});
@ -30,28 +34,76 @@ describe('getAvailableVersions', () => {
it.each([
[
{ version: '11', architecture: 'x86', packageType: 'jdk', checkLatest: false },
{
version: '11',
architecture: 'x86',
packageType: 'jdk',
checkLatest: false
},
'?os=macos&ext=tar.gz&bundle_type=jdk&javafx=false&arch=x86&hw_bitness=32&release_status=ga'
],
[
{ version: '11-ea', architecture: 'x86', packageType: 'jdk', checkLatest: false },
{
version: '11-ea',
architecture: 'x86',
packageType: 'jdk',
checkLatest: false
},
'?os=macos&ext=tar.gz&bundle_type=jdk&javafx=false&arch=x86&hw_bitness=32&release_status=ea'
],
[
{ version: '8', architecture: 'x64', packageType: 'jdk', checkLatest: false },
{
version: '8',
architecture: 'x64',
packageType: 'jdk',
checkLatest: false
},
'?os=macos&ext=tar.gz&bundle_type=jdk&javafx=false&arch=x86&hw_bitness=64&release_status=ga'
],
[
{ version: '8', architecture: 'x64', packageType: 'jre', checkLatest: false },
{
version: '8',
architecture: 'x64',
packageType: 'jre',
checkLatest: false
},
'?os=macos&ext=tar.gz&bundle_type=jre&javafx=false&arch=x86&hw_bitness=64&release_status=ga'
],
[
{ version: '8', architecture: 'x64', packageType: 'jdk+fx', checkLatest: false },
{
version: '8',
architecture: 'x64',
packageType: 'jdk+fx',
checkLatest: false
},
'?os=macos&ext=tar.gz&bundle_type=jdk&javafx=true&arch=x86&hw_bitness=64&release_status=ga&features=fx'
],
[
{ 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'
],
[
{
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) => {
const distribution = new ZuluDistribution(input);
@ -64,6 +116,34 @@ describe('getAvailableVersions', () => {
expect(spyHttpClient.mock.calls[0][0]).toBe(buildUrl);
});
type DistroArch = {
bitness: string;
arch: string;
};
it.each([
['amd64', {bitness: '64', arch: 'x86'}],
['arm64', {bitness: '64', arch: 'arm'}]
])(
'defaults to os.arch(): %s mapped to distro arch: %s',
async (osArch: string, distroArch: DistroArch) => {
jest.spyOn(os, 'arch').mockReturnValue(osArch);
const distribution = new ZuluDistribution({
version: '17',
architecture: '', // to get default value
packageType: 'jdk',
checkLatest: false
});
distribution['getPlatformOption'] = () => 'macos';
const buildUrl = `https://api.azul.com/zulu/download/community/v1.0/bundles/?os=macos&ext=tar.gz&bundle_type=jdk&javafx=false&arch=${distroArch.arch}&hw_bitness=${distroArch.bitness}&release_status=ga`;
await distribution['getAvailableVersions']();
expect(spyHttpClient.mock.calls).toHaveLength(1);
expect(spyHttpClient.mock.calls[0][0]).toBe(buildUrl);
}
);
it('load available versions', async () => {
const distribution = new ZuluDistribution({
version: '11',
@ -78,10 +158,10 @@ describe('getAvailableVersions', () => {
describe('getArchitectureOptions', () => {
it.each([
[{ architecture: 'x64' }, { arch: 'x86', hw_bitness: '64', abi: '' }],
[{ architecture: 'x86' }, { arch: 'x86', hw_bitness: '32', abi: '' }],
[{ architecture: 'x32' }, { arch: 'x32', hw_bitness: '', abi: '' }],
[{ architecture: 'arm' }, { arch: 'arm', hw_bitness: '', abi: '' }]
[{architecture: 'x64'}, {arch: 'x86', hw_bitness: '64', abi: ''}],
[{architecture: 'x86'}, {arch: 'x86', hw_bitness: '32', abi: ''}],
[{architecture: 'x32'}, {arch: 'x32', hw_bitness: '', abi: ''}],
[{architecture: 'arm'}, {arch: 'arm', hw_bitness: '', abi: ''}]
])('%s -> %s', (input, expected) => {
const distribution = new ZuluDistribution({
version: '11',
@ -102,7 +182,7 @@ describe('findPackageForDownload', () => {
['15', '15.0.2+7'],
['9.0.0', '9.0.0+0'],
['9.0', '9.0.1+0'],
['8.0.262', '8.0.262+19'], // validate correct choise between [8.0.262.17, 8.0.262.19, 8.0.262.18]
['8.0.262', '8.0.262+19'], // validate correct choice between [8.0.262.17, 8.0.262.19, 8.0.262.18]
['8.0.262+17', '8.0.262+17'],
['15.0.1+8', '15.0.1+8'],
['15.0.1+9', '15.0.1+9']
@ -114,7 +194,9 @@ describe('findPackageForDownload', () => {
checkLatest: false
});
distribution['getAvailableVersions'] = async () => manifestData;
const result = await distribution['findPackageForDownload'](distribution['version']);
const result = await distribution['findPackageForDownload'](
distribution['version']
);
expect(result.version).toBe(expected);
});
@ -139,27 +221,9 @@ describe('findPackageForDownload', () => {
packageType: 'jdk',
checkLatest: false
});
distribution['getAvailableVersions'] = async () => manifestData;
await expect(
distribution['findPackageForDownload'](distribution['version'])
).rejects.toThrowError(/Could not find satisfied version for semver */);
});
});
describe('convertVersionToSemver', () => {
it.each([
[[12], '12'],
[[12, 0], '12.0'],
[[12, 0, 2], '12.0.2'],
[[12, 0, 2, 1], '12.0.2+1'],
[[12, 0, 2, 1, 3], '12.0.2+1']
])('%s -> %s', (input: number[], expected: string) => {
const distribution = new ZuluDistribution({
version: '18',
architecture: 'x86',
packageType: 'jdk',
checkLatest: false
});
const actual = distribution['convertVersionToSemver'](input);
expect(actual).toBe(expected);
).rejects.toThrow(/Could not find satisfied version for semver */);
});
});

View File

@ -0,0 +1,229 @@
import {HttpClient} from '@actions/http-client';
import * as semver from 'semver';
import {ZuluDistribution} from '../../src/distributions/zulu/installer';
import {IZuluVersions} from '../../src/distributions/zulu/models';
import * as utils from '../../src/util';
import os from 'os';
import manifestData from '../data/zulu-linux.json';
describe('getAvailableVersions', () => {
let spyHttpClient: jest.SpyInstance;
let spyUtilGetDownloadArchiveExtension: jest.SpyInstance;
beforeEach(() => {
spyHttpClient = jest.spyOn(HttpClient.prototype, 'getJson');
spyHttpClient.mockReturnValue({
statusCode: 200,
headers: {},
result: manifestData as IZuluVersions[]
});
spyUtilGetDownloadArchiveExtension = jest.spyOn(
utils,
'getDownloadArchiveExtension'
);
spyUtilGetDownloadArchiveExtension.mockReturnValue('zip');
});
afterEach(() => {
jest.resetAllMocks();
jest.clearAllMocks();
jest.restoreAllMocks();
});
it.each([
[
{
version: '11',
architecture: 'x86',
packageType: 'jdk',
checkLatest: false
},
'?os=linux&ext=zip&bundle_type=jdk&javafx=false&arch=x86&hw_bitness=32&release_status=ga'
],
[
{
version: '11-ea',
architecture: 'x86',
packageType: 'jdk',
checkLatest: false
},
'?os=linux&ext=zip&bundle_type=jdk&javafx=false&arch=x86&hw_bitness=32&release_status=ea'
],
[
{
version: '8',
architecture: 'x64',
packageType: 'jdk',
checkLatest: false
},
'?os=linux&ext=zip&bundle_type=jdk&javafx=false&arch=x86&hw_bitness=64&release_status=ga'
],
[
{
version: '8',
architecture: 'x64',
packageType: 'jre',
checkLatest: false
},
'?os=linux&ext=zip&bundle_type=jre&javafx=false&arch=x86&hw_bitness=64&release_status=ga'
],
[
{
version: '8',
architecture: 'x64',
packageType: 'jdk+fx',
checkLatest: false
},
'?os=linux&ext=zip&bundle_type=jdk&javafx=true&arch=x86&hw_bitness=64&release_status=ga&features=fx'
],
[
{
version: '8',
architecture: 'x64',
packageType: 'jre+fx',
checkLatest: false
},
'?os=linux&ext=zip&bundle_type=jre&javafx=true&arch=x86&hw_bitness=64&release_status=ga&features=fx'
],
[
{
version: '11',
architecture: 'arm64',
packageType: 'jdk',
checkLatest: false
},
'?os=linux&ext=zip&bundle_type=jdk&javafx=false&arch=arm&hw_bitness=64&release_status=ga'
],
[
{
version: '11',
architecture: 'arm',
packageType: 'jdk',
checkLatest: false
},
'?os=linux&ext=zip&bundle_type=jdk&javafx=false&arch=arm&hw_bitness=&release_status=ga'
]
])('build correct url for %s -> %s', async (input, parsedUrl) => {
const distribution = new ZuluDistribution(input);
distribution['getPlatformOption'] = () => 'linux';
const buildUrl = `https://api.azul.com/zulu/download/community/v1.0/bundles/${parsedUrl}`;
await distribution['getAvailableVersions']();
expect(spyHttpClient.mock.calls).toHaveLength(1);
expect(spyHttpClient.mock.calls[0][0]).toBe(buildUrl);
});
type DistroArch = {
bitness: string;
arch: string;
};
it.each([
['amd64', {bitness: '64', arch: 'x86'}],
['arm64', {bitness: '64', arch: 'arm'}]
])(
'defaults to os.arch(): %s mapped to distro arch: %s',
async (osArch: string, distroArch: DistroArch) => {
jest.spyOn(os, 'arch').mockReturnValue(osArch);
const distribution = new ZuluDistribution({
version: '17',
architecture: '', // to get default value
packageType: 'jdk',
checkLatest: false
});
distribution['getPlatformOption'] = () => 'linux';
const buildUrl = `https://api.azul.com/zulu/download/community/v1.0/bundles/?os=linux&ext=zip&bundle_type=jdk&javafx=false&arch=${distroArch.arch}&hw_bitness=${distroArch.bitness}&release_status=ga`;
await distribution['getAvailableVersions']();
expect(spyHttpClient.mock.calls).toHaveLength(1);
expect(spyHttpClient.mock.calls[0][0]).toBe(buildUrl);
}
);
it('load available versions', async () => {
const distribution = new ZuluDistribution({
version: '11',
architecture: 'x86',
packageType: 'jdk',
checkLatest: false
});
const availableVersions = await distribution['getAvailableVersions']();
expect(availableVersions).toHaveLength(manifestData.length);
});
});
describe('getArchitectureOptions', () => {
it.each([
[{architecture: 'x64'}, {arch: 'x86', hw_bitness: '64', abi: ''}],
[{architecture: 'x86'}, {arch: 'x86', hw_bitness: '32', abi: ''}],
[{architecture: 'x32'}, {arch: 'x32', hw_bitness: '', abi: ''}],
[{architecture: 'arm'}, {arch: 'arm', hw_bitness: '', abi: ''}]
])('%s -> %s', (input, expected) => {
const distribution = new ZuluDistribution({
version: '11',
architecture: input.architecture,
packageType: 'jdk',
checkLatest: false
});
expect(distribution['getArchitectureOptions']()).toEqual(expected);
});
});
describe('findPackageForDownload', () => {
it.each([
['8', '8.0.282+8'],
['11.x', '11.0.10+9'],
['8.0', '8.0.282+8'],
['11.0.x', '11.0.10+9'],
['15', '15.0.2+7'],
['9.0.0', '9.0.0+0'],
['9.0', '9.0.1+0'],
['8.0.262', '8.0.262+19'], // validate correct choice between [8.0.262.17, 8.0.262.19, 8.0.262.18]
['8.0.262+17', '8.0.262+17'],
['15.0.1+8', '15.0.1+8'],
['15.0.1+9', '15.0.1+9']
])('version is %s -> %s', async (input, expected) => {
const distribution = new ZuluDistribution({
version: input,
architecture: 'x86',
packageType: 'jdk',
checkLatest: false
});
distribution['getAvailableVersions'] = async () => manifestData;
const result = await distribution['findPackageForDownload'](
distribution['version']
);
expect(result.version).toBe(expected);
});
it('select correct bundle if there are multiple items with the same jdk version but different zulu versions', async () => {
const distribution = new ZuluDistribution({
version: '',
architecture: 'arm64',
packageType: 'jdk',
checkLatest: false
});
distribution['getAvailableVersions'] = async () => manifestData;
const result = await distribution['findPackageForDownload']('21.0.2');
expect(result.url).toBe(
'https://cdn.azul.com/zulu/bin/zulu21.32.17-ca-jdk21.0.2-linux_aarch64.tar.gz'
);
});
it('should throw an error', async () => {
const distribution = new ZuluDistribution({
version: '18',
architecture: 'x86',
packageType: 'jdk',
checkLatest: false
});
distribution['getAvailableVersions'] = async () => manifestData;
await expect(
distribution['findPackageForDownload'](distribution['version'])
).rejects.toThrow(/Could not find satisfied version for semver */);
});
});

View File

@ -0,0 +1,229 @@
import {HttpClient} from '@actions/http-client';
import * as semver from 'semver';
import {ZuluDistribution} from '../../src/distributions/zulu/installer';
import {IZuluVersions} from '../../src/distributions/zulu/models';
import * as utils from '../../src/util';
import os from 'os';
import manifestData from '../data/zulu-windows.json';
describe('getAvailableVersions', () => {
let spyHttpClient: jest.SpyInstance;
let spyUtilGetDownloadArchiveExtension: jest.SpyInstance;
beforeEach(() => {
spyHttpClient = jest.spyOn(HttpClient.prototype, 'getJson');
spyHttpClient.mockReturnValue({
statusCode: 200,
headers: {},
result: manifestData as IZuluVersions[]
});
spyUtilGetDownloadArchiveExtension = jest.spyOn(
utils,
'getDownloadArchiveExtension'
);
spyUtilGetDownloadArchiveExtension.mockReturnValue('zip');
});
afterEach(() => {
jest.resetAllMocks();
jest.clearAllMocks();
jest.restoreAllMocks();
});
it.each([
[
{
version: '11',
architecture: 'x86',
packageType: 'jdk',
checkLatest: false
},
'?os=windows&ext=zip&bundle_type=jdk&javafx=false&arch=x86&hw_bitness=32&release_status=ga'
],
[
{
version: '11-ea',
architecture: 'x86',
packageType: 'jdk',
checkLatest: false
},
'?os=windows&ext=zip&bundle_type=jdk&javafx=false&arch=x86&hw_bitness=32&release_status=ea'
],
[
{
version: '8',
architecture: 'x64',
packageType: 'jdk',
checkLatest: false
},
'?os=windows&ext=zip&bundle_type=jdk&javafx=false&arch=x86&hw_bitness=64&release_status=ga'
],
[
{
version: '8',
architecture: 'x64',
packageType: 'jre',
checkLatest: false
},
'?os=windows&ext=zip&bundle_type=jre&javafx=false&arch=x86&hw_bitness=64&release_status=ga'
],
[
{
version: '8',
architecture: 'x64',
packageType: 'jdk+fx',
checkLatest: false
},
'?os=windows&ext=zip&bundle_type=jdk&javafx=true&arch=x86&hw_bitness=64&release_status=ga&features=fx'
],
[
{
version: '8',
architecture: 'x64',
packageType: 'jre+fx',
checkLatest: false
},
'?os=windows&ext=zip&bundle_type=jre&javafx=true&arch=x86&hw_bitness=64&release_status=ga&features=fx'
],
[
{
version: '11',
architecture: 'arm64',
packageType: 'jdk',
checkLatest: false
},
'?os=windows&ext=zip&bundle_type=jdk&javafx=false&arch=arm&hw_bitness=64&release_status=ga'
],
[
{
version: '11',
architecture: 'arm',
packageType: 'jdk',
checkLatest: false
},
'?os=windows&ext=zip&bundle_type=jdk&javafx=false&arch=arm&hw_bitness=&release_status=ga'
]
])('build correct url for %s -> %s', async (input, parsedUrl) => {
const distribution = new ZuluDistribution(input);
distribution['getPlatformOption'] = () => 'windows';
const buildUrl = `https://api.azul.com/zulu/download/community/v1.0/bundles/${parsedUrl}`;
await distribution['getAvailableVersions']();
expect(spyHttpClient.mock.calls).toHaveLength(1);
expect(spyHttpClient.mock.calls[0][0]).toBe(buildUrl);
});
type DistroArch = {
bitness: string;
arch: string;
};
it.each([
['amd64', {bitness: '64', arch: 'x86'}],
['arm64', {bitness: '64', arch: 'arm'}]
])(
'defaults to os.arch(): %s mapped to distro arch: %s',
async (osArch: string, distroArch: DistroArch) => {
jest.spyOn(os, 'arch').mockReturnValue(osArch);
const distribution = new ZuluDistribution({
version: '17',
architecture: '', // to get default value
packageType: 'jdk',
checkLatest: false
});
distribution['getPlatformOption'] = () => 'windows';
const buildUrl = `https://api.azul.com/zulu/download/community/v1.0/bundles/?os=windows&ext=zip&bundle_type=jdk&javafx=false&arch=${distroArch.arch}&hw_bitness=${distroArch.bitness}&release_status=ga`;
await distribution['getAvailableVersions']();
expect(spyHttpClient.mock.calls).toHaveLength(1);
expect(spyHttpClient.mock.calls[0][0]).toBe(buildUrl);
}
);
it('load available versions', async () => {
const distribution = new ZuluDistribution({
version: '11',
architecture: 'x86',
packageType: 'jdk',
checkLatest: false
});
const availableVersions = await distribution['getAvailableVersions']();
expect(availableVersions).toHaveLength(manifestData.length);
});
});
describe('getArchitectureOptions', () => {
it.each([
[{architecture: 'x64'}, {arch: 'x86', hw_bitness: '64', abi: ''}],
[{architecture: 'x86'}, {arch: 'x86', hw_bitness: '32', abi: ''}],
[{architecture: 'x32'}, {arch: 'x32', hw_bitness: '', abi: ''}],
[{architecture: 'arm'}, {arch: 'arm', hw_bitness: '', abi: ''}]
])('%s -> %s', (input, expected) => {
const distribution = new ZuluDistribution({
version: '11',
architecture: input.architecture,
packageType: 'jdk',
checkLatest: false
});
expect(distribution['getArchitectureOptions']()).toEqual(expected);
});
});
describe('findPackageForDownload', () => {
it.each([
['8', '8.0.282+8'],
['11.x', '11.0.10+9'],
['8.0', '8.0.282+8'],
['11.0.x', '11.0.10+9'],
['15', '15.0.2+7'],
['9.0.0', '9.0.0+0'],
['9.0', '9.0.1+0'],
['8.0.262', '8.0.262+19'], // validate correct choice between [8.0.262.17, 8.0.262.19, 8.0.262.18]
['8.0.262+17', '8.0.262+17'],
['15.0.1+8', '15.0.1+8'],
['15.0.1+9', '15.0.1+9']
])('version is %s -> %s', async (input, expected) => {
const distribution = new ZuluDistribution({
version: input,
architecture: 'x86',
packageType: 'jdk',
checkLatest: false
});
distribution['getAvailableVersions'] = async () => manifestData;
const result = await distribution['findPackageForDownload'](
distribution['version']
);
expect(result.version).toBe(expected);
});
it('select correct bundle if there are multiple items with the same jdk version but different zulu versions', async () => {
const distribution = new ZuluDistribution({
version: '',
architecture: 'arm64',
packageType: 'jdk',
checkLatest: false
});
distribution['getAvailableVersions'] = async () => manifestData;
const result = await distribution['findPackageForDownload']('17.0.10');
expect(result.url).toBe(
'https://cdn.azul.com/zulu/bin/zulu17.48.15-ca-jdk17.0.10-windows_aarch64.zip'
);
});
it('should throw an error', async () => {
const distribution = new ZuluDistribution({
version: '18',
architecture: 'x86',
packageType: 'jdk',
checkLatest: false
});
distribution['getAvailableVersions'] = async () => manifestData;
await expect(
distribution['findPackageForDownload'](distribution['version'])
).rejects.toThrow(/Could not find satisfied version for semver */);
});
});

View File

@ -1,6 +1,7 @@
import path = require('path');
import io = require('@actions/io');
import exec = require('@actions/exec');
import * as path from 'path';
import * as io from '@actions/io';
import * as exec from '@actions/exec';
import * as gpg from '../src/gpg';
jest.mock('@actions/exec', () => {
return {
@ -11,8 +12,6 @@ jest.mock('@actions/exec', () => {
const tempDir = path.join(__dirname, 'runner', 'temp');
process.env['RUNNER_TEMP'] = tempDir;
import gpg = require('../src/gpg');
describe('gpg tests', () => {
beforeEach(async () => {
await io.mkdirP(tempDir);
@ -33,7 +32,11 @@ describe('gpg tests', () => {
expect(keyId).toBeNull();
expect(exec.exec).toHaveBeenCalledWith('gpg', expect.anything(), expect.anything());
expect(exec.exec).toHaveBeenCalledWith(
'gpg',
expect.anything(),
expect.anything()
);
});
});
@ -42,7 +45,11 @@ describe('gpg tests', () => {
const keyId = 'asdfhjkl';
await gpg.deleteKey(keyId);
expect(exec.exec).toHaveBeenCalledWith('gpg', expect.anything(), expect.anything());
expect(exec.exec).toHaveBeenCalledWith(
'gpg',
expect.anything(),
expect.anything()
);
});
});
});

Some files were not shown because too many files have changed in this diff Show More