mirror of
https://github.com/actions/setup-java.git
synced 2026-07-16 13:52:59 +00:00
Compare commits
12 Commits
main
..
releases/v5
| Author | SHA1 | Date | |
|---|---|---|---|
| 03ad4de099 | |||
| d229d2e858 | |||
| bbf0f69670 | |||
| 513edc4f87 | |||
| 62df799a9c | |||
| 176156a187 | |||
| bf7b8deac2 | |||
| 0173e6dd1b | |||
| f45cd82b67 | |||
| e2863ad499 | |||
| 78efe031a6 | |||
| 3be16b57e9 |
@@ -0,0 +1,6 @@
|
||||
# Ignore list
|
||||
/*
|
||||
|
||||
# Do not ignore these folders:
|
||||
!__tests__/
|
||||
!src/
|
||||
@@ -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
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,102 @@
|
||||
name: Validate cache with cache-dependency-path option
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- releases/*
|
||||
paths-ignore:
|
||||
- '**.md'
|
||||
pull_request:
|
||||
paths-ignore:
|
||||
- '**.md'
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
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@v7
|
||||
with:
|
||||
persist-credentials: false
|
||||
- name: Run setup-java with the cache for gradle
|
||||
uses: ./
|
||||
id: setup-java
|
||||
with:
|
||||
distribution: 'adopt'
|
||||
java-version: '17'
|
||||
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@v7
|
||||
with:
|
||||
persist-credentials: false
|
||||
- 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@v7
|
||||
with:
|
||||
persist-credentials: false
|
||||
- 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
|
||||
+54
-255
@@ -42,7 +42,10 @@ jobs:
|
||||
# https://github.com/actions/cache/issues/454#issuecomment-840493935
|
||||
run: |
|
||||
gradle downloadDependencies --no-daemon -p __tests__/cache/gradle1
|
||||
bash __tests__/check-dir.sh "$HOME/.gradle/caches"
|
||||
if [ ! -d ~/.gradle/caches ]; then
|
||||
echo "::error::The ~/.gradle/caches directory does not exist unexpectedly"
|
||||
exit 1
|
||||
fi
|
||||
gradle-restore:
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
@@ -63,7 +66,12 @@ jobs:
|
||||
java-version: '11'
|
||||
cache: gradle
|
||||
- name: Confirm that ~/.gradle/caches directory has been made
|
||||
run: bash __tests__/check-dir.sh "$HOME/.gradle/caches"
|
||||
run: |
|
||||
if [ ! -d ~/.gradle/caches ]; then
|
||||
echo "::error::The ~/.gradle/caches directory does not exist unexpectedly"
|
||||
exit 1
|
||||
fi
|
||||
ls ~/.gradle/caches/
|
||||
maven-save:
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
@@ -85,7 +93,10 @@ jobs:
|
||||
- name: Create files to cache
|
||||
run: |
|
||||
mvn verify -f __tests__/cache/maven/pom.xml
|
||||
bash __tests__/check-dir.sh "$HOME/.m2/repository"
|
||||
if [ ! -d ~/.m2/repository ]; then
|
||||
echo "::error::The ~/.m2/repository directory does not exist unexpectedly"
|
||||
exit 1
|
||||
fi
|
||||
maven-restore:
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
@@ -106,7 +117,12 @@ jobs:
|
||||
java-version: '11'
|
||||
cache: maven
|
||||
- name: Confirm that ~/.m2/repository directory has been made
|
||||
run: bash __tests__/check-dir.sh "$HOME/.m2/repository"
|
||||
run: |
|
||||
if [ ! -d ~/.m2/repository ]; then
|
||||
echo "::error::The ~/.m2/repository directory does not exist unexpectedly"
|
||||
exit 1
|
||||
fi
|
||||
ls ~/.m2/repository
|
||||
sbt-save:
|
||||
runs-on: ${{ matrix.os }}
|
||||
defaults:
|
||||
@@ -139,13 +155,25 @@ jobs:
|
||||
|
||||
- name: Check files to cache on macos-latest
|
||||
if: matrix.os == 'macos-15-intel'
|
||||
run: bash "$GITHUB_WORKSPACE/__tests__/check-dir.sh" "$HOME/Library/Caches/Coursier"
|
||||
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: bash "$GITHUB_WORKSPACE/__tests__/check-dir.sh" "$HOME/AppData/Local/Coursier/Cache"
|
||||
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-22.04'
|
||||
run: bash "$GITHUB_WORKSPACE/__tests__/check-dir.sh" "$HOME/.cache/coursier"
|
||||
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:
|
||||
@@ -172,254 +200,25 @@ jobs:
|
||||
|
||||
- name: Confirm that ~/Library/Caches/Coursier directory has been made
|
||||
if: matrix.os == 'macos-15-intel'
|
||||
run: bash "$GITHUB_WORKSPACE/__tests__/check-dir.sh" "$HOME/Library/Caches/Coursier"
|
||||
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: bash "$GITHUB_WORKSPACE/__tests__/check-dir.sh" "$HOME/AppData/Local/Coursier/Cache"
|
||||
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-22.04'
|
||||
run: bash "$GITHUB_WORKSPACE/__tests__/check-dir.sh" "$HOME/.cache/coursier"
|
||||
gradle1-save:
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [macos-latest, windows-latest, ubuntu-latest]
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v7
|
||||
with:
|
||||
persist-credentials: false
|
||||
- name: Run setup-java with the cache for gradle
|
||||
uses: ./
|
||||
id: setup-java
|
||||
with:
|
||||
distribution: 'adopt'
|
||||
java-version: '17'
|
||||
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
|
||||
if: matrix.os == 'ubuntu-latest'
|
||||
run: |
|
||||
gradle downloadDependencies --no-daemon -p __tests__/cache/gradle1
|
||||
bash __tests__/check-dir.sh "$HOME/.gradle/caches"
|
||||
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@v7
|
||||
with:
|
||||
persist-credentials: false
|
||||
- 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: bash __tests__/check-dir.sh "$HOME/.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@v7
|
||||
with:
|
||||
persist-credentials: false
|
||||
- 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: bash __tests__/check-dir.sh "$HOME/.gradle/caches" absent
|
||||
maven1-save:
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [macos-15-intel, windows-latest, ubuntu-latest]
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v7
|
||||
with:
|
||||
persist-credentials: false
|
||||
- name: Run setup-java with the cache for maven
|
||||
uses: ./
|
||||
id: setup-java
|
||||
with:
|
||||
distribution: 'adopt'
|
||||
java-version: '11'
|
||||
cache: maven
|
||||
cache-dependency-path: __tests__/cache/maven/pom.xml
|
||||
- name: Create files to cache
|
||||
run: |
|
||||
mvn verify -f __tests__/cache/maven/pom.xml
|
||||
bash __tests__/check-dir.sh "$HOME/.m2/repository"
|
||||
maven1-restore:
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [macos-15-intel, windows-latest, ubuntu-latest]
|
||||
needs: maven1-save
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v7
|
||||
with:
|
||||
persist-credentials: false
|
||||
- name: Run setup-java with the cache for maven
|
||||
uses: ./
|
||||
id: setup-java
|
||||
with:
|
||||
distribution: 'adopt'
|
||||
java-version: '11'
|
||||
cache: maven
|
||||
cache-dependency-path: __tests__/cache/maven/pom.xml
|
||||
- name: Confirm that ~/.m2/repository directory has been made
|
||||
run: bash __tests__/check-dir.sh "$HOME/.m2/repository"
|
||||
maven2-restore:
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [macos-15-intel, windows-latest, ubuntu-latest]
|
||||
needs: maven1-save
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v7
|
||||
with:
|
||||
persist-credentials: false
|
||||
- name: Run setup-java with the cache for maven
|
||||
uses: ./
|
||||
id: setup-java
|
||||
with:
|
||||
distribution: 'adopt'
|
||||
java-version: '11'
|
||||
cache: maven
|
||||
cache-dependency-path: __tests__/cache/maven2/pom.xml
|
||||
- name: Confirm that ~/.m2/repository directory has not been made
|
||||
run: bash __tests__/check-dir.sh "$HOME/.m2/repository" absent
|
||||
sbt1-save:
|
||||
runs-on: ${{ matrix.os }}
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
working-directory: __tests__/cache/sbt
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [macos-15-intel, windows-latest, ubuntu-22.04]
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v7
|
||||
with:
|
||||
persist-credentials: false
|
||||
- name: Run setup-java with the cache for sbt
|
||||
uses: ./
|
||||
id: setup-java
|
||||
with:
|
||||
distribution: 'adopt'
|
||||
java-version: '11'
|
||||
cache: sbt
|
||||
cache-dependency-path: __tests__/cache/sbt/*.sbt
|
||||
- name: Setup SBT
|
||||
if: matrix.os == 'macos-15-intel'
|
||||
run: |
|
||||
echo ""Installing SBT...""
|
||||
brew install sbt
|
||||
- name: Create files to cache
|
||||
run: sbt update
|
||||
|
||||
- name: Check files to cache on macos-latest
|
||||
if: matrix.os == 'macos-15-intel'
|
||||
run: bash "$GITHUB_WORKSPACE/__tests__/check-dir.sh" "$HOME/Library/Caches/Coursier"
|
||||
- name: Check files to cache on windows-latest
|
||||
if: matrix.os == 'windows-latest'
|
||||
run: bash "$GITHUB_WORKSPACE/__tests__/check-dir.sh" "$HOME/AppData/Local/Coursier/Cache"
|
||||
- name: Check files to cache on ubuntu-latest
|
||||
if: matrix.os == 'ubuntu-22.04'
|
||||
run: bash "$GITHUB_WORKSPACE/__tests__/check-dir.sh" "$HOME/.cache/coursier"
|
||||
sbt1-restore:
|
||||
runs-on: ${{ matrix.os }}
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
working-directory: __tests__/cache/sbt
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [macos-15-intel, windows-latest, ubuntu-22.04]
|
||||
needs: sbt1-save
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v7
|
||||
with:
|
||||
persist-credentials: false
|
||||
- name: Run setup-java with the cache for sbt
|
||||
uses: ./
|
||||
id: setup-java
|
||||
with:
|
||||
distribution: 'adopt'
|
||||
java-version: '11'
|
||||
cache: sbt
|
||||
cache-dependency-path: __tests__/cache/sbt/*.sbt
|
||||
|
||||
- name: Confirm that ~/Library/Caches/Coursier directory has been made
|
||||
if: matrix.os == 'macos-15-intel'
|
||||
run: bash "$GITHUB_WORKSPACE/__tests__/check-dir.sh" "$HOME/Library/Caches/Coursier"
|
||||
- name: Confirm that ~/AppData/Local/Coursier/Cache directory has been made
|
||||
if: matrix.os == 'windows-latest'
|
||||
run: bash "$GITHUB_WORKSPACE/__tests__/check-dir.sh" "$HOME/AppData/Local/Coursier/Cache"
|
||||
- name: Confirm that ~/.cache/coursier directory has been made
|
||||
if: matrix.os == 'ubuntu-22.04'
|
||||
run: bash "$GITHUB_WORKSPACE/__tests__/check-dir.sh" "$HOME/.cache/coursier"
|
||||
sbt2-restore:
|
||||
runs-on: ${{ matrix.os }}
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
working-directory: __tests__/cache/sbt2
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [macos-15-intel, windows-latest, ubuntu-22.04]
|
||||
needs: sbt1-save
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v7
|
||||
with:
|
||||
persist-credentials: false
|
||||
- name: Run setup-java with the cache for sbt
|
||||
uses: ./
|
||||
id: setup-java
|
||||
with:
|
||||
distribution: 'adopt'
|
||||
java-version: '11'
|
||||
cache: sbt
|
||||
cache-dependency-path: __tests__/cache/sbt2/*.sbt
|
||||
|
||||
- name: Confirm that ~/Library/Caches/Coursier directory has not been made
|
||||
if: matrix.os == 'macos-15-intel'
|
||||
run: bash "$GITHUB_WORKSPACE/__tests__/check-dir.sh" "$HOME/Library/Caches/Coursier" absent
|
||||
- name: Confirm that ~/AppData/Local/Coursier/Cache directory has not been made
|
||||
if: matrix.os == 'windows-latest'
|
||||
run: bash "$GITHUB_WORKSPACE/__tests__/check-dir.sh" "$HOME/AppData/Local/Coursier/Cache" absent
|
||||
- name: Confirm that ~/.cache/coursier directory has not been made
|
||||
if: matrix.os == 'ubuntu-22.04'
|
||||
run: bash "$GITHUB_WORKSPACE/__tests__/check-dir.sh" "$HOME/.cache/coursier" absent
|
||||
if [ ! -d ~/.cache/coursier ]; then
|
||||
echo "::error::The ~/.cache/coursier directory does not exist unexpectedly"
|
||||
exit 1
|
||||
fi
|
||||
ls ~/.cache/coursier
|
||||
|
||||
@@ -46,25 +46,13 @@ jobs:
|
||||
$xmlPath = Join-Path $HOME ".m2" "settings.xml"
|
||||
Get-Content $xmlPath | ForEach-Object { Write-Host $_ }
|
||||
|
||||
$content = [System.IO.File]::ReadAllText($xmlPath)
|
||||
$expected = @(
|
||||
'<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"'
|
||||
' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"'
|
||||
' xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 https://maven.apache.org/xsd/settings-1.0.0.xsd">'
|
||||
' <interactiveMode>false</interactiveMode>'
|
||||
' <servers>'
|
||||
' <server>'
|
||||
' <id>maven</id>'
|
||||
' <username>${env.MAVEN_USERNAME}</username>'
|
||||
' <password>${env.MAVEN_CENTRAL_TOKEN}</password>'
|
||||
' </server>'
|
||||
' </servers>'
|
||||
'</settings>'
|
||||
) -join "`n"
|
||||
[xml]$xml = Get-Content $xmlPath
|
||||
$servers = $xml.settings.servers.server
|
||||
if (($servers[0].id -ne 'maven') -or ($servers[0].username -ne '${env.MAVEN_USERNAME}') -or ($servers[0].password -ne '${env.MAVEN_CENTRAL_TOKEN}')) {
|
||||
throw "Generated XML file is incorrect"
|
||||
}
|
||||
|
||||
if ($content -ne $expected) {
|
||||
Write-Host "Expected settings.xml:"
|
||||
$expected -split "`n" | ForEach-Object { Write-Host $_ }
|
||||
if (($servers[1].id -ne 'gpg.passphrase') -or ($servers[1].passphrase -ne '${env.MAVEN_GPG_PASSPHRASE}')) {
|
||||
throw "Generated XML file is incorrect"
|
||||
}
|
||||
|
||||
|
||||
@@ -37,8 +37,7 @@ jobs:
|
||||
'dragonwell',
|
||||
'sapmachine',
|
||||
'jetbrains',
|
||||
'kona',
|
||||
'liberica-nik'
|
||||
'kona'
|
||||
] # internally 'adopt-hotspot' is the same as 'adopt'
|
||||
version: ['21', '11', '17']
|
||||
exclude:
|
||||
@@ -65,15 +64,6 @@ jobs:
|
||||
- distribution: kona
|
||||
os: macos-latest
|
||||
version: 25
|
||||
- distribution: liberica-nik
|
||||
os: windows-latest
|
||||
version: 25
|
||||
- distribution: liberica-nik
|
||||
os: ubuntu-latest
|
||||
version: 25
|
||||
- distribution: liberica-nik
|
||||
os: macos-latest
|
||||
version: 25
|
||||
- distribution: oracle
|
||||
os: macos-15-intel
|
||||
version: 17
|
||||
@@ -96,8 +86,7 @@ jobs:
|
||||
os: ubuntu-latest
|
||||
version: '24-ea'
|
||||
steps:
|
||||
- &checkout_step
|
||||
name: Checkout
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v7
|
||||
with:
|
||||
persist-credentials: false
|
||||
@@ -128,7 +117,10 @@ jobs:
|
||||
distribution: ['temurin', 'sapmachine']
|
||||
version: ['21', '17']
|
||||
steps:
|
||||
- *checkout_step
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v7
|
||||
with:
|
||||
persist-credentials: false
|
||||
- name: Install bash
|
||||
run: apk add --no-cache bash
|
||||
- name: setup-java
|
||||
@@ -151,7 +143,7 @@ jobs:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: &default_os [macos-latest, windows-latest, ubuntu-latest]
|
||||
os: [macos-latest, windows-latest, ubuntu-latest]
|
||||
distribution: ['temurin', 'zulu', 'liberica']
|
||||
version:
|
||||
- '11.0'
|
||||
@@ -180,7 +172,10 @@ jobs:
|
||||
os: ubuntu-latest
|
||||
version: '17.0.7'
|
||||
steps:
|
||||
- *checkout_step
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v7
|
||||
with:
|
||||
persist-credentials: false
|
||||
- name: setup-java
|
||||
uses: ./
|
||||
id: setup-java
|
||||
@@ -202,7 +197,7 @@ jobs:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: *default_os
|
||||
os: [macos-latest, windows-latest, ubuntu-latest]
|
||||
distribution:
|
||||
[
|
||||
'temurin',
|
||||
@@ -216,7 +211,10 @@ jobs:
|
||||
- distribution: dragonwell
|
||||
os: macos-latest
|
||||
steps:
|
||||
- *checkout_step
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v7
|
||||
with:
|
||||
persist-credentials: false
|
||||
- name: setup-java
|
||||
uses: ./
|
||||
id: setup-java
|
||||
@@ -239,7 +237,7 @@ jobs:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: *default_os
|
||||
os: [macos-latest, windows-latest, ubuntu-latest]
|
||||
distribution:
|
||||
[
|
||||
'temurin',
|
||||
@@ -253,7 +251,10 @@ jobs:
|
||||
- distribution: dragonwell
|
||||
os: macos-latest
|
||||
steps:
|
||||
- *checkout_step
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v7
|
||||
with:
|
||||
persist-credentials: false
|
||||
- name: setup-java
|
||||
uses: ./
|
||||
id: setup-java
|
||||
@@ -283,37 +284,26 @@ jobs:
|
||||
run: bash __tests__/verify-java.sh "17" "$JAVA_PATH"
|
||||
shell: bash
|
||||
|
||||
setup-java-ea-versions:
|
||||
name: ${{ matrix.distribution }} ${{ matrix.version }} (jdk-${{ contains(matrix.os, 'macos') && !contains(matrix.os, 'intel') && 'arm64' || 'x64' }}) - ${{ matrix.os }}
|
||||
setup-java-ea-versions-zulu:
|
||||
name: zulu ${{ matrix.version }} (jdk-${{ contains(matrix.os, 'macos') && !contains(matrix.os, 'intel') && 'arm64' || 'x64' }}) - ${{ matrix.os }}
|
||||
needs: setup-java-major-minor-versions
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- {os: macos-15-intel, version: '17-ea', distribution: zulu}
|
||||
- {os: windows-latest, version: '17-ea', distribution: zulu}
|
||||
- {os: ubuntu-latest, version: '17-ea', distribution: zulu}
|
||||
- {os: macos-15-intel, version: '15.0.0-ea.14', distribution: zulu}
|
||||
- {os: windows-latest, version: '15.0.0-ea.14', distribution: zulu}
|
||||
- {os: ubuntu-latest, version: '15.0.0-ea.14', distribution: zulu}
|
||||
- {os: macos-latest, version: '17-ea', distribution: temurin}
|
||||
- {os: windows-latest, version: '17-ea', distribution: temurin}
|
||||
- {os: ubuntu-latest, version: '17-ea', distribution: temurin}
|
||||
- {os: macos-latest, version: '17-ea', distribution: sapmachine}
|
||||
- {os: windows-latest, version: '17-ea', distribution: sapmachine}
|
||||
- {os: ubuntu-latest, version: '17-ea', distribution: sapmachine}
|
||||
- {os: macos-latest, version: '21-ea', distribution: sapmachine}
|
||||
- {os: windows-latest, version: '21-ea', distribution: sapmachine}
|
||||
- {os: ubuntu-latest, version: '21-ea', distribution: sapmachine}
|
||||
os: [macos-15-intel, windows-latest, ubuntu-latest]
|
||||
version: ['17-ea', '15.0.0-ea.14']
|
||||
steps:
|
||||
- *checkout_step
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v7
|
||||
with:
|
||||
persist-credentials: false
|
||||
- name: setup-java
|
||||
uses: ./
|
||||
id: setup-java
|
||||
with:
|
||||
java-version: ${{ matrix.version }}
|
||||
distribution: ${{ matrix.distribution }}
|
||||
distribution: zulu
|
||||
- name: Verify Java
|
||||
env:
|
||||
JAVA_VERSION: ${{ matrix.version }}
|
||||
@@ -321,24 +311,53 @@ jobs:
|
||||
run: bash __tests__/verify-java.sh "$JAVA_VERSION" "$JAVA_PATH"
|
||||
shell: bash
|
||||
|
||||
setup-java-signature-verification:
|
||||
name: ${{ matrix.distribution }} ${{ matrix.version }} signature verification - ${{ matrix.os }}
|
||||
setup-java-ea-versions-temurin:
|
||||
name: temurin ${{ matrix.version }} (jdk-${{ contains(matrix.os, 'macos') && !contains(matrix.os, 'intel') && 'arm64' || 'x64' }}) - ${{ matrix.os }}
|
||||
needs: setup-java-major-minor-versions
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: *default_os
|
||||
version: ['21', '17']
|
||||
distribution: [temurin, microsoft]
|
||||
os: [macos-latest, windows-latest, ubuntu-latest]
|
||||
version: ['17-ea']
|
||||
steps:
|
||||
- *checkout_step
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v7
|
||||
with:
|
||||
persist-credentials: false
|
||||
- name: setup-java
|
||||
uses: ./
|
||||
id: setup-java
|
||||
with:
|
||||
java-version: ${{ matrix.version }}
|
||||
distribution: temurin
|
||||
- name: Verify Java
|
||||
env:
|
||||
JAVA_VERSION: ${{ matrix.version }}
|
||||
JAVA_PATH: ${{ steps.setup-java.outputs.path }}
|
||||
run: bash __tests__/verify-java.sh "$JAVA_VERSION" "$JAVA_PATH"
|
||||
shell: bash
|
||||
|
||||
setup-java-temurin-signature-verification:
|
||||
name: temurin ${{ matrix.version }} signature verification - ${{ matrix.os }}
|
||||
needs: setup-java-major-minor-versions
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [macos-latest, windows-latest, ubuntu-latest]
|
||||
version: ['21', '17']
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v7
|
||||
with:
|
||||
persist-credentials: false
|
||||
- name: setup-java with signature verification
|
||||
uses: ./
|
||||
id: setup-java
|
||||
with:
|
||||
java-version: ${{ matrix.version }}
|
||||
distribution: ${{ matrix.distribution }}
|
||||
distribution: temurin
|
||||
verify-signature: true
|
||||
- name: Verify Java
|
||||
env:
|
||||
@@ -347,6 +366,61 @@ jobs:
|
||||
run: bash __tests__/verify-java.sh "$JAVA_VERSION" "$JAVA_PATH"
|
||||
shell: bash
|
||||
|
||||
setup-java-microsoft-signature-verification:
|
||||
name: microsoft ${{ matrix.version }} signature verification - ${{ matrix.os }}
|
||||
needs: setup-java-major-minor-versions
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [macos-latest, windows-latest, ubuntu-latest]
|
||||
version: ['21', '17']
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v7
|
||||
with:
|
||||
persist-credentials: false
|
||||
- name: setup-java with signature verification
|
||||
uses: ./
|
||||
id: setup-java
|
||||
with:
|
||||
java-version: ${{ matrix.version }}
|
||||
distribution: microsoft
|
||||
verify-signature: true
|
||||
- name: Verify Java
|
||||
env:
|
||||
JAVA_VERSION: ${{ matrix.version }}
|
||||
JAVA_PATH: ${{ steps.setup-java.outputs.path }}
|
||||
run: bash __tests__/verify-java.sh "$JAVA_VERSION" "$JAVA_PATH"
|
||||
shell: bash
|
||||
|
||||
setup-java-ea-versions-sapmachine:
|
||||
name: sapmachine ${{ matrix.version }} (jdk-${{ contains(matrix.os, 'macos') && !contains(matrix.os, 'intel') && 'arm64' || 'x64' }}) - ${{ matrix.os }}
|
||||
needs: setup-java-major-minor-versions
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [macos-latest, windows-latest, ubuntu-latest]
|
||||
version: ['17-ea', '21-ea']
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v7
|
||||
with:
|
||||
persist-credentials: false
|
||||
- name: setup-java
|
||||
uses: ./
|
||||
id: setup-java
|
||||
with:
|
||||
java-version: ${{ matrix.version }}
|
||||
distribution: sapmachine
|
||||
- name: Verify Java
|
||||
env:
|
||||
JAVA_VERSION: ${{ matrix.version }}
|
||||
JAVA_PATH: ${{ steps.setup-java.outputs.path }}
|
||||
run: bash __tests__/verify-java.sh "$JAVA_VERSION" "$JAVA_PATH"
|
||||
shell: bash
|
||||
|
||||
setup-java-custom-package-type:
|
||||
name: ${{ matrix.distribution }} ${{ matrix.version }} (${{ matrix.java-package }}-x64) - ${{ matrix.os }}
|
||||
needs: setup-java-major-minor-versions
|
||||
@@ -376,10 +450,6 @@ jobs:
|
||||
java-package: jre+fx
|
||||
version: '11'
|
||||
os: ubuntu-latest
|
||||
- distribution: 'liberica-nik'
|
||||
java-package: jdk+fx
|
||||
version: '21'
|
||||
os: ubuntu-latest
|
||||
- distribution: 'corretto'
|
||||
java-package: jre
|
||||
version: '8'
|
||||
@@ -426,7 +496,10 @@ jobs:
|
||||
os: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- *checkout_step
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v7
|
||||
with:
|
||||
persist-credentials: false
|
||||
- name: setup-java
|
||||
uses: ./
|
||||
id: setup-java
|
||||
@@ -456,7 +529,10 @@ jobs:
|
||||
distribution: ['liberica', 'zulu', 'corretto']
|
||||
version: ['11']
|
||||
steps:
|
||||
- *checkout_step
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v7
|
||||
with:
|
||||
persist-credentials: false
|
||||
- name: setup-java
|
||||
uses: ./
|
||||
id: setup-java
|
||||
@@ -477,11 +553,14 @@ jobs:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: *default_os
|
||||
os: [macos-latest, windows-latest, ubuntu-latest]
|
||||
distribution: ['temurin', 'microsoft', 'corretto']
|
||||
java-version-file: ['.java-version', '.tool-versions']
|
||||
steps:
|
||||
- *checkout_step
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v7
|
||||
with:
|
||||
persist-credentials: false
|
||||
- name: Create .java-version file
|
||||
shell: bash
|
||||
run: echo "17" > .java-version
|
||||
@@ -507,11 +586,14 @@ jobs:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: *default_os
|
||||
os: [macos-latest, windows-latest, ubuntu-latest]
|
||||
distribution: ['temurin', 'zulu', 'liberica', 'microsoft', 'corretto']
|
||||
java-version-file: ['.java-version', '.tool-versions']
|
||||
steps:
|
||||
- *checkout_step
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v7
|
||||
with:
|
||||
persist-credentials: false
|
||||
- name: Create .java-version file
|
||||
shell: bash
|
||||
run: echo "11" > .java-version
|
||||
@@ -536,11 +618,14 @@ jobs:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: *default_os
|
||||
os: [macos-latest, windows-latest, ubuntu-latest]
|
||||
distribution: ['adopt', 'adopt-openj9', 'zulu']
|
||||
java-version-file: ['.java-version', '.tool-versions']
|
||||
steps:
|
||||
- *checkout_step
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v7
|
||||
with:
|
||||
persist-credentials: false
|
||||
- name: Create .java-version file
|
||||
shell: bash
|
||||
run: echo "17.0.10" > .java-version
|
||||
@@ -565,11 +650,14 @@ jobs:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: *default_os
|
||||
os: [macos-latest, windows-latest, ubuntu-latest]
|
||||
distribution: ['adopt', 'zulu', 'liberica']
|
||||
java-version-file: ['.java-version', '.tool-versions', '.sdkmanrc']
|
||||
steps:
|
||||
- *checkout_step
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v7
|
||||
with:
|
||||
persist-credentials: false
|
||||
- name: Create .java-version file
|
||||
shell: bash
|
||||
run: echo "openjdk64-17.0.10" > .java-version
|
||||
@@ -598,9 +686,10 @@ jobs:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: *default_os
|
||||
os: [macos-latest, windows-latest, ubuntu-latest]
|
||||
steps:
|
||||
- *checkout_step
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v6
|
||||
- name: Setup Java 17 as default
|
||||
uses: ./
|
||||
id: setup-java-17
|
||||
@@ -619,12 +708,10 @@ jobs:
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Verify JAVA_HOME still points to Java 17
|
||||
env:
|
||||
JAVA_17_PATH: ${{ steps.setup-java-17.outputs.path }}
|
||||
run: |
|
||||
echo "JAVA_HOME=$JAVA_HOME"
|
||||
echo "Java 17 path=$JAVA_17_PATH"
|
||||
if [ "$JAVA_HOME" != "$JAVA_17_PATH" ]; then
|
||||
echo "Java 17 path=${{ steps.setup-java-17.outputs.path }}"
|
||||
if [ "$JAVA_HOME" != "${{ steps.setup-java-17.outputs.path }}" ]; then
|
||||
echo "JAVA_HOME should still point to Java 17"
|
||||
exit 1
|
||||
fi
|
||||
@@ -653,17 +740,14 @@ jobs:
|
||||
Write-Host "$envName=$JavaVersionPath"
|
||||
shell: pwsh
|
||||
- name: Verify Java 21 outputs are set
|
||||
env:
|
||||
JAVA_21_PATH: ${{ steps.setup-java-21.outputs.path }}
|
||||
JAVA_21_VERSION: ${{ steps.setup-java-21.outputs.version }}
|
||||
run: |
|
||||
echo "Java 21 path=$JAVA_21_PATH"
|
||||
echo "Java 21 version=$JAVA_21_VERSION"
|
||||
if [ -z "$JAVA_21_PATH" ]; then
|
||||
echo "Java 21 path=${{ steps.setup-java-21.outputs.path }}"
|
||||
echo "Java 21 version=${{ steps.setup-java-21.outputs.version }}"
|
||||
if [ -z "${{ steps.setup-java-21.outputs.path }}" ]; then
|
||||
echo "Java 21 path output should be set"
|
||||
exit 1
|
||||
fi
|
||||
if [ -z "$JAVA_21_VERSION" ]; then
|
||||
if [ -z "${{ steps.setup-java-21.outputs.version }}" ]; then
|
||||
echo "Java 21 version output should be set"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@@ -10,11 +10,8 @@ allowed:
|
||||
- mit
|
||||
- cc0-1.0
|
||||
- unlicense
|
||||
- blueoak-1.0.0
|
||||
|
||||
reviewed:
|
||||
npm:
|
||||
- "@actions/http-client" # MIT (license text present), but detected as "other"
|
||||
- "argparse" # Python Software Foundation License (PSF), but detected as "other"
|
||||
- "balanced-match"
|
||||
- "brace-expansion"
|
||||
|
||||
Generated
+1
-1
@@ -1,6 +1,6 @@
|
||||
---
|
||||
name: "@actions/cache"
|
||||
version: 6.2.0
|
||||
version: 5.1.0
|
||||
type: npm
|
||||
summary: Actions cache lib
|
||||
homepage: https://github.com/actions/toolkit/tree/main/packages/cache
|
||||
|
||||
Generated
+1
-1
@@ -1,6 +1,6 @@
|
||||
---
|
||||
name: "@actions/core"
|
||||
version: 3.0.1
|
||||
version: 2.0.3
|
||||
type: npm
|
||||
summary: Actions core lib
|
||||
homepage: https://github.com/actions/toolkit/tree/main/packages/core
|
||||
|
||||
Generated
+1
-1
@@ -1,6 +1,6 @@
|
||||
---
|
||||
name: "@actions/exec"
|
||||
version: 3.0.0
|
||||
version: 2.0.0
|
||||
type: npm
|
||||
summary: Actions exec lib
|
||||
homepage: https://github.com/actions/toolkit/tree/main/packages/exec
|
||||
|
||||
-20
@@ -1,20 +0,0 @@
|
||||
---
|
||||
name: "@actions/glob"
|
||||
version: 0.7.0
|
||||
type: npm
|
||||
summary: Actions glob lib
|
||||
homepage: https://github.com/actions/toolkit/tree/main/packages/glob
|
||||
license: mit
|
||||
licenses:
|
||||
- sources: LICENSE.md
|
||||
text: |-
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright 2019 GitHub
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
notices: []
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
---
|
||||
name: "@actions/glob"
|
||||
version: 0.6.1
|
||||
version: 0.5.1
|
||||
type: npm
|
||||
summary: Actions glob lib
|
||||
homepage: https://github.com/actions/toolkit/tree/main/packages/glob
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
---
|
||||
name: "@actions/http-client"
|
||||
version: 4.0.1
|
||||
version: 3.0.2
|
||||
type: npm
|
||||
summary: Actions Http Client
|
||||
homepage: https://github.com/actions/toolkit/tree/main/packages/http-client
|
||||
|
||||
Generated
+1
-1
@@ -1,6 +1,6 @@
|
||||
---
|
||||
name: "@actions/io"
|
||||
version: 3.0.2
|
||||
version: 2.0.0
|
||||
type: npm
|
||||
summary: Actions io lib
|
||||
homepage: https://github.com/actions/toolkit/tree/main/packages/io
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
---
|
||||
name: "@actions/tool-cache"
|
||||
version: 4.0.0
|
||||
version: 3.0.1
|
||||
type: npm
|
||||
summary: Actions tool-cache lib
|
||||
homepage: https://github.com/actions/toolkit/tree/main/packages/tool-cache
|
||||
|
||||
+6
-9
@@ -1,17 +1,16 @@
|
||||
---
|
||||
name: is-unsafe
|
||||
version: 1.0.1
|
||||
name: "@azure/abort-controller"
|
||||
version: 1.1.0
|
||||
type: npm
|
||||
summary: Zero-dependency, DOM-free, pure predicate for detecting unsafe strings across
|
||||
HTML, XML, SVG, SQL, SHELL, and REGEX contexts
|
||||
homepage:
|
||||
summary: Microsoft Azure SDK for JavaScript - Aborter
|
||||
homepage: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/core/abort-controller/README.md
|
||||
license: mit
|
||||
licenses:
|
||||
- sources: LICENSE
|
||||
text: |
|
||||
MIT License
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2026 Natural Intelligence
|
||||
Copyright (c) 2020 Microsoft
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -30,6 +29,4 @@ licenses:
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
- sources: README.md
|
||||
text: MIT
|
||||
notices: []
|
||||
Generated
Generated
+1
-1
@@ -1,6 +1,6 @@
|
||||
---
|
||||
name: "@azure/core-client"
|
||||
version: 1.10.2
|
||||
version: 1.10.1
|
||||
type: npm
|
||||
summary: Core library for interfacing with AutoRest generated code
|
||||
homepage: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/core/core-client/
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
---
|
||||
name: "@azure/core-http-compat"
|
||||
version: 2.4.0
|
||||
version: 2.3.1
|
||||
type: npm
|
||||
summary: Core HTTP Compatibility Library to bridge the gap between Core V1 & V2 packages.
|
||||
homepage: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/core/core-compat/
|
||||
|
||||
+2
-2
@@ -1,9 +1,9 @@
|
||||
---
|
||||
name: "@azure/core-rest-pipeline"
|
||||
version: 1.24.0
|
||||
version: 1.22.2
|
||||
type: npm
|
||||
summary: Isomorphic client library for making HTTP requests in node.js and browser.
|
||||
homepage: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/core/core-rest-pipeline/README.md
|
||||
homepage: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/core/core-rest-pipeline/
|
||||
license: mit
|
||||
licenses:
|
||||
- sources: LICENSE
|
||||
|
||||
Generated
+1
-1
@@ -1,6 +1,6 @@
|
||||
---
|
||||
name: "@azure/core-xml"
|
||||
version: 1.5.1
|
||||
version: 1.5.0
|
||||
type: npm
|
||||
summary: Core library for interacting with XML payloads
|
||||
homepage: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/core/core-xml/
|
||||
|
||||
+2
-2
@@ -1,9 +1,9 @@
|
||||
---
|
||||
name: "@azure/storage-blob"
|
||||
version: 12.33.0
|
||||
version: 12.29.1
|
||||
type: npm
|
||||
summary: Microsoft Azure Storage SDK for JavaScript - Blob
|
||||
homepage: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/storage/storage-blob/README.md
|
||||
homepage: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/storage/storage-blob/
|
||||
license: mit
|
||||
licenses:
|
||||
- sources: LICENSE
|
||||
|
||||
+2
-2
@@ -1,9 +1,9 @@
|
||||
---
|
||||
name: "@azure/storage-common"
|
||||
version: 12.4.1
|
||||
version: 12.1.1
|
||||
type: npm
|
||||
summary: Azure Storage Common Client Library for JavaScript
|
||||
homepage: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/storage/storage-common/README.md
|
||||
homepage: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/storage/storage-internal-avro/
|
||||
license: mit
|
||||
licenses:
|
||||
- sources: LICENSE
|
||||
|
||||
+2
-2
@@ -1,9 +1,9 @@
|
||||
---
|
||||
name: "@typespec/ts-http-runtime"
|
||||
version: 0.3.6
|
||||
version: 0.3.2
|
||||
type: npm
|
||||
summary: Isomorphic client library for making HTTP requests in node.js and browser.
|
||||
homepage: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/core/ts-http-runtime/README.md
|
||||
homepage: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/core/ts-http-runtime/
|
||||
license: mit
|
||||
licenses:
|
||||
- sources: LICENSE
|
||||
|
||||
Generated
+1
-3
@@ -1,6 +1,6 @@
|
||||
---
|
||||
name: anynum
|
||||
version: 1.0.1
|
||||
version: 1.0.0
|
||||
type: npm
|
||||
summary: Normalize all Unicode decimal digits (Devanagari, Arabic, Thai, etc.) to
|
||||
ASCII numerals. Zero dependencies, performance-first.
|
||||
@@ -30,6 +30,4 @@ licenses:
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
- sources: README.md
|
||||
text: MIT
|
||||
notices: []
|
||||
|
||||
-34
@@ -1,34 +0,0 @@
|
||||
---
|
||||
name: balanced-match
|
||||
version: 4.0.4
|
||||
type: npm
|
||||
summary: Match balanced character pairs, like "{" and "}"
|
||||
homepage:
|
||||
license: other
|
||||
licenses:
|
||||
- sources: LICENSE.md
|
||||
text: |
|
||||
(MIT)
|
||||
|
||||
Original code Copyright Julian Gruber <julian@juliangruber.com>
|
||||
|
||||
Port to TypeScript Copyright Isaac Z. Schlueter <i@izs.me>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
notices: []
|
||||
-34
@@ -1,34 +0,0 @@
|
||||
---
|
||||
name: brace-expansion
|
||||
version: 5.0.7
|
||||
type: npm
|
||||
summary: Brace expansion as known from sh/bash
|
||||
homepage:
|
||||
license: other
|
||||
licenses:
|
||||
- sources: LICENSE
|
||||
text: |
|
||||
MIT License
|
||||
|
||||
Copyright Julian Gruber <julian@juliangruber.com>
|
||||
|
||||
TypeScript port Copyright Isaac Z. Schlueter <i@izs.me>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
notices: []
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
---
|
||||
name: brace-expansion
|
||||
version: 1.1.15
|
||||
version: 1.1.13
|
||||
type: npm
|
||||
summary: Brace expansion as known from sh/bash
|
||||
homepage: https://github.com/juliangruber/brace-expansion
|
||||
Generated
+1
-1
@@ -1,6 +1,6 @@
|
||||
---
|
||||
name: fast-xml-builder
|
||||
version: 1.2.1
|
||||
version: 1.2.0
|
||||
type: npm
|
||||
summary: Build XML from JSON without C/C++ based libraries
|
||||
homepage:
|
||||
|
||||
Generated
+1
-1
@@ -1,6 +1,6 @@
|
||||
---
|
||||
name: fast-xml-parser
|
||||
version: 5.9.3
|
||||
version: 5.8.0
|
||||
type: npm
|
||||
summary: Validate XML, Parse XML, Build XML without C/C++ based libraries
|
||||
homepage:
|
||||
|
||||
Generated
+1
-1
@@ -1,6 +1,6 @@
|
||||
---
|
||||
name: js-yaml
|
||||
version: 4.3.0
|
||||
version: 4.1.1
|
||||
type: npm
|
||||
summary: YAML 1.2 parser and serializer
|
||||
homepage:
|
||||
|
||||
Generated
-66
@@ -1,66 +0,0 @@
|
||||
---
|
||||
name: minimatch
|
||||
version: 10.2.5
|
||||
type: npm
|
||||
summary: a glob matcher in javascript
|
||||
homepage:
|
||||
license: blueoak-1.0.0
|
||||
licenses:
|
||||
- sources: LICENSE.md
|
||||
text: |
|
||||
# Blue Oak Model License
|
||||
|
||||
Version 1.0.0
|
||||
|
||||
## Purpose
|
||||
|
||||
This license gives everyone as much permission to work with
|
||||
this software as possible, while protecting contributors
|
||||
from liability.
|
||||
|
||||
## Acceptance
|
||||
|
||||
In order to receive this license, you must agree to its
|
||||
rules. The rules of this license are both obligations
|
||||
under that agreement and conditions to your license.
|
||||
You must not do anything with this software that triggers
|
||||
a rule that you cannot or will not follow.
|
||||
|
||||
## Copyright
|
||||
|
||||
Each contributor licenses you to do everything with this
|
||||
software that would otherwise infringe that contributor's
|
||||
copyright in it.
|
||||
|
||||
## Notices
|
||||
|
||||
You must ensure that everyone who gets a copy of
|
||||
any part of this software from you, with or without
|
||||
changes, also gets the text of this license or a link to
|
||||
<https://blueoakcouncil.org/license/1.0.0>.
|
||||
|
||||
## Excuse
|
||||
|
||||
If anyone notifies you in writing that you have not
|
||||
complied with [Notices](#notices), you can keep your
|
||||
license by taking all practical steps to comply within 30
|
||||
days after the notice. If you do not do so, your license
|
||||
ends immediately.
|
||||
|
||||
## Patent
|
||||
|
||||
Each contributor licenses you to do everything with this
|
||||
software that would otherwise infringe any patent claims
|
||||
they can license or become able to license.
|
||||
|
||||
## Reliability
|
||||
|
||||
No contributor can revoke this license.
|
||||
|
||||
## No Liability
|
||||
|
||||
**_As far as the law allows, this software comes as is,
|
||||
without any warranty or condition, and no contributor
|
||||
will be liable to anyone for any damages related to this
|
||||
software or this license, under any kind of legal claim._**
|
||||
notices: []
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
---
|
||||
name: path-expression-matcher
|
||||
version: 1.6.1
|
||||
version: 1.5.0
|
||||
type: npm
|
||||
summary: Efficient path tracking and pattern matching for XML/JSON parsers
|
||||
homepage: https://github.com/NaturalIntelligence/path-expression-matcher#readme
|
||||
|
||||
Generated
+26
@@ -0,0 +1,26 @@
|
||||
---
|
||||
name: semver
|
||||
version: 6.3.1
|
||||
type: npm
|
||||
summary: The semantic version parser used by npm.
|
||||
homepage:
|
||||
license: isc
|
||||
licenses:
|
||||
- sources: LICENSE
|
||||
text: |
|
||||
The ISC License
|
||||
|
||||
Copyright (c) Isaac Z. Schlueter and Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
|
||||
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
notices: []
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
name: semver
|
||||
version: 7.8.5
|
||||
version: 7.8.4
|
||||
type: npm
|
||||
summary: The semantic version parser used by npm.
|
||||
homepage:
|
||||
Generated
+1
-1
@@ -1,6 +1,6 @@
|
||||
---
|
||||
name: strnum
|
||||
version: 2.4.1
|
||||
version: 2.4.0
|
||||
type: npm
|
||||
summary: Parse String to Number based on configuration
|
||||
homepage:
|
||||
|
||||
@@ -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'
|
||||
};
|
||||
@@ -1,10 +0,0 @@
|
||||
{
|
||||
"printWidth": 80,
|
||||
"tabWidth": 2,
|
||||
"useTabs": false,
|
||||
"semi": true,
|
||||
"singleQuote": true,
|
||||
"trailingComma": "none",
|
||||
"bracketSpacing": false,
|
||||
"arrowParens": "avoid"
|
||||
}
|
||||
@@ -18,16 +18,6 @@ The `setup-java` action provides the following functionality for GitHub Actions
|
||||
|
||||
This action allows you to work with Java and Scala projects.
|
||||
|
||||
## What's new in V6
|
||||
|
||||
- **Migrated to ESM** to enable support for the latest `@actions/*` package versions. This is an internal implementation change only. No changes are required to your workflow configuration, and the action's behavior is unchanged. Existing workflows continue to work as before.
|
||||
|
||||
## Breaking changes in V6
|
||||
|
||||
- **The GPG passphrase is now passed to the Maven GPG Plugin through an environment variable (`gpg.passphraseEnvName`) instead of the deprecated `gpg.passphrase` server in `settings.xml`.** The `gpg-passphrase` input and its default (`GPG_PASSPHRASE`) are unchanged, so if you already set that environment variable in your build step your workflow keeps working. However, this now requires `maven-gpg-plugin` **3.2.0 or newer**; older versions do not honor `gpg.passphraseEnvName` and, because the `gpg.passphrase` server is no longer written, will not pick up the passphrase. Upgrade the plugin to 3.2.0+.
|
||||
|
||||
See [GPG](docs/advanced-usage.md#gpg) for details.
|
||||
|
||||
## Breaking changes in V5
|
||||
|
||||
- Upgraded action from node20 to node24
|
||||
@@ -57,8 +47,6 @@ For more details, see the full release notes on the [releases page](https://git
|
||||
|
||||
- `verify-signature-public-key`: ASCII-armored GPG public key used to verify the downloaded package signature. Overrides the default bundled key for the selected distribution.
|
||||
|
||||
- `token`: The token used to authenticate when fetching version manifests hosted on GitHub.com. Defaults to `${{ github.token }}` when running on GitHub.com; defaults to an empty string on GitHub Enterprise Server. On GHES, provide a GitHub.com personal access token if manifest requests are rate-limited. See [Using Microsoft distribution on GHES](docs/advanced-usage.md#using-microsoft-distribution-on-ghes) for more details.
|
||||
|
||||
- `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.
|
||||
@@ -84,8 +72,6 @@ For more details, see the full release notes on the [releases page](https://git
|
||||
|
||||
- `mvn-toolchain-vendor`: Name of Maven Toolchain Vendor if the default name of `${distribution}` is not wanted.
|
||||
|
||||
- `show-download-progress`: Set to `true` to keep Maven artifact download and transfer progress in build logs. Default value: `false`. By default, the action adds `-ntp` (`--no-transfer-progress`) to `MAVEN_ARGS`. This input has no effect on non-Maven builds. See [Maven transfer progress](docs/advanced-usage.md#maven-transfer-progress-download-logs) for more details.
|
||||
|
||||
### Basic Configuration
|
||||
|
||||
#### Eclipse Temurin
|
||||
@@ -114,16 +100,7 @@ steps:
|
||||
The `java-version` input supports an exact version or a version range using [SemVer](https://semver.org/) notation. The values below are examples, not an exhaustive list:
|
||||
- major versions, such as: `8`, `11`, `16`, `17`, `21`, `25`
|
||||
- more specific versions: `8.0.282+8`, `8.0.232`, `11.0`, `11.0.4`, `17.0`
|
||||
- multi-field Java versions (JEP 322), such as: `11.0.9.1`, `18.0.1.1`
|
||||
- early access (EA) versions: `15-ea`, `15.0.0-ea`
|
||||
- the `latest` alias, which floats to the newest available stable (GA) release
|
||||
|
||||
> [!NOTE]
|
||||
> - `latest` always resolves the newest version from the distribution's remote metadata (it behaves like `check-latest: true`), so it ignores any older version already present in the runner tool cache. This has the same performance trade-off described in [Check latest](#check-latest).
|
||||
> - `latest` is only supported through the `java-version` input, not through `java-version-file`, and it resolves stable (GA) releases only — it cannot be combined with `-ea`.
|
||||
> - The `jdkfile` distribution does not support `latest`, as it installs from a local file.
|
||||
> - For `oracle` and `graalvm` (Oracle GraalVM), `latest` uses the Adoptium API only to determine the newest GA **major version number** — the JDK binary itself is still downloaded from the Oracle / GraalVM servers for that major. Because these distributions have no endpoint to list their own releases, if their servers haven't published the resolved major yet, the action fails and asks you to specify a concrete version. Note the Oracle JDK license caveat below still applies to a floating `latest`.
|
||||
> - For `graalvm-community`, `latest` floats to the newest GA release published on GitHub, so it never depends on the Adoptium API and always resolves to the newest major that GraalVM Community actually ships.
|
||||
|
||||
#### Supported distributions
|
||||
Currently, the following distributions are supported:
|
||||
@@ -134,7 +111,6 @@ Currently, the following distributions are supported:
|
||||
| `adopt` or `adopt-hotspot` | [AdoptOpenJDK Hotspot](https://adoptopenjdk.net/) | [`adopt-hotspot` license](https://adoptopenjdk.net/about.html) |
|
||||
| `adopt-openj9` | [AdoptOpenJDK OpenJ9](https://adoptopenjdk.net/) | [`adopt-openj9` license](https://adoptopenjdk.net/about.html) |
|
||||
| `liberica` | [Liberica JDK](https://bell-sw.com/) | [`liberica` license](https://bell-sw.com/liberica_eula/) |
|
||||
| `liberica-nik` | [Liberica Native Image Kit](https://bell-sw.com/pages/downloads/native-image-kit/) | [`liberica-nik` license](https://bell-sw.com/liberica_nik_eula/) |
|
||||
| `microsoft` | [Microsoft Build of OpenJDK](https://www.microsoft.com/openjdk) | [`microsoft` license](https://docs.microsoft.com/java/openjdk/faq)
|
||||
| `corretto` | [Amazon Corretto Build of OpenJDK](https://aws.amazon.com/corretto/) | [`corretto` license](https://aws.amazon.com/corretto/faqs/)
|
||||
| `semeru` | [IBM Semeru Runtime Open Edition](https://developer.ibm.com/languages/java/semeru-runtimes/downloads/) | [`semeru` license](https://openjdk.java.net/legal/gplv2+ce.html) |
|
||||
@@ -211,13 +187,6 @@ steps:
|
||||
run: mvn -B package --file pom.xml
|
||||
```
|
||||
|
||||
> [!NOTE]
|
||||
> Maven resolves plugin dependencies lazily, so a cache created by a "thin" goal
|
||||
> (e.g. `mvn compile`) can be missing plugin dependencies that later
|
||||
> `test`/`verify`/`package` jobs then re-download on every run. See
|
||||
> [Ensuring the Maven cache is complete](docs/advanced-usage.md#ensuring-the-maven-cache-is-complete-plugin-dependencies)
|
||||
> for how to seed a complete cache.
|
||||
|
||||
#### Caching sbt dependencies
|
||||
```yaml
|
||||
steps:
|
||||
@@ -314,7 +283,6 @@ In the example above multiple JDKs are installed for the same job. The result af
|
||||
- [Adopt](docs/advanced-usage.md#Adopt)
|
||||
- [Zulu](docs/advanced-usage.md#Zulu)
|
||||
- [Liberica](docs/advanced-usage.md#Liberica)
|
||||
- [Liberica Native Image Kit](docs/advanced-usage.md#Liberica-Native-Image-Kit)
|
||||
- [Microsoft](docs/advanced-usage.md#Microsoft)
|
||||
- [Amazon Corretto](docs/advanced-usage.md#Amazon-Corretto)
|
||||
- [Oracle](docs/advanced-usage.md#Oracle)
|
||||
@@ -329,7 +297,6 @@ In the example above multiple JDKs are installed for the same job. The result af
|
||||
- [Testing against different Java distributions](docs/advanced-usage.md#Testing-against-different-Java-distributions)
|
||||
- [Testing against different platforms](docs/advanced-usage.md#Testing-against-different-platforms)
|
||||
- [Publishing using Apache Maven](docs/advanced-usage.md#Publishing-using-Apache-Maven)
|
||||
- [Maven transfer progress (download logs)](docs/advanced-usage.md#maven-transfer-progress-download-logs)
|
||||
- [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)
|
||||
|
||||
+8
-78
@@ -1,63 +1,24 @@
|
||||
import {
|
||||
jest,
|
||||
describe,
|
||||
it,
|
||||
expect,
|
||||
beforeEach,
|
||||
afterEach,
|
||||
beforeAll,
|
||||
afterAll
|
||||
} from '@jest/globals';
|
||||
import {fileURLToPath} from 'url';
|
||||
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';
|
||||
|
||||
// Mock @actions/core before importing source modules that depend on it
|
||||
jest.unstable_mockModule('@actions/core', () => ({
|
||||
info: jest.fn(),
|
||||
warning: jest.fn(),
|
||||
debug: jest.fn(),
|
||||
error: jest.fn(),
|
||||
notice: jest.fn(),
|
||||
setFailed: jest.fn(),
|
||||
setOutput: jest.fn(),
|
||||
getInput: jest.fn(),
|
||||
getBooleanInput: jest.fn(),
|
||||
getMultilineInput: jest.fn(),
|
||||
addPath: jest.fn(),
|
||||
exportVariable: jest.fn(),
|
||||
saveState: jest.fn(),
|
||||
getState: jest.fn(),
|
||||
setSecret: jest.fn(),
|
||||
isDebug: jest.fn(() => false),
|
||||
startGroup: jest.fn(),
|
||||
endGroup: jest.fn(),
|
||||
group: jest.fn((_name: string, fn: () => Promise<unknown>) => fn()),
|
||||
toPlatformPath: jest.fn((p: string) => p),
|
||||
toWin32Path: jest.fn((p: string) => p),
|
||||
toPosixPath: jest.fn((p: string) => p)
|
||||
}));
|
||||
import * as auth from '../src/auth';
|
||||
import {M2_DIR, MVN_SETTINGS_FILE} from '../src/constants';
|
||||
|
||||
// Dynamic imports after mocking
|
||||
const core = await import('@actions/core');
|
||||
const auth = await import('../src/auth.js');
|
||||
const {M2_DIR, MVN_SETTINGS_FILE} = await import('../src/constants.js');
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
const m2Dir = path.join(__dirname, M2_DIR);
|
||||
const settingsFile = path.join(m2Dir, MVN_SETTINGS_FILE);
|
||||
|
||||
describe('auth tests', () => {
|
||||
let spyOSHomedir: any;
|
||||
let spyInfo: any;
|
||||
let spyOSHomedir: jest.SpyInstance;
|
||||
let spyInfo: jest.SpyInstance;
|
||||
|
||||
beforeEach(async () => {
|
||||
await io.rmRF(m2Dir);
|
||||
spyOSHomedir = jest.spyOn(os, 'homedir');
|
||||
spyOSHomedir.mockReturnValue(__dirname);
|
||||
spyInfo = core.info as jest.Mock;
|
||||
spyInfo = jest.spyOn(core, 'info');
|
||||
spyInfo.mockImplementation(() => null);
|
||||
}, 300000);
|
||||
|
||||
@@ -228,40 +189,9 @@ describe('auth tests', () => {
|
||||
<username>\${env.${username}}</username>
|
||||
<password>\${env.&<>"''"><&}</password>
|
||||
</server>
|
||||
</servers>
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>setup-java-gpg</id>
|
||||
<properties>
|
||||
<gpg.passphraseEnvName>${gpgPassphrase}</gpg.passphraseEnvName>
|
||||
</properties>
|
||||
</profile>
|
||||
</profiles>
|
||||
<activeProfiles>
|
||||
<activeProfile>setup-java-gpg</activeProfile>
|
||||
</activeProfiles>
|
||||
</settings>`;
|
||||
|
||||
expect(auth.generate(id, username, password, gpgPassphrase)).toEqual(
|
||||
expectedSettings
|
||||
);
|
||||
});
|
||||
|
||||
it('does not add a gpg profile when the passphrase env var is the maven-gpg-plugin default', () => {
|
||||
const id = 'packages';
|
||||
const username = 'USER';
|
||||
const password = '&<>"\'\'"><&';
|
||||
const gpgPassphrase = 'MAVEN_GPG_PASSPHRASE';
|
||||
|
||||
const expectedSettings = `<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 https://maven.apache.org/xsd/settings-1.0.0.xsd">
|
||||
<interactiveMode>false</interactiveMode>
|
||||
<servers>
|
||||
<server>
|
||||
<id>${id}</id>
|
||||
<username>\${env.${username}}</username>
|
||||
<password>\${env.&<>"''"><&}</password>
|
||||
<id>gpg.passphrase</id>
|
||||
<passphrase>\${env.${gpgPassphrase}}</passphrase>
|
||||
</server>
|
||||
</servers>
|
||||
</settings>`;
|
||||
|
||||
+98
-215
@@ -1,84 +1,23 @@
|
||||
import {
|
||||
jest,
|
||||
describe,
|
||||
it,
|
||||
expect,
|
||||
beforeEach,
|
||||
afterEach,
|
||||
beforeAll,
|
||||
afterAll
|
||||
} from '@jest/globals';
|
||||
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';
|
||||
|
||||
// Mock @actions/core before importing source modules that depend on it
|
||||
jest.unstable_mockModule('@actions/core', () => ({
|
||||
info: jest.fn(),
|
||||
warning: jest.fn(),
|
||||
debug: jest.fn(),
|
||||
error: jest.fn(),
|
||||
notice: jest.fn(),
|
||||
setFailed: jest.fn(),
|
||||
setOutput: jest.fn(),
|
||||
getInput: jest.fn(),
|
||||
getBooleanInput: jest.fn(),
|
||||
getMultilineInput: jest.fn(),
|
||||
addPath: jest.fn(),
|
||||
exportVariable: jest.fn(),
|
||||
saveState: jest.fn(),
|
||||
getState: jest.fn(),
|
||||
setSecret: jest.fn(),
|
||||
isDebug: jest.fn(() => false),
|
||||
startGroup: jest.fn(),
|
||||
endGroup: jest.fn(),
|
||||
group: jest.fn((_name: string, fn: () => Promise<unknown>) => fn()),
|
||||
toPlatformPath: jest.fn((p: string) => p),
|
||||
toWin32Path: jest.fn((p: string) => p),
|
||||
toPosixPath: jest.fn((p: string) => p)
|
||||
}));
|
||||
|
||||
jest.unstable_mockModule('@actions/cache', () => ({
|
||||
restoreCache: jest.fn(),
|
||||
saveCache: jest.fn(),
|
||||
isFeatureAvailable: jest.fn(),
|
||||
ValidationError: class ValidationError extends Error {
|
||||
constructor(message: string) {
|
||||
super(message);
|
||||
this.name = 'ValidationError';
|
||||
}
|
||||
},
|
||||
ReserveCacheError: class ReserveCacheError extends Error {
|
||||
constructor(message: string) {
|
||||
super(message);
|
||||
this.name = 'ReserveCacheError';
|
||||
}
|
||||
}
|
||||
}));
|
||||
|
||||
jest.unstable_mockModule('@actions/glob', () => ({
|
||||
hashFiles: jest.fn(),
|
||||
create: jest.fn()
|
||||
}));
|
||||
|
||||
// Dynamic imports after mocking
|
||||
const core = await import('@actions/core');
|
||||
const cache = await import('@actions/cache');
|
||||
const glob = await import('@actions/glob');
|
||||
const {restore, save} = await import('../src/cache.js');
|
||||
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'];
|
||||
const ORIGINAL_GITHUB_WORKSPACE = process.env['GITHUB_WORKSPACE'];
|
||||
const ORIGINAL_CWD = process.cwd();
|
||||
let workspace: string;
|
||||
let spyInfo: any;
|
||||
let spyWarning: any;
|
||||
let spyDebug: any;
|
||||
let spySaveState: any;
|
||||
let spyCoreError: any;
|
||||
let spyInfo: jest.SpyInstance<void, Parameters<typeof core.info>>;
|
||||
let spyWarning: jest.SpyInstance<void, Parameters<typeof core.warning>>;
|
||||
let spyDebug: jest.SpyInstance<void, Parameters<typeof core.debug>>;
|
||||
let spySaveState: jest.SpyInstance<void, Parameters<typeof core.saveState>>;
|
||||
let spyCoreError: jest.SpyInstance;
|
||||
|
||||
beforeEach(() => {
|
||||
workspace = mkdtempSync(join(tmpdir(), 'setup-java-cache-'));
|
||||
@@ -102,20 +41,20 @@ describe('dependency cache', () => {
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
spyInfo = core.info as jest.Mock;
|
||||
spyInfo = jest.spyOn(core, 'info');
|
||||
spyInfo.mockImplementation(() => null);
|
||||
|
||||
spyWarning = core.warning as jest.Mock;
|
||||
spyWarning = jest.spyOn(core, 'warning');
|
||||
spyWarning.mockImplementation(() => null);
|
||||
|
||||
spyDebug = core.debug as jest.Mock;
|
||||
spyDebug = jest.spyOn(core, 'debug');
|
||||
spyDebug.mockImplementation(() => null);
|
||||
|
||||
spySaveState = core.saveState as jest.Mock;
|
||||
spySaveState = jest.spyOn(core, 'saveState');
|
||||
spySaveState.mockImplementation(() => null);
|
||||
|
||||
// Mock core.error to suppress error logs
|
||||
spyCoreError = core.error as jest.Mock;
|
||||
spyCoreError = jest.spyOn(core, 'error');
|
||||
spyCoreError.mockImplementation(() => {});
|
||||
});
|
||||
|
||||
@@ -131,18 +70,27 @@ describe('dependency cache', () => {
|
||||
});
|
||||
|
||||
describe('restore', () => {
|
||||
let spyCacheRestore: any;
|
||||
let spyGlobHashFiles: any;
|
||||
let spySetOutput: any;
|
||||
let spyCacheRestore: jest.SpyInstance<
|
||||
ReturnType<typeof cache.restoreCache>,
|
||||
Parameters<typeof cache.restoreCache>
|
||||
>;
|
||||
let spyGlobHashFiles: jest.SpyInstance<
|
||||
ReturnType<typeof glob.hashFiles>,
|
||||
Parameters<typeof glob.hashFiles>
|
||||
>;
|
||||
let spySetOutput: jest.SpyInstance<
|
||||
ReturnType<typeof core.setOutput>,
|
||||
Parameters<typeof core.setOutput>
|
||||
>;
|
||||
|
||||
beforeEach(() => {
|
||||
spyCacheRestore = (cache.restoreCache as any).mockImplementation(
|
||||
(paths: string[], primaryKey: string) => Promise.resolve(undefined)
|
||||
);
|
||||
spyGlobHashFiles = glob.hashFiles as jest.Mock;
|
||||
spyGlobHashFiles.mockResolvedValue('hash-stub');
|
||||
spySetOutput = core.setOutput as jest.Mock;
|
||||
spySetOutput.mockImplementation(() => null);
|
||||
spyCacheRestore = jest
|
||||
.spyOn(cache, 'restoreCache')
|
||||
.mockImplementation((paths: string[], primaryKey: string) =>
|
||||
Promise.resolve(undefined)
|
||||
);
|
||||
spyGlobHashFiles = jest.spyOn(glob, 'hashFiles');
|
||||
spySetOutput = jest.spyOn(core, 'setOutput').mockImplementation(() => {});
|
||||
spyWarning.mockImplementation(() => null);
|
||||
});
|
||||
|
||||
@@ -154,7 +102,6 @@ describe('dependency cache', () => {
|
||||
|
||||
describe('for maven', () => {
|
||||
it('throws error if no pom.xml, maven-wrapper.properties, or extensions.xml found', async () => {
|
||||
spyGlobHashFiles.mockResolvedValue('');
|
||||
await expect(restore('maven', '')).rejects.toThrow(
|
||||
`No file in ${projectRoot(
|
||||
workspace
|
||||
@@ -218,6 +165,7 @@ describe('dependency cache', () => {
|
||||
expect(spyInfo).toHaveBeenCalledWith('maven cache is not found');
|
||||
});
|
||||
it('restores the maven wrapper distribution cache independently of the main cache', async () => {
|
||||
createFile(join(workspace, 'pom.xml'));
|
||||
createDirectory(join(workspace, '.mvn'));
|
||||
createDirectory(join(workspace, '.mvn', 'wrapper'));
|
||||
createFile(
|
||||
@@ -225,43 +173,33 @@ describe('dependency cache', () => {
|
||||
);
|
||||
|
||||
await restore('maven', '');
|
||||
// Main dependency cache no longer carries the wrapper dists path.
|
||||
// Main cache no longer includes the wrapper distribution.
|
||||
expect(spyCacheRestore).toHaveBeenCalledWith(
|
||||
[join(os.homedir(), '.m2', 'repository')],
|
||||
expect.any(String)
|
||||
);
|
||||
// Wrapper distribution is restored on its own, keyed only on the
|
||||
// maven-wrapper.properties hash.
|
||||
expect(spyCacheRestore).toHaveBeenCalledWith(
|
||||
[join(os.homedir(), '.m2', 'wrapper', 'dists')],
|
||||
expect.stringContaining('maven-wrapper')
|
||||
expect.any(String)
|
||||
);
|
||||
expect(spyGlobHashFiles).toHaveBeenCalledWith(
|
||||
'**/.mvn/wrapper/maven-wrapper.properties'
|
||||
);
|
||||
});
|
||||
it('skips the maven wrapper cache when no wrapper properties exist', async () => {
|
||||
it('skips the maven wrapper cache when no maven-wrapper.properties exists', async () => {
|
||||
createFile(join(workspace, 'pom.xml'));
|
||||
spyGlobHashFiles.mockImplementation((pattern: string) =>
|
||||
Promise.resolve(
|
||||
pattern === '**/.mvn/wrapper/maven-wrapper.properties'
|
||||
? ''
|
||||
: 'hash-stub'
|
||||
)
|
||||
);
|
||||
|
||||
await restore('maven', '');
|
||||
// Only the main dependency cache is restored; the wrapper cache path is
|
||||
// never touched because the project does not use mvnw.
|
||||
expect(spyCacheRestore).toHaveBeenCalledTimes(1);
|
||||
expect(spyCacheRestore).toHaveBeenCalledWith(
|
||||
[join(os.homedir(), '.m2', 'repository')],
|
||||
expect(spyCacheRestore).not.toHaveBeenCalledWith(
|
||||
[join(os.homedir(), '.m2', 'wrapper', 'dists')],
|
||||
expect.any(String)
|
||||
);
|
||||
expect(spyWarning).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
describe('for gradle', () => {
|
||||
it('throws error if no build.gradle found', async () => {
|
||||
spyGlobHashFiles.mockResolvedValue('');
|
||||
await expect(restore('gradle', '')).rejects.toThrow(
|
||||
`No file in ${projectRoot(
|
||||
workspace
|
||||
@@ -316,45 +254,31 @@ describe('dependency cache', () => {
|
||||
});
|
||||
it('restores the gradle wrapper distribution cache independently of the main cache', async () => {
|
||||
createFile(join(workspace, 'build.gradle'));
|
||||
createDirectory(join(workspace, 'gradle'));
|
||||
createDirectory(join(workspace, 'gradle', 'wrapper'));
|
||||
createFile(
|
||||
join(workspace, 'gradle', 'wrapper', 'gradle-wrapper.properties')
|
||||
);
|
||||
|
||||
await restore('gradle', '');
|
||||
// Main dependency cache no longer carries the wrapper path.
|
||||
// Main cache no longer includes the wrapper distribution.
|
||||
expect(spyCacheRestore).toHaveBeenCalledWith(
|
||||
[join(os.homedir(), '.gradle', 'caches')],
|
||||
expect.any(String)
|
||||
);
|
||||
// Wrapper distribution is restored on its own, keyed only on the
|
||||
// wrapper properties file.
|
||||
// gradle-wrapper.properties hash.
|
||||
expect(spyCacheRestore).toHaveBeenCalledWith(
|
||||
[join(os.homedir(), '.gradle', 'wrapper')],
|
||||
expect.stringContaining('setup-java-')
|
||||
expect.any(String)
|
||||
);
|
||||
expect(spyGlobHashFiles).toHaveBeenCalledWith(
|
||||
'**/gradle-wrapper.properties'
|
||||
);
|
||||
});
|
||||
it('skips the gradle wrapper cache when no wrapper properties exist', async () => {
|
||||
createFile(join(workspace, 'build.gradle'));
|
||||
spyGlobHashFiles.mockImplementation((pattern: string) =>
|
||||
Promise.resolve(
|
||||
pattern === '**/gradle-wrapper.properties' ? '' : 'hash-stub'
|
||||
)
|
||||
);
|
||||
|
||||
await restore('gradle', '');
|
||||
// Only the main dependency cache is restored; the wrapper cache path is
|
||||
// never touched because the project does not use the gradle wrapper.
|
||||
expect(spyCacheRestore).toHaveBeenCalledTimes(1);
|
||||
expect(spyCacheRestore).toHaveBeenCalledWith(
|
||||
[join(os.homedir(), '.gradle', 'caches')],
|
||||
expect.any(String)
|
||||
);
|
||||
expect(spyWarning).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
describe('for sbt', () => {
|
||||
it('throws error if no build.sbt found', async () => {
|
||||
spyGlobHashFiles.mockResolvedValue('');
|
||||
await expect(restore('sbt', '')).rejects.toThrow(
|
||||
`No file in ${projectRoot(
|
||||
workspace
|
||||
@@ -373,13 +297,6 @@ describe('dependency cache', () => {
|
||||
expect(spyInfo).toHaveBeenCalledWith('sbt cache is not found');
|
||||
});
|
||||
it('detects scala and sbt changes under **/project/ folder', async () => {
|
||||
let callCount = 0;
|
||||
spyGlobHashFiles.mockImplementation(async () => {
|
||||
callCount++;
|
||||
// Return same hash for first two calls, different for third
|
||||
return callCount <= 2 ? 'hash-v1' : 'hash-v2';
|
||||
});
|
||||
|
||||
createFile(join(workspace, 'build.sbt'));
|
||||
createDirectory(join(workspace, 'project'));
|
||||
createFile(join(workspace, 'project/DependenciesV1.scala'));
|
||||
@@ -415,7 +332,6 @@ describe('dependency cache', () => {
|
||||
});
|
||||
describe('cache-dependency-path', () => {
|
||||
it('throws error if no matching dependency file found', async () => {
|
||||
spyGlobHashFiles.mockResolvedValue('');
|
||||
createFile(join(workspace, 'build.gradle.kts'));
|
||||
await expect(
|
||||
restore('gradle', 'sub-project/**/build.gradle.kts')
|
||||
@@ -457,12 +373,17 @@ describe('dependency cache', () => {
|
||||
});
|
||||
});
|
||||
describe('save', () => {
|
||||
let spyCacheSave: any;
|
||||
let spyCacheSave: jest.SpyInstance<
|
||||
ReturnType<typeof cache.saveCache>,
|
||||
Parameters<typeof cache.saveCache>
|
||||
>;
|
||||
|
||||
beforeEach(() => {
|
||||
spyCacheSave = (cache.saveCache as any).mockImplementation(
|
||||
(paths: string[], key: string) => Promise.resolve(0)
|
||||
);
|
||||
spyCacheSave = jest
|
||||
.spyOn(cache, 'saveCache')
|
||||
.mockImplementation((paths: string[], key: string) =>
|
||||
Promise.resolve(0)
|
||||
);
|
||||
spyWarning.mockImplementation(() => null);
|
||||
});
|
||||
|
||||
@@ -528,41 +449,17 @@ describe('dependency cache', () => {
|
||||
});
|
||||
it('saves the maven wrapper distribution cache under its own key', async () => {
|
||||
createFile(join(workspace, 'pom.xml'));
|
||||
(core.getState as jest.Mock<any>).mockImplementation((name: any) => {
|
||||
switch (name) {
|
||||
case 'cache-primary-key':
|
||||
return 'setup-java-cache-primary-key';
|
||||
case 'cache-matched-key':
|
||||
return 'setup-java-cache-matched-key';
|
||||
case 'cache-primary-key-maven-wrapper':
|
||||
return 'setup-java-maven-wrapper-key';
|
||||
default:
|
||||
return '';
|
||||
}
|
||||
});
|
||||
createStateForWrapperRestore('maven-wrapper', false);
|
||||
|
||||
await save('maven');
|
||||
expect(spyCacheSave).toHaveBeenCalledWith(
|
||||
[join(os.homedir(), '.m2', 'wrapper', 'dists')],
|
||||
'setup-java-maven-wrapper-key'
|
||||
'setup-java-maven-wrapper-primary-key'
|
||||
);
|
||||
expect(spyWarning).not.toHaveBeenCalled();
|
||||
});
|
||||
it('does not save the maven wrapper cache on an exact wrapper hit', async () => {
|
||||
createFile(join(workspace, 'pom.xml'));
|
||||
(core.getState as jest.Mock<any>).mockImplementation((name: any) => {
|
||||
switch (name) {
|
||||
case 'cache-primary-key':
|
||||
return 'setup-java-cache-primary-key';
|
||||
case 'cache-matched-key':
|
||||
return 'setup-java-cache-matched-key';
|
||||
case 'cache-primary-key-maven-wrapper':
|
||||
case 'cache-matched-key-maven-wrapper':
|
||||
return 'setup-java-maven-wrapper-key';
|
||||
default:
|
||||
return '';
|
||||
}
|
||||
});
|
||||
createStateForWrapperRestore('maven-wrapper', true);
|
||||
|
||||
await save('maven');
|
||||
expect(spyCacheSave).not.toHaveBeenCalledWith(
|
||||
@@ -572,30 +469,17 @@ describe('dependency cache', () => {
|
||||
});
|
||||
it('does not fail the post step when the wrapper distribution path is missing', async () => {
|
||||
createFile(join(workspace, 'pom.xml'));
|
||||
(core.getState as jest.Mock<any>).mockImplementation((name: any) => {
|
||||
switch (name) {
|
||||
case 'cache-primary-key':
|
||||
return 'setup-java-cache-primary-key';
|
||||
case 'cache-matched-key':
|
||||
return 'setup-java-cache-matched-key';
|
||||
case 'cache-primary-key-maven-wrapper':
|
||||
return 'setup-java-maven-wrapper-key';
|
||||
default:
|
||||
return '';
|
||||
createStateForWrapperRestore('maven-wrapper', false);
|
||||
spyCacheSave.mockImplementation((paths: string[], key: string) => {
|
||||
if (paths.includes(join(os.homedir(), '.m2', 'wrapper', 'dists'))) {
|
||||
return Promise.reject(
|
||||
new cache.ValidationError('Path Validation Error')
|
||||
);
|
||||
}
|
||||
return Promise.resolve(0);
|
||||
});
|
||||
spyCacheSave.mockImplementation((paths: string[]) =>
|
||||
paths.includes(join(os.homedir(), '.m2', 'wrapper', 'dists'))
|
||||
? Promise.reject(
|
||||
new cache.ValidationError(
|
||||
'Path Validation Error: Path(s) specified in the action for caching do(es) not exist'
|
||||
)
|
||||
)
|
||||
: Promise.resolve(0)
|
||||
);
|
||||
|
||||
await expect(save('maven')).resolves.toBeUndefined();
|
||||
expect(spyWarning).not.toHaveBeenCalled();
|
||||
await expect(save('maven')).resolves.not.toThrow();
|
||||
});
|
||||
});
|
||||
describe('for gradle', () => {
|
||||
@@ -651,41 +535,17 @@ describe('dependency cache', () => {
|
||||
});
|
||||
it('saves the gradle wrapper distribution cache under its own key', async () => {
|
||||
createFile(join(workspace, 'build.gradle'));
|
||||
(core.getState as jest.Mock<any>).mockImplementation((name: any) => {
|
||||
switch (name) {
|
||||
case 'cache-primary-key':
|
||||
return 'setup-java-cache-primary-key';
|
||||
case 'cache-matched-key':
|
||||
return 'setup-java-cache-matched-key';
|
||||
case 'cache-primary-key-gradle-wrapper':
|
||||
return 'setup-java-gradle-wrapper-key';
|
||||
default:
|
||||
return '';
|
||||
}
|
||||
});
|
||||
createStateForWrapperRestore('gradle-wrapper', false);
|
||||
|
||||
await save('gradle');
|
||||
expect(spyCacheSave).toHaveBeenCalledWith(
|
||||
[join(os.homedir(), '.gradle', 'wrapper')],
|
||||
'setup-java-gradle-wrapper-key'
|
||||
'setup-java-gradle-wrapper-primary-key'
|
||||
);
|
||||
expect(spyWarning).not.toHaveBeenCalled();
|
||||
});
|
||||
it('does not save the gradle wrapper cache on an exact wrapper hit', async () => {
|
||||
createFile(join(workspace, 'build.gradle'));
|
||||
(core.getState as jest.Mock<any>).mockImplementation((name: any) => {
|
||||
switch (name) {
|
||||
case 'cache-primary-key':
|
||||
return 'setup-java-cache-primary-key';
|
||||
case 'cache-matched-key':
|
||||
return 'setup-java-cache-matched-key';
|
||||
case 'cache-primary-key-gradle-wrapper':
|
||||
case 'cache-matched-key-gradle-wrapper':
|
||||
return 'setup-java-gradle-wrapper-key';
|
||||
default:
|
||||
return '';
|
||||
}
|
||||
});
|
||||
createStateForWrapperRestore('gradle-wrapper', true);
|
||||
|
||||
await save('gradle');
|
||||
expect(spyCacheSave).not.toHaveBeenCalledWith(
|
||||
@@ -737,14 +597,14 @@ describe('dependency cache', () => {
|
||||
});
|
||||
|
||||
function resetState() {
|
||||
(core.getState as jest.Mock).mockReset();
|
||||
jest.spyOn(core, 'getState').mockReset();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create states to emulate a restore process without build file.
|
||||
*/
|
||||
function createStateForMissingBuildFile() {
|
||||
(core.getState as jest.Mock<any>).mockImplementation((name: any) => {
|
||||
jest.spyOn(core, 'getState').mockImplementation(name => {
|
||||
switch (name) {
|
||||
case 'cache-primary-key':
|
||||
return 'setup-java-cache-';
|
||||
@@ -758,7 +618,7 @@ function createStateForMissingBuildFile() {
|
||||
* Create states to emulate a successful restore process.
|
||||
*/
|
||||
function createStateForSuccessfulRestore() {
|
||||
(core.getState as jest.Mock<any>).mockImplementation((name: any) => {
|
||||
jest.spyOn(core, 'getState').mockImplementation(name => {
|
||||
switch (name) {
|
||||
case 'cache-primary-key':
|
||||
return 'setup-java-cache-primary-key';
|
||||
@@ -770,6 +630,29 @@ function createStateForSuccessfulRestore() {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Create states to emulate a restore process where an additional (wrapper)
|
||||
* cache was restored. When `hit` is true the matched key equals the primary
|
||||
* key, emulating an exact wrapper cache hit.
|
||||
*/
|
||||
function createStateForWrapperRestore(wrapperName: string, hit: boolean) {
|
||||
const primaryKey = `setup-java-${wrapperName}-primary-key`;
|
||||
jest.spyOn(core, 'getState').mockImplementation(name => {
|
||||
switch (name) {
|
||||
case 'cache-primary-key':
|
||||
return 'setup-java-cache-primary-key';
|
||||
case 'cache-matched-key':
|
||||
return 'setup-java-cache-matched-key';
|
||||
case `cache-primary-key-${wrapperName}`:
|
||||
return primaryKey;
|
||||
case `cache-matched-key-${wrapperName}`:
|
||||
return hit ? primaryKey : '';
|
||||
default:
|
||||
return '';
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function createFile(path: string) {
|
||||
core.info(`created a file at ${path}`);
|
||||
fs.writeFileSync(path, '');
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
target/
|
||||
pom.xml.tag
|
||||
pom.xml.releaseBackup
|
||||
pom.xml.versionsBackup
|
||||
pom.xml.next
|
||||
release.properties
|
||||
dependency-reduced-pom.xml
|
||||
buildNumber.properties
|
||||
.mvn/timing.properties
|
||||
# https://github.com/takari/maven-wrapper#usage-without-binary-jar
|
||||
.mvn/wrapper/maven-wrapper.jar
|
||||
Vendored
-15
@@ -1,15 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>io.github.actions</groupId>
|
||||
<artifactId>setup-java-maven2-example</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<version>3.12.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -1 +0,0 @@
|
||||
target/
|
||||
Vendored
-3
@@ -1,3 +0,0 @@
|
||||
ThisBuild / scalaVersion := "2.12.15"
|
||||
|
||||
libraryDependencies += "org.scala-lang.modules" %% "scala-parser-combinators" % "2.1.1"
|
||||
@@ -1,39 +0,0 @@
|
||||
#!/bin/sh
|
||||
# Assert whether a directory exists, for use in the e2e cache workflows.
|
||||
#
|
||||
# Usage: check-dir.sh <dir> [present|absent]
|
||||
#
|
||||
# present (default): fail if <dir> does NOT exist, otherwise list its contents.
|
||||
# absent: fail if <dir> DOES exist.
|
||||
#
|
||||
# Call with already-expanded paths (e.g. "$HOME/.gradle/caches") to avoid
|
||||
# tilde-expansion pitfalls.
|
||||
set -eu
|
||||
|
||||
if [ "$#" -lt 1 ]; then
|
||||
echo "Usage: check-dir.sh <dir> [present|absent]" >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
dir=$1
|
||||
mode=${2:-present}
|
||||
|
||||
case "$mode" in
|
||||
present)
|
||||
if [ ! -d "$dir" ]; then
|
||||
echo "::error::The $dir directory does not exist unexpectedly"
|
||||
exit 1
|
||||
fi
|
||||
ls "$dir"
|
||||
;;
|
||||
absent)
|
||||
if [ -d "$dir" ]; then
|
||||
echo "::error::The $dir directory exists unexpectedly"
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
echo "::error::Unknown mode '$mode' (expected 'present' or 'absent')"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
@@ -1,87 +1,32 @@
|
||||
import {
|
||||
jest,
|
||||
describe,
|
||||
it,
|
||||
expect,
|
||||
beforeEach,
|
||||
afterEach,
|
||||
beforeAll,
|
||||
afterAll
|
||||
} from '@jest/globals';
|
||||
|
||||
// Mock @actions/cache before importing source modules
|
||||
const real_cache_module = await import('@actions/cache');
|
||||
jest.unstable_mockModule('@actions/cache', () => ({
|
||||
...real_cache_module,
|
||||
saveCache: jest.fn(),
|
||||
restoreCache: jest.fn()
|
||||
}));
|
||||
|
||||
// Mock @actions/core before importing source modules that depend on it
|
||||
jest.unstable_mockModule('@actions/core', () => ({
|
||||
info: jest.fn(),
|
||||
warning: jest.fn(),
|
||||
debug: jest.fn(),
|
||||
error: jest.fn(),
|
||||
notice: jest.fn(),
|
||||
setFailed: jest.fn(),
|
||||
setOutput: jest.fn(),
|
||||
getInput: jest.fn(),
|
||||
getBooleanInput: jest.fn(),
|
||||
getMultilineInput: jest.fn(),
|
||||
addPath: jest.fn(),
|
||||
exportVariable: jest.fn(),
|
||||
saveState: jest.fn(),
|
||||
getState: jest.fn(),
|
||||
setSecret: jest.fn(),
|
||||
isDebug: jest.fn(() => false),
|
||||
startGroup: jest.fn(),
|
||||
endGroup: jest.fn(),
|
||||
group: jest.fn((_name: string, fn: () => Promise<unknown>) => fn()),
|
||||
toPlatformPath: jest.fn((p: string) => p),
|
||||
toWin32Path: jest.fn((p: string) => p),
|
||||
toPosixPath: jest.fn((p: string) => p)
|
||||
}));
|
||||
|
||||
const real_util_module = await import('../src/util.js');
|
||||
jest.unstable_mockModule('../src/util.js', () => ({
|
||||
...real_util_module,
|
||||
extractJdkFile: jest.fn(),
|
||||
getDownloadArchiveExtension: jest.fn(),
|
||||
getToolcachePath: jest.fn(),
|
||||
isJobStatusSuccess: jest.fn(),
|
||||
renameWinArchive: jest.fn(),
|
||||
isVersionSatisfies: real_util_module.isVersionSatisfies,
|
||||
getTempDir: real_util_module.getTempDir
|
||||
}));
|
||||
|
||||
// Dynamic imports after mocking
|
||||
const core = await import('@actions/core');
|
||||
const cache = await import('@actions/cache');
|
||||
const {run: cleanup} = await import('../src/cleanup-java.js');
|
||||
const util = await import('../src/util.js');
|
||||
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';
|
||||
|
||||
describe('cleanup', () => {
|
||||
let spyWarning: any;
|
||||
let spyInfo: any;
|
||||
let spyCacheSave: any;
|
||||
let spyJobStatusSuccess: any;
|
||||
let spyCoreError: any;
|
||||
let spyWarning: jest.SpyInstance<void, Parameters<typeof core.warning>>;
|
||||
let spyInfo: jest.SpyInstance<void, Parameters<typeof core.info>>;
|
||||
let spyCacheSave: jest.SpyInstance<
|
||||
ReturnType<typeof cache.saveCache>,
|
||||
Parameters<typeof cache.saveCache>
|
||||
>;
|
||||
let spyJobStatusSuccess: jest.SpyInstance;
|
||||
let spyCoreError: jest.SpyInstance;
|
||||
|
||||
beforeEach(() => {
|
||||
spyWarning = core.warning as jest.Mock;
|
||||
spyWarning = jest.spyOn(core, 'warning');
|
||||
spyWarning.mockImplementation(() => null);
|
||||
|
||||
spyInfo = core.info as jest.Mock;
|
||||
spyInfo = jest.spyOn(core, 'info');
|
||||
spyInfo.mockImplementation(() => null);
|
||||
|
||||
spyCacheSave = cache.saveCache as jest.Mock;
|
||||
spyCacheSave = jest.spyOn(cache, 'saveCache');
|
||||
|
||||
spyJobStatusSuccess = util.isJobStatusSuccess as jest.Mock;
|
||||
spyJobStatusSuccess = jest.spyOn(util, 'isJobStatusSuccess');
|
||||
spyJobStatusSuccess.mockReturnValue(true);
|
||||
|
||||
// Mock core.error to suppress error logs
|
||||
spyCoreError = core.error as jest.Mock;
|
||||
spyCoreError = jest.spyOn(core, 'error');
|
||||
spyCoreError.mockImplementation(() => {});
|
||||
|
||||
createStateForSuccessfulRestore();
|
||||
@@ -102,7 +47,7 @@ describe('cleanup', () => {
|
||||
)
|
||||
)
|
||||
);
|
||||
(core.getInput as jest.Mock<any>).mockImplementation((name: string) => {
|
||||
jest.spyOn(core, 'getInput').mockImplementation((name: string) => {
|
||||
return name === 'cache' ? 'gradle' : '';
|
||||
});
|
||||
await cleanup();
|
||||
@@ -114,7 +59,7 @@ describe('cleanup', () => {
|
||||
spyCacheSave.mockImplementation((paths: string[], key: string) =>
|
||||
Promise.reject(new Error('Unexpected error'))
|
||||
);
|
||||
(core.getInput as jest.Mock<any>).mockImplementation((name: string) => {
|
||||
jest.spyOn(core, 'getInput').mockImplementation((name: string) => {
|
||||
return name === 'cache' ? 'gradle' : '';
|
||||
});
|
||||
await cleanup();
|
||||
@@ -123,14 +68,14 @@ describe('cleanup', () => {
|
||||
});
|
||||
|
||||
function resetState() {
|
||||
(core.getState as jest.Mock).mockReset();
|
||||
jest.spyOn(core, 'getState').mockReset();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create states to emulate a successful restore process.
|
||||
*/
|
||||
function createStateForSuccessfulRestore() {
|
||||
(core.getState as jest.Mock<any>).mockImplementation((name: any) => {
|
||||
jest.spyOn(core, 'getState').mockImplementation(name => {
|
||||
switch (name) {
|
||||
case 'cache-primary-key':
|
||||
return 'setup-java-cache-primary-key';
|
||||
|
||||
@@ -1,739 +0,0 @@
|
||||
[
|
||||
{
|
||||
"downloadUrl": "https://github.com/bell-sw/LibericaNIK/releases/download/25.0.1+3-25.0.1+16/bellsoft-liberica-vm-openjdk25.0.1+16-25.0.1+3-linux-amd64.tar.gz",
|
||||
"version": "25.0.1+3",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "25.0.1+16",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://github.com/bell-sw/LibericaNIK/releases/download/24.1.0+1-23+38/bellsoft-liberica-vm-openjdk23+38-24.1.0+1-linux-amd64.tar.gz",
|
||||
"version": "24.1.0+1",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "23+38",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://download.bell-sw.com/vm/21.3.2/bellsoft-liberica-vm-openjdk11.0.15.1+2-21.3.2+2-linux-amd64.tar.gz",
|
||||
"version": "21.3.2+2",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "11.0.15.1+2",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://download.bell-sw.com/vm/22.3.0/bellsoft-liberica-vm-openjdk17.0.5+8-22.3.0+2-linux-amd64.tar.gz",
|
||||
"version": "22.3.0+2",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "17.0.5+8",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://github.com/bell-sw/LibericaNIK/releases/download/23.0.9+1-17.0.16+13/bellsoft-liberica-vm-openjdk17.0.16+13-23.0.9+1-linux-amd64.tar.gz",
|
||||
"version": "23.0.9+1",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "17.0.16+13",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://download.bell-sw.com/vm/23.0.0/bellsoft-liberica-vm-openjdk17.0.7+7-23.0.0+1-src.tar.gz",
|
||||
"version": "23.0.0+1",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "17.0.7+7",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://github.com/bell-sw/LibericaNIK/releases/download/25.0.2+1-25.0.2+13/bellsoft-liberica-vm-openjdk25.0.2+13-25.0.2+1-linux-amd64.tar.gz",
|
||||
"version": "25.0.2+1",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "25.0.2+13",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://github.com/bell-sw/LibericaNIK/releases/download/24.1.1+1-23.0.1+13/bellsoft-liberica-vm-openjdk23.0.1+13-24.1.1+1-linux-amd64.tar.gz",
|
||||
"version": "24.1.1+1",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "23.0.1+13",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://github.com/bell-sw/LibericaNIK/releases/download/23.0.12+1-17.0.19+12/bellsoft-liberica-vm-openjdk17.0.19+12-23.0.12+1-linux-amd64.tar.gz",
|
||||
"version": "23.0.12+1",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "17.0.19+12",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://github.com/bell-sw/LibericaNIK/releases/download/23.0.3+1-17.0.10+13/bellsoft-liberica-vm-openjdk17.0.10+13-23.0.3+1-linux-amd64.tar.gz",
|
||||
"version": "23.0.3+1",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "17.0.10+13",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://download.bell-sw.com/vm/21.3.2/bellsoft-liberica-vm-openjdk11-21.3.2-src.tar.gz",
|
||||
"version": "21.3.2+1",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "11.0.15+10",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://download.bell-sw.com/vm/22.3.3/bellsoft-liberica-vm-openjdk11.0.20+8-22.3.3+1-src.tar.gz",
|
||||
"version": "22.3.3+1",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "11.0.20+8",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://github.com/bell-sw/LibericaNIK/releases/download/23.0.8+1-17.0.15+10/bellsoft-liberica-vm-openjdk17.0.15+10-23.0.8+1-linux-amd64.tar.gz",
|
||||
"version": "23.0.8+1",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "17.0.15+10",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://download.bell-sw.com/vm/21.3.3/bellsoft-liberica-vm-openjdk17.0.4-21.3.3-src.tar.gz",
|
||||
"version": "21.3.3+1",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "17.0.4+8",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://github.com/bell-sw/LibericaNIK/releases/download/23.1.7+1-21.0.7+9/bellsoft-liberica-vm-openjdk21.0.7+9-23.1.7+1-linux-amd64.tar.gz",
|
||||
"version": "23.1.7+1",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "21.0.7+9",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://github.com/bell-sw/LibericaNIK/releases/download/23.1.8+1-21.0.8+13/bellsoft-liberica-vm-openjdk21.0.8+13-23.1.8+1-linux-amd64.tar.gz",
|
||||
"version": "23.1.8+1",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "21.0.8+13",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://download.bell-sw.com/vm/21.0.0.2/bellsoft-liberica-vm-openjdk11-21.0.0.2-src.tar.gz",
|
||||
"version": "21.0.0.2",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "11.0.10+9",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://download.bell-sw.com/vm/23.0.1/bellsoft-liberica-vm-openjdk17.0.8+7-23.0.1+1-linux-amd64.tar.gz",
|
||||
"version": "23.0.1+1",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "17.0.8+7",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://github.com/bell-sw/LibericaNIK/releases/download/24.0.0+1-22+37/bellsoft-liberica-vm-openjdk22+37-24.0.0+1-linux-amd64.tar.gz",
|
||||
"version": "24.0.0+1",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "22+37",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://download.bell-sw.com/vm/22.1.0/bellsoft-liberica-vm-openjdk17-22.1.0-src.tar.gz",
|
||||
"version": "22.1.0+1",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "17.0.3+7",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://github.com/bell-sw/LibericaNIK/releases/download/24.0.2+1-22.0.2+11/bellsoft-liberica-vm-openjdk22.0.2+11-24.0.2+1-linux-amd64.tar.gz",
|
||||
"version": "24.0.2+1",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "22.0.2+11",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://download.bell-sw.com/vm/23.0.1/bellsoft-liberica-vm-openjdk20.0.2+10-23.0.1+1-src.tar.gz",
|
||||
"version": "23.0.1+1",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "20.0.2+10",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://download.bell-sw.com/vm/23.1.0/bellsoft-liberica-vm-openjdk21+37-23.1.0+1-linux-amd64.tar.gz",
|
||||
"version": "23.1.0+1",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "21+37",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://github.com/bell-sw/LibericaNIK/releases/download/23.1.4+3-21.0.4+9/bellsoft-liberica-vm-openjdk21.0.4+9-23.1.4+3-linux-amd64.tar.gz",
|
||||
"version": "23.1.4+3",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "21.0.4+9",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://download.bell-sw.com/vm/22.3.3/bellsoft-liberica-vm-openjdk11.0.20.1+1-22.3.3+2-linux-amd64.tar.gz",
|
||||
"version": "22.3.3+2",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "11.0.20.1+1",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://github.com/bell-sw/LibericaNIK/releases/download/23.0.4+1-17.0.11+10/bellsoft-liberica-vm-openjdk17.0.11+10-23.0.4+1-linux-amd64.tar.gz",
|
||||
"version": "23.0.4+1",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "17.0.11+10",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://github.com/bell-sw/LibericaNIK/releases/download/24.1.2+1-23.0.2+9/bellsoft-liberica-vm-openjdk23.0.2+9-24.1.2+1-linux-amd64.tar.gz",
|
||||
"version": "24.1.2+1",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "23.0.2+9",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://github.com/bell-sw/LibericaNIK/releases/download/23.0.10+1-17.0.17+12/bellsoft-liberica-vm-openjdk17.0.17+12-23.0.10+1-linux-amd64.tar.gz",
|
||||
"version": "23.0.10+1",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "17.0.17+12",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://download.bell-sw.com/vm/22.3.1/bellsoft-liberica-vm-openjdk11.0.18+10-22.3.1+1-src.tar.gz",
|
||||
"version": "22.3.1+1",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "11.0.18+10",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://download.bell-sw.com/vm/22.0.0.2/bellsoft-liberica-vm-openjdk17-22.0.0.2-src.tar.gz",
|
||||
"version": "22.0.0.2",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "17.0.2+9",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://download.bell-sw.com/vm/22.0.0.2/bellsoft-liberica-vm-openjdk11-22.0.0.2-linux-amd64.tar.gz",
|
||||
"version": "22.0.0.2",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "11.0.14.1+1",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://github.com/bell-sw/LibericaNIK/releases/download/25.0.1+2-25.0.1+14/bellsoft-liberica-vm-openjdk25.0.1+14-25.0.1+2-linux-amd64.tar.gz",
|
||||
"version": "25.0.1+2",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "25.0.1+14",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://download.bell-sw.com/vm/21.3.3/bellsoft-liberica-vm-openjdk11.0.16-21.3.3-src.tar.gz",
|
||||
"version": "21.3.3+1",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "11.0.16+8",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://github.com/bell-sw/LibericaNIK/releases/download/23.1.5+1-21.0.5+11/bellsoft-liberica-vm-openjdk21.0.5+11-23.1.5+1-linux-amd64.tar.gz",
|
||||
"version": "23.1.5+1",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "21.0.5+11",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://download.bell-sw.com/vm/22.3.4/bellsoft-liberica-vm-openjdk17.0.9+11-22.3.4+1-linux-amd64.tar.gz",
|
||||
"version": "22.3.4+1",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "17.0.9+11",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://github.com/bell-sw/LibericaNIK/releases/download/25.0.0+1-25+37/bellsoft-liberica-vm-openjdk25+37-25.0.0+1-linux-amd64.tar.gz",
|
||||
"version": "25.0.0+1",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "25+37",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://download.bell-sw.com/vm/22.3.3/bellsoft-liberica-vm-openjdk17.0.8.1+1-22.3.3+2-linux-amd64.tar.gz",
|
||||
"version": "22.3.3+2",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "17.0.8.1+1",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://github.com/bell-sw/LibericaNIK/releases/download/23.1.3+1-21.0.3+10/bellsoft-liberica-vm-openjdk21.0.3+10-23.1.3+1-linux-amd64.tar.gz",
|
||||
"version": "23.1.3+1",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "21.0.3+10",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://github.com/bell-sw/LibericaNIK/releases/download/24.2.0+1-24+37/bellsoft-liberica-vm-openjdk24+37-24.2.0+1-linux-amd64.tar.gz",
|
||||
"version": "24.2.0+1",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "24+37",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://download.bell-sw.com/vm/23.1.1/bellsoft-liberica-vm-openjdk21.0.1+12-23.1.1+1-linux-amd64.tar.gz",
|
||||
"version": "23.1.1+1",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "21.0.1+12",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://download.bell-sw.com/vm/21.3.3/bellsoft-liberica-vm-openjdk17.0.4.1-21.3.3-src.tar.gz",
|
||||
"version": "21.3.3+2",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "17.0.4.1+1",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://github.com/bell-sw/LibericaNIK/releases/download/23.1.11+2-21.0.11+12/bellsoft-liberica-vm-openjdk21.0.11+12-23.1.11+2-linux-amd64.tar.gz",
|
||||
"version": "23.1.11+2",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "21.0.11+12",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://download.bell-sw.com/vm/22.3.2/bellsoft-liberica-vm-openjdk11.0.19+7-22.3.2+1-src.tar.gz",
|
||||
"version": "22.3.2+1",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "11.0.19+7",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://download.bell-sw.com/vm/22.3.4/bellsoft-liberica-vm-openjdk11.0.21+10-22.3.4+1-src.tar.gz",
|
||||
"version": "22.3.4+1",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "11.0.21+10",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://github.com/bell-sw/LibericaNIK/releases/download/25.0.3+2-25.0.3+12/bellsoft-liberica-vm-openjdk25.0.3+12-25.0.3+2-linux-amd64.tar.gz",
|
||||
"version": "25.0.3+2",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "25.0.3+12",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://download.bell-sw.com/vm/21.3.2/bellsoft-liberica-vm-openjdk17.0.3.1+2-21.3.2+2-linux-amd64.tar.gz",
|
||||
"version": "21.3.2+2",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "17.0.3.1+2",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://github.com/bell-sw/LibericaNIK/releases/download/24.2.1+1-24.0.1+11/bellsoft-liberica-vm-openjdk24.0.1+11-24.2.1+1-linux-amd64.tar.gz",
|
||||
"version": "24.2.1+1",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "24.0.1+11",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://download.bell-sw.com/vm/22.2.0/bellsoft-liberica-vm-openjdk11.0.16.1+1-22.2.0+3-linux-amd64.tar.gz",
|
||||
"version": "22.2.0+3",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "11.0.16.1+1",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://github.com/bell-sw/LibericaNIK/releases/download/23.0.6+1-17.0.13+12/bellsoft-liberica-vm-openjdk17.0.13+12-23.0.6+1-linux-amd64.tar.gz",
|
||||
"version": "23.0.6+1",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "17.0.13+12",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://download.bell-sw.com/vm/23.0.0/bellsoft-liberica-vm-openjdk20.0.1+10-23.0.0+1-linux-amd64.tar.gz",
|
||||
"version": "23.0.0+1",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "20.0.1+10",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://github.com/bell-sw/LibericaNIK/releases/download/23.1.10+1-21.0.10+11/bellsoft-liberica-vm-openjdk21.0.10+11-23.1.10+1-linux-amd64.tar.gz",
|
||||
"version": "23.1.10+1",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "21.0.10+11",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://download.bell-sw.com/vm/22.3.1/bellsoft-liberica-vm-openjdk17.0.6+10-22.3.1+1-src.tar.gz",
|
||||
"version": "22.3.1+1",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "17.0.6+10",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://download.bell-sw.com/vm/21.3.0/bellsoft-liberica-vm-openjdk17-21.3.0-src.tar.gz",
|
||||
"version": "21.3.0",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "17.0.1+12",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://download.bell-sw.com/vm/21.3.0/bellsoft-liberica-vm-openjdk11-21.3.0-src.tar.gz",
|
||||
"version": "21.3.0",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "11.0.13+8",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://github.com/bell-sw/LibericaNIK/releases/download/24.0.1+1-22.0.1+10/bellsoft-liberica-vm-openjdk22.0.1+10-24.0.1+1-linux-amd64.tar.gz",
|
||||
"version": "24.0.1+1",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "22.0.1+10",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://github.com/bell-sw/LibericaNIK/releases/download/23.0.7+1-17.0.14+10/bellsoft-liberica-vm-openjdk17.0.14+10-23.0.7+1-linux-amd64.tar.gz",
|
||||
"version": "23.0.7+1",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "17.0.14+10",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://download.bell-sw.com/vm/21.1.0/bellsoft-liberica-vm-openjdk11-21.1.0-src.tar.gz",
|
||||
"version": "21.1.0",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "11.0.11+9",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://github.com/bell-sw/LibericaNIK/releases/download/23.1.6+1-21.0.6+10/bellsoft-liberica-vm-openjdk21.0.6+10-23.1.6+1-linux-amd64.tar.gz",
|
||||
"version": "23.1.6+1",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "21.0.6+10",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://github.com/bell-sw/LibericaNIK/releases/download/25.0.1+1-25.0.1+12/bellsoft-liberica-vm-openjdk25.0.1+12-25.0.1+1-linux-amd64.tar.gz",
|
||||
"version": "25.0.1+1",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "25.0.1+12",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://github.com/bell-sw/LibericaNIK/releases/download/23.1.9+1-21.0.9+12/bellsoft-liberica-vm-openjdk21.0.9+12-23.1.9+1-linux-amd64.tar.gz",
|
||||
"version": "23.1.9+1",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "21.0.9+12",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://github.com/bell-sw/LibericaNIK/releases/download/22.3.5+1-11.0.22+12/bellsoft-liberica-vm-openjdk11.0.22+12-22.3.5+1-linux-amd64.tar.gz",
|
||||
"version": "22.3.5+1",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "11.0.22+12",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://github.com/bell-sw/LibericaNIK/releases/download/23.0.5+1-17.0.12+10/bellsoft-liberica-vm-openjdk17.0.12+10-23.0.5+1-linux-amd64.tar.gz",
|
||||
"version": "23.0.5+1",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "17.0.12+10",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://download.bell-sw.com/vm/21.3.3.1/bellsoft-liberica-vm-openjdk11.0.17+7-21.3.3.1+1-linux-amd64.tar.gz",
|
||||
"version": "21.3.3.1+1",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "11.0.17+7",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://download.bell-sw.com/vm/21.2.0/bellsoft-liberica-vm-openjdk11-21.2.0-linux-amd64.tar.gz",
|
||||
"version": "21.2.0",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "11.0.12+7",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://github.com/bell-sw/LibericaNIK/releases/download/23.0.11+1-17.0.18+11/bellsoft-liberica-vm-openjdk17.0.18+11-23.0.11+1-linux-amd64.tar.gz",
|
||||
"version": "23.0.11+1",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "17.0.18+11",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://github.com/bell-sw/LibericaNIK/releases/download/23.1.2+1-21.0.2+14/bellsoft-liberica-vm-openjdk21.0.2+14-23.1.2+1-linux-amd64.tar.gz",
|
||||
"version": "23.1.2+1",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "21.0.2+14",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://github.com/bell-sw/LibericaNIK/releases/download/24.2.2+1-24.0.2+13/bellsoft-liberica-vm-openjdk24.0.2+13-24.2.2+1-linux-amd64.tar.gz",
|
||||
"version": "24.2.2+1",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "24.0.2+13",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
@@ -1,59 +1,21 @@
|
||||
import {
|
||||
jest,
|
||||
describe,
|
||||
it,
|
||||
expect,
|
||||
beforeEach,
|
||||
afterEach,
|
||||
beforeAll,
|
||||
afterAll
|
||||
} from '@jest/globals';
|
||||
import {HttpClient} from '@actions/http-client';
|
||||
import {IAdoptAvailableVersions} from '../../src/distributions/adopt/models';
|
||||
import {
|
||||
AdoptDistribution,
|
||||
AdoptImplementation
|
||||
} from '../../src/distributions/adopt/installer';
|
||||
import {TemurinDistribution} from '../../src/distributions/temurin/installer';
|
||||
import {JavaInstallerOptions} from '../../src/distributions/base-models';
|
||||
|
||||
import os from 'os';
|
||||
|
||||
import manifestData from '../data/adopt.json' with {type: 'json'};
|
||||
|
||||
// Mock @actions/core before importing source modules that depend on it
|
||||
jest.unstable_mockModule('@actions/core', () => ({
|
||||
info: jest.fn(),
|
||||
warning: jest.fn(),
|
||||
debug: jest.fn(),
|
||||
error: jest.fn(),
|
||||
notice: jest.fn(),
|
||||
setFailed: jest.fn(),
|
||||
setOutput: jest.fn(),
|
||||
getInput: jest.fn(),
|
||||
getBooleanInput: jest.fn(),
|
||||
getMultilineInput: jest.fn(),
|
||||
addPath: jest.fn(),
|
||||
exportVariable: jest.fn(),
|
||||
saveState: jest.fn(),
|
||||
getState: jest.fn(),
|
||||
setSecret: jest.fn(),
|
||||
isDebug: jest.fn(() => false),
|
||||
startGroup: jest.fn(),
|
||||
endGroup: jest.fn(),
|
||||
group: jest.fn((_name: string, fn: () => Promise<unknown>) => fn()),
|
||||
toPlatformPath: jest.fn((p: string) => p),
|
||||
toWin32Path: jest.fn((p: string) => p),
|
||||
toPosixPath: jest.fn((p: string) => p)
|
||||
}));
|
||||
|
||||
// Dynamic imports after mocking
|
||||
const core = await import('@actions/core');
|
||||
const {AdoptDistribution, AdoptImplementation} =
|
||||
await import('../../src/distributions/adopt/installer.js');
|
||||
const {TemurinDistribution} =
|
||||
await import('../../src/distributions/temurin/installer.js');
|
||||
|
||||
import type {IAdoptAvailableVersions} from '../../src/distributions/adopt/models.js';
|
||||
import type {AdoptImplementation as AdoptImplementationType} from '../../src/distributions/adopt/installer.js';
|
||||
import type {JavaInstallerOptions} from '../../src/distributions/base-models.js';
|
||||
import manifestData from '../data/adopt.json';
|
||||
import * as core from '@actions/core';
|
||||
|
||||
describe('getAvailableVersions', () => {
|
||||
let spyHttpClient: any;
|
||||
let spyCoreError: any;
|
||||
let spyCoreWarning: any;
|
||||
let spyHttpClient: jest.SpyInstance;
|
||||
let spyCoreError: jest.SpyInstance;
|
||||
let spyCoreWarning: jest.SpyInstance;
|
||||
|
||||
beforeEach(() => {
|
||||
spyHttpClient = jest.spyOn(HttpClient.prototype, 'getJson');
|
||||
@@ -64,9 +26,9 @@ describe('getAvailableVersions', () => {
|
||||
});
|
||||
|
||||
// Mock core.error to suppress error logs
|
||||
spyCoreError = core.error as jest.Mock;
|
||||
spyCoreError = jest.spyOn(core, 'error');
|
||||
spyCoreError.mockImplementation(() => {});
|
||||
spyCoreWarning = core.warning as jest.Mock;
|
||||
spyCoreWarning = jest.spyOn(core, 'warning');
|
||||
spyCoreWarning.mockImplementation(() => {});
|
||||
});
|
||||
|
||||
@@ -161,7 +123,7 @@ describe('getAvailableVersions', () => {
|
||||
'build correct url for %s',
|
||||
async (
|
||||
installerOptions: JavaInstallerOptions,
|
||||
impl: AdoptImplementationType,
|
||||
impl: AdoptImplementation,
|
||||
expectedParameters
|
||||
) => {
|
||||
const distribution = new AdoptDistribution(installerOptions, impl);
|
||||
@@ -242,7 +204,7 @@ describe('getAvailableVersions', () => {
|
||||
[AdoptImplementation.OpenJ9, 'jre', 'Java_Adopt-OpenJ9_jre']
|
||||
])(
|
||||
'find right toolchain folder',
|
||||
(impl: AdoptImplementationType, packageType: string, expected: string) => {
|
||||
(impl: AdoptImplementation, packageType: string, expected: string) => {
|
||||
const distribution = new AdoptDistribution(
|
||||
{
|
||||
version: '11',
|
||||
@@ -301,11 +263,11 @@ describe('findPackageForDownload', () => {
|
||||
url: 'https://example.test/temurin-11.tar.gz'
|
||||
};
|
||||
const temurinFindPackageForDownload = jest
|
||||
.fn<any>()
|
||||
.fn()
|
||||
.mockResolvedValue(temurinRelease);
|
||||
const temurinDistribution = {
|
||||
findPackageForDownload: temurinFindPackageForDownload
|
||||
} as any;
|
||||
} as unknown as TemurinDistribution;
|
||||
|
||||
const distribution = new AdoptDistribution(
|
||||
{
|
||||
@@ -317,7 +279,7 @@ describe('findPackageForDownload', () => {
|
||||
AdoptImplementation.Hotspot,
|
||||
temurinDistribution
|
||||
);
|
||||
const adoptLookupSpy = jest.fn<any>();
|
||||
const adoptLookupSpy = jest.fn();
|
||||
distribution['getAvailableVersions'] = adoptLookupSpy;
|
||||
|
||||
const resolvedVersion = await distribution['findPackageForDownload']('11');
|
||||
|
||||
@@ -1,90 +1,19 @@
|
||||
import {
|
||||
jest,
|
||||
describe,
|
||||
it,
|
||||
expect,
|
||||
beforeEach,
|
||||
afterEach,
|
||||
beforeAll,
|
||||
afterAll
|
||||
} from '@jest/globals';
|
||||
import type {
|
||||
JavaDownloadRelease,
|
||||
JavaInstallerOptions,
|
||||
JavaInstallerResults
|
||||
} from '../../src/distributions/base-models.js';
|
||||
import * as tc from '@actions/tool-cache';
|
||||
import * as core from '@actions/core';
|
||||
import * as util from '../../src/util';
|
||||
|
||||
import path from 'path';
|
||||
import * as semver from 'semver';
|
||||
|
||||
import {JavaBase} from '../../src/distributions/base-installer';
|
||||
import {
|
||||
JavaDownloadRelease,
|
||||
JavaInstallerOptions,
|
||||
JavaInstallerResults
|
||||
} from '../../src/distributions/base-models';
|
||||
|
||||
import os from 'os';
|
||||
|
||||
// Mock @actions/core before importing source modules that depend on it
|
||||
jest.unstable_mockModule('@actions/core', () => ({
|
||||
info: jest.fn(),
|
||||
warning: jest.fn(),
|
||||
debug: jest.fn(),
|
||||
error: jest.fn(),
|
||||
notice: jest.fn(),
|
||||
setFailed: jest.fn(),
|
||||
setOutput: jest.fn(),
|
||||
getInput: jest.fn(),
|
||||
getBooleanInput: jest.fn(),
|
||||
getMultilineInput: jest.fn(),
|
||||
addPath: jest.fn(),
|
||||
exportVariable: jest.fn(),
|
||||
saveState: jest.fn(),
|
||||
getState: jest.fn(),
|
||||
setSecret: jest.fn(),
|
||||
isDebug: jest.fn(() => false),
|
||||
startGroup: jest.fn(),
|
||||
endGroup: jest.fn(),
|
||||
group: jest.fn((_name: string, fn: () => Promise<unknown>) => fn()),
|
||||
toPlatformPath: jest.fn((p: string) => p),
|
||||
toWin32Path: jest.fn((p: string) => p),
|
||||
toPosixPath: jest.fn((p: string) => p)
|
||||
}));
|
||||
|
||||
jest.unstable_mockModule('@actions/tool-cache', () => ({
|
||||
find: jest.fn(),
|
||||
findAllVersions: jest.fn(),
|
||||
downloadTool: jest.fn(),
|
||||
extractZip: jest.fn(),
|
||||
extractTar: jest.fn(),
|
||||
extract7z: jest.fn(),
|
||||
extractXar: jest.fn(),
|
||||
cacheDir: jest.fn(),
|
||||
cacheFile: jest.fn(),
|
||||
getManifestFromRepo: jest.fn(),
|
||||
findFromManifest: jest.fn(),
|
||||
evaluateVersions: jest.fn(),
|
||||
HTTPError: class HTTPError extends Error {
|
||||
httpStatusCode: number;
|
||||
constructor(statusCode: number) {
|
||||
super(`HTTP Error: ${statusCode}`);
|
||||
this.httpStatusCode = statusCode;
|
||||
}
|
||||
}
|
||||
}));
|
||||
|
||||
const real_util_module = await import('../../src/util.js');
|
||||
jest.unstable_mockModule('../../src/util.js', () => ({
|
||||
...real_util_module,
|
||||
extractJdkFile: jest.fn(),
|
||||
getDownloadArchiveExtension: jest.fn(),
|
||||
getToolcachePath: jest.fn(),
|
||||
isJobStatusSuccess: jest.fn(),
|
||||
renameWinArchive: jest.fn(),
|
||||
isVersionSatisfies: real_util_module.isVersionSatisfies,
|
||||
getTempDir: real_util_module.getTempDir
|
||||
}));
|
||||
|
||||
// Dynamic imports after mocking
|
||||
const core = await import('@actions/core');
|
||||
const tc = await import('@actions/tool-cache');
|
||||
const util = await import('../../src/util.js');
|
||||
const {JavaBase} = await import('../../src/distributions/base-installer.js');
|
||||
|
||||
class EmptyJavaBase extends JavaBase {
|
||||
constructor(installerOptions: JavaInstallerOptions) {
|
||||
super('Empty', installerOptions);
|
||||
@@ -124,12 +53,12 @@ describe('findInToolcache', () => {
|
||||
const javaPath = path.join('Java_Empty_jdk', actualJavaVersion, 'x64');
|
||||
|
||||
let mockJavaBase: EmptyJavaBase;
|
||||
let spyGetToolcachePath: any;
|
||||
let spyTcFindAllVersions: any;
|
||||
let spyGetToolcachePath: jest.SpyInstance;
|
||||
let spyTcFindAllVersions: jest.SpyInstance;
|
||||
|
||||
beforeEach(() => {
|
||||
spyGetToolcachePath = util.getToolcachePath as jest.Mock;
|
||||
spyTcFindAllVersions = tc.findAllVersions as jest.Mock;
|
||||
spyGetToolcachePath = jest.spyOn(util, 'getToolcachePath');
|
||||
spyTcFindAllVersions = jest.spyOn(tc, 'findAllVersions');
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
@@ -312,17 +241,17 @@ describe('setupJava', () => {
|
||||
|
||||
let mockJavaBase: EmptyJavaBase;
|
||||
|
||||
let spyGetToolcachePath: any;
|
||||
let spyTcFindAllVersions: any;
|
||||
let spyCoreDebug: any;
|
||||
let spyCoreInfo: any;
|
||||
let spyCoreExportVariable: any;
|
||||
let spyCoreAddPath: any;
|
||||
let spyCoreSetOutput: any;
|
||||
let spyCoreError: any;
|
||||
let spyGetToolcachePath: jest.SpyInstance;
|
||||
let spyTcFindAllVersions: jest.SpyInstance;
|
||||
let spyCoreDebug: jest.SpyInstance;
|
||||
let spyCoreInfo: jest.SpyInstance;
|
||||
let spyCoreExportVariable: jest.SpyInstance;
|
||||
let spyCoreAddPath: jest.SpyInstance;
|
||||
let spyCoreSetOutput: jest.SpyInstance;
|
||||
let spyCoreError: jest.SpyInstance;
|
||||
|
||||
beforeEach(() => {
|
||||
spyGetToolcachePath = util.getToolcachePath as jest.Mock;
|
||||
spyGetToolcachePath = jest.spyOn(util, 'getToolcachePath');
|
||||
spyGetToolcachePath.mockImplementation(
|
||||
(toolname: string, javaVersion: string, architecture: string) => {
|
||||
const semverVersion = new semver.Range(javaVersion);
|
||||
@@ -340,27 +269,27 @@ describe('setupJava', () => {
|
||||
}
|
||||
);
|
||||
|
||||
spyTcFindAllVersions = tc.findAllVersions as jest.Mock;
|
||||
spyTcFindAllVersions = jest.spyOn(tc, 'findAllVersions');
|
||||
spyTcFindAllVersions.mockReturnValue([installedJavaVersion]);
|
||||
|
||||
// Spy on core methods
|
||||
spyCoreDebug = core.debug as jest.Mock;
|
||||
spyCoreDebug = jest.spyOn(core, 'debug');
|
||||
spyCoreDebug.mockImplementation(() => undefined);
|
||||
|
||||
spyCoreInfo = core.info as jest.Mock;
|
||||
spyCoreInfo = jest.spyOn(core, 'info');
|
||||
spyCoreInfo.mockImplementation(() => undefined);
|
||||
|
||||
spyCoreAddPath = core.addPath as jest.Mock;
|
||||
spyCoreAddPath = jest.spyOn(core, 'addPath');
|
||||
spyCoreAddPath.mockImplementation(() => undefined);
|
||||
|
||||
spyCoreExportVariable = core.exportVariable as jest.Mock;
|
||||
spyCoreExportVariable = jest.spyOn(core, 'exportVariable');
|
||||
spyCoreExportVariable.mockImplementation(() => undefined);
|
||||
|
||||
spyCoreSetOutput = core.setOutput as jest.Mock;
|
||||
spyCoreSetOutput = jest.spyOn(core, 'setOutput');
|
||||
spyCoreSetOutput.mockImplementation(() => undefined);
|
||||
|
||||
// Mock core.error to suppress error logs
|
||||
spyCoreError = core.error as jest.Mock;
|
||||
spyCoreError = jest.spyOn(core, 'error');
|
||||
spyCoreError.mockImplementation(() => undefined);
|
||||
|
||||
jest.spyOn(os, 'arch').mockReturnValue('x86' as ReturnType<typeof os.arch>);
|
||||
@@ -420,29 +349,6 @@ describe('setupJava', () => {
|
||||
expect(spyCoreInfo).not.toHaveBeenCalledWith('Trying to download...');
|
||||
});
|
||||
|
||||
it('should resolve the latest version from remote when java-version is "latest", even if a version is cached', async () => {
|
||||
mockJavaBase = new EmptyJavaBase({
|
||||
version: 'latest',
|
||||
architecture: 'x86',
|
||||
packageType: 'jdk',
|
||||
checkLatest: false
|
||||
});
|
||||
|
||||
await expect(mockJavaBase.setupJava()).resolves.toEqual({
|
||||
version: actualJavaVersion,
|
||||
path: javaPathInstalled
|
||||
});
|
||||
|
||||
// `latest` must bypass the tool-cache short-circuit and always resolve remotely
|
||||
expect(spyCoreInfo).toHaveBeenCalledWith(
|
||||
'Trying to resolve the latest version from remote'
|
||||
);
|
||||
expect(spyCoreInfo).toHaveBeenCalledWith('Trying to download...');
|
||||
expect(spyCoreInfo).not.toHaveBeenCalledWith(
|
||||
`Resolved Java ${installedJavaVersion} from tool-cache`
|
||||
);
|
||||
});
|
||||
|
||||
it.each([
|
||||
[
|
||||
{
|
||||
@@ -767,18 +673,11 @@ describe('normalizeVersion', () => {
|
||||
const DummyJavaBase = JavaBase as any;
|
||||
|
||||
it.each([
|
||||
['11', {version: '11', stable: true, latest: false}],
|
||||
['11.0', {version: '11.0', stable: true, latest: false}],
|
||||
['11.0.10', {version: '11.0.10', stable: true, latest: false}],
|
||||
['11-ea', {version: '11', stable: false, latest: false}],
|
||||
['11.0.2-ea', {version: '11.0.2', stable: false, latest: false}],
|
||||
['18.0.1.1', {version: '18.0.1+1', stable: true, latest: false}],
|
||||
['11.0.9.1', {version: '11.0.9+1', stable: true, latest: false}],
|
||||
['12.0.2.1.0', {version: '12.0.2+1.0', stable: true, latest: false}],
|
||||
['18.0.1.1-ea', {version: '18.0.1+1', stable: false, latest: false}],
|
||||
['latest', {version: 'x', stable: true, latest: true}],
|
||||
['LATEST', {version: 'x', stable: true, latest: true}],
|
||||
[' Latest ', {version: 'x', stable: true, latest: true}]
|
||||
['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
|
||||
@@ -793,17 +692,6 @@ describe('normalizeVersion', () => {
|
||||
`The string '${version}' is not valid SemVer notation for a Java version. Please check README file for code snippets and more detailed information`
|
||||
);
|
||||
});
|
||||
|
||||
it.each(['latest-ea', 'latest.1', 'LATEST-EA', ' latest-ea '])(
|
||||
'normalizeVersion should throw a targeted error for latest combined with a qualifier (%s)',
|
||||
version => {
|
||||
expect(
|
||||
DummyJavaBase.prototype.normalizeVersion.bind(null, version)
|
||||
).toThrow(
|
||||
`The 'latest' alias resolves stable (GA) releases only and cannot be combined with '-ea' or other qualifiers (received '${version}'). Use 'latest' on its own, or specify a concrete version.`
|
||||
);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
describe('createVersionNotFoundError', () => {
|
||||
|
||||
@@ -1,62 +1,17 @@
|
||||
import {
|
||||
jest,
|
||||
describe,
|
||||
it,
|
||||
expect,
|
||||
beforeEach,
|
||||
afterEach,
|
||||
beforeAll,
|
||||
afterAll
|
||||
} from '@jest/globals';
|
||||
import type {JavaInstallerOptions} from '../../src/distributions/base-models.js';
|
||||
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 * as core from '@actions/core';
|
||||
|
||||
import manifestData from '../data/corretto.json' with {type: 'json'};
|
||||
|
||||
// Mock @actions/core before importing source modules that depend on it
|
||||
jest.unstable_mockModule('@actions/core', () => ({
|
||||
info: jest.fn(),
|
||||
warning: jest.fn(),
|
||||
debug: jest.fn(),
|
||||
error: jest.fn(),
|
||||
notice: jest.fn(),
|
||||
setFailed: jest.fn(),
|
||||
setOutput: jest.fn(),
|
||||
getInput: jest.fn(),
|
||||
getBooleanInput: jest.fn(),
|
||||
getMultilineInput: jest.fn(),
|
||||
addPath: jest.fn(),
|
||||
exportVariable: jest.fn(),
|
||||
saveState: jest.fn(),
|
||||
getState: jest.fn(),
|
||||
setSecret: jest.fn(),
|
||||
isDebug: jest.fn(() => false),
|
||||
startGroup: jest.fn(),
|
||||
endGroup: jest.fn(),
|
||||
group: jest.fn((_name: string, fn: () => Promise<unknown>) => fn()),
|
||||
toPlatformPath: jest.fn((p: string) => p),
|
||||
toWin32Path: jest.fn((p: string) => p),
|
||||
toPosixPath: jest.fn((p: string) => p)
|
||||
}));
|
||||
|
||||
const real_util_module = await import('../../src/util.js');
|
||||
jest.unstable_mockModule('../../src/util.js', () => ({
|
||||
...real_util_module,
|
||||
getDownloadArchiveExtension: jest.fn()
|
||||
}));
|
||||
|
||||
// Dynamic imports after mocking
|
||||
const core = await import('@actions/core');
|
||||
const {CorrettoDistribution} =
|
||||
await import('../../src/distributions/corretto/installer.js');
|
||||
const util = await import('../../src/util.js');
|
||||
import manifestData from '../data/corretto.json';
|
||||
|
||||
describe('getAvailableVersions', () => {
|
||||
let spyHttpClient: ReturnType<typeof jest.spyOn>;
|
||||
let spyGetDownloadArchiveExtension: any;
|
||||
let spyCoreError: any;
|
||||
let spyHttpClient: jest.SpyInstance;
|
||||
let spyGetDownloadArchiveExtension: jest.SpyInstance;
|
||||
let spyCoreError: jest.SpyInstance;
|
||||
|
||||
beforeEach(() => {
|
||||
spyHttpClient = jest.spyOn(HttpClient.prototype, 'getJson');
|
||||
@@ -65,11 +20,13 @@ describe('getAvailableVersions', () => {
|
||||
headers: {},
|
||||
result: manifestData
|
||||
});
|
||||
spyGetDownloadArchiveExtension =
|
||||
util.getDownloadArchiveExtension as jest.Mock;
|
||||
spyGetDownloadArchiveExtension = jest.spyOn(
|
||||
util,
|
||||
'getDownloadArchiveExtension'
|
||||
);
|
||||
|
||||
// Mock core.error to suppress error logs
|
||||
spyCoreError = core.error as jest.Mock;
|
||||
spyCoreError = jest.spyOn(core, 'error');
|
||||
spyCoreError.mockImplementation(() => {});
|
||||
});
|
||||
|
||||
@@ -204,24 +161,6 @@ describe('getAvailableVersions', () => {
|
||||
expect(availableVersion.url).toBe(expectedLink);
|
||||
});
|
||||
|
||||
it('with latest resolves to the newest available major version', async () => {
|
||||
const distribution = new CorrettoDistribution({
|
||||
version: 'latest',
|
||||
architecture: 'x64',
|
||||
packageType: 'jdk',
|
||||
checkLatest: false
|
||||
});
|
||||
mockPlatform(distribution, 'linux');
|
||||
|
||||
const availableVersion =
|
||||
await distribution['findPackageForDownload']('x');
|
||||
expect(availableVersion).not.toBeNull();
|
||||
// 18 is the newest major present in the mocked Corretto index
|
||||
expect(availableVersion.url).toBe(
|
||||
'https://corretto.aws/downloads/resources/18.0.0.37.1/amazon-corretto-18.0.0.37.1-linux-x64.tar.gz'
|
||||
);
|
||||
});
|
||||
|
||||
it('with unstable version expect to throw not supported error', async () => {
|
||||
const version = '18.0.1-ea';
|
||||
const distribution = new CorrettoDistribution({
|
||||
@@ -296,7 +235,7 @@ describe('getAvailableVersions', () => {
|
||||
});
|
||||
|
||||
const mockPlatform = (
|
||||
distribution: InstanceType<typeof CorrettoDistribution>,
|
||||
distribution: CorrettoDistribution,
|
||||
platform: string
|
||||
) => {
|
||||
distribution['getPlatformOption'] = () => platform;
|
||||
|
||||
@@ -1,59 +1,14 @@
|
||||
import {
|
||||
jest,
|
||||
describe,
|
||||
it,
|
||||
expect,
|
||||
beforeEach,
|
||||
afterEach,
|
||||
beforeAll,
|
||||
afterAll
|
||||
} from '@jest/globals';
|
||||
import {HttpClient} from '@actions/http-client';
|
||||
import {DragonwellDistribution} from '../../src/distributions/dragonwell/installer';
|
||||
import * as utils from '../../src/util';
|
||||
import * as core from '@actions/core';
|
||||
|
||||
import manifestData from '../data/dragonwell.json' with {type: 'json'};
|
||||
|
||||
// Mock @actions/core before importing source modules that depend on it
|
||||
jest.unstable_mockModule('@actions/core', () => ({
|
||||
info: jest.fn(),
|
||||
warning: jest.fn(),
|
||||
debug: jest.fn(),
|
||||
error: jest.fn(),
|
||||
notice: jest.fn(),
|
||||
setFailed: jest.fn(),
|
||||
setOutput: jest.fn(),
|
||||
getInput: jest.fn(),
|
||||
getBooleanInput: jest.fn(),
|
||||
getMultilineInput: jest.fn(),
|
||||
addPath: jest.fn(),
|
||||
exportVariable: jest.fn(),
|
||||
saveState: jest.fn(),
|
||||
getState: jest.fn(),
|
||||
setSecret: jest.fn(),
|
||||
isDebug: jest.fn(() => false),
|
||||
startGroup: jest.fn(),
|
||||
endGroup: jest.fn(),
|
||||
group: jest.fn((_name: string, fn: () => Promise<unknown>) => fn()),
|
||||
toPlatformPath: jest.fn((p: string) => p),
|
||||
toWin32Path: jest.fn((p: string) => p),
|
||||
toPosixPath: jest.fn((p: string) => p)
|
||||
}));
|
||||
|
||||
const real_util_module = await import('../../src/util.js');
|
||||
jest.unstable_mockModule('../../src/util.js', () => ({
|
||||
...real_util_module,
|
||||
getDownloadArchiveExtension: jest.fn()
|
||||
}));
|
||||
|
||||
// Dynamic imports after mocking
|
||||
const core = await import('@actions/core');
|
||||
const {DragonwellDistribution} =
|
||||
await import('../../src/distributions/dragonwell/installer.js');
|
||||
const utils = await import('../../src/util.js');
|
||||
import manifestData from '../data/dragonwell.json';
|
||||
|
||||
describe('getAvailableVersions', () => {
|
||||
let spyHttpClient: any;
|
||||
let spyUtilGetDownloadArchiveExtension: any;
|
||||
let spyCoreError: any;
|
||||
let spyHttpClient: jest.SpyInstance;
|
||||
let spyUtilGetDownloadArchiveExtension: jest.SpyInstance;
|
||||
let spyCoreError: jest.SpyInstance;
|
||||
|
||||
beforeEach(() => {
|
||||
spyHttpClient = jest.spyOn(HttpClient.prototype, 'getJson');
|
||||
@@ -63,12 +18,14 @@ describe('getAvailableVersions', () => {
|
||||
result: manifestData
|
||||
});
|
||||
|
||||
spyUtilGetDownloadArchiveExtension =
|
||||
utils.getDownloadArchiveExtension as jest.Mock;
|
||||
spyUtilGetDownloadArchiveExtension = jest.spyOn(
|
||||
utils,
|
||||
'getDownloadArchiveExtension'
|
||||
);
|
||||
spyUtilGetDownloadArchiveExtension.mockReturnValue('tar.gz');
|
||||
|
||||
// Mock core.error to suppress error logs
|
||||
spyCoreError = core.error as jest.Mock;
|
||||
spyCoreError = jest.spyOn(core, 'error');
|
||||
spyCoreError.mockImplementation(() => {});
|
||||
});
|
||||
|
||||
@@ -79,7 +36,7 @@ describe('getAvailableVersions', () => {
|
||||
});
|
||||
|
||||
const mockPlatform = (
|
||||
distribution: InstanceType<typeof DragonwellDistribution>,
|
||||
distribution: DragonwellDistribution,
|
||||
platform: string
|
||||
) => {
|
||||
distribution['getPlatformOption'] = () => platform;
|
||||
|
||||
@@ -1,116 +1,53 @@
|
||||
import {
|
||||
jest,
|
||||
describe,
|
||||
it,
|
||||
expect,
|
||||
beforeEach,
|
||||
beforeAll,
|
||||
afterAll
|
||||
} from '@jest/globals';
|
||||
import * as core from '@actions/core';
|
||||
import * as tc from '@actions/tool-cache';
|
||||
import * as http from '@actions/http-client';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import {
|
||||
GraalVMCommunityDistribution,
|
||||
GraalVMDistribution
|
||||
} from '../../src/distributions/graalvm/installer';
|
||||
import {getJavaDistribution} from '../../src/distributions/distribution-factory';
|
||||
import {JavaInstallerOptions} from '../../src/distributions/base-models';
|
||||
import * as util from '../../src/util';
|
||||
|
||||
// Mock @actions modules
|
||||
jest.unstable_mockModule('@actions/core', () => ({
|
||||
info: jest.fn(),
|
||||
warning: jest.fn(),
|
||||
debug: jest.fn(),
|
||||
error: jest.fn(),
|
||||
notice: jest.fn(),
|
||||
setFailed: jest.fn(),
|
||||
setOutput: jest.fn(),
|
||||
getInput: jest.fn(),
|
||||
getBooleanInput: jest.fn(),
|
||||
getMultilineInput: jest.fn(),
|
||||
addPath: jest.fn(),
|
||||
exportVariable: jest.fn(),
|
||||
saveState: jest.fn(),
|
||||
getState: jest.fn(),
|
||||
setSecret: jest.fn(),
|
||||
isDebug: jest.fn(() => false),
|
||||
startGroup: jest.fn(),
|
||||
endGroup: jest.fn(),
|
||||
group: jest.fn((_name: string, fn: () => Promise<unknown>) => fn()),
|
||||
toPlatformPath: jest.fn((p: string) => p),
|
||||
toWin32Path: jest.fn((p: string) => p),
|
||||
toPosixPath: jest.fn((p: string) => p)
|
||||
}));
|
||||
jest.mock('@actions/core');
|
||||
jest.mock('@actions/tool-cache');
|
||||
jest.mock('@actions/http-client');
|
||||
|
||||
jest.unstable_mockModule('@actions/tool-cache', () => ({
|
||||
find: jest.fn(),
|
||||
findAllVersions: jest.fn(),
|
||||
downloadTool: jest.fn(),
|
||||
extractZip: jest.fn(),
|
||||
extractTar: jest.fn(),
|
||||
extract7z: jest.fn(),
|
||||
extractXar: jest.fn(),
|
||||
cacheDir: jest.fn(),
|
||||
cacheFile: jest.fn(),
|
||||
getManifestFromRepo: jest.fn(),
|
||||
findFromManifest: jest.fn(),
|
||||
evaluateVersions: jest.fn()
|
||||
}));
|
||||
|
||||
jest.unstable_mockModule('@actions/http-client', () => ({
|
||||
HttpClient: jest.fn().mockImplementation(() => ({
|
||||
getJson: jest.fn(),
|
||||
head: jest.fn(),
|
||||
get: jest.fn()
|
||||
})),
|
||||
HttpClientError: class HttpClientError extends Error {
|
||||
statusCode: number;
|
||||
constructor(message: string, statusCode: number) {
|
||||
super(message);
|
||||
this.statusCode = statusCode;
|
||||
}
|
||||
},
|
||||
HttpCodes: {OK: 200, NotFound: 404, Unauthorized: 401, Forbidden: 403}
|
||||
}));
|
||||
|
||||
// Get real util first, then mock specific functions
|
||||
const realUtil = await import('../../src/util.js');
|
||||
jest.unstable_mockModule('../../src/util.js', () => ({
|
||||
...realUtil,
|
||||
jest.mock('../../src/util', () => ({
|
||||
...jest.requireActual('../../src/util'),
|
||||
extractJdkFile: jest.fn(),
|
||||
getDownloadArchiveExtension: jest.fn(),
|
||||
renameWinArchive: jest.fn(),
|
||||
getGitHubHttpHeaders: jest.fn().mockReturnValue({Accept: 'application/json'})
|
||||
}));
|
||||
|
||||
const real_fs_module = await import('fs');
|
||||
jest.unstable_mockModule('fs', () => ({
|
||||
...real_fs_module,
|
||||
default: {
|
||||
...real_fs_module.default,
|
||||
readdirSync: jest.fn(),
|
||||
existsSync: jest.fn()
|
||||
},
|
||||
jest.mock('fs', () => ({
|
||||
...jest.requireActual('fs'),
|
||||
readdirSync: jest.fn(),
|
||||
existsSync: jest.fn()
|
||||
}));
|
||||
|
||||
// Dynamic imports after mocking
|
||||
const core = await import('@actions/core');
|
||||
const tc = await import('@actions/tool-cache');
|
||||
const http = await import('@actions/http-client');
|
||||
const fs = (await import('fs')).default;
|
||||
const util = await import('../../src/util.js');
|
||||
const {GraalVMCommunityDistribution, GraalVMDistribution} =
|
||||
await import('../../src/distributions/graalvm/installer.js');
|
||||
const {getJavaDistribution} =
|
||||
await import('../../src/distributions/distribution-factory.js');
|
||||
|
||||
import type {JavaInstallerOptions} from '../../src/distributions/base-models.js';
|
||||
|
||||
beforeAll(() => {
|
||||
process.env.NODE_ENV = 'test';
|
||||
|
||||
if (!jest.isMockFunction(http.HttpClient)) {
|
||||
throw new Error('HTTP client must be mocked in tests!');
|
||||
}
|
||||
|
||||
if (!jest.isMockFunction(tc.downloadTool)) {
|
||||
throw new Error('Tool cache downloadTool must be mocked in tests!');
|
||||
}
|
||||
|
||||
console.log('✅ All external dependencies are properly mocked');
|
||||
});
|
||||
|
||||
describe('GraalVMDistribution', () => {
|
||||
let distribution: InstanceType<typeof GraalVMDistribution>;
|
||||
let communityDistribution: InstanceType<typeof GraalVMCommunityDistribution>;
|
||||
let mockHttpClient: any;
|
||||
let spyCoreError: any;
|
||||
let distribution: GraalVMDistribution;
|
||||
let communityDistribution: GraalVMCommunityDistribution;
|
||||
let mockHttpClient: jest.Mocked<http.HttpClient>;
|
||||
let spyCoreError: jest.SpyInstance;
|
||||
|
||||
const defaultOptions: JavaInstallerOptions = {
|
||||
version: '17',
|
||||
@@ -125,20 +62,23 @@ describe('GraalVMDistribution', () => {
|
||||
distribution = new GraalVMDistribution(defaultOptions);
|
||||
communityDistribution = new GraalVMCommunityDistribution(defaultOptions);
|
||||
|
||||
mockHttpClient = new (http.HttpClient as any)();
|
||||
mockHttpClient = new http.HttpClient() as jest.Mocked<http.HttpClient>;
|
||||
(distribution as any).http = mockHttpClient;
|
||||
(communityDistribution as any).http = mockHttpClient;
|
||||
|
||||
(util.getDownloadArchiveExtension as jest.Mock<any>).mockReturnValue(
|
||||
'tar.gz'
|
||||
);
|
||||
(util.getDownloadArchiveExtension as jest.Mock).mockReturnValue('tar.gz');
|
||||
|
||||
// Mock core.error to suppress error logs
|
||||
spyCoreError = core.error as jest.Mock;
|
||||
spyCoreError = jest.spyOn(core, 'error');
|
||||
spyCoreError.mockImplementation(() => {});
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
expect(jest.isMockFunction(http.HttpClient)).toBe(true);
|
||||
|
||||
expect(jest.isMockFunction(tc.downloadTool)).toBe(true);
|
||||
expect(jest.isMockFunction(tc.cacheDir)).toBe(true);
|
||||
|
||||
jest.restoreAllMocks();
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
@@ -173,24 +113,20 @@ describe('GraalVMDistribution', () => {
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
(tc.downloadTool as any).mockResolvedValue('/tmp/archive.tar.gz');
|
||||
(tc.cacheDir as any).mockResolvedValue('/cached/java/path');
|
||||
(tc.downloadTool as jest.Mock).mockResolvedValue('/tmp/archive.tar.gz');
|
||||
(tc.cacheDir as jest.Mock).mockResolvedValue('/cached/java/path');
|
||||
|
||||
(util.extractJdkFile as any).mockResolvedValue('/tmp/extracted');
|
||||
(util.extractJdkFile as jest.Mock).mockResolvedValue('/tmp/extracted');
|
||||
|
||||
// Mock renameWinArchive - it returns the same path (no renaming)
|
||||
(util.renameWinArchive as any).mockImplementation((p: string) => p);
|
||||
(util.renameWinArchive as jest.Mock).mockImplementation((p: string) => p);
|
||||
|
||||
(util.getDownloadArchiveExtension as jest.Mock<any>).mockReturnValue(
|
||||
'tar.gz'
|
||||
);
|
||||
(util.getDownloadArchiveExtension as jest.Mock).mockReturnValue('tar.gz');
|
||||
|
||||
// Mock fs.existsSync to return true for extracted path
|
||||
(fs.existsSync as jest.Mock<any>).mockReturnValue(true);
|
||||
(fs.existsSync as jest.Mock).mockReturnValue(true);
|
||||
|
||||
(fs.readdirSync as jest.Mock<any>).mockReturnValue([
|
||||
'graalvm-jdk-17.0.5'
|
||||
]);
|
||||
(fs.readdirSync as jest.Mock).mockReturnValue(['graalvm-jdk-17.0.5']);
|
||||
|
||||
jest
|
||||
.spyOn(distribution as any, 'getToolcacheVersionName')
|
||||
@@ -237,7 +173,7 @@ describe('GraalVMDistribution', () => {
|
||||
});
|
||||
|
||||
it('should throw error when extracted path does not exist', async () => {
|
||||
(fs.existsSync as jest.Mock<any>).mockReturnValue(false);
|
||||
(fs.existsSync as jest.Mock).mockReturnValue(false);
|
||||
|
||||
await expect(
|
||||
(distribution as any).downloadTool(javaRelease)
|
||||
@@ -251,8 +187,8 @@ describe('GraalVMDistribution', () => {
|
||||
});
|
||||
|
||||
it('should throw error when extracted directory is empty', async () => {
|
||||
(fs.existsSync as jest.Mock<any>).mockReturnValue(true);
|
||||
(fs.readdirSync as jest.Mock<any>).mockReturnValue([]);
|
||||
(fs.existsSync as jest.Mock).mockReturnValue(true);
|
||||
(fs.readdirSync as jest.Mock).mockReturnValue([]);
|
||||
|
||||
await expect(
|
||||
(distribution as any).downloadTool(javaRelease)
|
||||
@@ -267,7 +203,7 @@ describe('GraalVMDistribution', () => {
|
||||
|
||||
it('should handle download errors', async () => {
|
||||
const downloadError = new Error('Network error during download');
|
||||
(tc.downloadTool as any).mockRejectedValue(downloadError);
|
||||
(tc.downloadTool as jest.Mock).mockRejectedValue(downloadError);
|
||||
|
||||
await expect(
|
||||
(distribution as any).downloadTool(javaRelease)
|
||||
@@ -280,7 +216,7 @@ describe('GraalVMDistribution', () => {
|
||||
|
||||
it('should handle extraction errors', async () => {
|
||||
const extractError = new Error('Failed to extract archive');
|
||||
(util.extractJdkFile as any).mockRejectedValue(extractError);
|
||||
(util.extractJdkFile as jest.Mock).mockRejectedValue(extractError);
|
||||
|
||||
await expect(
|
||||
(distribution as any).downloadTool(javaRelease)
|
||||
@@ -293,10 +229,8 @@ describe('GraalVMDistribution', () => {
|
||||
|
||||
it('should handle different archive extensions', async () => {
|
||||
// Test with a .zip file
|
||||
(util.getDownloadArchiveExtension as jest.Mock<any>).mockReturnValue(
|
||||
'zip'
|
||||
);
|
||||
(tc.downloadTool as any).mockResolvedValue('/tmp/archive.zip');
|
||||
(util.getDownloadArchiveExtension as jest.Mock).mockReturnValue('zip');
|
||||
(tc.downloadTool as jest.Mock).mockResolvedValue('/tmp/archive.zip');
|
||||
|
||||
const zipRelease = {
|
||||
version: '17.0.5',
|
||||
@@ -375,7 +309,7 @@ describe('GraalVMDistribution', () => {
|
||||
it('should construct correct URL for specific version', async () => {
|
||||
const mockResponse = {
|
||||
message: {statusCode: 200}
|
||||
} as any;
|
||||
} as http.HttpClientResponse;
|
||||
mockHttpClient.head.mockResolvedValue(mockResponse);
|
||||
|
||||
const result = await (distribution as any).findPackageForDownload(
|
||||
@@ -392,7 +326,7 @@ describe('GraalVMDistribution', () => {
|
||||
it('should construct correct URL for major version (latest)', async () => {
|
||||
const mockResponse = {
|
||||
message: {statusCode: 200}
|
||||
} as any;
|
||||
} as http.HttpClientResponse;
|
||||
mockHttpClient.head.mockResolvedValue(mockResponse);
|
||||
|
||||
const result = await (distribution as any).findPackageForDownload('21');
|
||||
@@ -417,61 +351,6 @@ describe('GraalVMDistribution', () => {
|
||||
);
|
||||
});
|
||||
|
||||
describe('latest alias', () => {
|
||||
it('resolves the newest major version from the Adoptium API', async () => {
|
||||
const latestDistribution = new GraalVMDistribution({
|
||||
...defaultOptions,
|
||||
version: 'latest'
|
||||
});
|
||||
(latestDistribution as any).http = mockHttpClient;
|
||||
jest
|
||||
.spyOn(latestDistribution, 'getPlatform')
|
||||
.mockReturnValue('linux');
|
||||
mockHttpClient.getJson.mockResolvedValue({
|
||||
statusCode: 200,
|
||||
result: {most_recent_feature_release: 25},
|
||||
headers: {}
|
||||
});
|
||||
mockHttpClient.head.mockResolvedValue({
|
||||
message: {statusCode: 200}
|
||||
});
|
||||
|
||||
const result = await (
|
||||
latestDistribution as any
|
||||
).findPackageForDownload('x');
|
||||
|
||||
expect(result).toEqual({
|
||||
url: 'https://download.oracle.com/graalvm/25/latest/graalvm-jdk-25_linux-x64_bin.tar.gz',
|
||||
version: '25'
|
||||
});
|
||||
});
|
||||
|
||||
it('throws an actionable error when the latest major is not yet available', async () => {
|
||||
const latestDistribution = new GraalVMDistribution({
|
||||
...defaultOptions,
|
||||
version: 'latest'
|
||||
});
|
||||
(latestDistribution as any).http = mockHttpClient;
|
||||
jest
|
||||
.spyOn(latestDistribution, 'getPlatform')
|
||||
.mockReturnValue('linux');
|
||||
mockHttpClient.getJson.mockResolvedValue({
|
||||
statusCode: 200,
|
||||
result: {most_recent_feature_release: 25},
|
||||
headers: {}
|
||||
});
|
||||
mockHttpClient.head.mockResolvedValue({
|
||||
message: {statusCode: 404}
|
||||
});
|
||||
|
||||
await expect(
|
||||
(latestDistribution as any).findPackageForDownload('x')
|
||||
).rejects.toThrow(
|
||||
/is not yet available for the GraalVM distribution/
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('should throw error for JDK versions less than 17', async () => {
|
||||
await expect(
|
||||
(distribution as any).findPackageForDownload('11')
|
||||
@@ -495,7 +374,7 @@ describe('GraalVMDistribution', () => {
|
||||
it('should throw error when file not found (404)', async () => {
|
||||
const mockResponse = {
|
||||
message: {statusCode: 404}
|
||||
} as any;
|
||||
} as http.HttpClientResponse;
|
||||
mockHttpClient.head.mockResolvedValue(mockResponse);
|
||||
|
||||
// Verify the error is thrown with the expected message
|
||||
@@ -516,7 +395,7 @@ describe('GraalVMDistribution', () => {
|
||||
it('should throw error for unauthorized access (401)', async () => {
|
||||
const mockResponse = {
|
||||
message: {statusCode: 401}
|
||||
} as any;
|
||||
} as http.HttpClientResponse;
|
||||
mockHttpClient.head.mockResolvedValue(mockResponse);
|
||||
|
||||
await expect(
|
||||
@@ -529,7 +408,7 @@ describe('GraalVMDistribution', () => {
|
||||
it('should throw error for forbidden access (403)', async () => {
|
||||
const mockResponse = {
|
||||
message: {statusCode: 403}
|
||||
} as any;
|
||||
} as http.HttpClientResponse;
|
||||
mockHttpClient.head.mockResolvedValue(mockResponse);
|
||||
|
||||
await expect(
|
||||
@@ -545,7 +424,7 @@ describe('GraalVMDistribution', () => {
|
||||
statusCode: 500,
|
||||
statusMessage: 'Internal Server Error'
|
||||
}
|
||||
} as any;
|
||||
} as http.HttpClientResponse;
|
||||
mockHttpClient.head.mockResolvedValue(mockResponse);
|
||||
|
||||
await expect(
|
||||
@@ -558,7 +437,7 @@ describe('GraalVMDistribution', () => {
|
||||
it('should throw error for other HTTP errors without status message', async () => {
|
||||
const mockResponse = {
|
||||
message: {statusCode: 500}
|
||||
} as any;
|
||||
} as http.HttpClientResponse;
|
||||
mockHttpClient.head.mockResolvedValue(mockResponse);
|
||||
|
||||
await expect(
|
||||
@@ -834,7 +713,7 @@ describe('GraalVMDistribution', () => {
|
||||
}
|
||||
];
|
||||
|
||||
let fetchEASpy: any;
|
||||
let fetchEASpy: jest.SpyInstance;
|
||||
|
||||
beforeEach(() => {
|
||||
fetchEASpy = jest.spyOn(distribution as any, 'fetchEAJson');
|
||||
@@ -1053,7 +932,7 @@ describe('GraalVMDistribution', () => {
|
||||
|
||||
const mockResponse = {
|
||||
message: {statusCode: 200}
|
||||
} as any;
|
||||
} as http.HttpClientResponse;
|
||||
mockHttpClient.head.mockResolvedValue(mockResponse);
|
||||
|
||||
const result = await (distribution as any).findPackageForDownload('17');
|
||||
@@ -1081,7 +960,7 @@ describe('GraalVMDistribution', () => {
|
||||
|
||||
const mockResponse = {
|
||||
message: {statusCode: 200}
|
||||
} as any;
|
||||
} as http.HttpClientResponse;
|
||||
mockHttpClient.head.mockResolvedValue(mockResponse);
|
||||
|
||||
const result = await (distribution as any).findPackageForDownload('17');
|
||||
@@ -1170,60 +1049,6 @@ describe('GraalVMDistribution', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('resolves latest to the newest GA across all Community majors without calling Adoptium', async () => {
|
||||
const latestCommunity = new GraalVMCommunityDistribution({
|
||||
...defaultOptions,
|
||||
version: 'latest'
|
||||
});
|
||||
(latestCommunity as any).http = mockHttpClient;
|
||||
jest.spyOn(latestCommunity, 'getPlatform').mockReturnValue('linux');
|
||||
|
||||
mockHttpClient.getJson.mockResolvedValue({
|
||||
result: [
|
||||
{
|
||||
draft: false,
|
||||
prerelease: false,
|
||||
assets: [
|
||||
{
|
||||
name: 'graalvm-community-jdk-21.0.2_linux-x64_bin.tar.gz',
|
||||
browser_download_url:
|
||||
'https://github.com/graalvm/graalvm-ce-builds/releases/download/jdk-21.0.2/graalvm-community-jdk-21.0.2_linux-x64_bin.tar.gz'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
draft: false,
|
||||
prerelease: false,
|
||||
assets: [
|
||||
{
|
||||
name: 'graalvm-community-jdk-24.0.1_linux-x64_bin.tar.gz',
|
||||
browser_download_url:
|
||||
'https://github.com/graalvm/graalvm-ce-builds/releases/download/jdk-24.0.1/graalvm-community-jdk-24.0.1_linux-x64_bin.tar.gz'
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
statusCode: 200,
|
||||
headers: {}
|
||||
});
|
||||
|
||||
const result = await (latestCommunity as any).findPackageForDownload(
|
||||
'x'
|
||||
);
|
||||
|
||||
expect(result).toEqual({
|
||||
url: 'https://github.com/graalvm/graalvm-ce-builds/releases/download/jdk-24.0.1/graalvm-community-jdk-24.0.1_linux-x64_bin.tar.gz',
|
||||
version: '24.0.1'
|
||||
});
|
||||
// The Community release list is authoritative, so the Adoptium
|
||||
// most_recent_feature_release endpoint must not be consulted.
|
||||
expect(mockHttpClient.getJson).toHaveBeenCalledTimes(1);
|
||||
expect(mockHttpClient.getJson).toHaveBeenCalledWith(
|
||||
expect.stringContaining('graalvm-ce-builds/releases'),
|
||||
expect.anything()
|
||||
);
|
||||
});
|
||||
|
||||
it('should reject GraalVM Community early access requests', async () => {
|
||||
(communityDistribution as any).stable = false;
|
||||
|
||||
|
||||
@@ -1,53 +1,14 @@
|
||||
import {
|
||||
jest,
|
||||
describe,
|
||||
it,
|
||||
expect,
|
||||
beforeEach,
|
||||
afterEach,
|
||||
beforeAll,
|
||||
afterAll
|
||||
} from '@jest/globals';
|
||||
import https from 'https';
|
||||
import {HttpClient} from '@actions/http-client';
|
||||
import {JetBrainsDistribution} from '../../src/distributions/jetbrains/installer';
|
||||
|
||||
import manifestData from '../data/jetbrains.json' with {type: 'json'};
|
||||
import manifestData from '../data/jetbrains.json';
|
||||
import os from 'os';
|
||||
|
||||
// Mock @actions/core before importing source modules that depend on it
|
||||
jest.unstable_mockModule('@actions/core', () => ({
|
||||
info: jest.fn(),
|
||||
warning: jest.fn(),
|
||||
debug: jest.fn(),
|
||||
error: jest.fn(),
|
||||
notice: jest.fn(),
|
||||
setFailed: jest.fn(),
|
||||
setOutput: jest.fn(),
|
||||
getInput: jest.fn(),
|
||||
getBooleanInput: jest.fn(),
|
||||
getMultilineInput: jest.fn(),
|
||||
addPath: jest.fn(),
|
||||
exportVariable: jest.fn(),
|
||||
saveState: jest.fn(),
|
||||
getState: jest.fn(),
|
||||
setSecret: jest.fn(),
|
||||
isDebug: jest.fn(() => false),
|
||||
startGroup: jest.fn(),
|
||||
endGroup: jest.fn(),
|
||||
group: jest.fn((_name: string, fn: () => Promise<unknown>) => fn()),
|
||||
toPlatformPath: jest.fn((p: string) => p),
|
||||
toWin32Path: jest.fn((p: string) => p),
|
||||
toPosixPath: jest.fn((p: string) => p)
|
||||
}));
|
||||
|
||||
// Dynamic imports after mocking
|
||||
const core = await import('@actions/core');
|
||||
const {JetBrainsDistribution} =
|
||||
await import('../../src/distributions/jetbrains/installer.js');
|
||||
import * as core from '@actions/core';
|
||||
|
||||
describe('getAvailableVersions', () => {
|
||||
let spyHttpClient: any;
|
||||
let spyCoreError: any;
|
||||
let spyHttpClient: jest.SpyInstance;
|
||||
let spyCoreError: jest.SpyInstance;
|
||||
|
||||
beforeEach(() => {
|
||||
spyHttpClient = jest.spyOn(HttpClient.prototype, 'getJson');
|
||||
@@ -58,7 +19,7 @@ describe('getAvailableVersions', () => {
|
||||
});
|
||||
|
||||
// Mock core.error to suppress error logs
|
||||
spyCoreError = core.error as jest.Mock;
|
||||
spyCoreError = jest.spyOn(core, 'error');
|
||||
spyCoreError.mockImplementation(() => {});
|
||||
});
|
||||
|
||||
@@ -70,17 +31,11 @@ describe('getAvailableVersions', () => {
|
||||
|
||||
it('load available versions', async () => {
|
||||
spyHttpClient = jest.spyOn(HttpClient.prototype, 'getJson');
|
||||
spyHttpClient
|
||||
.mockReturnValueOnce({
|
||||
statusCode: 200,
|
||||
headers: {},
|
||||
result: manifestData as any
|
||||
})
|
||||
.mockReturnValue({
|
||||
statusCode: 200,
|
||||
headers: {},
|
||||
result: []
|
||||
});
|
||||
spyHttpClient.mockReturnValueOnce({
|
||||
statusCode: 200,
|
||||
headers: {},
|
||||
result: manifestData as any
|
||||
});
|
||||
|
||||
const distribution = new JetBrainsDistribution({
|
||||
version: '17',
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import {KonaDistribution} from '../../src/distributions/kona/installer.js';
|
||||
import {KonaDistribution} from '../../src/distributions/kona/installer';
|
||||
|
||||
import manifestData from '../data/kona.json' with {type: 'json'};
|
||||
import manifestData from '../data/kona.json';
|
||||
|
||||
function mockDistr(
|
||||
version: string,
|
||||
|
||||
@@ -1,56 +1,17 @@
|
||||
import {LibericaDistributions} from '../../src/distributions/liberica/installer';
|
||||
import {
|
||||
jest,
|
||||
describe,
|
||||
it,
|
||||
expect,
|
||||
beforeEach,
|
||||
afterEach,
|
||||
beforeAll,
|
||||
afterAll
|
||||
} from '@jest/globals';
|
||||
import type {
|
||||
ArchitectureOptions,
|
||||
LibericaVersion
|
||||
} from '../../src/distributions/liberica/models.js';
|
||||
} from '../../src/distributions/liberica/models';
|
||||
import {HttpClient} from '@actions/http-client';
|
||||
import os from 'os';
|
||||
import * as core from '@actions/core';
|
||||
|
||||
import manifestData from '../data/liberica.json' with {type: 'json'};
|
||||
|
||||
// Mock @actions/core before importing source modules that depend on it
|
||||
jest.unstable_mockModule('@actions/core', () => ({
|
||||
info: jest.fn(),
|
||||
warning: jest.fn(),
|
||||
debug: jest.fn(),
|
||||
error: jest.fn(),
|
||||
notice: jest.fn(),
|
||||
setFailed: jest.fn(),
|
||||
setOutput: jest.fn(),
|
||||
getInput: jest.fn(),
|
||||
getBooleanInput: jest.fn(),
|
||||
getMultilineInput: jest.fn(),
|
||||
addPath: jest.fn(),
|
||||
exportVariable: jest.fn(),
|
||||
saveState: jest.fn(),
|
||||
getState: jest.fn(),
|
||||
setSecret: jest.fn(),
|
||||
isDebug: jest.fn(() => false),
|
||||
startGroup: jest.fn(),
|
||||
endGroup: jest.fn(),
|
||||
group: jest.fn((_name: string, fn: () => Promise<unknown>) => fn()),
|
||||
toPlatformPath: jest.fn((p: string) => p),
|
||||
toWin32Path: jest.fn((p: string) => p),
|
||||
toPosixPath: jest.fn((p: string) => p)
|
||||
}));
|
||||
|
||||
// Dynamic imports after mocking
|
||||
const core = await import('@actions/core');
|
||||
const {LibericaDistributions} =
|
||||
await import('../../src/distributions/liberica/installer.js');
|
||||
import manifestData from '../data/liberica.json';
|
||||
|
||||
describe('getAvailableVersions', () => {
|
||||
let spyHttpClient: any;
|
||||
let spyCoreError: any;
|
||||
let spyHttpClient: jest.SpyInstance;
|
||||
let spyCoreError: jest.SpyInstance;
|
||||
|
||||
beforeEach(() => {
|
||||
spyHttpClient = jest.spyOn(HttpClient.prototype, 'getJson');
|
||||
@@ -61,7 +22,7 @@ describe('getAvailableVersions', () => {
|
||||
});
|
||||
|
||||
// Mock core.error to suppress error logs
|
||||
spyCoreError = core.error as jest.Mock;
|
||||
spyCoreError = jest.spyOn(core, 'error');
|
||||
spyCoreError.mockImplementation(() => {});
|
||||
});
|
||||
|
||||
@@ -223,7 +184,7 @@ describe('getArchitectureOptions', () => {
|
||||
});
|
||||
|
||||
describe('findPackageForDownload', () => {
|
||||
let distribution: InstanceType<typeof LibericaDistributions>;
|
||||
let distribution: LibericaDistributions;
|
||||
|
||||
beforeEach(() => {
|
||||
distribution = new LibericaDistributions({
|
||||
|
||||
@@ -1,56 +1,17 @@
|
||||
import {LibericaDistributions} from '../../src/distributions/liberica/installer';
|
||||
import {
|
||||
jest,
|
||||
describe,
|
||||
it,
|
||||
expect,
|
||||
beforeEach,
|
||||
afterEach,
|
||||
beforeAll,
|
||||
afterAll
|
||||
} from '@jest/globals';
|
||||
import type {
|
||||
ArchitectureOptions,
|
||||
LibericaVersion
|
||||
} from '../../src/distributions/liberica/models.js';
|
||||
} from '../../src/distributions/liberica/models';
|
||||
import {HttpClient} from '@actions/http-client';
|
||||
import os from 'os';
|
||||
import * as core from '@actions/core';
|
||||
|
||||
import manifestData from '../data/liberica-linux.json' with {type: 'json'};
|
||||
|
||||
// Mock @actions/core before importing source modules that depend on it
|
||||
jest.unstable_mockModule('@actions/core', () => ({
|
||||
info: jest.fn(),
|
||||
warning: jest.fn(),
|
||||
debug: jest.fn(),
|
||||
error: jest.fn(),
|
||||
notice: jest.fn(),
|
||||
setFailed: jest.fn(),
|
||||
setOutput: jest.fn(),
|
||||
getInput: jest.fn(),
|
||||
getBooleanInput: jest.fn(),
|
||||
getMultilineInput: jest.fn(),
|
||||
addPath: jest.fn(),
|
||||
exportVariable: jest.fn(),
|
||||
saveState: jest.fn(),
|
||||
getState: jest.fn(),
|
||||
setSecret: jest.fn(),
|
||||
isDebug: jest.fn(() => false),
|
||||
startGroup: jest.fn(),
|
||||
endGroup: jest.fn(),
|
||||
group: jest.fn((_name: string, fn: () => Promise<unknown>) => fn()),
|
||||
toPlatformPath: jest.fn((p: string) => p),
|
||||
toWin32Path: jest.fn((p: string) => p),
|
||||
toPosixPath: jest.fn((p: string) => p)
|
||||
}));
|
||||
|
||||
// Dynamic imports after mocking
|
||||
const core = await import('@actions/core');
|
||||
const {LibericaDistributions} =
|
||||
await import('../../src/distributions/liberica/installer.js');
|
||||
import manifestData from '../data/liberica-linux.json';
|
||||
|
||||
describe('getAvailableVersions', () => {
|
||||
let spyHttpClient: any;
|
||||
let spyCoreError: any;
|
||||
let spyHttpClient: jest.SpyInstance;
|
||||
let spyCoreError: jest.SpyInstance;
|
||||
|
||||
beforeEach(() => {
|
||||
spyHttpClient = jest.spyOn(HttpClient.prototype, 'getJson');
|
||||
@@ -61,7 +22,7 @@ describe('getAvailableVersions', () => {
|
||||
});
|
||||
|
||||
// Mock core.error to suppress error logs
|
||||
spyCoreError = core.error as jest.Mock;
|
||||
spyCoreError = jest.spyOn(core, 'error');
|
||||
spyCoreError.mockImplementation(() => {});
|
||||
});
|
||||
|
||||
@@ -223,7 +184,7 @@ describe('getArchitectureOptions', () => {
|
||||
});
|
||||
|
||||
describe('findPackageForDownload', () => {
|
||||
let distribution: InstanceType<typeof LibericaDistributions>;
|
||||
let distribution: LibericaDistributions;
|
||||
|
||||
beforeEach(() => {
|
||||
distribution = new LibericaDistributions({
|
||||
|
||||
@@ -1,219 +0,0 @@
|
||||
import {jest, describe, it, expect, beforeEach, afterEach} from '@jest/globals';
|
||||
import type {
|
||||
ArchitectureOptions,
|
||||
NikVersion
|
||||
} from '../../src/distributions/liberica-nik/models.js';
|
||||
import {HttpClient} from '@actions/http-client';
|
||||
|
||||
import manifestData from '../data/liberica-nik.json' with {type: 'json'};
|
||||
|
||||
// Mock @actions/core before importing source modules that depend on it
|
||||
jest.unstable_mockModule('@actions/core', () => ({
|
||||
info: jest.fn(),
|
||||
warning: jest.fn(),
|
||||
debug: jest.fn(),
|
||||
error: jest.fn(),
|
||||
notice: jest.fn(),
|
||||
setFailed: jest.fn(),
|
||||
setOutput: jest.fn(),
|
||||
getInput: jest.fn(),
|
||||
getBooleanInput: jest.fn(),
|
||||
getMultilineInput: jest.fn(),
|
||||
addPath: jest.fn(),
|
||||
exportVariable: jest.fn(),
|
||||
saveState: jest.fn(),
|
||||
getState: jest.fn(),
|
||||
setSecret: jest.fn(),
|
||||
isDebug: jest.fn(() => false),
|
||||
startGroup: jest.fn(),
|
||||
endGroup: jest.fn(),
|
||||
group: jest.fn((_name: string, fn: () => Promise<unknown>) => fn()),
|
||||
toPlatformPath: jest.fn((p: string) => p),
|
||||
toWin32Path: jest.fn((p: string) => p),
|
||||
toPosixPath: jest.fn((p: string) => p)
|
||||
}));
|
||||
|
||||
// Dynamic imports after mocking
|
||||
const {LibericaNikDistributions} =
|
||||
await import('../../src/distributions/liberica-nik/installer.js');
|
||||
|
||||
const ADDITIONAL_PARAMS =
|
||||
'&installation-type=archive&fields=downloadUrl%2Cversion%2Ccomponents%2Ccomponent%2Cembedded';
|
||||
|
||||
describe('getAvailableVersions', () => {
|
||||
let spyHttpClient: any;
|
||||
|
||||
beforeEach(() => {
|
||||
spyHttpClient = jest.spyOn(HttpClient.prototype, 'getJson');
|
||||
spyHttpClient.mockReturnValue({
|
||||
statusCode: 200,
|
||||
headers: {},
|
||||
result: manifestData as NikVersion[]
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
jest.resetAllMocks();
|
||||
jest.clearAllMocks();
|
||||
jest.restoreAllMocks();
|
||||
});
|
||||
|
||||
it.each([
|
||||
[
|
||||
{version: '21', architecture: 'x64', packageType: 'jdk'},
|
||||
'bundle-type=standard&bitness=64&arch=x86&build-type=all'
|
||||
],
|
||||
[
|
||||
{version: '21-ea', architecture: 'x64', packageType: 'jdk'},
|
||||
'bundle-type=standard&bitness=64&arch=x86&build-type=ea'
|
||||
],
|
||||
[
|
||||
{version: '21', architecture: 'aarch64', packageType: 'jdk'},
|
||||
'bundle-type=standard&bitness=64&arch=arm&build-type=all'
|
||||
],
|
||||
[
|
||||
{version: '21', architecture: 'x64', packageType: 'jdk+fx'},
|
||||
'bundle-type=full&bitness=64&arch=x86&build-type=all'
|
||||
]
|
||||
])('build correct url for %s -> %s', async (input, urlParams) => {
|
||||
const distribution = new LibericaNikDistributions({
|
||||
...input,
|
||||
checkLatest: false
|
||||
});
|
||||
distribution['getPlatformOption'] = () => 'linux';
|
||||
const buildUrl = `https://api.bell-sw.com/v1/nik/releases?os=linux&${urlParams}${ADDITIONAL_PARAMS}`;
|
||||
|
||||
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 LibericaNikDistributions({
|
||||
version: '21',
|
||||
architecture: 'x64',
|
||||
packageType: 'jdk',
|
||||
checkLatest: false
|
||||
});
|
||||
const availableVersions = await distribution['getAvailableVersions']();
|
||||
expect(availableVersions).toEqual(manifestData);
|
||||
});
|
||||
});
|
||||
|
||||
describe('getArchitectureOptions', () => {
|
||||
it.each([
|
||||
['x64', {bitness: '64', arch: 'x86'}],
|
||||
['aarch64', {bitness: '64', arch: 'arm'}]
|
||||
] as [string, ArchitectureOptions][])(
|
||||
'parse architecture %s -> %s',
|
||||
(input, expected) => {
|
||||
const distributions = new LibericaNikDistributions({
|
||||
architecture: input,
|
||||
checkLatest: false,
|
||||
packageType: 'jdk',
|
||||
version: '21'
|
||||
});
|
||||
|
||||
expect(distributions['getArchitectureOptions']()).toEqual(expected);
|
||||
}
|
||||
);
|
||||
|
||||
it.each(['x86', 'armv7', 's390x'])('not support architecture %s', input => {
|
||||
const distributions = new LibericaNikDistributions({
|
||||
architecture: input,
|
||||
checkLatest: false,
|
||||
packageType: 'jdk',
|
||||
version: '21'
|
||||
});
|
||||
|
||||
expect(() => distributions['getArchitectureOptions']()).toThrow(
|
||||
/Architecture '\w+' is not supported\. Supported architectures: .*/
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('findPackageForDownload', () => {
|
||||
let distribution: InstanceType<typeof LibericaNikDistributions>;
|
||||
|
||||
beforeEach(() => {
|
||||
distribution = new LibericaNikDistributions({
|
||||
version: '',
|
||||
architecture: 'x64',
|
||||
packageType: 'jdk',
|
||||
checkLatest: false
|
||||
});
|
||||
distribution['getAvailableVersions'] = async () => manifestData;
|
||||
});
|
||||
|
||||
// The user's java-version resolves against the embedded JDK version, not
|
||||
// NIK's own GraalVM version.
|
||||
it.each([
|
||||
['21', '21.0.11+12'],
|
||||
['17', '17.0.19+12'],
|
||||
['25', '25.0.3+12'],
|
||||
['11', '11.0.22+12'],
|
||||
['21.0.2', '21.0.2+14'],
|
||||
['23', '23.0.2+9'],
|
||||
['20.x', '20.0.2+10'],
|
||||
['25.0.1', '25.0.1+16']
|
||||
])('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']('7')).rejects.toThrow(
|
||||
/No matching version found for SemVer/
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('getPlatformOption', () => {
|
||||
const distributions = new LibericaNikDistributions({
|
||||
architecture: 'x64',
|
||||
version: '21',
|
||||
packageType: 'jdk',
|
||||
checkLatest: false
|
||||
});
|
||||
|
||||
it.each([
|
||||
['linux', 'linux'],
|
||||
['darwin', 'macos'],
|
||||
['win32', 'windows'],
|
||||
['cygwin', 'windows']
|
||||
])('os version %s -> %s', (input, expected) => {
|
||||
const actual = distributions['getPlatformOption'](input as NodeJS.Platform);
|
||||
|
||||
expect(actual).toEqual(expected);
|
||||
});
|
||||
|
||||
it.each(['sunos', 'aix', 'android', 'freebsd'])(
|
||||
'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 LibericaNikDistributions({
|
||||
architecture: 'x64',
|
||||
version: '21',
|
||||
packageType: 'jdk',
|
||||
checkLatest: false
|
||||
});
|
||||
|
||||
it.each([
|
||||
['25.0.1+16', '25.0.1+16'],
|
||||
['21+37', '21.0.0+37'],
|
||||
['23+38', '23.0.0+38'],
|
||||
['11.0.15.1+2', '11.0.15+1.2'],
|
||||
['17.0.5', '17.0.5']
|
||||
])('%s -> %s', (input, expected) => {
|
||||
const actual = distributions['convertVersionToSemver'](input);
|
||||
expect(actual).toEqual(expected);
|
||||
});
|
||||
});
|
||||
@@ -1,56 +1,17 @@
|
||||
import {LibericaDistributions} from '../../src/distributions/liberica/installer';
|
||||
import {
|
||||
jest,
|
||||
describe,
|
||||
it,
|
||||
expect,
|
||||
beforeEach,
|
||||
afterEach,
|
||||
beforeAll,
|
||||
afterAll
|
||||
} from '@jest/globals';
|
||||
import type {
|
||||
ArchitectureOptions,
|
||||
LibericaVersion
|
||||
} from '../../src/distributions/liberica/models.js';
|
||||
} from '../../src/distributions/liberica/models';
|
||||
import {HttpClient} from '@actions/http-client';
|
||||
import os from 'os';
|
||||
import * as core from '@actions/core';
|
||||
|
||||
import manifestData from '../data/liberica-windows.json' with {type: 'json'};
|
||||
|
||||
// Mock @actions/core before importing source modules that depend on it
|
||||
jest.unstable_mockModule('@actions/core', () => ({
|
||||
info: jest.fn(),
|
||||
warning: jest.fn(),
|
||||
debug: jest.fn(),
|
||||
error: jest.fn(),
|
||||
notice: jest.fn(),
|
||||
setFailed: jest.fn(),
|
||||
setOutput: jest.fn(),
|
||||
getInput: jest.fn(),
|
||||
getBooleanInput: jest.fn(),
|
||||
getMultilineInput: jest.fn(),
|
||||
addPath: jest.fn(),
|
||||
exportVariable: jest.fn(),
|
||||
saveState: jest.fn(),
|
||||
getState: jest.fn(),
|
||||
setSecret: jest.fn(),
|
||||
isDebug: jest.fn(() => false),
|
||||
startGroup: jest.fn(),
|
||||
endGroup: jest.fn(),
|
||||
group: jest.fn((_name: string, fn: () => Promise<unknown>) => fn()),
|
||||
toPlatformPath: jest.fn((p: string) => p),
|
||||
toWin32Path: jest.fn((p: string) => p),
|
||||
toPosixPath: jest.fn((p: string) => p)
|
||||
}));
|
||||
|
||||
// Dynamic imports after mocking
|
||||
const core = await import('@actions/core');
|
||||
const {LibericaDistributions} =
|
||||
await import('../../src/distributions/liberica/installer.js');
|
||||
import manifestData from '../data/liberica-windows.json';
|
||||
|
||||
describe('getAvailableVersions', () => {
|
||||
let spyHttpClient: any;
|
||||
let spyCoreError: any;
|
||||
let spyHttpClient: jest.SpyInstance;
|
||||
let spyCoreError: jest.SpyInstance;
|
||||
|
||||
beforeEach(() => {
|
||||
spyHttpClient = jest.spyOn(HttpClient.prototype, 'getJson');
|
||||
@@ -60,7 +21,7 @@ describe('getAvailableVersions', () => {
|
||||
result: manifestData as LibericaVersion[]
|
||||
});
|
||||
// Mock core.error to suppress error logs
|
||||
spyCoreError = core.error as jest.Mock;
|
||||
spyCoreError = jest.spyOn(core, 'error');
|
||||
spyCoreError.mockImplementation(() => {});
|
||||
});
|
||||
|
||||
@@ -222,7 +183,7 @@ describe('getArchitectureOptions', () => {
|
||||
});
|
||||
|
||||
describe('findPackageForDownload', () => {
|
||||
let distribution: InstanceType<typeof LibericaDistributions>;
|
||||
let distribution: LibericaDistributions;
|
||||
|
||||
beforeEach(() => {
|
||||
distribution = new LibericaDistributions({
|
||||
|
||||
@@ -1,101 +1,37 @@
|
||||
import {
|
||||
jest,
|
||||
describe,
|
||||
it,
|
||||
expect,
|
||||
beforeEach,
|
||||
afterEach,
|
||||
beforeAll,
|
||||
afterAll
|
||||
} from '@jest/globals';
|
||||
import fs from 'fs';
|
||||
|
||||
import * as tc from '@actions/tool-cache';
|
||||
import * as core from '@actions/core';
|
||||
|
||||
import path from 'path';
|
||||
import * as semver from 'semver';
|
||||
import * as util from '../../src/util';
|
||||
|
||||
// Mock @actions/core before importing source modules that depend on it
|
||||
jest.unstable_mockModule('@actions/core', () => ({
|
||||
info: jest.fn(),
|
||||
warning: jest.fn(),
|
||||
debug: jest.fn(),
|
||||
error: jest.fn(),
|
||||
notice: jest.fn(),
|
||||
setFailed: jest.fn(),
|
||||
setOutput: jest.fn(),
|
||||
getInput: jest.fn(),
|
||||
getBooleanInput: jest.fn(),
|
||||
getMultilineInput: jest.fn(),
|
||||
addPath: jest.fn(),
|
||||
exportVariable: jest.fn(),
|
||||
saveState: jest.fn(),
|
||||
getState: jest.fn(),
|
||||
setSecret: jest.fn(),
|
||||
isDebug: jest.fn(() => false),
|
||||
startGroup: jest.fn(),
|
||||
endGroup: jest.fn(),
|
||||
group: jest.fn((_name: string, fn: () => Promise<unknown>) => fn()),
|
||||
toPlatformPath: jest.fn((p: string) => p),
|
||||
toWin32Path: jest.fn((p: string) => p),
|
||||
toPosixPath: jest.fn((p: string) => p)
|
||||
}));
|
||||
|
||||
jest.unstable_mockModule('@actions/tool-cache', () => ({
|
||||
find: jest.fn(),
|
||||
findAllVersions: jest.fn(),
|
||||
downloadTool: jest.fn(),
|
||||
extractZip: jest.fn(),
|
||||
extractTar: jest.fn(),
|
||||
extract7z: jest.fn(),
|
||||
extractXar: jest.fn(),
|
||||
cacheDir: jest.fn(),
|
||||
cacheFile: jest.fn(),
|
||||
getManifestFromRepo: jest.fn(),
|
||||
findFromManifest: jest.fn(),
|
||||
evaluateVersions: jest.fn()
|
||||
}));
|
||||
|
||||
const real_util_module = await import('../../src/util.js');
|
||||
jest.unstable_mockModule('../../src/util.js', () => ({
|
||||
...real_util_module,
|
||||
extractJdkFile: jest.fn(),
|
||||
getDownloadArchiveExtension: jest.fn(),
|
||||
getToolcachePath: jest.fn(),
|
||||
isJobStatusSuccess: jest.fn(),
|
||||
renameWinArchive: jest.fn(),
|
||||
isVersionSatisfies: real_util_module.isVersionSatisfies,
|
||||
getTempDir: real_util_module.getTempDir
|
||||
}));
|
||||
|
||||
// Dynamic imports after mocking
|
||||
const core = await import('@actions/core');
|
||||
const tc = await import('@actions/tool-cache');
|
||||
const util = await import('../../src/util.js');
|
||||
const {LocalDistribution} =
|
||||
await import('../../src/distributions/local/installer.js');
|
||||
import {LocalDistribution} from '../../src/distributions/local/installer';
|
||||
|
||||
describe('setupJava', () => {
|
||||
const actualJavaVersion = '11.1.10';
|
||||
const javaPath = path.join('Java_jdkfile_jdk', actualJavaVersion, 'x86');
|
||||
|
||||
let mockJavaBase: InstanceType<typeof LocalDistribution>;
|
||||
let mockJavaBase: LocalDistribution;
|
||||
|
||||
let spyGetToolcachePath: any;
|
||||
let spyTcCacheDir: any;
|
||||
let spyTcFindAllVersions: any;
|
||||
let spyCoreDebug: any;
|
||||
let spyCoreInfo: any;
|
||||
let spyCoreExportVariable: any;
|
||||
let spyCoreAddPath: any;
|
||||
let spyCoreSetOutput: any;
|
||||
let spyFsStat: any;
|
||||
let spyFsReadDir: any;
|
||||
let spyUtilsExtractJdkFile: any;
|
||||
let spyPathResolve: any;
|
||||
let spyCoreError: any;
|
||||
let spyGetToolcachePath: jest.SpyInstance;
|
||||
let spyTcCacheDir: jest.SpyInstance;
|
||||
let spyTcFindAllVersions: jest.SpyInstance;
|
||||
let spyCoreDebug: jest.SpyInstance;
|
||||
let spyCoreInfo: jest.SpyInstance;
|
||||
let spyCoreExportVariable: jest.SpyInstance;
|
||||
let spyCoreAddPath: jest.SpyInstance;
|
||||
let spyCoreSetOutput: jest.SpyInstance;
|
||||
let spyFsStat: jest.SpyInstance;
|
||||
let spyFsReadDir: jest.SpyInstance;
|
||||
let spyUtilsExtractJdkFile: jest.SpyInstance;
|
||||
let spyPathResolve: jest.SpyInstance;
|
||||
let spyCoreError: jest.SpyInstance;
|
||||
const expectedJdkFile = 'JavaLocalJdkFile';
|
||||
|
||||
beforeEach(() => {
|
||||
spyGetToolcachePath = util.getToolcachePath as jest.Mock;
|
||||
spyGetToolcachePath = jest.spyOn(util, 'getToolcachePath');
|
||||
spyGetToolcachePath.mockImplementation(
|
||||
(toolname: string, javaVersion: string, architecture: string) => {
|
||||
const semverVersion = new semver.Range(javaVersion);
|
||||
@@ -113,7 +49,7 @@ describe('setupJava', () => {
|
||||
}
|
||||
);
|
||||
|
||||
spyTcCacheDir = tc.cacheDir as jest.Mock;
|
||||
spyTcCacheDir = jest.spyOn(tc, 'cacheDir');
|
||||
spyTcCacheDir.mockImplementation(
|
||||
(
|
||||
archivePath: string,
|
||||
@@ -123,23 +59,23 @@ describe('setupJava', () => {
|
||||
) => path.join(toolcacheFolderName, version, architecture)
|
||||
);
|
||||
|
||||
spyTcFindAllVersions = tc.findAllVersions as jest.Mock;
|
||||
spyTcFindAllVersions = jest.spyOn(tc, 'findAllVersions');
|
||||
spyTcFindAllVersions.mockReturnValue([actualJavaVersion]);
|
||||
|
||||
// Spy on core methods
|
||||
spyCoreDebug = core.debug as jest.Mock;
|
||||
spyCoreDebug = jest.spyOn(core, 'debug');
|
||||
spyCoreDebug.mockImplementation(() => undefined);
|
||||
|
||||
spyCoreInfo = core.info as jest.Mock;
|
||||
spyCoreInfo = jest.spyOn(core, 'info');
|
||||
spyCoreInfo.mockImplementation(() => undefined);
|
||||
|
||||
spyCoreAddPath = core.addPath as jest.Mock;
|
||||
spyCoreAddPath = jest.spyOn(core, 'addPath');
|
||||
spyCoreAddPath.mockImplementation(() => undefined);
|
||||
|
||||
spyCoreExportVariable = core.exportVariable as jest.Mock;
|
||||
spyCoreExportVariable = jest.spyOn(core, 'exportVariable');
|
||||
spyCoreExportVariable.mockImplementation(() => undefined);
|
||||
|
||||
spyCoreSetOutput = core.setOutput as jest.Mock;
|
||||
spyCoreSetOutput = jest.spyOn(core, 'setOutput');
|
||||
spyCoreSetOutput.mockImplementation(() => undefined);
|
||||
|
||||
// Spy on fs methods
|
||||
@@ -152,7 +88,7 @@ describe('setupJava', () => {
|
||||
});
|
||||
|
||||
// Spy on util methods
|
||||
spyUtilsExtractJdkFile = util.extractJdkFile as jest.Mock;
|
||||
spyUtilsExtractJdkFile = jest.spyOn(util, 'extractJdkFile');
|
||||
spyUtilsExtractJdkFile.mockImplementation(() => 'some/random/path/');
|
||||
|
||||
// Spy on path methods
|
||||
@@ -160,7 +96,7 @@ describe('setupJava', () => {
|
||||
spyPathResolve.mockImplementation((path: string) => path);
|
||||
|
||||
// Mock core.error to suppress error logs
|
||||
spyCoreError = core.error as jest.Mock;
|
||||
spyCoreError = jest.spyOn(core, 'error');
|
||||
spyCoreError.mockImplementation(() => {});
|
||||
});
|
||||
|
||||
@@ -170,20 +106,6 @@ describe('setupJava', () => {
|
||||
jest.restoreAllMocks();
|
||||
});
|
||||
|
||||
it('throws for the latest alias since jdkfile has no version list', async () => {
|
||||
const inputs = {
|
||||
version: 'latest',
|
||||
architecture: 'x86',
|
||||
packageType: 'jdk',
|
||||
checkLatest: false
|
||||
};
|
||||
|
||||
mockJavaBase = new LocalDistribution(inputs, expectedJdkFile);
|
||||
await expect(mockJavaBase.setupJava()).rejects.toThrow(
|
||||
"The 'latest' version alias is not supported for the 'jdkfile' distribution. Please specify a concrete version."
|
||||
);
|
||||
});
|
||||
|
||||
it('java is resolved from toolcache, jdkfile is untouched', async () => {
|
||||
const inputs = {
|
||||
version: actualJavaVersion,
|
||||
|
||||
@@ -1,115 +1,23 @@
|
||||
import {
|
||||
jest,
|
||||
describe,
|
||||
it,
|
||||
expect,
|
||||
beforeEach,
|
||||
afterEach,
|
||||
beforeAll,
|
||||
afterAll
|
||||
} from '@jest/globals';
|
||||
import {HttpClient} from '@actions/http-client';
|
||||
import data from '../data/microsoft.json' with {type: 'json'};
|
||||
|
||||
const mockOsArch = jest.fn(() => 'x64');
|
||||
const mockOsPlatform = jest.fn(() => 'linux');
|
||||
|
||||
const real_os_module = await import('os');
|
||||
jest.unstable_mockModule('os', () => ({
|
||||
...real_os_module,
|
||||
default: {
|
||||
...real_os_module.default,
|
||||
arch: mockOsArch,
|
||||
platform: mockOsPlatform,
|
||||
homedir: real_os_module.default.homedir
|
||||
},
|
||||
arch: mockOsArch,
|
||||
platform: mockOsPlatform
|
||||
}));
|
||||
|
||||
const real_fs_module = await import('fs');
|
||||
const mockReaddirSync = jest.fn();
|
||||
jest.unstable_mockModule('fs', () => ({
|
||||
...real_fs_module,
|
||||
default: {
|
||||
...real_fs_module.default,
|
||||
readdirSync: mockReaddirSync
|
||||
},
|
||||
readdirSync: mockReaddirSync
|
||||
}));
|
||||
|
||||
// Mock @actions/core before importing source modules that depend on it
|
||||
jest.unstable_mockModule('@actions/core', () => ({
|
||||
info: jest.fn(),
|
||||
warning: jest.fn(),
|
||||
debug: jest.fn(),
|
||||
error: jest.fn(),
|
||||
notice: jest.fn(),
|
||||
setFailed: jest.fn(),
|
||||
setOutput: jest.fn(),
|
||||
getInput: jest.fn(),
|
||||
getBooleanInput: jest.fn(),
|
||||
getMultilineInput: jest.fn(),
|
||||
addPath: jest.fn(),
|
||||
exportVariable: jest.fn(),
|
||||
saveState: jest.fn(),
|
||||
getState: jest.fn(),
|
||||
setSecret: jest.fn(),
|
||||
isDebug: jest.fn(() => false),
|
||||
startGroup: jest.fn(),
|
||||
endGroup: jest.fn(),
|
||||
group: jest.fn((_name: string, fn: () => Promise<unknown>) => fn()),
|
||||
toPlatformPath: jest.fn((p: string) => p),
|
||||
toWin32Path: jest.fn((p: string) => p),
|
||||
toPosixPath: jest.fn((p: string) => p)
|
||||
}));
|
||||
|
||||
const real_tc_module = await import('@actions/tool-cache');
|
||||
jest.unstable_mockModule('@actions/tool-cache', () => ({
|
||||
...real_tc_module,
|
||||
downloadTool: jest.fn(),
|
||||
cacheDir: jest.fn(),
|
||||
cacheFile: jest.fn()
|
||||
}));
|
||||
|
||||
const real_util_module = await import('../../src/util.js');
|
||||
jest.unstable_mockModule('../../src/util.js', () => ({
|
||||
...real_util_module,
|
||||
extractJdkFile: jest.fn(),
|
||||
getDownloadArchiveExtension: jest.fn(),
|
||||
getToolcachePath: jest.fn(),
|
||||
isJobStatusSuccess: jest.fn(),
|
||||
renameWinArchive: jest.fn(),
|
||||
isVersionSatisfies: real_util_module.isVersionSatisfies,
|
||||
getTempDir: real_util_module.getTempDir
|
||||
}));
|
||||
|
||||
jest.unstable_mockModule('../../src/gpg.js', () => ({
|
||||
importKey: jest.fn(),
|
||||
deleteKey: jest.fn(),
|
||||
verifyPackageSignature: jest.fn()
|
||||
}));
|
||||
|
||||
// Dynamic imports after mocking
|
||||
const core = await import('@actions/core');
|
||||
const gpg = await import('../../src/gpg.js');
|
||||
const tc = await import('@actions/tool-cache');
|
||||
const os = (await import('os')).default;
|
||||
const fs = (await import('fs')).default;
|
||||
const {MicrosoftDistributions, MICROSOFT_PUBLIC_KEY} =
|
||||
await import('../../src/distributions/microsoft/installer.js');
|
||||
const util = await import('../../src/util.js');
|
||||
MicrosoftDistributions,
|
||||
MICROSOFT_PUBLIC_KEY
|
||||
} 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';
|
||||
import * as tc from '@actions/tool-cache';
|
||||
import * as gpg from '../../src/gpg';
|
||||
import * as util from '../../src/util';
|
||||
import fs from 'fs';
|
||||
|
||||
describe('findPackageForDownload', () => {
|
||||
let distribution: InstanceType<typeof MicrosoftDistributions>;
|
||||
let spyGetManifestFromRepo: any;
|
||||
let spyDebug: any;
|
||||
let spyCoreError: any;
|
||||
let distribution: MicrosoftDistributions;
|
||||
let spyGetManifestFromRepo: jest.SpyInstance;
|
||||
let spyDebug: jest.SpyInstance;
|
||||
let spyCoreError: jest.SpyInstance;
|
||||
|
||||
beforeEach(() => {
|
||||
mockOsArch.mockReturnValue('x64');
|
||||
mockOsPlatform.mockReturnValue(process.platform);
|
||||
|
||||
distribution = new MicrosoftDistributions({
|
||||
version: '',
|
||||
architecture: 'x64',
|
||||
@@ -117,18 +25,18 @@ describe('findPackageForDownload', () => {
|
||||
checkLatest: false
|
||||
});
|
||||
|
||||
spyGetManifestFromRepo = jest.spyOn(HttpClient.prototype, 'getJson');
|
||||
spyGetManifestFromRepo = jest.spyOn(httpm.HttpClient.prototype, 'getJson');
|
||||
spyGetManifestFromRepo.mockReturnValue({
|
||||
result: data,
|
||||
statusCode: 200,
|
||||
headers: {}
|
||||
});
|
||||
|
||||
spyDebug = core.debug as jest.Mock;
|
||||
spyDebug = jest.spyOn(core, 'debug');
|
||||
spyDebug.mockImplementation(() => {});
|
||||
|
||||
// Mock core.error to suppress error logs
|
||||
spyCoreError = core.error as jest.Mock;
|
||||
spyCoreError = jest.spyOn(core, 'error');
|
||||
spyCoreError.mockImplementation(() => {});
|
||||
});
|
||||
|
||||
@@ -210,8 +118,10 @@ describe('findPackageForDownload', () => {
|
||||
])(
|
||||
'defaults to os.arch(): %s mapped to distro arch: %s',
|
||||
async (osArch: string, distroArch: string) => {
|
||||
mockOsArch.mockReturnValue(osArch);
|
||||
mockOsPlatform.mockReturnValue('darwin');
|
||||
jest
|
||||
.spyOn(os, 'arch')
|
||||
.mockReturnValue(osArch as ReturnType<typeof os.arch>);
|
||||
jest.spyOn(os, 'platform').mockReturnValue('darwin');
|
||||
|
||||
const version = '17';
|
||||
const distro = new MicrosoftDistributions({
|
||||
@@ -234,8 +144,10 @@ describe('findPackageForDownload', () => {
|
||||
])(
|
||||
'defaults to os.arch(): %s mapped to distro arch: %s',
|
||||
async (osArch: string, distroArch: string) => {
|
||||
mockOsArch.mockReturnValue(osArch);
|
||||
mockOsPlatform.mockReturnValue('linux');
|
||||
jest
|
||||
.spyOn(os, 'arch')
|
||||
.mockReturnValue(osArch as ReturnType<typeof os.arch>);
|
||||
jest.spyOn(os, 'platform').mockReturnValue('linux');
|
||||
|
||||
const version = '17';
|
||||
const distro = new MicrosoftDistributions({
|
||||
@@ -258,8 +170,10 @@ describe('findPackageForDownload', () => {
|
||||
])(
|
||||
'defaults to os.arch(): %s mapped to distro arch: %s',
|
||||
async (osArch: string, distroArch: string) => {
|
||||
mockOsArch.mockReturnValue(osArch);
|
||||
mockOsPlatform.mockReturnValue('win32');
|
||||
jest
|
||||
.spyOn(os, 'arch')
|
||||
.mockReturnValue(osArch as ReturnType<typeof os.arch>);
|
||||
jest.spyOn(os, 'platform').mockReturnValue('win32');
|
||||
|
||||
const version = '17';
|
||||
const distro = new MicrosoftDistributions({
|
||||
@@ -303,7 +217,7 @@ describe('findPackageForDownload', () => {
|
||||
statusCode: 200,
|
||||
headers: {}
|
||||
});
|
||||
mockOsPlatform.mockReturnValue('linux');
|
||||
jest.spyOn(os, 'platform').mockReturnValue('linux');
|
||||
|
||||
const result = await distribution['findPackageForDownload']('17.0.10');
|
||||
|
||||
@@ -314,14 +228,16 @@ describe('findPackageForDownload', () => {
|
||||
});
|
||||
|
||||
describe('downloadTool', () => {
|
||||
let spyDownloadTool: any;
|
||||
let spyExtractJdkFile: any;
|
||||
let spyCacheDir: any;
|
||||
let spyVerifySignature: any;
|
||||
let distribution: InstanceType<typeof MicrosoftDistributions>;
|
||||
let spyDownloadTool: jest.SpyInstance;
|
||||
let spyExtractJdkFile: jest.SpyInstance;
|
||||
let spyCacheDir: jest.SpyInstance;
|
||||
let spyVerifySignature: jest.SpyInstance;
|
||||
let distribution: MicrosoftDistributions;
|
||||
|
||||
beforeEach(() => {
|
||||
mockOsPlatform.mockReturnValue(process.platform);
|
||||
jest
|
||||
.spyOn(os, 'platform')
|
||||
.mockReturnValue(process.platform as ReturnType<typeof os.platform>);
|
||||
|
||||
distribution = new MicrosoftDistributions({
|
||||
version: '17',
|
||||
@@ -330,27 +246,27 @@ describe('downloadTool', () => {
|
||||
checkLatest: false
|
||||
});
|
||||
|
||||
spyDownloadTool = tc.downloadTool as jest.Mock;
|
||||
spyDownloadTool = jest.spyOn(tc, 'downloadTool');
|
||||
spyDownloadTool.mockImplementation(async () => {
|
||||
return '/tmp/jdk.tar.gz';
|
||||
});
|
||||
|
||||
spyExtractJdkFile = util.extractJdkFile as jest.Mock;
|
||||
spyExtractJdkFile = jest.spyOn(util, 'extractJdkFile');
|
||||
spyExtractJdkFile.mockImplementation(async () => {
|
||||
return '/tmp/unpacked';
|
||||
});
|
||||
|
||||
mockReaddirSync.mockReturnValue(['jdk'] as any);
|
||||
spyCacheDir = tc.cacheDir as jest.Mock;
|
||||
jest.spyOn(fs, 'readdirSync').mockReturnValue(['jdk'] as any);
|
||||
spyCacheDir = jest.spyOn(tc, 'cacheDir');
|
||||
spyCacheDir.mockImplementation(async () => {
|
||||
return '/tmp/cached';
|
||||
});
|
||||
|
||||
(util.renameWinArchive as jest.Mock<any>).mockImplementation(
|
||||
(archivePath: string) => `${archivePath}.zip`
|
||||
);
|
||||
jest
|
||||
.spyOn(util, 'renameWinArchive')
|
||||
.mockImplementation((archivePath: string) => `${archivePath}.zip`);
|
||||
|
||||
spyVerifySignature = gpg.verifyPackageSignature as jest.Mock;
|
||||
spyVerifySignature = jest.spyOn(gpg, 'verifyPackageSignature');
|
||||
spyVerifySignature.mockImplementation(async () => {});
|
||||
});
|
||||
|
||||
|
||||
@@ -1,53 +1,14 @@
|
||||
import {
|
||||
jest,
|
||||
describe,
|
||||
it,
|
||||
expect,
|
||||
beforeEach,
|
||||
afterEach,
|
||||
beforeAll,
|
||||
afterAll
|
||||
} from '@jest/globals';
|
||||
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';
|
||||
|
||||
// Mock @actions/core before importing source modules that depend on it
|
||||
jest.unstable_mockModule('@actions/core', () => ({
|
||||
info: jest.fn(),
|
||||
warning: jest.fn(),
|
||||
debug: jest.fn(),
|
||||
error: jest.fn(),
|
||||
notice: jest.fn(),
|
||||
setFailed: jest.fn(),
|
||||
setOutput: jest.fn(),
|
||||
getInput: jest.fn(),
|
||||
getBooleanInput: jest.fn(),
|
||||
getMultilineInput: jest.fn(),
|
||||
addPath: jest.fn(),
|
||||
exportVariable: jest.fn(),
|
||||
saveState: jest.fn(),
|
||||
getState: jest.fn(),
|
||||
setSecret: jest.fn(),
|
||||
isDebug: jest.fn(() => false),
|
||||
startGroup: jest.fn(),
|
||||
endGroup: jest.fn(),
|
||||
group: jest.fn((_name: string, fn: () => Promise<unknown>) => fn()),
|
||||
toPlatformPath: jest.fn((p: string) => p),
|
||||
toWin32Path: jest.fn((p: string) => p),
|
||||
toPosixPath: jest.fn((p: string) => p)
|
||||
}));
|
||||
|
||||
// Dynamic imports after mocking
|
||||
const core = await import('@actions/core');
|
||||
const {OracleDistribution} =
|
||||
await import('../../src/distributions/oracle/installer.js');
|
||||
const {getDownloadArchiveExtension} = await import('../../src/util.js');
|
||||
|
||||
describe('findPackageForDownload', () => {
|
||||
let distribution: InstanceType<typeof OracleDistribution>;
|
||||
let spyDebug: any;
|
||||
let spyHttpClient: any;
|
||||
let spyCoreError: any;
|
||||
let distribution: OracleDistribution;
|
||||
let spyDebug: jest.SpyInstance;
|
||||
let spyHttpClient: jest.SpyInstance;
|
||||
let spyCoreError: jest.SpyInstance;
|
||||
|
||||
beforeEach(() => {
|
||||
distribution = new OracleDistribution({
|
||||
@@ -57,11 +18,11 @@ describe('findPackageForDownload', () => {
|
||||
checkLatest: false
|
||||
});
|
||||
|
||||
spyDebug = core.debug as jest.Mock;
|
||||
spyDebug = jest.spyOn(core, 'debug');
|
||||
spyDebug.mockImplementation(() => {});
|
||||
|
||||
// Mock core.error to suppress error logs
|
||||
spyCoreError = core.error as jest.Mock;
|
||||
spyCoreError = jest.spyOn(core, 'error');
|
||||
spyCoreError.mockImplementation(() => {});
|
||||
});
|
||||
|
||||
@@ -174,59 +135,3 @@ describe('findPackageForDownload', () => {
|
||||
);
|
||||
});
|
||||
});
|
||||
describe('findPackageForDownload with latest', () => {
|
||||
let spyHttpClientHead: any;
|
||||
let spyHttpClientGetJson: any;
|
||||
|
||||
beforeEach(() => {
|
||||
(core.debug as jest.Mock).mockImplementation(() => {});
|
||||
(core.error as jest.Mock).mockImplementation(() => {});
|
||||
spyHttpClientGetJson = jest.spyOn(HttpClient.prototype, 'getJson');
|
||||
spyHttpClientGetJson.mockResolvedValue({
|
||||
statusCode: 200,
|
||||
result: {most_recent_feature_release: 25},
|
||||
headers: {}
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
jest.restoreAllMocks();
|
||||
});
|
||||
|
||||
it('resolves the newest major version from the Adoptium API', async () => {
|
||||
spyHttpClientHead = jest.spyOn(HttpClient.prototype, 'head');
|
||||
spyHttpClientHead.mockResolvedValue({message: {statusCode: 200}});
|
||||
|
||||
const distribution = new OracleDistribution({
|
||||
version: 'latest',
|
||||
architecture: 'x64',
|
||||
packageType: 'jdk',
|
||||
checkLatest: false
|
||||
});
|
||||
|
||||
const result = await distribution['findPackageForDownload']('x');
|
||||
const osType = distribution.getPlatform();
|
||||
const archiveType = getDownloadArchiveExtension();
|
||||
|
||||
expect(result.version).toBe('25');
|
||||
expect(result.url).toBe(
|
||||
`https://download.oracle.com/java/25/latest/jdk-25_${osType}-x64_bin.${archiveType}`
|
||||
);
|
||||
});
|
||||
|
||||
it('throws an actionable error when the latest major is not yet available', async () => {
|
||||
spyHttpClientHead = jest.spyOn(HttpClient.prototype, 'head');
|
||||
spyHttpClientHead.mockResolvedValue({message: {statusCode: 404}});
|
||||
|
||||
const distribution = new OracleDistribution({
|
||||
version: 'latest',
|
||||
architecture: 'x64',
|
||||
packageType: 'jdk',
|
||||
checkLatest: false
|
||||
});
|
||||
|
||||
await expect(distribution['findPackageForDownload']('x')).rejects.toThrow(
|
||||
/is not yet available for the Oracle JDK distribution/
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,59 +1,14 @@
|
||||
import {
|
||||
jest,
|
||||
describe,
|
||||
it,
|
||||
expect,
|
||||
beforeEach,
|
||||
afterEach,
|
||||
beforeAll,
|
||||
afterAll
|
||||
} from '@jest/globals';
|
||||
import {HttpClient} from '@actions/http-client';
|
||||
import {SapMachineDistribution} from '../../src/distributions/sapmachine/installer';
|
||||
import * as utils from '../../src/util';
|
||||
import * as core from '@actions/core';
|
||||
|
||||
import manifestData from '../data/sapmachine.json' with {type: 'json'};
|
||||
|
||||
// Mock @actions/core before importing source modules that depend on it
|
||||
jest.unstable_mockModule('@actions/core', () => ({
|
||||
info: jest.fn(),
|
||||
warning: jest.fn(),
|
||||
debug: jest.fn(),
|
||||
error: jest.fn(),
|
||||
notice: jest.fn(),
|
||||
setFailed: jest.fn(),
|
||||
setOutput: jest.fn(),
|
||||
getInput: jest.fn(),
|
||||
getBooleanInput: jest.fn(),
|
||||
getMultilineInput: jest.fn(),
|
||||
addPath: jest.fn(),
|
||||
exportVariable: jest.fn(),
|
||||
saveState: jest.fn(),
|
||||
getState: jest.fn(),
|
||||
setSecret: jest.fn(),
|
||||
isDebug: jest.fn(() => false),
|
||||
startGroup: jest.fn(),
|
||||
endGroup: jest.fn(),
|
||||
group: jest.fn((_name: string, fn: () => Promise<unknown>) => fn()),
|
||||
toPlatformPath: jest.fn((p: string) => p),
|
||||
toWin32Path: jest.fn((p: string) => p),
|
||||
toPosixPath: jest.fn((p: string) => p)
|
||||
}));
|
||||
|
||||
const real_util_module = await import('../../src/util.js');
|
||||
jest.unstable_mockModule('../../src/util.js', () => ({
|
||||
...real_util_module,
|
||||
getDownloadArchiveExtension: jest.fn()
|
||||
}));
|
||||
|
||||
// Dynamic imports after mocking
|
||||
const core = await import('@actions/core');
|
||||
const {SapMachineDistribution} =
|
||||
await import('../../src/distributions/sapmachine/installer.js');
|
||||
const utils = await import('../../src/util.js');
|
||||
import manifestData from '../data/sapmachine.json';
|
||||
|
||||
describe('getAvailableVersions', () => {
|
||||
let spyHttpClient: any;
|
||||
let spyUtilGetDownloadArchiveExtension: any;
|
||||
let spyCoreError: any;
|
||||
let spyHttpClient: jest.SpyInstance;
|
||||
let spyUtilGetDownloadArchiveExtension: jest.SpyInstance;
|
||||
let spyCoreError: jest.SpyInstance;
|
||||
|
||||
beforeEach(() => {
|
||||
spyHttpClient = jest.spyOn(HttpClient.prototype, 'getJson');
|
||||
@@ -63,12 +18,14 @@ describe('getAvailableVersions', () => {
|
||||
result: manifestData
|
||||
});
|
||||
|
||||
spyUtilGetDownloadArchiveExtension =
|
||||
utils.getDownloadArchiveExtension as jest.Mock<any>;
|
||||
spyUtilGetDownloadArchiveExtension = jest.spyOn(
|
||||
utils,
|
||||
'getDownloadArchiveExtension'
|
||||
);
|
||||
spyUtilGetDownloadArchiveExtension.mockReturnValue('tar.gz');
|
||||
|
||||
// Mock core.error to suppress error logs
|
||||
spyCoreError = core.error as jest.Mock;
|
||||
spyCoreError = jest.spyOn(core, 'error');
|
||||
spyCoreError.mockImplementation(() => {});
|
||||
});
|
||||
|
||||
@@ -79,7 +36,7 @@ describe('getAvailableVersions', () => {
|
||||
});
|
||||
|
||||
const mockPlatform = (
|
||||
distribution: InstanceType<typeof SapMachineDistribution>,
|
||||
distribution: SapMachineDistribution,
|
||||
platform: string
|
||||
) => {
|
||||
distribution['getPlatformOption'] = () => platform;
|
||||
|
||||
@@ -1,53 +1,15 @@
|
||||
import {
|
||||
jest,
|
||||
describe,
|
||||
it,
|
||||
expect,
|
||||
beforeEach,
|
||||
afterEach,
|
||||
beforeAll,
|
||||
afterAll
|
||||
} from '@jest/globals';
|
||||
import type {JavaInstallerOptions} from '../../src/distributions/base-models.js';
|
||||
import {HttpClient} from '@actions/http-client';
|
||||
|
||||
import manifestData from '../data/semeru.json' with {type: 'json'};
|
||||
import {JavaInstallerOptions} from '../../src/distributions/base-models';
|
||||
import {SemeruDistribution} from '../../src/distributions/semeru/installer';
|
||||
|
||||
// Mock @actions/core before importing source modules that depend on it
|
||||
jest.unstable_mockModule('@actions/core', () => ({
|
||||
info: jest.fn(),
|
||||
warning: jest.fn(),
|
||||
debug: jest.fn(),
|
||||
error: jest.fn(),
|
||||
notice: jest.fn(),
|
||||
setFailed: jest.fn(),
|
||||
setOutput: jest.fn(),
|
||||
getInput: jest.fn(),
|
||||
getBooleanInput: jest.fn(),
|
||||
getMultilineInput: jest.fn(),
|
||||
addPath: jest.fn(),
|
||||
exportVariable: jest.fn(),
|
||||
saveState: jest.fn(),
|
||||
getState: jest.fn(),
|
||||
setSecret: jest.fn(),
|
||||
isDebug: jest.fn(() => false),
|
||||
startGroup: jest.fn(),
|
||||
endGroup: jest.fn(),
|
||||
group: jest.fn((_name: string, fn: () => Promise<unknown>) => fn()),
|
||||
toPlatformPath: jest.fn((p: string) => p),
|
||||
toWin32Path: jest.fn((p: string) => p),
|
||||
toPosixPath: jest.fn((p: string) => p)
|
||||
}));
|
||||
|
||||
// Dynamic imports after mocking
|
||||
const core = await import('@actions/core');
|
||||
const {SemeruDistribution} =
|
||||
await import('../../src/distributions/semeru/installer.js');
|
||||
import manifestData from '../data/semeru.json';
|
||||
import * as core from '@actions/core';
|
||||
|
||||
describe('getAvailableVersions', () => {
|
||||
let spyHttpClient: any;
|
||||
let spyCoreError: any;
|
||||
let spyCoreWarning: any;
|
||||
let spyHttpClient: jest.SpyInstance;
|
||||
let spyCoreError: jest.SpyInstance;
|
||||
let spyCoreWarning: jest.SpyInstance;
|
||||
|
||||
beforeEach(() => {
|
||||
spyHttpClient = jest.spyOn(HttpClient.prototype, 'getJson');
|
||||
@@ -57,9 +19,9 @@ describe('getAvailableVersions', () => {
|
||||
result: []
|
||||
});
|
||||
// Mock core.error to suppress error logs
|
||||
spyCoreError = core.error as jest.Mock;
|
||||
spyCoreError = jest.spyOn(core, 'error');
|
||||
spyCoreError.mockImplementation(() => {});
|
||||
spyCoreWarning = core.warning as jest.Mock;
|
||||
spyCoreWarning = jest.spyOn(core, 'warning');
|
||||
spyCoreWarning.mockImplementation(() => {});
|
||||
});
|
||||
|
||||
|
||||
@@ -1,92 +1,23 @@
|
||||
import {
|
||||
jest,
|
||||
describe,
|
||||
it,
|
||||
expect,
|
||||
beforeEach,
|
||||
afterEach,
|
||||
beforeAll,
|
||||
afterAll
|
||||
} from '@jest/globals';
|
||||
import type {JavaInstallerOptions} from '../../src/distributions/base-models.js';
|
||||
import type {TemurinImplementation as TemurinImplementationType} from '../../src/distributions/temurin/installer.js';
|
||||
import {HttpClient} from '@actions/http-client';
|
||||
import * as tc from '@actions/tool-cache';
|
||||
import fs from 'fs';
|
||||
import os from 'os';
|
||||
import {
|
||||
TemurinDistribution,
|
||||
TemurinImplementation,
|
||||
ADOPTIUM_PUBLIC_KEY
|
||||
} from '../../src/distributions/temurin/installer';
|
||||
import {JavaInstallerOptions} from '../../src/distributions/base-models';
|
||||
import * as util from '../../src/util';
|
||||
import * as gpg from '../../src/gpg';
|
||||
|
||||
import manifestData from '../data/temurin.json' with {type: 'json'};
|
||||
|
||||
// Mock @actions/core before importing source modules that depend on it
|
||||
jest.unstable_mockModule('@actions/core', () => ({
|
||||
info: jest.fn(),
|
||||
warning: jest.fn(),
|
||||
debug: jest.fn(),
|
||||
error: jest.fn(),
|
||||
notice: jest.fn(),
|
||||
setFailed: jest.fn(),
|
||||
setOutput: jest.fn(),
|
||||
getInput: jest.fn(),
|
||||
getBooleanInput: jest.fn(),
|
||||
getMultilineInput: jest.fn(),
|
||||
addPath: jest.fn(),
|
||||
exportVariable: jest.fn(),
|
||||
saveState: jest.fn(),
|
||||
getState: jest.fn(),
|
||||
setSecret: jest.fn(),
|
||||
isDebug: jest.fn(() => false),
|
||||
startGroup: jest.fn(),
|
||||
endGroup: jest.fn(),
|
||||
group: jest.fn((_name: string, fn: () => Promise<unknown>) => fn()),
|
||||
toPlatformPath: jest.fn((p: string) => p),
|
||||
toWin32Path: jest.fn((p: string) => p),
|
||||
toPosixPath: jest.fn((p: string) => p)
|
||||
}));
|
||||
|
||||
jest.unstable_mockModule('@actions/tool-cache', () => ({
|
||||
find: jest.fn(),
|
||||
findAllVersions: jest.fn(),
|
||||
downloadTool: jest.fn(),
|
||||
extractZip: jest.fn(),
|
||||
extractTar: jest.fn(),
|
||||
extract7z: jest.fn(),
|
||||
extractXar: jest.fn(),
|
||||
cacheDir: jest.fn(),
|
||||
cacheFile: jest.fn(),
|
||||
getManifestFromRepo: jest.fn(),
|
||||
findFromManifest: jest.fn(),
|
||||
evaluateVersions: jest.fn()
|
||||
}));
|
||||
|
||||
const real_util_module = await import('../../src/util.js');
|
||||
jest.unstable_mockModule('../../src/util.js', () => ({
|
||||
...real_util_module,
|
||||
extractJdkFile: jest.fn(),
|
||||
getDownloadArchiveExtension: jest.fn(),
|
||||
getToolcachePath: jest.fn(),
|
||||
isJobStatusSuccess: jest.fn(),
|
||||
renameWinArchive: jest.fn(),
|
||||
isVersionSatisfies: real_util_module.isVersionSatisfies,
|
||||
getTempDir: real_util_module.getTempDir
|
||||
}));
|
||||
|
||||
jest.unstable_mockModule('../../src/gpg.js', () => ({
|
||||
importKey: jest.fn(),
|
||||
deleteKey: jest.fn(),
|
||||
verifyPackageSignature: jest.fn()
|
||||
}));
|
||||
|
||||
// Dynamic imports after mocking
|
||||
const core = await import('@actions/core');
|
||||
const gpg = await import('../../src/gpg.js');
|
||||
const tc = await import('@actions/tool-cache');
|
||||
const {TemurinDistribution, TemurinImplementation, ADOPTIUM_PUBLIC_KEY} =
|
||||
await import('../../src/distributions/temurin/installer.js');
|
||||
const util = await import('../../src/util.js');
|
||||
import manifestData from '../data/temurin.json';
|
||||
import * as core from '@actions/core';
|
||||
|
||||
describe('getAvailableVersions', () => {
|
||||
let spyHttpClient: any;
|
||||
let spyCoreError: any;
|
||||
let spyCoreWarning: any;
|
||||
let spyHttpClient: jest.SpyInstance;
|
||||
let spyCoreError: jest.SpyInstance;
|
||||
let spyCoreWarning: jest.SpyInstance;
|
||||
|
||||
beforeEach(() => {
|
||||
spyHttpClient = jest.spyOn(HttpClient.prototype, 'getJson');
|
||||
@@ -96,9 +27,9 @@ describe('getAvailableVersions', () => {
|
||||
result: []
|
||||
});
|
||||
// Mock core.error to suppress error logs
|
||||
spyCoreError = core.error as jest.Mock;
|
||||
spyCoreError = jest.spyOn(core, 'error');
|
||||
spyCoreError.mockImplementation(() => {});
|
||||
spyCoreWarning = core.warning as jest.Mock;
|
||||
spyCoreWarning = jest.spyOn(core, 'warning');
|
||||
spyCoreWarning.mockImplementation(() => {});
|
||||
});
|
||||
|
||||
@@ -153,7 +84,7 @@ describe('getAvailableVersions', () => {
|
||||
'build correct url for %s',
|
||||
async (
|
||||
installerOptions: JavaInstallerOptions,
|
||||
impl: TemurinImplementationType,
|
||||
impl: TemurinImplementation,
|
||||
expectedParameters
|
||||
) => {
|
||||
const distribution = new TemurinDistribution(installerOptions, impl);
|
||||
@@ -232,11 +163,7 @@ describe('getAvailableVersions', () => {
|
||||
[TemurinImplementation.Hotspot, 'jre', 'Java_Temurin-Hotspot_jre']
|
||||
])(
|
||||
'find right toolchain folder',
|
||||
(
|
||||
impl: TemurinImplementationType,
|
||||
packageType: string,
|
||||
expected: string
|
||||
) => {
|
||||
(impl: TemurinImplementation, packageType: string, expected: string) => {
|
||||
const distribution = new TemurinDistribution(
|
||||
{
|
||||
version: '8',
|
||||
@@ -312,24 +239,6 @@ describe('findPackageForDownload', () => {
|
||||
expect(resolvedVersion.signatureUrl).toBeDefined();
|
||||
});
|
||||
|
||||
it('version "latest" is normalized to the newest available version', async () => {
|
||||
const distribution = new TemurinDistribution(
|
||||
{
|
||||
version: 'latest',
|
||||
architecture: 'x64',
|
||||
packageType: 'jdk',
|
||||
checkLatest: false
|
||||
},
|
||||
TemurinImplementation.Hotspot
|
||||
);
|
||||
distribution['getAvailableVersions'] = async () => manifestData as any;
|
||||
// normalizeVersion turns `latest` into the wildcard carried on `this.version`
|
||||
const resolvedVersion = await distribution['findPackageForDownload'](
|
||||
distribution['version']
|
||||
);
|
||||
expect(resolvedVersion.version).toBe('16.0.2+7');
|
||||
});
|
||||
|
||||
it('version is found but binaries list is empty', async () => {
|
||||
const distribution = new TemurinDistribution(
|
||||
{
|
||||
@@ -380,25 +289,25 @@ describe('findPackageForDownload', () => {
|
||||
});
|
||||
|
||||
describe('downloadTool', () => {
|
||||
let spyDownloadTool: any;
|
||||
let spyVerifySignature: any;
|
||||
let spyExtractJdkFile: any;
|
||||
let spyCacheDir: any;
|
||||
let spyReadDirSync: any;
|
||||
let spyRenameWinArchive: any;
|
||||
let spyDownloadTool: jest.SpyInstance;
|
||||
let spyVerifySignature: jest.SpyInstance;
|
||||
let spyExtractJdkFile: jest.SpyInstance;
|
||||
let spyCacheDir: jest.SpyInstance;
|
||||
let spyReadDirSync: jest.SpyInstance;
|
||||
let spyRenameWinArchive: jest.SpyInstance;
|
||||
|
||||
beforeEach(() => {
|
||||
spyDownloadTool = tc.downloadTool as jest.Mock;
|
||||
spyDownloadTool = jest.spyOn(tc, 'downloadTool');
|
||||
spyDownloadTool.mockResolvedValue('/tmp/jdk.tar.gz');
|
||||
spyVerifySignature = gpg.verifyPackageSignature as jest.Mock;
|
||||
spyVerifySignature = jest.spyOn(gpg, 'verifyPackageSignature');
|
||||
spyVerifySignature.mockResolvedValue(undefined);
|
||||
spyExtractJdkFile = util.extractJdkFile as jest.Mock;
|
||||
spyExtractJdkFile = jest.spyOn(util, 'extractJdkFile');
|
||||
spyExtractJdkFile.mockResolvedValue('/tmp/extracted');
|
||||
spyCacheDir = tc.cacheDir as jest.Mock;
|
||||
spyCacheDir = jest.spyOn(tc, 'cacheDir');
|
||||
spyCacheDir.mockResolvedValue('/tmp/toolcache');
|
||||
spyReadDirSync = jest.spyOn(fs, 'readdirSync');
|
||||
spyReadDirSync.mockReturnValue(['jdk-17'] as any);
|
||||
spyRenameWinArchive = util.renameWinArchive as jest.Mock;
|
||||
spyRenameWinArchive = jest.spyOn(util, 'renameWinArchive');
|
||||
spyRenameWinArchive.mockReturnValue('/tmp/jdk.tar.gz.zip');
|
||||
});
|
||||
|
||||
|
||||
@@ -1,60 +1,16 @@
|
||||
import {
|
||||
jest,
|
||||
describe,
|
||||
it,
|
||||
expect,
|
||||
beforeEach,
|
||||
afterEach,
|
||||
beforeAll,
|
||||
afterAll
|
||||
} from '@jest/globals';
|
||||
import type {IZuluVersions} from '../../src/distributions/zulu/models.js';
|
||||
import {HttpClient} from '@actions/http-client';
|
||||
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 * as core from '@actions/core';
|
||||
|
||||
import manifestData from '../data/zulu-releases-default.json' with {type: 'json'};
|
||||
|
||||
// Mock @actions/core before importing source modules that depend on it
|
||||
jest.unstable_mockModule('@actions/core', () => ({
|
||||
info: jest.fn(),
|
||||
warning: jest.fn(),
|
||||
debug: jest.fn(),
|
||||
error: jest.fn(),
|
||||
notice: jest.fn(),
|
||||
setFailed: jest.fn(),
|
||||
setOutput: jest.fn(),
|
||||
getInput: jest.fn(),
|
||||
getBooleanInput: jest.fn(),
|
||||
getMultilineInput: jest.fn(),
|
||||
addPath: jest.fn(),
|
||||
exportVariable: jest.fn(),
|
||||
saveState: jest.fn(),
|
||||
getState: jest.fn(),
|
||||
setSecret: jest.fn(),
|
||||
isDebug: jest.fn(() => false),
|
||||
startGroup: jest.fn(),
|
||||
endGroup: jest.fn(),
|
||||
group: jest.fn((_name: string, fn: () => Promise<unknown>) => fn()),
|
||||
toPlatformPath: jest.fn((p: string) => p),
|
||||
toWin32Path: jest.fn((p: string) => p),
|
||||
toPosixPath: jest.fn((p: string) => p)
|
||||
}));
|
||||
|
||||
const real_util_module = await import('../../src/util.js');
|
||||
jest.unstable_mockModule('../../src/util.js', () => ({
|
||||
...real_util_module,
|
||||
getDownloadArchiveExtension: jest.fn()
|
||||
}));
|
||||
|
||||
// Dynamic imports after mocking
|
||||
const core = await import('@actions/core');
|
||||
const {ZuluDistribution} =
|
||||
await import('../../src/distributions/zulu/installer.js');
|
||||
const utils = await import('../../src/util.js');
|
||||
import manifestData from '../data/zulu-releases-default.json';
|
||||
|
||||
describe('getAvailableVersions', () => {
|
||||
let spyHttpClient: any;
|
||||
let spyCoreError: any;
|
||||
let spyHttpClient: jest.SpyInstance;
|
||||
let spyUtilGetDownloadArchiveExtension: jest.SpyInstance;
|
||||
let spyCoreError: jest.SpyInstance;
|
||||
|
||||
beforeEach(() => {
|
||||
spyHttpClient = jest.spyOn(HttpClient.prototype, 'getJson');
|
||||
@@ -64,12 +20,14 @@ describe('getAvailableVersions', () => {
|
||||
result: [] as IZuluVersions[]
|
||||
});
|
||||
|
||||
(utils.getDownloadArchiveExtension as jest.Mock<any>).mockReturnValue(
|
||||
'tar.gz'
|
||||
spyUtilGetDownloadArchiveExtension = jest.spyOn(
|
||||
utils,
|
||||
'getDownloadArchiveExtension'
|
||||
);
|
||||
spyUtilGetDownloadArchiveExtension.mockReturnValue('tar.gz');
|
||||
|
||||
// Mock core.error to suppress error logs
|
||||
spyCoreError = core.error as jest.Mock;
|
||||
spyCoreError = jest.spyOn(core, 'error');
|
||||
spyCoreError.mockImplementation(() => {});
|
||||
});
|
||||
|
||||
|
||||
@@ -1,62 +1,17 @@
|
||||
import {
|
||||
jest,
|
||||
describe,
|
||||
it,
|
||||
expect,
|
||||
beforeEach,
|
||||
afterEach,
|
||||
beforeAll,
|
||||
afterAll
|
||||
} from '@jest/globals';
|
||||
import type {IZuluVersions} from '../../src/distributions/zulu/models.js';
|
||||
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 * as core from '@actions/core';
|
||||
|
||||
import manifestData from '../data/zulu-linux.json' with {type: 'json'};
|
||||
|
||||
// Mock @actions/core before importing source modules that depend on it
|
||||
jest.unstable_mockModule('@actions/core', () => ({
|
||||
info: jest.fn(),
|
||||
warning: jest.fn(),
|
||||
debug: jest.fn(),
|
||||
error: jest.fn(),
|
||||
notice: jest.fn(),
|
||||
setFailed: jest.fn(),
|
||||
setOutput: jest.fn(),
|
||||
getInput: jest.fn(),
|
||||
getBooleanInput: jest.fn(),
|
||||
getMultilineInput: jest.fn(),
|
||||
addPath: jest.fn(),
|
||||
exportVariable: jest.fn(),
|
||||
saveState: jest.fn(),
|
||||
getState: jest.fn(),
|
||||
setSecret: jest.fn(),
|
||||
isDebug: jest.fn(() => false),
|
||||
startGroup: jest.fn(),
|
||||
endGroup: jest.fn(),
|
||||
group: jest.fn((_name: string, fn: () => Promise<unknown>) => fn()),
|
||||
toPlatformPath: jest.fn((p: string) => p),
|
||||
toWin32Path: jest.fn((p: string) => p),
|
||||
toPosixPath: jest.fn((p: string) => p)
|
||||
}));
|
||||
|
||||
const real_util_module = await import('../../src/util.js');
|
||||
jest.unstable_mockModule('../../src/util.js', () => ({
|
||||
...real_util_module,
|
||||
getDownloadArchiveExtension: jest.fn()
|
||||
}));
|
||||
|
||||
// Dynamic imports after mocking
|
||||
const core = await import('@actions/core');
|
||||
const {ZuluDistribution} =
|
||||
await import('../../src/distributions/zulu/installer.js');
|
||||
const utils = await import('../../src/util.js');
|
||||
import manifestData from '../data/zulu-linux.json';
|
||||
|
||||
describe('getAvailableVersions', () => {
|
||||
let spyHttpClient: any;
|
||||
let spyUtilGetDownloadArchiveExtension: any;
|
||||
let spyCoreError: any;
|
||||
let spyHttpClient: jest.SpyInstance;
|
||||
let spyUtilGetDownloadArchiveExtension: jest.SpyInstance;
|
||||
let spyCoreError: jest.SpyInstance;
|
||||
|
||||
beforeEach(() => {
|
||||
spyHttpClient = jest.spyOn(HttpClient.prototype, 'getJson');
|
||||
@@ -66,12 +21,14 @@ describe('getAvailableVersions', () => {
|
||||
result: [] as IZuluVersions[]
|
||||
});
|
||||
|
||||
spyUtilGetDownloadArchiveExtension =
|
||||
utils.getDownloadArchiveExtension as jest.Mock<any>;
|
||||
spyUtilGetDownloadArchiveExtension = jest.spyOn(
|
||||
utils,
|
||||
'getDownloadArchiveExtension'
|
||||
);
|
||||
spyUtilGetDownloadArchiveExtension.mockReturnValue('zip');
|
||||
|
||||
// Mock core.error to suppress error logs
|
||||
spyCoreError = core.error as jest.Mock;
|
||||
spyCoreError = jest.spyOn(core, 'error');
|
||||
spyCoreError.mockImplementation(() => {});
|
||||
});
|
||||
|
||||
|
||||
@@ -1,61 +1,17 @@
|
||||
import {
|
||||
jest,
|
||||
describe,
|
||||
it,
|
||||
expect,
|
||||
beforeEach,
|
||||
afterEach,
|
||||
beforeAll,
|
||||
afterAll
|
||||
} from '@jest/globals';
|
||||
import type {IZuluVersions} from '../../src/distributions/zulu/models.js';
|
||||
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 * as core from '@actions/core';
|
||||
|
||||
import manifestData from '../data/zulu-windows.json' with {type: 'json'};
|
||||
|
||||
// Mock @actions/core before importing source modules that depend on it
|
||||
jest.unstable_mockModule('@actions/core', () => ({
|
||||
info: jest.fn(),
|
||||
warning: jest.fn(),
|
||||
debug: jest.fn(),
|
||||
error: jest.fn(),
|
||||
notice: jest.fn(),
|
||||
setFailed: jest.fn(),
|
||||
setOutput: jest.fn(),
|
||||
getInput: jest.fn(),
|
||||
getBooleanInput: jest.fn(),
|
||||
getMultilineInput: jest.fn(),
|
||||
addPath: jest.fn(),
|
||||
exportVariable: jest.fn(),
|
||||
saveState: jest.fn(),
|
||||
getState: jest.fn(),
|
||||
setSecret: jest.fn(),
|
||||
isDebug: jest.fn(() => false),
|
||||
startGroup: jest.fn(),
|
||||
endGroup: jest.fn(),
|
||||
group: jest.fn((_name: string, fn: () => Promise<unknown>) => fn()),
|
||||
toPlatformPath: jest.fn((p: string) => p),
|
||||
toWin32Path: jest.fn((p: string) => p),
|
||||
toPosixPath: jest.fn((p: string) => p)
|
||||
}));
|
||||
|
||||
const real_util_module = await import('../../src/util.js');
|
||||
jest.unstable_mockModule('../../src/util.js', () => ({
|
||||
...real_util_module,
|
||||
getDownloadArchiveExtension: jest.fn()
|
||||
}));
|
||||
|
||||
// Dynamic imports after mocking
|
||||
const core = await import('@actions/core');
|
||||
const {ZuluDistribution} =
|
||||
await import('../../src/distributions/zulu/installer.js');
|
||||
const utils = await import('../../src/util.js');
|
||||
import manifestData from '../data/zulu-windows.json';
|
||||
|
||||
describe('getAvailableVersions', () => {
|
||||
let spyHttpClient: any;
|
||||
let spyCoreError: any;
|
||||
let spyHttpClient: jest.SpyInstance;
|
||||
let spyUtilGetDownloadArchiveExtension: jest.SpyInstance;
|
||||
let spyCoreError: jest.SpyInstance;
|
||||
|
||||
beforeEach(() => {
|
||||
spyHttpClient = jest.spyOn(HttpClient.prototype, 'getJson');
|
||||
@@ -65,12 +21,14 @@ describe('getAvailableVersions', () => {
|
||||
result: [] as IZuluVersions[]
|
||||
});
|
||||
|
||||
(utils.getDownloadArchiveExtension as jest.Mock<any>).mockReturnValue(
|
||||
'zip'
|
||||
spyUtilGetDownloadArchiveExtension = jest.spyOn(
|
||||
utils,
|
||||
'getDownloadArchiveExtension'
|
||||
);
|
||||
spyUtilGetDownloadArchiveExtension.mockReturnValue('zip');
|
||||
|
||||
// Mock core.error to suppress error logs
|
||||
spyCoreError = core.error as jest.Mock;
|
||||
spyCoreError = jest.spyOn(core, 'error');
|
||||
spyCoreError.mockImplementation(() => {});
|
||||
});
|
||||
|
||||
|
||||
+14
-25
@@ -1,29 +1,20 @@
|
||||
import {
|
||||
jest,
|
||||
describe,
|
||||
it,
|
||||
expect,
|
||||
beforeEach,
|
||||
afterAll,
|
||||
afterEach
|
||||
} from '@jest/globals';
|
||||
import {fileURLToPath} from 'url';
|
||||
import * as path from 'path';
|
||||
import * as io from '@actions/io';
|
||||
import * as exec from '@actions/exec';
|
||||
import * as tc from '@actions/tool-cache';
|
||||
import * as gpg from '../src/gpg';
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
jest.mock('@actions/exec', () => {
|
||||
return {
|
||||
exec: jest.fn()
|
||||
};
|
||||
});
|
||||
|
||||
jest.unstable_mockModule('@actions/exec', () => ({
|
||||
exec: jest.fn()
|
||||
}));
|
||||
|
||||
jest.unstable_mockModule('@actions/tool-cache', () => ({
|
||||
downloadTool: jest.fn()
|
||||
}));
|
||||
|
||||
const exec = await import('@actions/exec');
|
||||
const tc = await import('@actions/tool-cache');
|
||||
const gpg = await import('../src/gpg.js');
|
||||
jest.mock('@actions/tool-cache', () => {
|
||||
return {
|
||||
downloadTool: jest.fn()
|
||||
};
|
||||
});
|
||||
|
||||
const tempDir = path.join(__dirname, 'runner', 'temp');
|
||||
process.env['RUNNER_TEMP'] = tempDir;
|
||||
@@ -101,9 +92,7 @@ describe('gpg tests', () => {
|
||||
it('imports bundled key and verifies package', async () => {
|
||||
const publicKeyContent =
|
||||
'-----BEGIN PGP PUBLIC KEY BLOCK-----\ntest\n-----END PGP PUBLIC KEY BLOCK-----';
|
||||
(tc.downloadTool as jest.Mock<any>).mockResolvedValue(
|
||||
'/tmp/jdk.tar.gz.sig'
|
||||
);
|
||||
(tc.downloadTool as jest.Mock).mockResolvedValue('/tmp/jdk.tar.gz.sig');
|
||||
await gpg.verifyPackageSignature(
|
||||
'/tmp/jdk.tar.gz',
|
||||
'https://example.com/jdk.tar.gz.sig',
|
||||
|
||||
@@ -1,68 +1,42 @@
|
||||
import {afterEach, beforeEach, describe, expect, it, jest} from '@jest/globals';
|
||||
import * as core from '@actions/core';
|
||||
|
||||
const mockGetInput = jest.fn<(...args: any[]) => any>();
|
||||
const mockExportVariable = jest.fn<(...args: any[]) => any>();
|
||||
const mockInfo = jest.fn<(...args: any[]) => any>();
|
||||
const mockDebug = jest.fn<(...args: any[]) => any>();
|
||||
const mockWarning = jest.fn<(...args: any[]) => any>();
|
||||
|
||||
jest.unstable_mockModule('@actions/core', () => ({
|
||||
getInput: mockGetInput,
|
||||
exportVariable: mockExportVariable,
|
||||
info: mockInfo,
|
||||
debug: mockDebug,
|
||||
warning: mockWarning,
|
||||
setSecret: jest.fn(),
|
||||
setFailed: jest.fn(),
|
||||
setOutput: jest.fn(),
|
||||
addPath: jest.fn(),
|
||||
getMultilineInput: jest.fn(),
|
||||
getBooleanInput: jest.fn(),
|
||||
getState: jest.fn(),
|
||||
saveState: jest.fn(),
|
||||
error: jest.fn(),
|
||||
notice: jest.fn(),
|
||||
startGroup: jest.fn(),
|
||||
endGroup: jest.fn(),
|
||||
group: jest.fn(),
|
||||
isDebug: jest.fn(),
|
||||
setCommandEcho: jest.fn(),
|
||||
getIDToken: jest.fn(),
|
||||
ExitCode: {Success: 0, Failure: 1},
|
||||
summary: {},
|
||||
markdownSummary: {},
|
||||
platform: {},
|
||||
toPosixPath: jest.fn(),
|
||||
toWin32Path: jest.fn(),
|
||||
toPlatformPath: jest.fn()
|
||||
}));
|
||||
|
||||
const {configureMavenArgs} = await import('../src/maven-args.js');
|
||||
const {
|
||||
import {configureMavenArgs} from '../src/maven-args';
|
||||
import {
|
||||
INPUT_SHOW_DOWNLOAD_PROGRESS,
|
||||
MAVEN_ARGS_ENV,
|
||||
MAVEN_NO_TRANSFER_PROGRESS_FLAG
|
||||
} = await import('../src/constants.js');
|
||||
} from '../src/constants';
|
||||
|
||||
describe('configureMavenArgs', () => {
|
||||
let inputs: Record<string, string>;
|
||||
let spyGetInput: jest.SpyInstance;
|
||||
let spyExportVariable: jest.SpyInstance;
|
||||
let spyInfo: jest.SpyInstance;
|
||||
let spyDebug: jest.SpyInstance;
|
||||
const originalMavenArgs = process.env[MAVEN_ARGS_ENV];
|
||||
|
||||
beforeEach(() => {
|
||||
inputs = {};
|
||||
|
||||
mockGetInput.mockImplementation((name: string) => inputs[name] ?? '');
|
||||
mockExportVariable.mockImplementation((name: string, value: string) => {
|
||||
spyGetInput = jest.spyOn(core, 'getInput');
|
||||
spyGetInput.mockImplementation((name: string) => inputs[name] ?? '');
|
||||
|
||||
spyExportVariable = jest.spyOn(core, 'exportVariable');
|
||||
spyExportVariable.mockImplementation((name: string, value: string) => {
|
||||
process.env[name] = value;
|
||||
});
|
||||
mockInfo.mockImplementation(() => undefined);
|
||||
mockDebug.mockImplementation(() => undefined);
|
||||
|
||||
spyInfo = jest.spyOn(core, 'info');
|
||||
spyInfo.mockImplementation(() => undefined);
|
||||
|
||||
spyDebug = jest.spyOn(core, 'debug');
|
||||
spyDebug.mockImplementation(() => undefined);
|
||||
|
||||
delete process.env[MAVEN_ARGS_ENV];
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
jest.resetAllMocks();
|
||||
jest.restoreAllMocks();
|
||||
if (originalMavenArgs === undefined) {
|
||||
delete process.env[MAVEN_ARGS_ENV];
|
||||
} else {
|
||||
@@ -73,7 +47,7 @@ describe('configureMavenArgs', () => {
|
||||
it('sets MAVEN_ARGS with -ntp by default', () => {
|
||||
configureMavenArgs();
|
||||
|
||||
expect(mockExportVariable).toHaveBeenCalledWith(
|
||||
expect(spyExportVariable).toHaveBeenCalledWith(
|
||||
MAVEN_ARGS_ENV,
|
||||
MAVEN_NO_TRANSFER_PROGRESS_FLAG
|
||||
);
|
||||
@@ -85,7 +59,7 @@ describe('configureMavenArgs', () => {
|
||||
|
||||
configureMavenArgs();
|
||||
|
||||
expect(mockExportVariable).not.toHaveBeenCalled();
|
||||
expect(spyExportVariable).not.toHaveBeenCalled();
|
||||
expect(process.env[MAVEN_ARGS_ENV]).toBeUndefined();
|
||||
});
|
||||
|
||||
@@ -94,7 +68,7 @@ describe('configureMavenArgs', () => {
|
||||
|
||||
configureMavenArgs();
|
||||
|
||||
expect(mockExportVariable).toHaveBeenCalledWith(
|
||||
expect(spyExportVariable).toHaveBeenCalledWith(
|
||||
MAVEN_ARGS_ENV,
|
||||
`-B -Dstyle.color=always ${MAVEN_NO_TRANSFER_PROGRESS_FLAG}`
|
||||
);
|
||||
@@ -105,7 +79,7 @@ describe('configureMavenArgs', () => {
|
||||
|
||||
configureMavenArgs();
|
||||
|
||||
expect(mockExportVariable).not.toHaveBeenCalled();
|
||||
expect(spyExportVariable).not.toHaveBeenCalled();
|
||||
expect(process.env[MAVEN_ARGS_ENV]).toBe('-B -ntp');
|
||||
});
|
||||
|
||||
@@ -114,7 +88,7 @@ describe('configureMavenArgs', () => {
|
||||
|
||||
configureMavenArgs();
|
||||
|
||||
expect(mockExportVariable).not.toHaveBeenCalled();
|
||||
expect(spyExportVariable).not.toHaveBeenCalled();
|
||||
expect(process.env[MAVEN_ARGS_ENV]).toBe('--no-transfer-progress -B');
|
||||
});
|
||||
|
||||
@@ -124,7 +98,7 @@ describe('configureMavenArgs', () => {
|
||||
|
||||
configureMavenArgs();
|
||||
|
||||
expect(mockExportVariable).not.toHaveBeenCalled();
|
||||
expect(spyExportVariable).not.toHaveBeenCalled();
|
||||
expect(process.env[MAVEN_ARGS_ENV]).toBe('-B');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,63 +1,23 @@
|
||||
import {
|
||||
jest,
|
||||
describe,
|
||||
it,
|
||||
expect,
|
||||
beforeEach,
|
||||
afterEach,
|
||||
beforeAll,
|
||||
afterAll
|
||||
} from '@jest/globals';
|
||||
import {fileURLToPath} from 'url';
|
||||
import * as fs from 'fs';
|
||||
import os from 'os';
|
||||
import * as path from 'path';
|
||||
import * as core from '@actions/core';
|
||||
import * as io from '@actions/io';
|
||||
import * as toolchains from '../src/toolchains';
|
||||
import {M2_DIR, MVN_TOOLCHAINS_FILE} from '../src/constants';
|
||||
|
||||
// Mock @actions/core before importing source modules that depend on it
|
||||
jest.unstable_mockModule('@actions/core', () => ({
|
||||
info: jest.fn(),
|
||||
warning: jest.fn(),
|
||||
debug: jest.fn(),
|
||||
error: jest.fn(),
|
||||
notice: jest.fn(),
|
||||
setFailed: jest.fn(),
|
||||
setOutput: jest.fn(),
|
||||
getInput: jest.fn(),
|
||||
getBooleanInput: jest.fn(),
|
||||
getMultilineInput: jest.fn(),
|
||||
addPath: jest.fn(),
|
||||
exportVariable: jest.fn(),
|
||||
saveState: jest.fn(),
|
||||
getState: jest.fn(),
|
||||
setSecret: jest.fn(),
|
||||
isDebug: jest.fn(() => false),
|
||||
startGroup: jest.fn(),
|
||||
endGroup: jest.fn(),
|
||||
group: jest.fn((_name: string, fn: () => Promise<unknown>) => fn()),
|
||||
toPlatformPath: jest.fn((p: string) => p),
|
||||
toWin32Path: jest.fn((p: string) => p),
|
||||
toPosixPath: jest.fn((p: string) => p)
|
||||
}));
|
||||
|
||||
// Dynamic imports after mocking
|
||||
const core = await import('@actions/core');
|
||||
const toolchains = await import('../src/toolchains.js');
|
||||
const {M2_DIR, MVN_TOOLCHAINS_FILE} = await import('../src/constants.js');
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
const m2Dir = path.join(__dirname, M2_DIR);
|
||||
const toolchainsFile = path.join(m2Dir, MVN_TOOLCHAINS_FILE);
|
||||
|
||||
describe('toolchains tests', () => {
|
||||
let spyOSHomedir: any;
|
||||
let spyInfo: any;
|
||||
let spyOSHomedir: jest.SpyInstance;
|
||||
let spyInfo: jest.SpyInstance;
|
||||
|
||||
beforeEach(async () => {
|
||||
await io.rmRF(m2Dir);
|
||||
spyOSHomedir = jest.spyOn(os, 'homedir');
|
||||
spyOSHomedir.mockReturnValue(__dirname);
|
||||
spyInfo = core.info as jest.Mock;
|
||||
spyInfo = jest.spyOn(core, 'info');
|
||||
spyInfo.mockImplementation(() => null);
|
||||
}, 300000);
|
||||
|
||||
@@ -882,7 +842,7 @@ describe('toolchains tests', () => {
|
||||
// The pre-existing (Sun 1.6) toolchain must be preserved ...
|
||||
expect(updated).toContain('<id>sun_1.6</id>');
|
||||
expect(updated).toContain('<jdkHome>/opt/jdk/sun/1.6</jdkHome>');
|
||||
// ... and the newly installed JDK must be appended.
|
||||
// ... and the newly installed JDK must be included in the merged result.
|
||||
expect(updated).toContain('<id>temurin_17</id>');
|
||||
expect(updated).toContain('<vendor>Eclipse Temurin</vendor>');
|
||||
expect(updated).toContain(`<jdkHome>${jdkInfo.jdkHome}</jdkHome>`);
|
||||
@@ -931,11 +891,6 @@ describe('toolchains tests', () => {
|
||||
const jdkHome =
|
||||
'/opt/hostedtoolcache/Java_Temurin-Hotspot_jdk/17.0.1-12/x64';
|
||||
|
||||
(core.getInput as jest.Mock<any>).mockImplementation((name: string) => {
|
||||
if (name === 'settings-path') return m2Dir;
|
||||
return '';
|
||||
});
|
||||
|
||||
await toolchains.configureToolchains(
|
||||
version,
|
||||
distributionName,
|
||||
@@ -961,7 +916,7 @@ describe('toolchains tests', () => {
|
||||
// Running setup-java several times in the same job (e.g. multiple steps / multiple
|
||||
// java-version entries) must accumulate every JDK in toolchains.xml rather
|
||||
// than replacing previously registered entries.
|
||||
(core.getInput as jest.Mock<any>).mockImplementation((name: string) => {
|
||||
jest.spyOn(core, 'getInput').mockImplementation((name: string) => {
|
||||
if (name === 'settings-path') return m2Dir;
|
||||
return '';
|
||||
});
|
||||
|
||||
+14
-97
@@ -1,64 +1,19 @@
|
||||
import {
|
||||
jest,
|
||||
describe,
|
||||
it,
|
||||
expect,
|
||||
beforeEach,
|
||||
afterAll,
|
||||
afterEach
|
||||
} from '@jest/globals';
|
||||
import {fileURLToPath} from 'url';
|
||||
import * as cache from '@actions/cache';
|
||||
import * as core from '@actions/core';
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
|
||||
// Mock @actions/cache
|
||||
jest.unstable_mockModule('@actions/cache', () => ({
|
||||
isFeatureAvailable: jest.fn(),
|
||||
saveCache: jest.fn(),
|
||||
restoreCache: jest.fn()
|
||||
}));
|
||||
|
||||
// Mock @actions/core
|
||||
jest.unstable_mockModule('@actions/core', () => ({
|
||||
getInput: jest.fn(),
|
||||
getBooleanInput: jest.fn(),
|
||||
getMultilineInput: jest.fn(),
|
||||
setOutput: jest.fn(),
|
||||
setFailed: jest.fn(),
|
||||
warning: jest.fn(),
|
||||
info: jest.fn(),
|
||||
debug: jest.fn(),
|
||||
error: jest.fn(),
|
||||
notice: jest.fn(),
|
||||
startGroup: jest.fn(),
|
||||
endGroup: jest.fn(),
|
||||
addPath: jest.fn(),
|
||||
exportVariable: jest.fn(),
|
||||
saveState: jest.fn(),
|
||||
getState: jest.fn(),
|
||||
setSecret: jest.fn(),
|
||||
isDebug: jest.fn(() => false),
|
||||
group: jest.fn((_name: string, fn: () => Promise<unknown>) => fn()),
|
||||
toPlatformPath: jest.fn((p: string) => p),
|
||||
toWin32Path: jest.fn((p: string) => p),
|
||||
toPosixPath: jest.fn((p: string) => p)
|
||||
}));
|
||||
|
||||
const cache = await import('@actions/cache');
|
||||
const core = await import('@actions/core');
|
||||
|
||||
const {
|
||||
import {
|
||||
convertVersionToSemver,
|
||||
getNextPageUrlFromLinkHeader,
|
||||
getVersionFromFileContent,
|
||||
isVersionSatisfies,
|
||||
isCacheFeatureAvailable,
|
||||
isGhes,
|
||||
validatePaginationUrl,
|
||||
getLatestMajorVersion
|
||||
} = await import('../src/util.js');
|
||||
validatePaginationUrl
|
||||
} from '../src/util';
|
||||
|
||||
jest.mock('@actions/cache');
|
||||
jest.mock('@actions/core');
|
||||
|
||||
describe('isVersionSatisfies', () => {
|
||||
it.each([
|
||||
@@ -90,10 +45,8 @@ describe('isVersionSatisfies', () => {
|
||||
|
||||
describe('isCacheFeatureAvailable', () => {
|
||||
it('isCacheFeatureAvailable disabled on GHES', () => {
|
||||
(cache.isFeatureAvailable as jest.Mock<any>).mockImplementation(
|
||||
() => false
|
||||
);
|
||||
const infoMock = core.warning as jest.Mock;
|
||||
jest.spyOn(cache, 'isFeatureAvailable').mockImplementation(() => false);
|
||||
const infoMock = jest.spyOn(core, 'warning');
|
||||
const message =
|
||||
'Caching is only supported on GHES version >= 3.5. If you are on a version >= 3.5, please check with your GHES admin if the Actions cache service is enabled or not.';
|
||||
try {
|
||||
@@ -106,10 +59,8 @@ describe('isCacheFeatureAvailable', () => {
|
||||
});
|
||||
|
||||
it('isCacheFeatureAvailable disabled on dotcom', () => {
|
||||
(cache.isFeatureAvailable as jest.Mock<any>).mockImplementation(
|
||||
() => false
|
||||
);
|
||||
const infoMock = core.warning as jest.Mock;
|
||||
jest.spyOn(cache, 'isFeatureAvailable').mockImplementation(() => false);
|
||||
const infoMock = jest.spyOn(core, 'warning');
|
||||
const message =
|
||||
'The runner was not able to contact the cache service. Caching will be skipped';
|
||||
try {
|
||||
@@ -122,14 +73,9 @@ describe('isCacheFeatureAvailable', () => {
|
||||
});
|
||||
|
||||
it('isCacheFeatureAvailable is enabled', () => {
|
||||
(cache.isFeatureAvailable as jest.Mock<any>).mockImplementation(() => true);
|
||||
jest.spyOn(cache, 'isFeatureAvailable').mockImplementation(() => true);
|
||||
expect(isCacheFeatureAvailable()).toBe(true);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
jest.resetAllMocks();
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
});
|
||||
|
||||
describe('convertVersionToSemver', () => {
|
||||
@@ -369,6 +315,7 @@ describe('isGhes', () => {
|
||||
const pristineEnv = process.env;
|
||||
|
||||
beforeEach(() => {
|
||||
jest.resetModules();
|
||||
process.env = {...pristineEnv};
|
||||
});
|
||||
|
||||
@@ -401,33 +348,3 @@ describe('isGhes', () => {
|
||||
expect(isGhes()).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
||||
describe('getLatestMajorVersion', () => {
|
||||
const makeHttp = (getJson: jest.Mock) =>
|
||||
({getJson}) as unknown as import('@actions/http-client').HttpClient;
|
||||
|
||||
it('returns most_recent_feature_release from the Adoptium API', async () => {
|
||||
const getJson = jest.fn(async () => ({
|
||||
statusCode: 200,
|
||||
result: {most_recent_feature_release: 25},
|
||||
headers: {}
|
||||
}));
|
||||
|
||||
await expect(getLatestMajorVersion(makeHttp(getJson))).resolves.toBe(25);
|
||||
expect(getJson).toHaveBeenCalledWith(
|
||||
'https://api.adoptium.net/v3/info/available_releases'
|
||||
);
|
||||
});
|
||||
|
||||
it('throws when the response does not contain a usable value', async () => {
|
||||
const getJson = jest.fn(async () => ({
|
||||
statusCode: 200,
|
||||
result: {},
|
||||
headers: {}
|
||||
}));
|
||||
|
||||
await expect(getLatestMajorVersion(makeHttp(getJson))).rejects.toThrow(
|
||||
'Could not determine the latest available Java major version'
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ description: 'Set up a specific version of the Java JDK and add the
|
||||
author: 'GitHub'
|
||||
inputs:
|
||||
java-version:
|
||||
description: 'The Java version to set up. Takes a whole or semver Java version, or the "latest" alias to use the newest available stable release. See examples of supported syntax in README file'
|
||||
description: 'The Java version to set up. Takes a whole or semver Java version. See examples of supported syntax in README file'
|
||||
required: false
|
||||
java-version-file:
|
||||
description: 'The path to a file containing the Java version to set up (.java-version, .tool-versions, .sdkmanrc). Used when java-version is not set. See examples of supported syntax in README file'
|
||||
|
||||
Vendored
+56512
-62217
File diff suppressed because one or more lines are too long
Vendored
-3
@@ -1,3 +0,0 @@
|
||||
{
|
||||
"type": "module"
|
||||
}
|
||||
Vendored
+65939
-70761
File diff suppressed because one or more lines are too long
Vendored
-3
@@ -1,3 +0,0 @@
|
||||
{
|
||||
"type": "module"
|
||||
}
|
||||
+22
-200
@@ -4,7 +4,6 @@
|
||||
- [Adopt](#Adopt)
|
||||
- [Zulu](#Zulu)
|
||||
- [Liberica](#Liberica)
|
||||
- [Liberica Native Image Kit](#Liberica-Native-Image-Kit)
|
||||
- [Microsoft](#Microsoft)
|
||||
- [Amazon Corretto](#Amazon-Corretto)
|
||||
- [Oracle](#Oracle)
|
||||
@@ -16,7 +15,6 @@
|
||||
- [Tencent Kona](#Tencent-Kona)
|
||||
- [Installing custom Java package type](#Installing-custom-Java-package-type)
|
||||
- [JavaFX Maven project](#JavaFX-Maven-project)
|
||||
- [Ensuring the Maven cache is complete (plugin dependencies)](#ensuring-the-maven-cache-is-complete-plugin-dependencies)
|
||||
- [Installing custom Java architecture](#Installing-custom-Java-architecture)
|
||||
- [Installing JDK without setting as default](#Installing-JDK-without-setting-as-default)
|
||||
- [Installing custom Java distribution from local file](#Installing-Java-from-local-file)
|
||||
@@ -86,20 +84,6 @@ steps:
|
||||
- run: java --version
|
||||
```
|
||||
|
||||
### Liberica Native Image Kit
|
||||
Liberica Native Image Kit (NIK) is a GraalVM-based distribution. `java-version` selects the underlying JDK version (e.g. `17`, `21`, `25`). Use `java-package: jdk+fx` to get the `full` bundle with JavaFX/Swing support; otherwise the `standard` bundle (with extra languages) is installed. Available on Linux, macOS and Windows for `x64` and `aarch64`.
|
||||
|
||||
```yaml
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
- uses: actions/setup-java@v5
|
||||
with:
|
||||
distribution: 'liberica-nik'
|
||||
java-version: '25'
|
||||
java-package: jdk # optional (jdk or jdk+fx) - defaults to jdk
|
||||
- run: native-image --version
|
||||
```
|
||||
|
||||
### Microsoft
|
||||
|
||||
```yaml
|
||||
@@ -301,129 +285,6 @@ To run the JavaFX application in CI:
|
||||
run: mvn --no-transfer-progress javafx:run
|
||||
```
|
||||
|
||||
## Ensuring the Maven cache is complete (plugin dependencies)
|
||||
|
||||
When you enable `cache: maven`, the action caches your local Maven repository
|
||||
(`~/.m2/repository`). The cache key is a hash of your Maven inputs — every
|
||||
`**/pom.xml`, plus `**/.mvn/wrapper/maven-wrapper.properties` and
|
||||
`**/.mvn/extensions.xml` — so changing any of those files (for example bumping
|
||||
the wrapper version or editing core extensions) produces a new key and
|
||||
invalidates the cache. At the end of the job the action saves whatever was
|
||||
downloaded during that run. It does **not** re-save the cache when the key
|
||||
already matches (a cache *hit*).
|
||||
|
||||
Downloaded Maven Wrapper distributions (`~/.m2/wrapper/dists`) are cached in a
|
||||
**separate** cache entry keyed only on `**/.mvn/wrapper/maven-wrapper.properties`.
|
||||
Because the wrapper distribution changes far less often than your `pom.xml`
|
||||
files, this keeps it available across the frequent dependency changes that
|
||||
rotate the main cache key, so wrapper-based (`./mvnw`) builds don't re-download
|
||||
the Maven distribution on every dependency change. See
|
||||
[issue #1095](https://github.com/actions/setup-java/issues/1095).
|
||||
|
||||
Maven resolves **plugin** dependencies lazily: it only downloads the plugins and
|
||||
plugin dependencies required by the goals that actually execute. As a result, the
|
||||
run that first creates the cache determines what is stored. If that run executed a
|
||||
"thin" goal such as `mvn compile`, plugins bound to later phases are never
|
||||
resolved. For example, `maven-shade-plugin` (bound to `package`) pulls in
|
||||
`plexus-archiver`, `commons-compress`, `io.airlift:aircompressor` and
|
||||
`org.tukaani:xz` — none of which a `compile` run downloads. Those artifacts are
|
||||
therefore absent from the cache, and because the action does not re-save on a
|
||||
hit, every later `test`/`verify`/`package` job re-downloads them on every run.
|
||||
|
||||
### Seed the cache with a resolution step
|
||||
|
||||
To populate `~/.m2` as comprehensively as possible on the run that creates the
|
||||
cache, run a dependency-resolution "seed" command before your build. Choose a
|
||||
command based on how thorough you need it to be:
|
||||
|
||||
| Seed command | Resolves plugin dependencies? | Notes |
|
||||
|--------------|:-----------------------------:|-------|
|
||||
| `mvn dependency:resolve` | No | Resolves project dependencies only — misses plugin dependencies (e.g. `aircompressor`). |
|
||||
| `mvn dependency:resolve-plugins` | Yes | Resolves plugins **and their dependencies**. |
|
||||
| `mvn dependency:go-offline` | Yes | Resolves project and plugin dependencies (a superset). |
|
||||
| `mvn dependency:go-offline dependency:resolve-plugins` | Yes (most thorough) | Recommended default. Use `dependency:resolve dependency:resolve-plugins` if `go-offline` is flaky or insufficient for your project. |
|
||||
|
||||
Single job — seed, then build (the cache saved at the end of this run contains
|
||||
the full set):
|
||||
|
||||
```yaml
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
- uses: actions/setup-java@v5
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: '25'
|
||||
cache: 'maven'
|
||||
- name: Seed the Maven cache
|
||||
run: mvn -B dependency:go-offline dependency:resolve-plugins
|
||||
- name: Build with Maven
|
||||
run: mvn -B verify --file pom.xml
|
||||
```
|
||||
|
||||
Separate seed job — useful for a matrix where different legs run different goals
|
||||
(`test`, `check`, `verify`, `-Pprofile1`, ...) but all share the same `~/.m2`
|
||||
cache. Without a seed, whichever job finishes first creates the cache from its
|
||||
own partial `.m2`, and parallel jobs race to save an equally partial cache; the
|
||||
seed job instead creates one comprehensive cache that every other job reuses:
|
||||
|
||||
```yaml
|
||||
jobs:
|
||||
seed-cache:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
- uses: actions/setup-java@v5
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: '25'
|
||||
cache: 'maven'
|
||||
- name: Seed the Maven cache
|
||||
run: mvn -B dependency:go-offline dependency:resolve-plugins
|
||||
|
||||
build:
|
||||
needs: seed-cache
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
goal: ['test', 'verify', 'test -Pprofile1']
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
- uses: actions/setup-java@v5
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: '25'
|
||||
cache: 'maven'
|
||||
- name: Build
|
||||
run: mvn -B ${{ matrix.goal }} --file pom.xml
|
||||
```
|
||||
|
||||
### Caveats
|
||||
|
||||
- **The seed only helps on the run that creates the cache.** Once a cache exists
|
||||
for the current `pom.xml` hash, later runs get a hit and any additional
|
||||
downloads are not saved. On an existing repository whose cache is already
|
||||
incomplete, invalidate it once (for example by changing `cache-dependency-path`
|
||||
or deleting the repository's caches) so a complete cache is created from the
|
||||
seed.
|
||||
- **Static resolution is not exhaustive.** `go-offline`/`resolve-plugins` resolve
|
||||
the statically declared plugin set for the *active* profiles and modules.
|
||||
Profile-gated plugins, conditionally-active modules, and artifacts a plugin
|
||||
fetches at execution time may still be missed. For the most complete cache,
|
||||
seed with the fullest goal set your CI actually uses (for example
|
||||
`mvn -B verify` with every profile enabled).
|
||||
- **Multi-module projects:** run the seed at the reactor root so every module's
|
||||
plugins are resolved.
|
||||
|
||||
> [!NOTE]
|
||||
> The same "the cache stores only what the creating run downloaded, and is not
|
||||
> re-saved on a hit" behavior applies to `cache: gradle`, since Gradle also
|
||||
> resolves dependencies and plugin/buildscript classpaths lazily. Gradle has no
|
||||
> direct equivalent of `dependency:go-offline`, so for complete and fine-grained
|
||||
> dependency caching on Gradle projects we recommend
|
||||
> [`gradle/actions/setup-gradle`](https://github.com/gradle/actions/tree/main/setup-gradle),
|
||||
> which provides purpose-built caching (see the
|
||||
> [setup-gradle documentation](https://github.com/gradle/actions/blob/main/docs/setup-gradle.md)).
|
||||
|
||||
## Installing custom Java architecture
|
||||
|
||||
```yaml
|
||||
@@ -600,13 +461,14 @@ jobs:
|
||||
server-id: maven # Value of the distributionManagement/repository/id field of the pom.xml
|
||||
server-username: MAVEN_USERNAME # env variable for username in deploy
|
||||
server-password: MAVEN_CENTRAL_TOKEN # env variable for token in deploy
|
||||
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }} # Value of the GPG private key to import
|
||||
gpg-passphrase: MAVEN_GPG_PASSPHRASE # env variable for GPG private key passphrase
|
||||
|
||||
- name: Publish to Apache Maven Central
|
||||
run: mvn deploy -Dgpg.signer=bc # requires maven-gpg-plugin >= 3.2.0 (bc signer support)
|
||||
run: mvn deploy
|
||||
env:
|
||||
MAVEN_USERNAME: maven_username123
|
||||
MAVEN_CENTRAL_TOKEN: ${{ secrets.MAVEN_CENTRAL_TOKEN }}
|
||||
MAVEN_GPG_KEY: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }} # ASCII-armored secret key (TSK), e.g. from `gpg --armor --export-secret-keys YOUR_ID`
|
||||
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
|
||||
```
|
||||
|
||||
@@ -624,6 +486,10 @@ The two `settings.xml` files created from the above example look like the follow
|
||||
<username>${env.GITHUB_ACTOR}</username>
|
||||
<password>${env.GITHUB_TOKEN}</password>
|
||||
</server>
|
||||
<server>
|
||||
<id>gpg.passphrase</id>
|
||||
<passphrase>${env.GPG_PASSPHRASE}</passphrase>
|
||||
</server>
|
||||
</servers>
|
||||
</settings>
|
||||
```
|
||||
@@ -640,6 +506,10 @@ The two `settings.xml` files created from the above example look like the follow
|
||||
<username>${env.MAVEN_USERNAME}</username>
|
||||
<password>${env.MAVEN_CENTRAL_TOKEN}</password>
|
||||
</server>
|
||||
<server>
|
||||
<id>gpg.passphrase</id>
|
||||
<passphrase>${env.MAVEN_GPG_PASSPHRASE}</passphrase>
|
||||
</server>
|
||||
</servers>
|
||||
</settings>
|
||||
```
|
||||
@@ -650,64 +520,9 @@ The two `settings.xml` files created from the above example look like the follow
|
||||
|
||||
If you don't want to overwrite the `settings.xml` file, you can set `overwrite-settings: false`
|
||||
|
||||
### GPG
|
||||
### Extra setup for pom.xml:
|
||||
|
||||
The example above uses the [Maven GPG Plugin](https://maven.apache.org/plugins/maven-gpg-plugin/)'s Bouncy Castle signer (`-Dgpg.signer=bc`, available since `maven-gpg-plugin` 3.2.0). It is a pure-Java signer that reads the key directly from the `MAVEN_GPG_KEY` environment variable, so it does **not** require the `gpg` executable, importing the key into a GPG keychain, or the `--pinentry-mode loopback` workaround in your `pom.xml`. The key must be an ASCII-armored secret key (transferable secret key format).
|
||||
|
||||
**GPG key should be exported by: `gpg --armor --export-secret-keys YOUR_ID`**
|
||||
|
||||
See the help docs on [Publishing a Package](https://help.github.com/en/github/managing-packages-with-github-packages/configuring-apache-maven-for-use-with-github-packages#publishing-a-package) for more information on the `pom.xml` file.
|
||||
|
||||
#### Legacy / alternative: let setup-java import the key
|
||||
|
||||
If you prefer signing with the `gpg` executable (for example because you are using `maven-gpg-plugin` older than 3.2.0), you can let setup-java import the key instead by providing the `gpg-private-key` and `gpg-passphrase` inputs. The private key is written to a file in the runner's temp directory, imported into the GPG keychain, and the file is promptly removed before proceeding with the rest of the setup process. A cleanup step removes the imported private key from the GPG keychain after the job completes regardless of the job status. This ensures that the private key is no longer accessible on self-hosted runners and cannot "leak" between jobs (hosted runners are always clean instances).
|
||||
|
||||
setup-java imports the key independently of the plugin version, but the generated passphrase profile described below uses `gpg.passphraseEnvName`, which requires `maven-gpg-plugin` 3.2.0 or newer. Since `gpg-passphrase` defaults to `GPG_PASSPHRASE`, setup-java writes that profile unless you override the input to `MAVEN_GPG_PASSPHRASE`.
|
||||
|
||||
```yaml
|
||||
- name: Set up Apache Maven Central
|
||||
uses: actions/setup-java@v5
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: '11'
|
||||
server-id: maven # Value of the distributionManagement/repository/id field of the pom.xml
|
||||
server-username: MAVEN_USERNAME # env variable for username in deploy
|
||||
server-password: MAVEN_CENTRAL_TOKEN # env variable for token in deploy
|
||||
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }} # Value of the GPG private key to import
|
||||
gpg-passphrase: MAVEN_GPG_PASSPHRASE # env variable for GPG private key passphrase
|
||||
|
||||
- name: Publish to Apache Maven Central
|
||||
run: mvn deploy
|
||||
env:
|
||||
MAVEN_USERNAME: maven_username123
|
||||
MAVEN_CENTRAL_TOKEN: ${{ secrets.MAVEN_CENTRAL_TOKEN }}
|
||||
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
|
||||
```
|
||||
|
||||
The `gpg-passphrase` input is the **name of the environment variable** that holds the passphrase (not the passphrase itself). It defaults to `GPG_PASSPHRASE`. The [Maven GPG Plugin](https://maven.apache.org/plugins/maven-gpg-plugin/) reads the passphrase from the environment variable named by its `gpg.passphraseEnvName` property, whose own default is `MAVEN_GPG_PASSPHRASE`.
|
||||
|
||||
- If `gpg-passphrase` is `MAVEN_GPG_PASSPHRASE`, the plugin already reads that variable by default, so setup-java writes nothing extra to `settings.xml`.
|
||||
- Otherwise (including the default `GPG_PASSPHRASE`), setup-java configures `gpg.passphraseEnvName` through an active profile in the generated `settings.xml` so the plugin reads the passphrase from that variable. For the default `gpg-passphrase: GPG_PASSPHRASE`:
|
||||
|
||||
```xml
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>setup-java-gpg</id>
|
||||
<properties>
|
||||
<gpg.passphraseEnvName>GPG_PASSPHRASE</gpg.passphraseEnvName>
|
||||
</properties>
|
||||
</profile>
|
||||
</profiles>
|
||||
<activeProfiles>
|
||||
<activeProfile>setup-java-gpg</activeProfile>
|
||||
</activeProfiles>
|
||||
```
|
||||
|
||||
> **Note:** Earlier versions of setup-java wrote a `gpg.passphrase` server to `settings.xml`. That mechanism is deprecated by the Maven GPG Plugin and fails when its `bestPractices` mode is enabled, so setup-java now relies on `gpg.passphraseEnvName` instead. The `gpg-passphrase` input and its `GPG_PASSPHRASE` default are unchanged, so existing workflows that set the `GPG_PASSPHRASE` environment variable keep working.
|
||||
|
||||
> **Compatibility note:** Reading the passphrase from an environment variable (`gpg.passphraseEnvName`) requires `maven-gpg-plugin` 3.2.0 or newer. Older versions do not honor this property and will not pick up the passphrase, because setup-java no longer writes the deprecated `gpg.passphrase` server to `settings.xml`. If you are pinned to `maven-gpg-plugin` older than 3.2.0, upgrade to 3.2.0+.
|
||||
|
||||
When signing with the `gpg` executable, the Maven GPG Plugin configuration in your `pom.xml` should contain the following structure to avoid possible issues like `Inappropriate ioctl for device` or `gpg: signing failed: No such file or directory`:
|
||||
The Maven GPG Plugin configuration in the pom.xml file should contain the following structure to avoid possible issues like `Inappropriate ioctl for device` or `gpg: signing failed: No such file or directory`:
|
||||
|
||||
```xml
|
||||
<configuration>
|
||||
@@ -718,10 +533,17 @@ When signing with the `gpg` executable, the Maven GPG Plugin configuration in yo
|
||||
</gpgArguments>
|
||||
</configuration>
|
||||
```
|
||||
GPG 2.1 requires `--pinentry-mode` to be set to `loopback` in order to pick up the `gpg.passphrase` value defined in Maven `settings.xml`.
|
||||
|
||||
GPG 2.1 requires `--pinentry-mode` to be set to `loopback` in order to read the passphrase non-interactively.
|
||||
### GPG
|
||||
|
||||
***NOTE***: If, when using the default `gpg` signer, the error `gpg: Sorry, no terminal at all requested - can't get input` [is encountered](https://github.com/actions/setup-java/issues/554), please update the version of `maven-gpg-plugin` to 1.6 or higher.
|
||||
If `gpg-private-key` input is provided, the private key will be written to a file in the runner's temp directory, the private key file will be imported into the GPG keychain, and then the file will be promptly removed before proceeding with the rest of the setup process. A cleanup step will remove the imported private key from the GPG keychain after the job completes regardless of the job status. This ensures that the private key is no longer accessible on self-hosted runners and cannot "leak" between jobs (hosted runners are always clean instances).
|
||||
|
||||
**GPG key should be exported by: `gpg --armor --export-secret-keys YOUR_ID`**
|
||||
|
||||
See the help docs on [Publishing a Package](https://help.github.com/en/github/managing-packages-with-github-packages/configuring-apache-maven-for-use-with-github-packages#publishing-a-package) for more information on the `pom.xml` file.
|
||||
|
||||
***NOTE***: If the error that states, `gpg: Sorry, no terminal at all requested - can't get input` [is encountered](https://github.com/actions/setup-java/issues/554), please update the version of `maven-gpg-plugin` to 1.6 or higher.
|
||||
|
||||
## Apache Maven with a settings path
|
||||
|
||||
|
||||
@@ -1,74 +0,0 @@
|
||||
// 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.
|
||||
import js from '@eslint/js';
|
||||
import tsParser from '@typescript-eslint/parser';
|
||||
import tsPlugin from '@typescript-eslint/eslint-plugin';
|
||||
import jest from 'eslint-plugin-jest';
|
||||
import n from 'eslint-plugin-n';
|
||||
import prettier from 'eslint-config-prettier';
|
||||
import globals from 'globals';
|
||||
|
||||
export default [
|
||||
{
|
||||
ignores: ['**/*', '!src/**', '!__tests__/**']
|
||||
},
|
||||
js.configs.recommended,
|
||||
{
|
||||
files: ['**/*.ts'],
|
||||
languageOptions: {
|
||||
parser: tsParser,
|
||||
ecmaVersion: 2022,
|
||||
sourceType: 'module',
|
||||
globals: {
|
||||
...globals.node,
|
||||
...globals.es2015
|
||||
}
|
||||
},
|
||||
plugins: {
|
||||
'@typescript-eslint': tsPlugin,
|
||||
n
|
||||
},
|
||||
rules: {
|
||||
...tsPlugin.configs.recommended.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}],
|
||||
'no-undef': 'off',
|
||||
'no-useless-assignment': 'off',
|
||||
'n/no-extraneous-import': 'error'
|
||||
}
|
||||
},
|
||||
{
|
||||
files: ['**/*{test,spec}.ts'],
|
||||
plugins: {jest},
|
||||
languageOptions: {
|
||||
globals: {
|
||||
...globals.jest
|
||||
}
|
||||
},
|
||||
rules: {
|
||||
...jest.configs['flat/recommended'].rules,
|
||||
'@typescript-eslint/no-unused-vars': 'off',
|
||||
'jest/no-standalone-expect': 'off',
|
||||
'jest/no-conditional-expect': 'off',
|
||||
'no-console': 'off'
|
||||
}
|
||||
},
|
||||
prettier
|
||||
];
|
||||
@@ -0,0 +1,11 @@
|
||||
module.exports = {
|
||||
clearMocks: true,
|
||||
moduleFileExtensions: ['js', 'ts'],
|
||||
testEnvironment: 'node',
|
||||
testMatch: ['**/*.test.ts'],
|
||||
testRunner: 'jest-circus/runner',
|
||||
transform: {
|
||||
'^.+\\.ts$': 'ts-jest'
|
||||
},
|
||||
verbose: true
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
export default {
|
||||
clearMocks: true,
|
||||
moduleFileExtensions: ['js', 'ts'],
|
||||
roots: ['<rootDir>'],
|
||||
testEnvironment: 'node',
|
||||
testMatch: ['**/*.test.ts'],
|
||||
transform: {
|
||||
'^.+\\.ts$': [
|
||||
'ts-jest',
|
||||
{
|
||||
useESM: true,
|
||||
diagnostics: {
|
||||
ignoreCodes: [151002]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
extensionsToTreatAsEsm: ['.ts'],
|
||||
transformIgnorePatterns: ['node_modules/(?!(@actions)/)'],
|
||||
moduleNameMapper: {
|
||||
'^(\\.{1,2}/.*)\\.js$': '$1'
|
||||
},
|
||||
verbose: true
|
||||
}
|
||||
Generated
+1707
-1718
File diff suppressed because it is too large
Load Diff
+26
-28
@@ -1,7 +1,6 @@
|
||||
{
|
||||
"name": "setup-java",
|
||||
"version": "6.0.0",
|
||||
"type": "module",
|
||||
"version": "5.6.0",
|
||||
"private": true,
|
||||
"description": "setup java action",
|
||||
"main": "dist/setup/index.js",
|
||||
@@ -10,24 +9,24 @@
|
||||
},
|
||||
"scripts": {
|
||||
"build": "ncc build -o dist/setup src/setup-java.ts && ncc build -o dist/cleanup src/cleanup-java.ts",
|
||||
"format": "prettier --no-error-on-unmatched-pattern --write \"**/*.{ts,yml,yaml}\"",
|
||||
"format-check": "prettier --no-error-on-unmatched-pattern --check \"**/*.{ts,yml,yaml}\"",
|
||||
"lint": "eslint \"**/*.ts\"",
|
||||
"lint:fix": "eslint \"**/*.ts\" --fix",
|
||||
"format": "prettier --no-error-on-unmatched-pattern --config ./.prettierrc.js --write \"**/*.{ts,yml,yaml}\"",
|
||||
"format-check": "prettier --no-error-on-unmatched-pattern --config ./.prettierrc.js --check \"**/*.{ts,yml,yaml}\"",
|
||||
"lint": "eslint --config ./.eslintrc.js \"**/*.ts\"",
|
||||
"lint:fix": "eslint --config ./.eslintrc.js \"**/*.ts\" --fix",
|
||||
"check": "npm run format-check && npm run lint && npm run build && npm test",
|
||||
"fix": "npm run format && npm run lint:fix && npm run build",
|
||||
"prepare": "husky install",
|
||||
"prerelease": "npm run-script build",
|
||||
"release": "git add -f dist/setup/index.js dist/cleanup/index.js",
|
||||
"test": "node --experimental-vm-modules ./node_modules/jest/bin/jest.js --runInBand --coverage"
|
||||
"test": "jest"
|
||||
},
|
||||
"lint-staged": {
|
||||
"*.ts": [
|
||||
"prettier --no-error-on-unmatched-pattern --write",
|
||||
"eslint --fix"
|
||||
"prettier --no-error-on-unmatched-pattern --config ./.prettierrc.js --write",
|
||||
"eslint --config ./.eslintrc.js --fix"
|
||||
],
|
||||
"*.{yml,yaml}": [
|
||||
"prettier --no-error-on-unmatched-pattern --write"
|
||||
"prettier --no-error-on-unmatched-pattern --config ./.prettierrc.js --write"
|
||||
]
|
||||
},
|
||||
"repository": {
|
||||
@@ -42,35 +41,34 @@
|
||||
"author": "GitHub",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@actions/cache": "^6.2.0",
|
||||
"@actions/core": "^3.0.1",
|
||||
"@actions/exec": "^3.0.0",
|
||||
"@actions/glob": "^0.7.0",
|
||||
"@actions/http-client": "^4.0.1",
|
||||
"@actions/io": "^3.0.2",
|
||||
"@actions/tool-cache": "^4.0.0",
|
||||
"semver": "^7.8.5",
|
||||
"@actions/cache": "^5.1.0",
|
||||
"@actions/core": "^2.0.3",
|
||||
"@actions/exec": "^2.0.0",
|
||||
"@actions/glob": "^0.5.1",
|
||||
"@actions/http-client": "^3.0.2",
|
||||
"@actions/io": "^2.0.0",
|
||||
"@actions/tool-cache": "^3.0.1",
|
||||
"semver": "^7.6.0",
|
||||
"xmlbuilder2": "^4.0.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@eslint/js": "^10.0.1",
|
||||
"@jest/globals": "^30.4.1",
|
||||
"@types/node": "^26.1.1",
|
||||
"@types/semver": "^7.7.0",
|
||||
"@typescript-eslint/eslint-plugin": "^8.62.0",
|
||||
"@types/jest": "^30.0.0",
|
||||
"@types/node": "^26.0.0",
|
||||
"@types/semver": "^7.5.8",
|
||||
"@typescript-eslint/eslint-plugin": "^8.48.0",
|
||||
"@typescript-eslint/parser": "^8.62.0",
|
||||
"@vercel/ncc": "^0.44.0",
|
||||
"eslint": "^10.7.0",
|
||||
"eslint": "^8.57.0",
|
||||
"eslint-config-prettier": "^10.1.8",
|
||||
"eslint-plugin-jest": "^29.15.4",
|
||||
"eslint-plugin-n": "^18.2.2",
|
||||
"globals": "^17.7.0",
|
||||
"eslint-plugin-node": "^11.1.0",
|
||||
"husky": "^9.1.7",
|
||||
"jest": "^30.4.2",
|
||||
"jest-circus": "^30.4.2",
|
||||
"lint-staged": "^17.0.8",
|
||||
"prettier": "^3.9.5",
|
||||
"prettier": "^3.9.1",
|
||||
"ts-jest": "^29.4.11",
|
||||
"typescript": "^6.0.3"
|
||||
"typescript": "^5.3.3"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/actions/setup-java/issues"
|
||||
|
||||
+8
-23
@@ -6,9 +6,9 @@ import * as fs from 'fs';
|
||||
import * as os from 'os';
|
||||
|
||||
import {create as xmlCreate} from 'xmlbuilder2';
|
||||
import * as constants from './constants.js';
|
||||
import * as gpg from './gpg.js';
|
||||
import {getBooleanInput} from './util.js';
|
||||
import * as constants from './constants';
|
||||
import * as gpg from './gpg';
|
||||
import {getBooleanInput} from './util';
|
||||
|
||||
export async function configureAuthentication() {
|
||||
const id = core.getInput(constants.INPUT_SERVER_ID);
|
||||
@@ -93,27 +93,12 @@ export function generate(
|
||||
}
|
||||
};
|
||||
|
||||
// The maven-gpg-plugin reads the passphrase from the environment variable
|
||||
// named by the `gpg.passphraseEnvName` property (default MAVEN_GPG_PASSPHRASE).
|
||||
// Only configure it when the requested env var name differs from that default;
|
||||
// otherwise the plugin already reads the right variable and no extra settings
|
||||
// are needed. Writing `gpg.passphrase` to settings.xml is deprecated and fails
|
||||
// when the plugin's `bestPractices` mode is enabled.
|
||||
if (
|
||||
gpgPassphrase &&
|
||||
gpgPassphrase !== constants.MAVEN_GPG_PASSPHRASE_DEFAULT_ENV
|
||||
) {
|
||||
xmlObj.settings.profiles = {
|
||||
profile: {
|
||||
id: constants.GPG_PASSPHRASE_PROFILE_ID,
|
||||
properties: {
|
||||
'gpg.passphraseEnvName': gpgPassphrase
|
||||
}
|
||||
}
|
||||
};
|
||||
xmlObj.settings.activeProfiles = {
|
||||
activeProfile: constants.GPG_PASSPHRASE_PROFILE_ID
|
||||
if (gpgPassphrase) {
|
||||
const gpgServer = {
|
||||
id: 'gpg.passphrase',
|
||||
passphrase: `\${env.${gpgPassphrase}}`
|
||||
};
|
||||
xmlObj.settings.servers.server.push(gpgServer);
|
||||
}
|
||||
|
||||
return xmlCreate(xmlObj).end({
|
||||
|
||||
+5
-6
@@ -1,9 +1,8 @@
|
||||
import * as core from '@actions/core';
|
||||
import * as gpg from './gpg.js';
|
||||
import * as constants from './constants.js';
|
||||
import {isJobStatusSuccess} from './util.js';
|
||||
import {save} from './cache.js';
|
||||
import {fileURLToPath} from 'url';
|
||||
import * as gpg from './gpg';
|
||||
import * as constants from './constants';
|
||||
import {isJobStatusSuccess} from './util';
|
||||
import {save} from './cache';
|
||||
|
||||
async function removePrivateKeyFromKeychain() {
|
||||
if (core.getInput(constants.INPUT_GPG_PRIVATE_KEY, {required: false})) {
|
||||
@@ -53,7 +52,7 @@ export async function run() {
|
||||
await ignoreError(saveCache());
|
||||
}
|
||||
|
||||
if (process.argv[1] === fileURLToPath(import.meta.url)) {
|
||||
if (require.main === module) {
|
||||
run();
|
||||
} else {
|
||||
// https://nodejs.org/api/modules.html#modules_accessing_the_main_module
|
||||
|
||||
@@ -21,14 +21,6 @@ export const INPUT_GPG_PASSPHRASE = 'gpg-passphrase';
|
||||
export const INPUT_DEFAULT_GPG_PRIVATE_KEY = undefined;
|
||||
export const INPUT_DEFAULT_GPG_PASSPHRASE = 'GPG_PASSPHRASE';
|
||||
|
||||
// The default name of the environment variable the maven-gpg-plugin reads the
|
||||
// passphrase from (property `gpg.passphraseEnvName`). When the configured
|
||||
// passphrase env var name matches this, no extra configuration is required.
|
||||
export const MAVEN_GPG_PASSPHRASE_DEFAULT_ENV = 'MAVEN_GPG_PASSPHRASE';
|
||||
|
||||
// Id of the settings.xml profile used to set `gpg.passphraseEnvName`.
|
||||
export const GPG_PASSPHRASE_PROFILE_ID = 'setup-java-gpg';
|
||||
|
||||
export const INPUT_CACHE = 'cache';
|
||||
export const INPUT_CACHE_DEPENDENCY_PATH = 'cache-dependency-path';
|
||||
export const INPUT_JOB_STATUS = 'job-status';
|
||||
|
||||
@@ -5,13 +5,13 @@ import fs from 'fs';
|
||||
import path from 'path';
|
||||
import semver from 'semver';
|
||||
|
||||
import {JavaBase} from '../base-installer.js';
|
||||
import {IAdoptAvailableVersions} from './models.js';
|
||||
import {JavaBase} from '../base-installer';
|
||||
import {IAdoptAvailableVersions} from './models';
|
||||
import {
|
||||
JavaDownloadRelease,
|
||||
JavaInstallerOptions,
|
||||
JavaInstallerResults
|
||||
} from '../base-models.js';
|
||||
} from '../base-models';
|
||||
import {
|
||||
extractJdkFile,
|
||||
getNextPageUrlFromLinkHeader,
|
||||
@@ -20,11 +20,8 @@ import {
|
||||
renameWinArchive,
|
||||
MAX_PAGINATION_PAGES,
|
||||
validatePaginationUrl
|
||||
} from '../../util.js';
|
||||
import {
|
||||
TemurinDistribution,
|
||||
TemurinImplementation
|
||||
} from '../temurin/installer.js';
|
||||
} from '../../util';
|
||||
import {TemurinDistribution, TemurinImplementation} from '../temurin/installer';
|
||||
|
||||
export enum AdoptImplementation {
|
||||
Hotspot = 'Hotspot',
|
||||
|
||||
@@ -4,17 +4,13 @@ import * as fs from 'fs';
|
||||
import semver from 'semver';
|
||||
import path from 'path';
|
||||
import * as httpm from '@actions/http-client';
|
||||
import {
|
||||
convertVersionToSemver,
|
||||
getToolcachePath,
|
||||
isVersionSatisfies
|
||||
} from '../util.js';
|
||||
import {getToolcachePath, isVersionSatisfies} from '../util';
|
||||
import {
|
||||
JavaDownloadRelease,
|
||||
JavaInstallerOptions,
|
||||
JavaInstallerResults
|
||||
} from './base-models.js';
|
||||
import {MACOS_JAVA_CONTENT_POSTFIX} from '../constants.js';
|
||||
} from './base-models';
|
||||
import {MACOS_JAVA_CONTENT_POSTFIX} from '../constants';
|
||||
import os from 'os';
|
||||
|
||||
export abstract class JavaBase {
|
||||
@@ -23,7 +19,6 @@ export abstract class JavaBase {
|
||||
protected architecture: string;
|
||||
protected packageType: string;
|
||||
protected stable: boolean;
|
||||
protected latest: boolean;
|
||||
protected checkLatest: boolean;
|
||||
protected setDefault: boolean;
|
||||
protected verifySignature: boolean;
|
||||
@@ -38,11 +33,9 @@ export abstract class JavaBase {
|
||||
maxRetries: 3
|
||||
});
|
||||
|
||||
({
|
||||
version: this.version,
|
||||
stable: this.stable,
|
||||
latest: this.latest
|
||||
} = this.normalizeVersion(installerOptions.version));
|
||||
({version: this.version, stable: this.stable} = this.normalizeVersion(
|
||||
installerOptions.version
|
||||
));
|
||||
this.architecture = installerOptions.architecture || os.arch();
|
||||
this.packageType = installerOptions.packageType;
|
||||
this.checkLatest = installerOptions.checkLatest;
|
||||
@@ -69,7 +62,7 @@ export abstract class JavaBase {
|
||||
}
|
||||
|
||||
let foundJava = this.findInToolcache();
|
||||
if (foundJava && !this.checkLatest && !this.latest) {
|
||||
if (foundJava && !this.checkLatest) {
|
||||
core.info(`Resolved Java ${foundJava.version} from tool-cache`);
|
||||
} else {
|
||||
core.info('Trying to resolve the latest version from remote');
|
||||
@@ -270,30 +263,6 @@ export abstract class JavaBase {
|
||||
|
||||
protected normalizeVersion(version: string) {
|
||||
let stable = true;
|
||||
const latest = false;
|
||||
|
||||
// Support the `latest` alias (case-insensitive), which floats to the newest
|
||||
// available stable/GA release. It is translated to the SemVer wildcard `x`
|
||||
// so the existing "newest satisfying version wins" resolution applies.
|
||||
const normalized = version.trim().toLowerCase();
|
||||
if (normalized === 'latest') {
|
||||
return {
|
||||
version: 'x',
|
||||
stable: true,
|
||||
latest: true
|
||||
};
|
||||
}
|
||||
|
||||
// Reject `latest` combined with any qualifier (e.g. `latest-ea`). Such inputs
|
||||
// would otherwise have their `-ea` suffix stripped and fall through to the
|
||||
// generic SemVer check, which fails with a confusing "'latest' is not valid
|
||||
// SemVer" message even though `latest` is a supported value. Fail early with a
|
||||
// targeted explanation instead.
|
||||
if (normalized.startsWith('latest')) {
|
||||
throw new Error(
|
||||
`The 'latest' alias resolves stable (GA) releases only and cannot be combined with '-ea' or other qualifiers (received '${version}'). Use 'latest' on its own, or specify a concrete version.`
|
||||
);
|
||||
}
|
||||
|
||||
if (version.endsWith('-ea')) {
|
||||
version = version.replace(/-ea$/, '');
|
||||
@@ -304,15 +273,6 @@ export abstract class JavaBase {
|
||||
stable = false;
|
||||
}
|
||||
|
||||
// Java uses a versioning scheme (JEP 322) that can contain more numeric
|
||||
// fields than SemVer allows, e.g. '18.0.1.1' or '11.0.9.1'. Convert such
|
||||
// exact versions to SemVer build notation ('18.0.1+1') so they are
|
||||
// accepted. Ranges and versions that already carry build metadata are
|
||||
// left untouched.
|
||||
if (/^\d+(\.\d+){3,}$/.test(version)) {
|
||||
version = convertVersionToSemver(version);
|
||||
}
|
||||
|
||||
if (!semver.validRange(version)) {
|
||||
throw new Error(
|
||||
`The string '${version}' is not valid SemVer notation for a Java version. Please check README file for code snippets and more detailed information`
|
||||
@@ -321,8 +281,7 @@ export abstract class JavaBase {
|
||||
|
||||
return {
|
||||
version,
|
||||
stable,
|
||||
latest
|
||||
stable
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -7,17 +7,17 @@ import {
|
||||
getDownloadArchiveExtension,
|
||||
convertVersionToSemver,
|
||||
renameWinArchive
|
||||
} from '../../util.js';
|
||||
import {JavaBase} from '../base-installer.js';
|
||||
} from '../../util';
|
||||
import {JavaBase} from '../base-installer';
|
||||
import {
|
||||
JavaDownloadRelease,
|
||||
JavaInstallerOptions,
|
||||
JavaInstallerResults
|
||||
} from '../base-models.js';
|
||||
} from '../base-models';
|
||||
import {
|
||||
ICorrettoAllAvailableVersions,
|
||||
ICorrettoAvailableVersions
|
||||
} from './models.js';
|
||||
} from './models';
|
||||
|
||||
export class CorrettoDistribution extends JavaBase {
|
||||
constructor(installerOptions: JavaInstallerOptions) {
|
||||
@@ -59,28 +59,10 @@ export class CorrettoDistribution extends JavaBase {
|
||||
if (!this.stable) {
|
||||
throw new Error('Early access versions are not supported');
|
||||
}
|
||||
const availableVersions = await this.getAvailableVersions();
|
||||
|
||||
// The `latest` alias is normalized to the SemVer wildcard, but Corretto
|
||||
// matches on an exact major version, so resolve it to the newest available
|
||||
// major from Corretto's own list.
|
||||
if (this.latest) {
|
||||
const majors = availableVersions
|
||||
.map(item => parseInt(item.version, 10))
|
||||
.filter(major => Number.isFinite(major) && major > 0);
|
||||
|
||||
if (majors.length === 0) {
|
||||
throw new Error(
|
||||
'Could not determine the latest available Corretto major version from remote metadata'
|
||||
);
|
||||
}
|
||||
|
||||
version = Math.max(...majors).toString();
|
||||
}
|
||||
|
||||
if (version.includes('.')) {
|
||||
throw new Error('Only major versions are supported');
|
||||
}
|
||||
const availableVersions = await this.getAvailableVersions();
|
||||
const matchingVersions = availableVersions
|
||||
.filter(item => item.version == version)
|
||||
.map(item => {
|
||||
|
||||
@@ -1,26 +1,22 @@
|
||||
import {JavaBase} from './base-installer.js';
|
||||
import {JavaInstallerOptions} from './base-models.js';
|
||||
import {LocalDistribution} from './local/installer.js';
|
||||
import {ZuluDistribution} from './zulu/installer.js';
|
||||
import {AdoptDistribution, AdoptImplementation} from './adopt/installer.js';
|
||||
import {
|
||||
TemurinDistribution,
|
||||
TemurinImplementation
|
||||
} from './temurin/installer.js';
|
||||
import {LibericaDistributions} from './liberica/installer.js';
|
||||
import {LibericaNikDistributions} from './liberica-nik/installer.js';
|
||||
import {MicrosoftDistributions} from './microsoft/installer.js';
|
||||
import {SemeruDistribution} from './semeru/installer.js';
|
||||
import {CorrettoDistribution} from './corretto/installer.js';
|
||||
import {OracleDistribution} from './oracle/installer.js';
|
||||
import {DragonwellDistribution} from './dragonwell/installer.js';
|
||||
import {SapMachineDistribution} from './sapmachine/installer.js';
|
||||
import {JavaBase} from './base-installer';
|
||||
import {JavaInstallerOptions} from './base-models';
|
||||
import {LocalDistribution} from './local/installer';
|
||||
import {ZuluDistribution} from './zulu/installer';
|
||||
import {AdoptDistribution, AdoptImplementation} from './adopt/installer';
|
||||
import {TemurinDistribution, TemurinImplementation} from './temurin/installer';
|
||||
import {LibericaDistributions} from './liberica/installer';
|
||||
import {MicrosoftDistributions} from './microsoft/installer';
|
||||
import {SemeruDistribution} from './semeru/installer';
|
||||
import {CorrettoDistribution} from './corretto/installer';
|
||||
import {OracleDistribution} from './oracle/installer';
|
||||
import {DragonwellDistribution} from './dragonwell/installer';
|
||||
import {SapMachineDistribution} from './sapmachine/installer';
|
||||
import {
|
||||
GraalVMCommunityDistribution,
|
||||
GraalVMDistribution
|
||||
} from './graalvm/installer.js';
|
||||
import {JetBrainsDistribution} from './jetbrains/installer.js';
|
||||
import {KonaDistribution} from './kona/installer.js';
|
||||
} from './graalvm/installer';
|
||||
import {JetBrainsDistribution} from './jetbrains/installer';
|
||||
import {KonaDistribution} from './kona/installer';
|
||||
|
||||
enum JavaDistribution {
|
||||
Adopt = 'adopt',
|
||||
@@ -29,7 +25,6 @@ enum JavaDistribution {
|
||||
Temurin = 'temurin',
|
||||
Zulu = 'zulu',
|
||||
Liberica = 'liberica',
|
||||
LibericaNik = 'liberica-nik',
|
||||
JdkFile = 'jdkfile',
|
||||
Microsoft = 'microsoft',
|
||||
Semeru = 'semeru',
|
||||
@@ -71,8 +66,6 @@ export function getJavaDistribution(
|
||||
return new ZuluDistribution(installerOptions);
|
||||
case JavaDistribution.Liberica:
|
||||
return new LibericaDistributions(installerOptions);
|
||||
case JavaDistribution.LibericaNik:
|
||||
return new LibericaNikDistributions(installerOptions);
|
||||
case JavaDistribution.Microsoft:
|
||||
return new MicrosoftDistributions(installerOptions);
|
||||
case JavaDistribution.Semeru:
|
||||
|
||||
@@ -5,7 +5,7 @@ import semver from 'semver';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
|
||||
import {JavaBase} from '../base-installer.js';
|
||||
import {JavaBase} from '../base-installer';
|
||||
import {
|
||||
convertVersionToSemver,
|
||||
extractJdkFile,
|
||||
@@ -13,13 +13,13 @@ import {
|
||||
getGitHubHttpHeaders,
|
||||
isVersionSatisfies,
|
||||
renameWinArchive
|
||||
} from '../../util.js';
|
||||
import {IDragonwellVersions, IDragonwellAllVersions} from './models.js';
|
||||
} from '../../util';
|
||||
import {IDragonwellVersions, IDragonwellAllVersions} from './models';
|
||||
import {
|
||||
JavaDownloadRelease,
|
||||
JavaInstallerOptions,
|
||||
JavaInstallerResults
|
||||
} from '../base-models.js';
|
||||
} from '../base-models';
|
||||
|
||||
export class DragonwellDistribution extends JavaBase {
|
||||
constructor(installerOptions: JavaInstallerOptions) {
|
||||
|
||||
@@ -3,26 +3,25 @@ import * as tc from '@actions/tool-cache';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import semver from 'semver';
|
||||
import {JavaBase} from '../base-installer.js';
|
||||
import {JavaBase} from '../base-installer';
|
||||
import {HttpCodes} from '@actions/http-client';
|
||||
import {GraalVMEAVersion} from './models.js';
|
||||
import {GraalVMEAVersion} from './models';
|
||||
import {
|
||||
JavaDownloadRelease,
|
||||
JavaInstallerOptions,
|
||||
JavaInstallerResults
|
||||
} from '../base-models.js';
|
||||
} from '../base-models';
|
||||
import {
|
||||
convertVersionToSemver,
|
||||
extractJdkFile,
|
||||
getDownloadArchiveExtension,
|
||||
getGitHubHttpHeaders,
|
||||
getLatestMajorVersion,
|
||||
getNextPageUrlFromLinkHeader,
|
||||
isVersionSatisfies,
|
||||
MAX_PAGINATION_PAGES,
|
||||
renameWinArchive,
|
||||
validatePaginationUrl
|
||||
} from '../../util.js';
|
||||
} from '../../util';
|
||||
|
||||
const GRAALVM_DL_BASE = 'https://download.oracle.com/graalvm';
|
||||
const GRAALVM_DOWNLOAD_URL = 'https://www.graalvm.org/downloads/';
|
||||
@@ -120,13 +119,6 @@ export class GraalVMDistribution extends JavaBase {
|
||||
return this.findEABuildDownloadUrl(`${range}-ea`);
|
||||
}
|
||||
|
||||
// The `latest` alias is normalized to the SemVer wildcard. Oracle GraalVM
|
||||
// builds its download URLs from a concrete major and has no endpoint to list
|
||||
// releases, so resolve the newest available GA major from the Adoptium API.
|
||||
if (this.latest) {
|
||||
range = (await getLatestMajorVersion(this.http)).toString();
|
||||
}
|
||||
|
||||
const {platform, extension, major} = this.validateStableBuildRequest(range);
|
||||
|
||||
const fileUrl = this.constructFileUrl(
|
||||
@@ -211,9 +203,6 @@ export class GraalVMDistribution extends JavaBase {
|
||||
if (statusCode === HttpCodes.NotFound) {
|
||||
// Create the standard error with additional hint about checking the download URL
|
||||
const error = this.createVersionNotFoundError(range);
|
||||
if (this.latest) {
|
||||
error.message += `\nThe latest Java major version (${range}) is not yet available for the ${this.distribution} distribution. Please specify a concrete version instead of 'latest'.`;
|
||||
}
|
||||
error.message += `\nPlease check if this version is available at ${GRAALVM_DOWNLOAD_URL} . Pick a version from the list.`;
|
||||
throw error;
|
||||
}
|
||||
@@ -311,20 +300,17 @@ export class GraalVMDistribution extends JavaBase {
|
||||
// Check if it's a 404 error (file not found)
|
||||
if (error.message?.includes('404')) {
|
||||
throw new Error(
|
||||
`GraalVM EA version '${javaEaVersion}' not found. Please verify the version exists in the EA builds repository.`,
|
||||
{cause: error}
|
||||
`GraalVM EA version '${javaEaVersion}' not found. Please verify the version exists in the EA builds repository.`
|
||||
);
|
||||
}
|
||||
// Re-throw with more context
|
||||
throw new Error(
|
||||
`Failed to fetch GraalVM EA version information for '${javaEaVersion}': ${error.message}`,
|
||||
{cause: error}
|
||||
`Failed to fetch GraalVM EA version information for '${javaEaVersion}': ${error.message}`
|
||||
);
|
||||
}
|
||||
// If it's not an Error instance, throw a generic error
|
||||
throw new Error(
|
||||
`Failed to fetch GraalVM EA version information for '${javaEaVersion}'`,
|
||||
{cause: error}
|
||||
`Failed to fetch GraalVM EA version information for '${javaEaVersion}'`
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -365,27 +351,7 @@ export class GraalVMCommunityDistribution extends GraalVMDistribution {
|
||||
}
|
||||
|
||||
const arch = this.getSupportedArchitecture();
|
||||
|
||||
// GraalVM Community publishes its releases on GitHub, so the `latest` alias
|
||||
// (normalized to the SemVer wildcard `x`) can float to the newest GA it
|
||||
// actually ships. Unlike Oracle GraalVM (which has no listing endpoint and
|
||||
// must derive the newest major from the Adoptium API), we match against the
|
||||
// real release list here, so `latest` never fails when GraalVM lags behind a
|
||||
// brand-new Java major.
|
||||
let platform: OsVersions;
|
||||
let extension: string;
|
||||
if (this.latest) {
|
||||
if (this.packageType !== 'jdk') {
|
||||
throw new Error(
|
||||
`${this.distribution} provides only the \`jdk\` package type`
|
||||
);
|
||||
}
|
||||
platform = this.getPlatform();
|
||||
extension = getDownloadArchiveExtension();
|
||||
} else {
|
||||
({platform, extension} = this.validateStableBuildRequest(range));
|
||||
}
|
||||
|
||||
const {platform, extension} = this.validateStableBuildRequest(range);
|
||||
// GraalVM Community asset names embed the platform, architecture and
|
||||
// archive type, e.g. `graalvm-community-jdk-21.0.2_linux-x64_bin.tar.gz`.
|
||||
const assetSuffix = `_${platform}-${arch}_bin.${extension}`;
|
||||
|
||||
@@ -5,14 +5,14 @@ import fs from 'fs';
|
||||
import path from 'path';
|
||||
import semver from 'semver';
|
||||
|
||||
import {JavaBase} from '../base-installer.js';
|
||||
import {IJetBrainsRawVersion, IJetBrainsVersion} from './models.js';
|
||||
import {JavaBase} from '../base-installer';
|
||||
import {IJetBrainsRawVersion, IJetBrainsVersion} from './models';
|
||||
import {
|
||||
JavaDownloadRelease,
|
||||
JavaInstallerOptions,
|
||||
JavaInstallerResults
|
||||
} from '../base-models.js';
|
||||
import {extractJdkFile, isVersionSatisfies} from '../../util.js';
|
||||
} from '../base-models';
|
||||
import {extractJdkFile, isVersionSatisfies} from '../../util';
|
||||
import {OutgoingHttpHeaders} from 'http';
|
||||
import {HttpCodes} from '@actions/http-client';
|
||||
|
||||
|
||||
@@ -5,19 +5,19 @@ import semver from 'semver';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
|
||||
import {JavaBase} from '../base-installer.js';
|
||||
import {IKonaReleaseInfo, IKonaRelease} from './models.js';
|
||||
import {JavaBase} from '../base-installer';
|
||||
import {IKonaReleaseInfo, IKonaRelease} from './models';
|
||||
import {
|
||||
JavaDownloadRelease,
|
||||
JavaInstallerOptions,
|
||||
JavaInstallerResults
|
||||
} from '../base-models.js';
|
||||
} from '../base-models';
|
||||
import {
|
||||
extractJdkFile,
|
||||
getDownloadArchiveExtension,
|
||||
isVersionSatisfies,
|
||||
renameWinArchive
|
||||
} from '../../util.js';
|
||||
} from '../../util';
|
||||
|
||||
export class KonaDistribution extends JavaBase {
|
||||
constructor(installerOptions: JavaInstallerOptions) {
|
||||
|
||||
@@ -1,180 +0,0 @@
|
||||
import {JavaBase} from '../base-installer.js';
|
||||
import {
|
||||
JavaDownloadRelease,
|
||||
JavaInstallerOptions,
|
||||
JavaInstallerResults
|
||||
} from '../base-models.js';
|
||||
import semver from 'semver';
|
||||
import {
|
||||
extractJdkFile,
|
||||
getDownloadArchiveExtension,
|
||||
isVersionSatisfies,
|
||||
renameWinArchive
|
||||
} from '../../util.js';
|
||||
import * as core from '@actions/core';
|
||||
import {ArchitectureOptions, NikVersion, OsVersions} from './models.js';
|
||||
import * as tc from '@actions/tool-cache';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
|
||||
const supportedPlatform = `'linux', 'macos', 'windows'`;
|
||||
|
||||
const supportedArchitectures = `'x64', 'aarch64'`;
|
||||
|
||||
export class LibericaNikDistributions extends JavaBase {
|
||||
constructor(installerOptions: JavaInstallerOptions) {
|
||||
super('Liberica_NIK', installerOptions);
|
||||
}
|
||||
|
||||
protected async downloadTool(
|
||||
javaRelease: JavaDownloadRelease
|
||||
): Promise<JavaInstallerResults> {
|
||||
core.info(
|
||||
`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`
|
||||
);
|
||||
let javaArchivePath = await tc.downloadTool(javaRelease.url);
|
||||
|
||||
core.info(`Extracting Java archive...`);
|
||||
const extension = getDownloadArchiveExtension();
|
||||
if (process.platform === 'win32') {
|
||||
javaArchivePath = renameWinArchive(javaArchivePath);
|
||||
}
|
||||
const extractedJavaPath = await extractJdkFile(javaArchivePath, extension);
|
||||
|
||||
const archiveName = fs.readdirSync(extractedJavaPath)[0];
|
||||
const archivePath = path.join(extractedJavaPath, archiveName);
|
||||
|
||||
const javaPath = await tc.cacheDir(
|
||||
archivePath,
|
||||
this.toolcacheFolderName,
|
||||
this.getToolcacheVersionName(javaRelease.version),
|
||||
this.architecture
|
||||
);
|
||||
|
||||
return {version: javaRelease.version, path: javaPath};
|
||||
}
|
||||
|
||||
protected async findPackageForDownload(
|
||||
range: string
|
||||
): Promise<JavaDownloadRelease> {
|
||||
const availableVersionsRaw = await this.getAvailableVersions();
|
||||
|
||||
const availableVersions = availableVersionsRaw
|
||||
.map(item => {
|
||||
const jdkVersion = this.getJdkVersion(item);
|
||||
return jdkVersion ? {url: item.downloadUrl, version: jdkVersion} : null;
|
||||
})
|
||||
.filter((item): item is {url: string; version: string} => item !== null);
|
||||
|
||||
const satisfiedVersion = availableVersions
|
||||
.filter(item => isVersionSatisfies(range, item.version))
|
||||
.sort((a, b) => -semver.compareBuild(a.version, b.version))[0];
|
||||
|
||||
if (!satisfiedVersion) {
|
||||
const availableVersionStrings = availableVersions.map(
|
||||
item => item.version
|
||||
);
|
||||
throw this.createVersionNotFoundError(range, availableVersionStrings);
|
||||
}
|
||||
|
||||
return satisfiedVersion;
|
||||
}
|
||||
|
||||
private async getAvailableVersions(): Promise<NikVersion[]> {
|
||||
if (core.isDebug()) {
|
||||
console.time('Retrieving available versions for Liberica NIK took'); // eslint-disable-line no-console
|
||||
}
|
||||
const url = this.prepareAvailableVersionsUrl();
|
||||
|
||||
core.debug(`Gathering available versions from '${url}'`);
|
||||
|
||||
const availableVersions =
|
||||
(await this.http.getJson<NikVersion[]>(url)).result ?? [];
|
||||
|
||||
if (core.isDebug()) {
|
||||
core.startGroup('Print information about available versions');
|
||||
console.timeEnd('Retrieving available versions for Liberica NIK took'); // eslint-disable-line no-console
|
||||
core.debug(`Available versions: [${availableVersions.length}]`);
|
||||
core.debug(availableVersions.map(item => item.version).join(', '));
|
||||
core.endGroup();
|
||||
}
|
||||
|
||||
return availableVersions;
|
||||
}
|
||||
|
||||
private prepareAvailableVersionsUrl() {
|
||||
const urlOptions = {
|
||||
os: this.getPlatformOption(),
|
||||
'bundle-type': this.getBundleType(),
|
||||
...this.getArchitectureOptions(),
|
||||
'build-type': this.stable ? 'all' : 'ea',
|
||||
'installation-type': 'archive',
|
||||
fields: 'downloadUrl,version,components,component,embedded'
|
||||
};
|
||||
|
||||
const searchParams = new URLSearchParams(urlOptions).toString();
|
||||
|
||||
return `https://api.bell-sw.com/v1/nik/releases?${searchParams}`;
|
||||
}
|
||||
|
||||
// NIK's top-level `version` is the GraalVM/NIK version; the JDK version that
|
||||
// users select on lives in the embedded `liberica` component.
|
||||
private getJdkVersion(release: NikVersion): string | null {
|
||||
const liberica = release.components?.find(
|
||||
component => component.component === 'liberica'
|
||||
);
|
||||
return liberica ? this.convertVersionToSemver(liberica.version) : null;
|
||||
}
|
||||
|
||||
// The `full` bundle adds JavaFX/Swing GUI support; otherwise use `standard`.
|
||||
private getBundleType(): string {
|
||||
const [, feature] = this.packageType.split('+');
|
||||
return feature?.includes('fx') ? 'full' : 'standard';
|
||||
}
|
||||
|
||||
private getArchitectureOptions(): ArchitectureOptions {
|
||||
const arch = this.distributionArchitecture();
|
||||
switch (arch) {
|
||||
case 'x64':
|
||||
return {bitness: '64', arch: 'x86'};
|
||||
case 'aarch64':
|
||||
return {bitness: '64', arch: 'arm'};
|
||||
default:
|
||||
throw new Error(
|
||||
`Architecture '${this.architecture}' is not supported. Supported architectures: ${supportedArchitectures}`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
private getPlatformOption(
|
||||
platform: NodeJS.Platform = process.platform
|
||||
): OsVersions {
|
||||
switch (platform) {
|
||||
case 'darwin':
|
||||
return 'macos';
|
||||
case 'win32':
|
||||
case 'cygwin':
|
||||
return 'windows';
|
||||
case 'linux':
|
||||
return 'linux';
|
||||
default:
|
||||
throw new Error(
|
||||
`Platform '${platform}' is not supported. Supported platforms: ${supportedPlatform}`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// JDK versions come as strings like '25.0.1+16', '23+38' or '11.0.15.1+2'.
|
||||
// Normalize them to valid SemVer while preserving build metadata so newer
|
||||
// NIK builds of the same JDK sort ahead of older ones.
|
||||
private convertVersionToSemver(jdkVersion: string): string {
|
||||
const [main, build] = jdkVersion.split('+');
|
||||
const parts = main.split('.');
|
||||
while (parts.length < 3) {
|
||||
parts.push('0');
|
||||
}
|
||||
const base = parts.slice(0, 3).join('.');
|
||||
const buildMeta = [...parts.slice(3), ...(build ? [build] : [])];
|
||||
return buildMeta.length ? `${base}+${buildMeta.join('.')}` : base;
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
// Models from https://api.bell-sw.com/api.html (NIK product)
|
||||
|
||||
export type Bitness = '32' | '64';
|
||||
export type ArchType = 'arm' | 'ppc' | 'sparc' | 'x86';
|
||||
|
||||
export type OsVersions = 'linux' | 'linux-musl' | 'macos' | 'windows';
|
||||
|
||||
export interface ArchitectureOptions {
|
||||
bitness: Bitness;
|
||||
arch: ArchType;
|
||||
}
|
||||
|
||||
export interface NikComponent {
|
||||
component: string;
|
||||
version: string;
|
||||
embedded?: boolean;
|
||||
}
|
||||
|
||||
export interface NikVersion {
|
||||
// The main Liberica NIK VM bundle download URL.
|
||||
downloadUrl: string;
|
||||
// NIK/GraalVM version (e.g. '24.1.0+1'), kept for logging only.
|
||||
version: string;
|
||||
// The embedded `liberica` component carries the actual JDK version.
|
||||
components: NikComponent[];
|
||||
}
|
||||
@@ -1,18 +1,18 @@
|
||||
import {JavaBase} from '../base-installer.js';
|
||||
import {JavaBase} from '../base-installer';
|
||||
import {
|
||||
JavaDownloadRelease,
|
||||
JavaInstallerOptions,
|
||||
JavaInstallerResults
|
||||
} from '../base-models.js';
|
||||
} from '../base-models';
|
||||
import semver from 'semver';
|
||||
import {
|
||||
extractJdkFile,
|
||||
getDownloadArchiveExtension,
|
||||
isVersionSatisfies,
|
||||
renameWinArchive
|
||||
} from '../../util.js';
|
||||
} from '../../util';
|
||||
import * as core from '@actions/core';
|
||||
import {ArchitectureOptions, LibericaVersion, OsVersions} from './models.js';
|
||||
import {ArchitectureOptions, LibericaVersion, OsVersions} from './models';
|
||||
import * as tc from '@actions/tool-cache';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
|
||||
@@ -4,14 +4,14 @@ import * as core from '@actions/core';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
|
||||
import {JavaBase} from '../base-installer.js';
|
||||
import {JavaBase} from '../base-installer';
|
||||
import {
|
||||
JavaInstallerOptions,
|
||||
JavaDownloadRelease,
|
||||
JavaInstallerResults
|
||||
} from '../base-models.js';
|
||||
import {extractJdkFile} from '../../util.js';
|
||||
import {MACOS_JAVA_CONTENT_POSTFIX} from '../../constants.js';
|
||||
} from '../base-models';
|
||||
import {extractJdkFile} from '../../util';
|
||||
import {MACOS_JAVA_CONTENT_POSTFIX} from '../../constants';
|
||||
|
||||
export class LocalDistribution extends JavaBase {
|
||||
constructor(
|
||||
@@ -22,12 +22,6 @@ export class LocalDistribution extends JavaBase {
|
||||
}
|
||||
|
||||
public async setupJava(): Promise<JavaInstallerResults> {
|
||||
if (this.latest) {
|
||||
throw new Error(
|
||||
"The 'latest' version alias is not supported for the 'jdkfile' distribution. Please specify a concrete version."
|
||||
);
|
||||
}
|
||||
|
||||
let foundJava = this.findInToolcache();
|
||||
|
||||
if (foundJava) {
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user