From 330fe63577717f626dd19f0242956a3c4ab6ccef Mon Sep 17 00:00:00 2001 From: Maxim Lobanov Date: Mon, 8 Mar 2021 18:34:14 +0300 Subject: [PATCH 1/6] Add unit tests and e2e tests --- .github/workflows/build.yml | 33 + .github/workflows/e2e-local-file.yml | 84 ++ .github/workflows/e2e-publishing.yml | 76 ++ .github/workflows/e2e-versions.yml | 165 ++++ __tests__/auth.test.ts | 38 +- __tests__/data/adoptium.json | 868 ++++++++++++++++++ __tests__/data/zulu-releases-default.json | 247 +++++ .../distributors/adoptium-installer.test.ts | 146 +++ __tests__/distributors/base-installer.test.ts | 246 +++++ .../distributors/local-installer.test.ts | 195 ++++ __tests__/distributors/zulu-installer.test.ts | 140 +++ __tests__/gpg.test.ts | 12 +- __tests__/installer.test.ts | 159 ---- __tests__/util.test.ts | 61 -- __tests__/verify-java.ps1 | 31 - __tests__/verify-java.sh | 30 +- __tests__/verify-no-unstaged-changes.sh | 17 + 17 files changed, 2251 insertions(+), 297 deletions(-) create mode 100755 .github/workflows/build.yml create mode 100644 .github/workflows/e2e-local-file.yml create mode 100644 .github/workflows/e2e-publishing.yml create mode 100644 .github/workflows/e2e-versions.yml create mode 100644 __tests__/data/adoptium.json create mode 100644 __tests__/data/zulu-releases-default.json create mode 100644 __tests__/distributors/adoptium-installer.test.ts create mode 100644 __tests__/distributors/base-installer.test.ts create mode 100644 __tests__/distributors/local-installer.test.ts create mode 100644 __tests__/distributors/zulu-installer.test.ts delete mode 100644 __tests__/installer.test.ts delete mode 100644 __tests__/util.test.ts delete mode 100644 __tests__/verify-java.ps1 create mode 100644 __tests__/verify-no-unstaged-changes.sh diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100755 index 000000000..9eb0e32ae --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,33 @@ +name: Build Action + +on: + push: + branches: + - main + - releases/* + paths-ignore: + - '**.md' + pull_request: + paths-ignore: + - '**.md' + +jobs: + build: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + steps: + - uses: actions/checkout@v2 + - name: Setup Node.JS 12 + uses: actions/setup-node@v2 + with: + node-version: 12.x + - run: npm ci + - run: npm run build + - run: npm run format-check + - run: npm test + - name: Verify no unstaged changes + if: runner.os != 'windows' + run: bash __tests__/verify-no-unstaged-changes.sh diff --git a/.github/workflows/e2e-local-file.yml b/.github/workflows/e2e-local-file.yml new file mode 100644 index 000000000..3bf6553de --- /dev/null +++ b/.github/workflows/e2e-local-file.yml @@ -0,0 +1,84 @@ +name: Validate local file +on: + push: + branches: + - main + - releases/* + paths-ignore: + - '**.md' + pull_request: + paths-ignore: + - '**.md' + +jobs: + setup-java-local-file-adopt: + name: Validate installation from local file Adopt + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [macos-latest, windows-latest, ubuntu-latest] + steps: + - name: Checkout + uses: actions/checkout@v2 + - run: | + if ($IsLinux) { + $downloadUrl = "https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.10%2B9/OpenJDK11U-jdk_x64_linux_hotspot_11.0.10_9.tar.gz" + $localFilename = "java_package.tar.gz" + } elseif ($IsMacOS) { + $downloadUrl = "https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.10%2B9/OpenJDK11U-jdk_x64_mac_hotspot_11.0.10_9.tar.gz" + $localFilename = "java_package.tar.gz" + } elseif ($IsWindows) { + $downloadUrl = "https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.10%2B9/OpenJDK11U-jdk_x64_windows_hotspot_11.0.10_9.zip" + $localFilename = "java_package.zip" + } + echo "LocalFilename=$localFilename" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append + (New-Object System.Net.WebClient).DownloadFile($downloadUrl, "$env:RUNNER_TEMP/$localFilename") + shell: pwsh + - name: setup-java + uses: ./ + id: setup-java + with: + distribution: 'jdkfile' + jdkFile: ${{ runner.temp }}/${{ env.LocalFilename }} + java-version: '11.0.0-ea' + architecture: x64 + - name: Verify Java version + run: bash __tests__/verify-java.sh "11.0.10" "${{ steps.setup-java.outputs.path }}" + shell: bash + + setup-java-local-file-zulu: + name: Validate installation from local file Zulu + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [macos-latest, windows-latest, ubuntu-latest] + steps: + - name: Checkout + uses: actions/checkout@v2 + - run: | + if ($IsLinux) { + $downloadUrl = "https://cdn.azul.com/zulu/bin/zulu11.2.3-jdk11.0.1-linux_x64.tar.gz" + $localFilename = "java_package.tar.gz" + } elseif ($IsMacOS) { + $downloadUrl = "https://cdn.azul.com/zulu/bin/zulu11.2.3-jdk11.0.1-macosx_x64.tar.gz" + $localFilename = "java_package.tar.gz" + } elseif ($IsWindows) { + $downloadUrl = "https://cdn.azul.com/zulu/bin/zulu11.45.27-ca-jdk11.0.10-win_x64.zip" + $localFilename = "java_package.zip" + } + echo "LocalFilename=$localFilename" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append + (New-Object System.Net.WebClient).DownloadFile($downloadUrl, "$env:RUNNER_TEMP/$localFilename") + shell: pwsh + - name: setup-java + uses: ./ + id: setup-java + with: + distribution: 'jdkfile' + jdkFile: ${{ runner.temp }}/${{ env.LocalFilename }} + java-version: '11.0.0-ea' + architecture: x64 + - name: Verify Java version + run: bash __tests__/verify-java.sh "11.0" "${{ steps.setup-java.outputs.path }}" + shell: bash \ No newline at end of file diff --git a/.github/workflows/e2e-publishing.yml b/.github/workflows/e2e-publishing.yml new file mode 100644 index 000000000..3ebd4a545 --- /dev/null +++ b/.github/workflows/e2e-publishing.yml @@ -0,0 +1,76 @@ +name: Validate publishing functionality +on: + push: + branches: + - main + - releases/* + paths-ignore: + - '**.md' + pull_request: + paths-ignore: + - '**.md' + +jobs: + setup-java-publishing: + name: Validate settings.xml + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [macos-latest, windows-latest, ubuntu-latest] + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: setup-java + uses: ./ + id: setup-java + with: + server-id: maven + server-username: MAVEN_USERNAME + server-password: MAVEN_CENTRAL_TOKEN + gpg-passphrase: MAVEN_GPG_PASSPHRASE + - run: | + $homePath = $env:USERPROFILE + if (-not $homePath) { + $homePath = $env:HOME + } + $xmlPath = Join-Path $homePath ".m2" "settings.xml" + + Get-Content $xmlPath | ForEach-Object { Write-Host $_ } + + [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 (($servers[1].id -ne 'gpg.passphrase') -or ($servers[1].passphrase -ne '${env.MAVEN_GPG_PASSPHRASE}')) { + throw "Generated XML file is incorrect" + } + shell: pwsh + + test-publishing-custom-location: + name: Validate settings.xml in custom location + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [macos-latest, windows-latest, ubuntu-latest] + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: setup-java + uses: ./ + id: setup-java + with: + server-id: maven + server-username: MAVEN_USERNAME + server-password: MAVEN_CENTRAL_TOKEN + gpg-passphrase: MAVEN_GPG_PASSPHRASE + settings-path: ${{ runner.temp }} + - run: | + $path = Join-Path $env:RUNNER_TEMP "settings.xml" + if (-not (Test-Path $path)) { + throw "settings.xml file is not found in expected location" + } + shell: pwsh \ No newline at end of file diff --git a/.github/workflows/e2e-versions.yml b/.github/workflows/e2e-versions.yml new file mode 100644 index 000000000..02aa80dc6 --- /dev/null +++ b/.github/workflows/e2e-versions.yml @@ -0,0 +1,165 @@ +name: Validate Java e2e +on: + push: + branches: + - main + - releases/* + paths-ignore: + - '**.md' + pull_request: + paths-ignore: + - '**.md' + +jobs: + setup-java-major-versions: + name: ${{ matrix.distribution }} ${{ matrix.version }} (jdk-x64) - ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [macos-latest, windows-latest, ubuntu-latest] + distribution: ['adoptium', 'zulu'] + version: ['8', '11', '15'] + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: setup-java + uses: ./ + id: setup-java + with: + java-version: ${{ matrix.version }} + java-package: 'jdk' + distribution: ${{ matrix.distribution }} + - name: Verify Java + run: bash __tests__/verify-java.sh "${{ matrix.version }}" "${{ steps.setup-java.outputs.path }}" + shell: bash + + setup-java-major-minor-versions: + name: ${{ matrix.distribution }} ${{ matrix.version }} (jdk-x64) - ${{ matrix.os }} + needs: setup-java-major-versions + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [macos-latest, windows-latest, ubuntu-latest] + distribution: ['adoptium', 'zulu'] + version: + - '8.0.282' + - '11.0' + - '11.0.10' + - '15.0' + exclude: + - os: windows-latest + distribution: 'zulu' + version: '8.0.282' + - os: windows-latest + distribution: 'zulu' + version: '11.0.10' + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: setup-java + uses: ./ + id: setup-java + with: + java-version: ${{ matrix.version }} + java-package: jdk + distribution: ${{ matrix.distribution }} + - name: Verify Java + run: bash __tests__/verify-java.sh "${{ matrix.version }}" "${{ steps.setup-java.outputs.path }}" + shell: bash + + setup-java-ea-versions: + name: ${{ matrix.distribution }} ${{ matrix.version }} (jdk-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] + distribution: ['adoptium', 'zulu'] + version: ['14-ea', '15-ea'] + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: setup-java + uses: ./ + id: setup-java + with: + java-version: ${{ matrix.version }} + java-package: jdk + distribution: ${{ matrix.distribution }} + - name: Verify Java + run: bash __tests__/verify-java.sh "${{ matrix.version }}" "${{ steps.setup-java.outputs.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 + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [macos-latest, windows-latest, ubuntu-latest] + distribution: ['adoptium', 'zulu'] + java-package: ['jre'] + version: + - '8.0.282' + - '11.0.10' + - '15.0' + exclude: + - os: windows-latest + distribution: 'zulu' + java-package: 'jre' + version: '8.0.282' + - os: windows-latest + java-package: 'jre' + distribution: 'zulu' + version: '11.0.10' + include: + - distribution: 'zulu' + java-package: jre+fx + version: '8' + os: ubuntu-latest + - distribution: 'zulu' + java-package: jdk+fx + version: '8.0.242' + os: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: setup-java + uses: ./ + id: setup-java + with: + java-version: ${{ matrix.version }} + java-package: ${{ matrix.java-package }} + distribution: ${{ matrix.distribution }} + - name: Verify Java + run: bash __tests__/verify-java.sh "${{ matrix.version }}" "${{ steps.setup-java.outputs.path }}" + shell: bash + + setup-java-custom-architecture: + name: ${{ matrix.distribution }} ${{ matrix.version }} (jdk-x86) - ${{ matrix.os }} + needs: setup-java-major-minor-versions + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + # Only Zulu provides x86 arch for now and only for windows / ubuntu + os: [windows-latest, ubuntu-latest] + distribution: ['zulu'] + version: ['8', '11'] + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: setup-java + uses: ./ + id: setup-java + with: + distribution: ${{ matrix.distribution }} + java-version: ${{ matrix.version }} + architecture: x86 + - name: Verify Java + run: bash __tests__/verify-java.sh "${{ matrix.version }}" "${{ steps.setup-java.outputs.path }}" + shell: bash \ No newline at end of file diff --git a/__tests__/auth.test.ts b/__tests__/auth.test.ts index b460e9338..b45b5109e 100644 --- a/__tests__/auth.test.ts +++ b/__tests__/auth.test.ts @@ -1,14 +1,7 @@ import io = require('@actions/io'); import fs = require('fs'); -import os = require('os'); import path = require('path'); - -// make the os.homedir() call be local to the tests -jest.doMock('os', () => { - return { - homedir: jest.fn(() => __dirname) - }; -}); +import os from 'os'; import * as auth from '../src/auth'; @@ -16,8 +9,12 @@ const m2Dir = path.join(__dirname, auth.M2_DIR); const settingsFile = path.join(m2Dir, auth.SETTINGS_FILE); describe('auth tests', () => { + let spyOSHomedir: jest.SpyInstance; + beforeEach(async () => { await io.rmRF(m2Dir); + spyOSHomedir = jest.spyOn(os, 'homedir'); + spyOSHomedir.mockReturnValue(__dirname); }, 300000); afterAll(async () => { @@ -26,6 +23,9 @@ describe('auth tests', () => { } catch { console.log('Failed to remove test directories'); } + jest.resetAllMocks(); + jest.clearAllMocks(); + jest.restoreAllMocks(); }, 100000); it('creates settings.xml in alternate locations', async () => { @@ -38,7 +38,7 @@ describe('auth tests', () => { process.env[`INPUT_SETTINGS-PATH`] = altHome; await io.rmRF(altHome); // ensure it doesn't already exist - await auth.configAuthentication(id, username, password); + await auth.createAuthenticationSettings(id, username, password); expect(fs.existsSync(m2Dir)).toBe(false); expect(fs.existsSync(settingsFile)).toBe(false); @@ -58,13 +58,11 @@ describe('auth tests', () => { const username = 'UNAME'; const password = 'TOKEN'; - await auth.configAuthentication(id, username, password); + await auth.createAuthenticationSettings(id, username, password); expect(fs.existsSync(m2Dir)).toBe(true); expect(fs.existsSync(settingsFile)).toBe(true); - expect(fs.readFileSync(settingsFile, 'utf-8')).toEqual( - auth.generate(id, username, password) - ); + expect(fs.readFileSync(settingsFile, 'utf-8')).toEqual(auth.generate(id, username, password)); }, 100000); it('creates settings.xml with additional configuration', async () => { @@ -73,7 +71,7 @@ describe('auth tests', () => { const password = 'TOKEN'; const gpgPassphrase = 'GPG'; - await auth.configAuthentication(id, username, password, gpgPassphrase); + await auth.createAuthenticationSettings(id, username, password, gpgPassphrase); expect(fs.existsSync(m2Dir)).toBe(true); expect(fs.existsSync(settingsFile)).toBe(true); @@ -87,18 +85,16 @@ describe('auth tests', () => { const username = 'USERNAME'; const password = 'PASSWORD'; - fs.mkdirSync(m2Dir, {recursive: true}); + fs.mkdirSync(m2Dir, { recursive: true }); fs.writeFileSync(settingsFile, 'FAKE FILE'); expect(fs.existsSync(m2Dir)).toBe(true); expect(fs.existsSync(settingsFile)).toBe(true); - await auth.configAuthentication(id, username, password); + await auth.createAuthenticationSettings(id, username, password); expect(fs.existsSync(m2Dir)).toBe(true); expect(fs.existsSync(settingsFile)).toBe(true); - expect(fs.readFileSync(settingsFile, 'utf-8')).toEqual( - auth.generate(id, username, password) - ); + expect(fs.readFileSync(settingsFile, 'utf-8')).toEqual(auth.generate(id, username, password)); }, 100000); it('generates valid settings.xml with minimal configuration', () => { @@ -143,8 +139,6 @@ describe('auth tests', () => { `; - expect(auth.generate(id, username, password, gpgPassphrase)).toEqual( - expectedSettings - ); + expect(auth.generate(id, username, password, gpgPassphrase)).toEqual(expectedSettings); }); }); diff --git a/__tests__/data/adoptium.json b/__tests__/data/adoptium.json new file mode 100644 index 000000000..631b1380c --- /dev/null +++ b/__tests__/data/adoptium.json @@ -0,0 +1,868 @@ +[ + { + "binaries": [ + { + "architecture": "x64", + "download_count": 74181, + "heap_size": "normal", + "image_type": "jdk", + "jvm_impl": "hotspot", + "os": "mac", + "package": { + "checksum": "09b7e6ab5d5eb4b73813f4caa793a0b616d33794a17988fa6a6b7c972e8f3dd3", + "checksum_link": "https://github.com/AdoptOpenJDK/openjdk14-binaries/releases/download/jdk-14.0.2%2B12/OpenJDK14U-jdk_x64_mac_hotspot_14.0.2_12.tar.gz.sha256.txt", + "download_count": 23872, + "link": "https://github.com/AdoptOpenJDK/openjdk14-binaries/releases/download/jdk-14.0.2%2B12/OpenJDK14U-jdk_x64_mac_hotspot_14.0.2_12.tar.gz", + "metadata_link": "https://github.com/AdoptOpenJDK/openjdk14-binaries/releases/download/jdk-14.0.2%2B12/OpenJDK14U-jdk_x64_mac_hotspot_14.0.2_12.tar.gz.json", + "name": "OpenJDK14U-jdk_x64_mac_hotspot_14.0.2_12.tar.gz", + "size": 195705010 + }, + "project": "jdk", + "scm_ref": "jdk-14.0.2+12_adopt", + "updated_at": "2020-07-16T08:55:45Z" + } + ], + "download_count": 477080, + "id": "MDc6UmVsZWFzZTI4NjIyMDc4.+ve8KojpqJUpsA==", + "release_link": "https://github.com/AdoptOpenJDK/openjdk14-binaries/releases/tag/jdk-14.0.2%2B12", + "release_name": "jdk-14.0.2+12", + "release_type": "ga", + "timestamp": "2020-07-16T08:54:16Z", + "updated_at": "2020-07-16T08:54:16Z", + "vendor": "adoptopenjdk", + "version_data": { + "build": 12, + "major": 14, + "minor": 0, + "openjdk_version": "14.0.2+12", + "security": 2, + "semver": "14.0.2+12" + } + }, + { + "binaries": [ + { + "architecture": "x64", + "download_count": 58023, + "heap_size": "normal", + "image_type": "jdk", + "jvm_impl": "hotspot", + "os": "mac", + "package": { + "checksum": "b11cb192312530bcd84607631203d0c1727e672af12813078e6b525e3cce862d", + "checksum_link": "https://github.com/AdoptOpenJDK/openjdk14-binaries/releases/download/jdk-14.0.1%2B7/OpenJDK14U-jdk_x64_mac_hotspot_14.0.1_7.tar.gz.sha256.txt", + "download_count": 25276, + "link": "https://github.com/AdoptOpenJDK/openjdk14-binaries/releases/download/jdk-14.0.1%2B7/OpenJDK14U-jdk_x64_mac_hotspot_14.0.1_7.tar.gz", + "metadata_link": "https://github.com/AdoptOpenJDK/openjdk14-binaries/releases/download/jdk-14.0.1%2B7/OpenJDK14U-jdk_x64_mac_hotspot_14.0.1_7.tar.gz.json", + "name": "OpenJDK14U-jdk_x64_mac_hotspot_14.0.1_7.tar.gz", + "size": 195769653 + }, + "project": "jdk", + "scm_ref": "jdk-14.0.1+7_adopt", + "updated_at": "2020-04-20T12:54:23Z" + } + ], + "download_count": 198607, + "id": "MDc6UmVsZWFzZTI1Njc4MzEw.z3NqYG25PFlG+Q==", + "release_link": "https://github.com/AdoptOpenJDK/openjdk14-binaries/releases/tag/jdk-14.0.1%2B7", + "release_name": "jdk-14.0.1+7", + "release_type": "ga", + "timestamp": "2020-04-20T12:52:51Z", + "updated_at": "2020-04-20T12:52:51Z", + "vendor": "adoptopenjdk", + "version_data": { + "adopt_build_number": 1, + "build": 7, + "major": 14, + "minor": 0, + "openjdk_version": "14.0.1+7", + "security": 1, + "semver": "14.0.1+7.1" + } + }, + { + "binaries": [ + { + "architecture": "x64", + "download_count": 30069, + "heap_size": "normal", + "image_type": "jdk", + "jvm_impl": "hotspot", + "os": "mac", + "package": { + "checksum": "d358a7ff03905282348c6c80562a4da2e04eb377b60ad2152be4c90f8d580b7f", + "checksum_link": "https://github.com/AdoptOpenJDK/openjdk15-binaries/releases/download/jdk-15.0.2%2B7/OpenJDK15U-jdk_x64_mac_hotspot_15.0.2_7.tar.gz.sha256.txt", + "download_count": 3718, + "link": "https://github.com/AdoptOpenJDK/openjdk15-binaries/releases/download/jdk-15.0.2%2B7/OpenJDK15U-jdk_x64_mac_hotspot_15.0.2_7.tar.gz", + "metadata_link": "https://github.com/AdoptOpenJDK/openjdk15-binaries/releases/download/jdk-15.0.2%2B7/OpenJDK15U-jdk_x64_mac_hotspot_15.0.2_7.tar.gz.json", + "name": "OpenJDK15U-jdk_x64_mac_hotspot_15.0.2_7.tar.gz", + "size": 195232978 + }, + "project": "jdk", + "scm_ref": "jdk-15.0.2+7_adopt", + "updated_at": "2021-01-22T17:33:20Z" + } + ], + "download_count": 124226, + "id": "MDc6UmVsZWFzZTM2NzgwOTAw.X2+6VqPND3E8CA==", + "release_link": "https://github.com/AdoptOpenJDK/openjdk15-binaries/releases/tag/jdk-15.0.2%2B7", + "release_name": "jdk-15.0.2+7", + "release_type": "ga", + "timestamp": "2021-01-22T17:31:37Z", + "updated_at": "2021-01-22T17:31:37Z", + "vendor": "adoptopenjdk", + "version_data": { + "build": 7, + "major": 15, + "minor": 0, + "openjdk_version": "15.0.2+7", + "security": 2, + "semver": "15.0.2+7" + } + }, + { + "binaries": [ + { + "architecture": "x64", + "download_count": 24542, + "heap_size": "normal", + "image_type": "jdk", + "jvm_impl": "hotspot", + "os": "mac", + "package": { + "checksum": "b8c2e2ad31f3d6676ea665d9505b06df15e23741847556612b40e3ee329fc046", + "checksum_link": "https://github.com/AdoptOpenJDK/openjdk15-binaries/releases/download/jdk-15.0.1%2B9.1/OpenJDK15U-jdk_x64_mac_hotspot_15.0.1_9.tar.gz.sha256.txt", + "download_count": 3274, + "link": "https://github.com/AdoptOpenJDK/openjdk15-binaries/releases/download/jdk-15.0.1%2B9.1/OpenJDK15U-jdk_x64_mac_hotspot_15.0.1_9.tar.gz", + "metadata_link": "https://github.com/AdoptOpenJDK/openjdk15-binaries/releases/download/jdk-15.0.1%2B9.1/OpenJDK15U-jdk_x64_mac_hotspot_15.0.1_9.tar.gz.json", + "name": "OpenJDK15U-jdk_x64_mac_hotspot_15.0.1_9.tar.gz", + "size": 195872839 + }, + "project": "jdk", + "scm_ref": "jdk-15.0.1+9_adopt", + "updated_at": "2020-12-01T16:57:47Z" + } + ], + "download_count": 25378, + "id": "MDc6UmVsZWFzZTM0NjQ2MDU4.Yj2XZf+VBGAPtw==", + "release_link": "https://github.com/AdoptOpenJDK/openjdk15-binaries/releases/tag/jdk-15.0.1%2B9.1", + "release_name": "jdk-15.0.1+9.1", + "release_type": "ga", + "timestamp": "2020-12-01T16:57:26Z", + "updated_at": "2020-12-01T16:57:26Z", + "vendor": "adoptopenjdk", + "version_data": { + "adopt_build_number": 1, + "build": 9, + "major": 15, + "minor": 0, + "openjdk_version": "15.0.1+9", + "security": 1, + "semver": "15.0.1+9.1" + } + }, + { + "binaries": [ + { + "architecture": "x64", + "download_count": 21675, + "heap_size": "normal", + "image_type": "jdk", + "jvm_impl": "hotspot", + "os": "mac", + "package": { + "checksum": "d32f9429c4992cef7be559a15c542011503d6bc38c89379800cd209a9d7ec539", + "checksum_link": "https://github.com/AdoptOpenJDK/openjdk15-binaries/releases/download/jdk-15.0.1%2B9/OpenJDK15U-jdk_x64_mac_hotspot_15.0.1_9.tar.gz.sha256.txt", + "download_count": 11935, + "link": "https://github.com/AdoptOpenJDK/openjdk15-binaries/releases/download/jdk-15.0.1%2B9/OpenJDK15U-jdk_x64_mac_hotspot_15.0.1_9.tar.gz", + "metadata_link": "https://github.com/AdoptOpenJDK/openjdk15-binaries/releases/download/jdk-15.0.1%2B9/OpenJDK15U-jdk_x64_mac_hotspot_15.0.1_9.tar.gz.json", + "name": "OpenJDK15U-jdk_x64_mac_hotspot_15.0.1_9.tar.gz", + "size": 195773522 + }, + "project": "jdk", + "scm_ref": "jdk-15.0.1+9_adopt", + "updated_at": "2020-10-23T20:48:09Z" + } + ], + "download_count": 308690, + "id": "MDc6UmVsZWFzZTMyOTk4MTUx.3oazo3YGfHhF3w==", + "release_link": "https://github.com/AdoptOpenJDK/openjdk15-binaries/releases/tag/jdk-15.0.1%2B9", + "release_name": "jdk-15.0.1+9", + "release_type": "ga", + "timestamp": "2020-10-23T20:46:22Z", + "updated_at": "2020-10-23T20:46:22Z", + "vendor": "adoptopenjdk", + "version_data": { + "build": 9, + "major": 15, + "minor": 0, + "openjdk_version": "15.0.1+9", + "security": 1, + "semver": "15.0.1+9" + } + }, + { + "binaries": [ + { + "architecture": "x64", + "download_count": 51254, + "heap_size": "normal", + "image_type": "jdk", + "jvm_impl": "hotspot", + "os": "mac", + "package": { + "checksum": "bd1fc774232e2dfee93056a01f5765bd92ffb19d68dd548c233a82bb5c162be4", + "checksum_link": "https://github.com/AdoptOpenJDK/openjdk15-binaries/releases/download/jdk-15%2B36/OpenJDK15U-jdk_x64_mac_hotspot_15_36.tar.gz.sha256.txt", + "download_count": 5325, + "link": "https://github.com/AdoptOpenJDK/openjdk15-binaries/releases/download/jdk-15%2B36/OpenJDK15U-jdk_x64_mac_hotspot_15_36.tar.gz", + "metadata_link": "https://github.com/AdoptOpenJDK/openjdk15-binaries/releases/download/jdk-15%2B36/OpenJDK15U-jdk_x64_mac_hotspot_15_36.tar.gz.json", + "name": "OpenJDK15U-jdk_x64_mac_hotspot_15_36.tar.gz", + "size": 195853361 + }, + "project": "jdk", + "scm_ref": "jdk-15+36_adopt", + "updated_at": "2020-09-17T07:43:54Z" + } + ], + "download_count": 157313, + "id": "MDc6UmVsZWFzZTMxNDUwMjA0.eYpt0EBEjldfEQ==", + "release_link": "https://github.com/AdoptOpenJDK/openjdk15-binaries/releases/tag/jdk-15%2B36", + "release_name": "jdk-15+36", + "release_type": "ga", + "timestamp": "2020-09-17T07:42:21Z", + "updated_at": "2020-09-17T07:42:21Z", + "vendor": "adoptopenjdk", + "version_data": { + "build": 36, + "major": 15, + "minor": 0, + "openjdk_version": "15+36", + "security": 0, + "semver": "15.0.0+36" + } + }, + { + "binaries": [ + { + "architecture": "x64", + "download_count": 27428, + "heap_size": "normal", + "image_type": "jdk", + "jvm_impl": "hotspot", + "os": "mac", + "package": { + "checksum": "aabc3aebb0abf1ba64d9bd5796d0c7eb7239983f6e4c0f015b5b88be5616e4bd", + "checksum_link": "https://github.com/AdoptOpenJDK/openjdk14-binaries/releases/download/jdk-14%2B36/OpenJDK14U-jdk_x64_mac_hotspot_14_36.tar.gz.sha256.txt", + "download_count": 19544, + "link": "https://github.com/AdoptOpenJDK/openjdk14-binaries/releases/download/jdk-14%2B36/OpenJDK14U-jdk_x64_mac_hotspot_14_36.tar.gz", + "metadata_link": "https://github.com/AdoptOpenJDK/openjdk14-binaries/releases/download/jdk-14%2B36/OpenJDK14U-jdk_x64_mac_hotspot_14_36.tar.gz.json", + "name": "OpenJDK14U-jdk_x64_mac_hotspot_14_36.tar.gz", + "size": 201087797 + }, + "project": "jdk", + "scm_ref": "jdk-14+36_adopt", + "updated_at": "2020-03-18T12:13:05Z" + } + ], + "download_count": 364816, + "id": "MDc6UmVsZWFzZTI0NjMxMDAy.AY7rtvmrnWWlIg==", + "release_link": "https://github.com/AdoptOpenJDK/openjdk14-binaries/releases/tag/jdk-14%2B36", + "release_name": "jdk-14+36", + "release_type": "ga", + "timestamp": "2020-03-18T12:11:08Z", + "updated_at": "2020-03-18T12:11:08Z", + "vendor": "adoptopenjdk", + "version_data": { + "adopt_build_number": 1, + "build": 36, + "major": 14, + "minor": 0, + "openjdk_version": "14+36", + "security": 0, + "semver": "14.0.0+36.1" + } + }, + { + "binaries": [ + { + "architecture": "x64", + "download_count": 63201, + "heap_size": "normal", + "image_type": "jdk", + "jvm_impl": "hotspot", + "os": "mac", + "package": { + "checksum": "0ddb24efdf5aab541898d19b7667b149a1a64a8bd039b708fc58ee0284fa7e07", + "checksum_link": "https://github.com/AdoptOpenJDK/openjdk13-binaries/releases/download/jdk-13.0.2%2B8/OpenJDK13U-jdk_x64_mac_hotspot_13.0.2_8.tar.gz.sha256.txt", + "download_count": 32531, + "link": "https://github.com/AdoptOpenJDK/openjdk13-binaries/releases/download/jdk-13.0.2%2B8/OpenJDK13U-jdk_x64_mac_hotspot_13.0.2_8.tar.gz", + "metadata_link": "https://github.com/AdoptOpenJDK/openjdk13-binaries/releases/download/jdk-13.0.2%2B8/OpenJDK13U-jdk_x64_mac_hotspot_13.0.2_8.tar.gz.json", + "name": "OpenJDK13U-jdk_x64_mac_hotspot_13.0.2_8.tar.gz", + "size": 198206427 + }, + "project": "jdk", + "scm_ref": "jdk-13.0.2+8_adopt", + "updated_at": "2020-01-20T16:46:24Z" + } + ], + "download_count": 349677, + "id": "MDc6UmVsZWFzZTIyOTgxNTM1.gtZYwGfBgkb3Gg==", + "release_link": "https://github.com/AdoptOpenJDK/openjdk13-binaries/releases/tag/jdk-13.0.2%2B8", + "release_name": "jdk-13.0.2+8", + "release_type": "ga", + "timestamp": "2020-01-20T16:42:35Z", + "updated_at": "2020-01-20T16:42:35Z", + "vendor": "adoptopenjdk", + "version_data": { + "adopt_build_number": 1, + "build": 8, + "major": 13, + "minor": 0, + "openjdk_version": "13.0.2+8", + "security": 2, + "semver": "13.0.2+8.1" + } + }, + { + "binaries": [ + { + "architecture": "x64", + "download_count": 41508, + "heap_size": "normal", + "image_type": "jdk", + "jvm_impl": "hotspot", + "os": "mac", + "package": { + "checksum": "9c82de98ce9bc2353bcf314d85366c9a2c572db034e10a71aa47e804e13748c1", + "checksum_link": "https://github.com/AdoptOpenJDK/openjdk13-binaries/releases/download/jdk-13.0.1%2B9/OpenJDK13U-jdk_x64_mac_hotspot_13.0.1_9.tar.gz.sha256.txt", + "download_count": 32262, + "link": "https://github.com/AdoptOpenJDK/openjdk13-binaries/releases/download/jdk-13.0.1%2B9/OpenJDK13U-jdk_x64_mac_hotspot_13.0.1_9.tar.gz", + "metadata_link": "https://github.com/AdoptOpenJDK/openjdk13-binaries/releases/download/jdk-13.0.1%2B9/OpenJDK13U-jdk_x64_mac_hotspot_13.0.1_9.tar.gz.json", + "name": "OpenJDK13U-jdk_x64_mac_hotspot_13.0.1_9.tar.gz", + "size": 198205689 + }, + "project": "jdk", + "scm_ref": "jdk-13.0.1+9_adopt", + "updated_at": "2019-10-26T14:44:27Z" + } + ], + "download_count": 680021, + "id": "MDc6UmVsZWFzZTIwOTk4NDA0.srlG2TmLho/j0w==", + "release_link": "https://github.com/AdoptOpenJDK/openjdk13-binaries/releases/tag/jdk-13.0.1%2B9", + "release_name": "jdk-13.0.1+9", + "release_type": "ga", + "timestamp": "2019-10-26T14:43:52Z", + "updated_at": "2019-10-26T14:43:52Z", + "vendor": "adoptopenjdk", + "version_data": { + "adopt_build_number": 1, + "build": 9, + "major": 13, + "minor": 0, + "openjdk_version": "13.0.1+9", + "security": 1, + "semver": "13.0.1+9.1" + } + }, + { + "binaries": [ + { + "architecture": "x64", + "download_count": 37738, + "heap_size": "normal", + "image_type": "jdk", + "jvm_impl": "hotspot", + "os": "mac", + "package": { + "checksum": "f948be96daba250b6695e22cb51372d2ba3060e4d778dd09c89548889783099f", + "checksum_link": "https://github.com/AdoptOpenJDK/openjdk13-binaries/releases/download/jdk-13%2B33/OpenJDK13U-jdk_x64_mac_hotspot_13_33.tar.gz.sha256.txt", + "download_count": 37738, + "link": "https://github.com/AdoptOpenJDK/openjdk13-binaries/releases/download/jdk-13%2B33/OpenJDK13U-jdk_x64_mac_hotspot_13_33.tar.gz", + "metadata_link": "https://github.com/AdoptOpenJDK/openjdk13-binaries/releases/download/jdk-13%2B33/OpenJDK13U-jdk_x64_mac_hotspot_13_33.tar.gz.json", + "name": "OpenJDK13U-jdk_x64_mac_hotspot_13_33.tar.gz", + "size": 198189530 + }, + "project": "jdk", + "scm_ref": "jdk-13+33_adopt", + "updated_at": "2019-09-19T10:20:21Z" + } + ], + "download_count": 226200, + "id": "MDc6UmVsZWFzZTIwMTA0MTUy.trK7qCbNtlMWFw==", + "release_link": "https://github.com/AdoptOpenJDK/openjdk13-binaries/releases/tag/jdk-13%2B33", + "release_name": "jdk-13+33", + "release_type": "ga", + "timestamp": "2019-09-19T10:19:58Z", + "updated_at": "2019-09-19T10:19:58Z", + "vendor": "adoptopenjdk", + "version_data": { + "adopt_build_number": 1, + "build": 33, + "major": 13, + "minor": 0, + "openjdk_version": "13+33", + "security": 0, + "semver": "13.0.0+33.1" + } + }, + { + "binaries": [ + { + "architecture": "x64", + "download_count": 24493, + "heap_size": "normal", + "image_type": "jdk", + "jvm_impl": "hotspot", + "os": "mac", + "package": { + "checksum": "9919eee037554d40c7d2f219bbd654f2bf119e16a2f4d284d8dedaf525ee59e6", + "checksum_link": "https://github.com/AdoptOpenJDK/openjdk12-binaries/releases/download/jdk-12.0.2%2B10/OpenJDK12U-jdk_x64_mac_hotspot_12.0.2_10.tar.gz.sha256.txt", + "download_count": 22907, + "link": "https://github.com/AdoptOpenJDK/openjdk12-binaries/releases/download/jdk-12.0.2%2B10/OpenJDK12U-jdk_x64_mac_hotspot_12.0.2_10.tar.gz", + "metadata_link": "https://github.com/AdoptOpenJDK/openjdk12-binaries/releases/download/jdk-12.0.2%2B10/OpenJDK12U-jdk_x64_mac_hotspot_12.0.2_10.tar.gz.json", + "name": "OpenJDK12U-jdk_x64_mac_hotspot_12.0.2_10.tar.gz", + "size": 198392994 + }, + "project": "jdk", + "scm_ref": "jdk-12.0.2+10_adopt", + "updated_at": "2019-07-18T20:27:24Z" + } + ], + "download_count": 396318, + "id": "MDc6UmVsZWFzZTE4NzE2Mzk5.S/VUFSgnrVIv8A==", + "release_link": "https://github.com/AdoptOpenJDK/openjdk12-binaries/releases/tag/jdk-12.0.2%2B10", + "release_name": "jdk-12.0.2+10", + "release_type": "ga", + "timestamp": "2019-07-18T20:26:29Z", + "updated_at": "2019-07-18T20:26:29Z", + "vendor": "adoptopenjdk", + "version_data": { + "adopt_build_number": 1, + "build": 10, + "major": 12, + "minor": 0, + "openjdk_version": "12.0.2+10", + "security": 2, + "semver": "12.0.2+10.1" + } + }, + { + "binaries": [ + { + "architecture": "x64", + "download_count": 5539, + "heap_size": "normal", + "image_type": "jdk", + "jvm_impl": "hotspot", + "os": "mac", + "package": { + "checksum": "7acd697e816491d31b24d0ae1867fd63060aa738cfa388757946ae312a60b4f2", + "checksum_link": "https://github.com/AdoptOpenJDK/openjdk12-binaries/releases/download/jdk-12.0.2%2B10.3/OpenJDK12U-jdk_x64_mac_hotspot_12.0.2_10.tar.gz.sha256.txt", + "download_count": 5539, + "link": "https://github.com/AdoptOpenJDK/openjdk12-binaries/releases/download/jdk-12.0.2%2B10.3/OpenJDK12U-jdk_x64_mac_hotspot_12.0.2_10.tar.gz", + "metadata_link": "https://github.com/AdoptOpenJDK/openjdk12-binaries/releases/download/jdk-12.0.2%2B10.3/OpenJDK12U-jdk_x64_mac_hotspot_12.0.2_10.tar.gz.json", + "name": "OpenJDK12U-jdk_x64_mac_hotspot_12.0.2_10.tar.gz", + "size": 198429049 + }, + "project": "jdk", + "scm_ref": "jdk-12.0.2+10_adopt", + "updated_at": "2019-09-19T17:17:37Z" + } + ], + "download_count": 5879, + "id": "MDc6UmVsZWFzZTIwMTE2ODQ3.QGQl8Nj1qkma4Q==", + "release_link": "https://github.com/AdoptOpenJDK/openjdk12-binaries/releases/tag/jdk-12.0.2%2B10.3", + "release_name": "jdk-12.0.2+10.3", + "release_type": "ga", + "timestamp": "2019-09-19T17:17:26Z", + "updated_at": "2019-12-06T15:10:37Z", + "vendor": "adoptopenjdk", + "version_data": { + "adopt_build_number": 3, + "build": 10, + "major": 12, + "minor": 0, + "openjdk_version": "12.0.2+10", + "security": 2, + "semver": "12.0.2+10.3" + } + }, + { + "binaries": [ + { + "architecture": "x64", + "download_count": 22794, + "heap_size": "normal", + "image_type": "jdk", + "jvm_impl": "hotspot", + "os": "mac", + "package": { + "checksum": "2c1a46c0fab6d4bdbc443f23c3f6a313c2de47fbbd9c16b5c1133a88f6c1ab8f", + "checksum_link": "https://github.com/AdoptOpenJDK/openjdk12-binaries/releases/download/jdk-12.0.2%2B10.2/OpenJDK12U-jdk_x64_mac_hotspot_12.0.2_10.tar.gz.sha256.txt", + "download_count": 637, + "link": "https://github.com/AdoptOpenJDK/openjdk12-binaries/releases/download/jdk-12.0.2%2B10.2/OpenJDK12U-jdk_x64_mac_hotspot_12.0.2_10.tar.gz", + "metadata_link": "https://github.com/AdoptOpenJDK/openjdk12-binaries/releases/download/jdk-12.0.2%2B10.2/OpenJDK12U-jdk_x64_mac_hotspot_12.0.2_10.tar.gz.json", + "name": "OpenJDK12U-jdk_x64_mac_hotspot_12.0.2_10.tar.gz", + "size": 198862174 + }, + "project": "jdk", + "scm_ref": "jdk-12.0.2+10_adopt", + "updated_at": "2019-08-06T10:41:10Z" + } + ], + "download_count": 23563, + "id": "MDc6UmVsZWFzZTE5MTAzMTI3.in65dKG+veAxOg==", + "release_link": "https://github.com/AdoptOpenJDK/openjdk12-binaries/releases/tag/jdk-12.0.2%2B10.2", + "release_name": "jdk-12.0.2+10.2", + "release_type": "ga", + "timestamp": "2019-08-06T10:40:44Z", + "updated_at": "2019-08-06T10:40:44Z", + "vendor": "adoptopenjdk", + "version_data": { + "adopt_build_number": 2, + "build": 10, + "major": 12, + "minor": 0, + "openjdk_version": "12.0.2+10", + "security": 2, + "semver": "12.0.2+10.2" + } + }, + { + "binaries": [ + { + "architecture": "x64", + "download_count": 39519, + "heap_size": "normal", + "image_type": "jdk", + "jvm_impl": "hotspot", + "os": "mac", + "package": { + "checksum": "dcb2ab681247298eda018df24166ba01674127083fb02892acf087e6181d8c56", + "checksum_link": "https://github.com/AdoptOpenJDK/openjdk12-binaries/releases/download/jdk-12.0.1%2B12/OpenJDK12U-jdk_x64_mac_hotspot_12.0.1_12.tar.gz.sha256.txt", + "download_count": 33306, + "link": "https://github.com/AdoptOpenJDK/openjdk12-binaries/releases/download/jdk-12.0.1%2B12/OpenJDK12U-jdk_x64_mac_hotspot_12.0.1_12.tar.gz", + "name": "OpenJDK12U-jdk_x64_mac_hotspot_12.0.1_12.tar.gz", + "size": 198112975 + }, + "project": "jdk", + "updated_at": "2019-04-21T15:12:34Z" + } + ], + "download_count": 1038669, + "id": "MDc6UmVsZWFzZTE2ODg3NDU3", + "release_link": "https://github.com/AdoptOpenJDK/openjdk12-binaries/releases/tag/jdk-12.0.1%2B12", + "release_name": "jdk-12.0.1+12", + "release_type": "ga", + "timestamp": "2019-04-21T15:11:56Z", + "updated_at": "2019-04-21T15:11:56Z", + "vendor": "adoptopenjdk", + "version_data": { + "build": 12, + "major": 12, + "minor": 0, + "openjdk_version": "12.0.1+12", + "security": 1, + "semver": "12.0.1+12" + } + }, + { + "binaries": [ + { + "architecture": "x64", + "download_count": 3136, + "heap_size": "normal", + "image_type": "jdk", + "jvm_impl": "hotspot", + "os": "mac", + "package": { + "checksum": "985036459d4ef0867a3fe83b0bf87877d8e66a121c7b9c145bb97bd921aaf3f1", + "checksum_link": "https://github.com/AdoptOpenJDK/openjdk12-binaries/releases/download/jdk-12%2B33/OpenJDK12U-jdk_x64_mac_hotspot_12_33.tar.gz.sha256.txt", + "download_count": 1905, + "link": "https://github.com/AdoptOpenJDK/openjdk12-binaries/releases/download/jdk-12%2B33/OpenJDK12U-jdk_x64_mac_hotspot_12_33.tar.gz", + "name": "OpenJDK12U-jdk_x64_mac_hotspot_12_33.tar.gz", + "size": 198099074 + }, + "project": "jdk", + "updated_at": "2019-03-22T12:09:13Z" + } + ], + "download_count": 757289, + "id": "MDc6UmVsZWFzZTE2MjgyMjM2", + "release_link": "https://github.com/AdoptOpenJDK/openjdk12-binaries/releases/tag/jdk-12%2B33", + "release_name": "jdk-12+33", + "release_type": "ga", + "timestamp": "2019-03-22T12:08:43Z", + "updated_at": "2019-03-22T12:08:43Z", + "vendor": "adoptopenjdk", + "version_data": { + "build": 33, + "major": 12, + "minor": 0, + "openjdk_version": "12+33", + "security": 0, + "semver": "12.0.0+33" + } + }, + { + "binaries": [ + { + "architecture": "x64", + "download_count": 75576, + "heap_size": "normal", + "image_type": "jdk", + "jvm_impl": "hotspot", + "os": "mac", + "package": { + "checksum": "ee7c98c9d79689aca6e717965747b8bf4eec5413e89d5444cc2bd6dbd59e3811", + "checksum_link": "https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.10%2B9/OpenJDK11U-jdk_x64_mac_hotspot_11.0.10_9.tar.gz.sha256.txt", + "download_count": 17426, + "link": "https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.10%2B9/OpenJDK11U-jdk_x64_mac_hotspot_11.0.10_9.tar.gz", + "metadata_link": "https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.10%2B9/OpenJDK11U-jdk_x64_mac_hotspot_11.0.10_9.tar.gz.json", + "name": "OpenJDK11U-jdk_x64_mac_hotspot_11.0.10_9.tar.gz", + "size": 186160219 + }, + "project": "jdk", + "scm_ref": "jdk-11.0.10+9_adopt", + "updated_at": "2021-01-22T14:16:47Z" + } + ], + "download_count": 636180, + "id": "MDc6UmVsZWFzZTM2NzcwNDUy.hAVJRiZZTufG+w==", + "release_link": "https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/tag/jdk-11.0.10%2B9", + "release_name": "jdk-11.0.10+9", + "release_type": "ga", + "timestamp": "2021-01-22T14:15:12Z", + "updated_at": "2021-01-22T14:15:12Z", + "vendor": "adoptopenjdk", + "version_data": { + "build": 9, + "major": 11, + "minor": 0, + "openjdk_version": "11.0.10+9", + "security": 10, + "semver": "11.0.10+9" + } + }, + { + "binaries": [ + { + "architecture": "x64", + "download_count": 108441, + "heap_size": "normal", + "image_type": "jdk", + "jvm_impl": "hotspot", + "os": "mac", + "package": { + "checksum": "96bc469f9b02a3b84382a0685b0bd7935e1ad1bd82a0aab9befb5b42a17cbd77", + "checksum_link": "https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.9.1%2B1/OpenJDK11U-jdk_x64_mac_hotspot_11.0.9.1_1.tar.gz.sha256.txt", + "download_count": 22211, + "link": "https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.9.1%2B1/OpenJDK11U-jdk_x64_mac_hotspot_11.0.9.1_1.tar.gz", + "metadata_link": "https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.9.1%2B1/OpenJDK11U-jdk_x64_mac_hotspot_11.0.9.1_1.tar.gz.json", + "name": "OpenJDK11U-jdk_x64_mac_hotspot_11.0.9.1_1.tar.gz", + "size": 185368626 + }, + "project": "jdk", + "scm_ref": "jdk-11.0.9.1+1_adopt", + "updated_at": "2020-11-12T14:10:45Z" + } + ], + "download_count": 815676, + "id": "MDc6UmVsZWFzZTMzODU4MDE1.94IbKUd3vvhzsA==", + "release_link": "https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/tag/jdk-11.0.9.1%2B1", + "release_name": "jdk-11.0.9.1+1", + "release_type": "ga", + "timestamp": "2020-11-12T14:08:55Z", + "updated_at": "2020-11-12T14:08:55Z", + "vendor": "adoptopenjdk", + "version_data": { + "build": 1, + "major": 11, + "minor": 0, + "openjdk_version": "11.0.9.1+1", + "patch": 1, + "security": 9, + "semver": "11.0.9+101" + } + }, + { + "binaries": [ + { + "architecture": "x64", + "download_count": 45450, + "heap_size": "normal", + "image_type": "jdk", + "jvm_impl": "hotspot", + "os": "mac", + "package": { + "checksum": "7b21961ffb2649e572721a0dfad64169b490e987937b661cb4e13a594c21e764", + "checksum_link": "https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.9%2B11.1/OpenJDK11U-jdk_x64_mac_hotspot_11.0.9_11.tar.gz.sha256.txt", + "download_count": 11117, + "link": "https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.9%2B11.1/OpenJDK11U-jdk_x64_mac_hotspot_11.0.9_11.tar.gz", + "metadata_link": "https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.9%2B11.1/OpenJDK11U-jdk_x64_mac_hotspot_11.0.9_11.tar.gz.json", + "name": "OpenJDK11U-jdk_x64_mac_hotspot_11.0.9_11.tar.gz", + "size": 186006796 + }, + "project": "jdk", + "scm_ref": "jdk-11.0.9+11_adopt", + "updated_at": "2020-10-25T14:43:54Z" + } + ], + "download_count": 423635, + "id": "MDc6UmVsZWFzZTMzMDI4MDcz.dRvNNRwJCgY3Xw==", + "release_link": "https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/tag/jdk-11.0.9%2B11.1", + "release_name": "jdk-11.0.9+11.1", + "release_type": "ga", + "timestamp": "2020-10-25T13:31:15Z", + "updated_at": "2020-10-25T13:31:15Z", + "vendor": "adoptopenjdk", + "version_data": { + "adopt_build_number": 1, + "build": 11, + "major": 11, + "minor": 0, + "openjdk_version": "11.0.9+11", + "security": 9, + "semver": "11.0.9+11.1" + } + }, + { + "binaries": [ + { + "architecture": "x64", + "download_count": 2456, + "heap_size": "normal", + "image_type": "jdk", + "jvm_impl": "hotspot", + "os": "mac", + "package": { + "checksum": "e84b00d74f08f059829bbf121c8423dc37ff65135968c1fcda5839600be4f542", + "checksum_link": "https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.9%2B11/OpenJDK11U-jdk_x64_mac_hotspot_11.0.9_11.tar.gz.sha256.txt", + "download_count": 1046, + "link": "https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.9%2B11/OpenJDK11U-jdk_x64_mac_hotspot_11.0.9_11.tar.gz", + "metadata_link": "https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.9%2B11/OpenJDK11U-jdk_x64_mac_hotspot_11.0.9_11.tar.gz.json", + "name": "OpenJDK11U-jdk_x64_mac_hotspot_11.0.9_11.tar.gz", + "size": 185532704 + }, + "project": "jdk", + "scm_ref": "jdk-11.0.9+11_adopt", + "updated_at": "2020-10-25T13:28:33Z" + } + ], + "download_count": 359580, + "id": "MDc6UmVsZWFzZTMyOTk4MzM5.6h9TT9pzYTK2Kg==", + "release_link": "https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/tag/jdk-11.0.9%2B11", + "release_name": "jdk-11.0.9+11", + "release_type": "ga", + "timestamp": "2020-10-23T20:52:14Z", + "updated_at": "2020-10-23T20:52:14Z", + "vendor": "adoptopenjdk", + "version_data": { + "build": 11, + "major": 11, + "minor": 0, + "openjdk_version": "11.0.9+11", + "security": 9, + "semver": "11.0.9+11" + } + }, + { + "binaries": [ + { + "architecture": "x64", + "download_count": 149393, + "heap_size": "normal", + "image_type": "jdk", + "jvm_impl": "hotspot", + "os": "mac", + "package": { + "checksum": "4a8dadd58cdc32c7e59978971d56aec610be7ee0ddf0dc1d137bb8b78456499f", + "checksum_link": "https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.8%2B10/OpenJDK11U-jdk_x64_mac_hotspot_11.0.8_10.tar.gz.sha256.txt", + "download_count": 40158, + "link": "https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.8%2B10/OpenJDK11U-jdk_x64_mac_hotspot_11.0.8_10.tar.gz", + "metadata_link": "https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.8%2B10/OpenJDK11U-jdk_x64_mac_hotspot_11.0.8_10.tar.gz.json", + "name": "OpenJDK11U-jdk_x64_mac_hotspot_11.0.8_10.tar.gz", + "size": 185054456 + }, + "project": "jdk", + "scm_ref": "jdk-11.0.8+10_adopt", + "updated_at": "2020-07-15T14:30:51Z" + } + ], + "download_count": 1968658, + "id": "MDc6UmVsZWFzZTI4NTg5Nzcz.pCNBA7G9E1o7pw==", + "release_link": "https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/tag/jdk-11.0.8%2B10", + "release_name": "jdk-11.0.8+10", + "release_type": "ga", + "timestamp": "2020-07-15T14:29:27Z", + "updated_at": "2020-07-15T14:29:27Z", + "vendor": "adoptopenjdk", + "version_data": { + "build": 10, + "major": 11, + "minor": 0, + "openjdk_version": "11.0.8+10", + "security": 8, + "semver": "11.0.8+10" + } + }, + { + "binaries": [], + "download_count": 1968658, + "id": "MDc6UmVsZWFzZTI4NTg5Nzcz.pCNBA7G9E1o7pw==", + "release_link": "https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/tag/jdk-11.0.8%2B10", + "release_name": "jdk-11.0.8+10", + "release_type": "ga", + "timestamp": "2020-07-15T14:29:27Z", + "updated_at": "2020-07-15T14:29:27Z", + "vendor": "adoptopenjdk", + "version_data": { + "build": 10, + "major": 9, + "minor": 0, + "openjdk_version": "9.0.8+10", + "security": 8, + "semver": "9.0.8+10" + } + }, + { + "binaries": [ + { + "architecture": "x64", + "download_count": 149393, + "heap_size": "normal", + "image_type": "jdk", + "jvm_impl": "hotspot", + "os": "mac", + "package": { + "checksum": "4a8dadd58cdc32c7e59978971d56aec610be7ee0ddf0dc1d137bb8b78456499f", + "checksum_link": "https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.8%2B10/OpenJDK11U-jdk_x64_mac_hotspot_11.0.8_10.tar.gz.sha256.txt", + "download_count": 40158, + "link": "https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.8%2B10/OpenJDK11U-jdk_x64_mac_hotspot_11.0.8_10.tar.gz", + "metadata_link": "https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.8%2B10/OpenJDK11U-jdk_x64_mac_hotspot_11.0.8_10.tar.gz.json", + "name": "OpenJDK11U-jdk_x64_mac_hotspot_11.0.8_10.tar.gz", + "size": 185054456 + }, + "project": "jdk", + "scm_ref": "jdk-11.0.8+10_adopt", + "updated_at": "2020-07-15T14:30:51Z" + } + ], + "download_count": 1968658, + "id": "MDc6UmVsZWFzZTI4NTg5Nzcz.pCNBA7G9E1o7pw==", + "release_link": "https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/tag/jdk-11.0.8%2B10", + "release_name": "jdk-11.0.8+10", + "release_type": "ga", + "timestamp": "2020-07-15T14:29:27Z", + "updated_at": "2020-07-15T14:29:27Z", + "vendor": "adoptopenjdk", + "version_data": { + "build": 10, + "major": 9, + "minor": 0, + "openjdk_version": "9.0.8+10", + "security": 8, + "semver": "9.0.7+10" + } + } +] \ No newline at end of file diff --git a/__tests__/data/zulu-releases-default.json b/__tests__/data/zulu-releases-default.json new file mode 100644 index 000000000..f23a87d43 --- /dev/null +++ b/__tests__/data/zulu-releases-default.json @@ -0,0 +1,247 @@ +[ + { + "id": 10996, + "url": "https://cdn.azul.com/zulu/bin/zulu1.8.0_05-8.1.0.10-macosx.tar.gz", + "name": "zulu1.8.0_05-8.1.0.10-macosx.tar.gz", + "zulu_version": [8, 1, 0, 10], + "jdk_version": [8, 0, 5, 13] + }, + { + "id": 10997, + "url": "https://cdn.azul.com/zulu/bin/zulu1.8.0_11-8.2.0.1-macosx.tar.gz", + "name": "zulu1.8.0_11-8.2.0.1-macosx.tar.gz", + "zulu_version": [8, 2, 0, 1], + "jdk_version": [8, 0, 11, 12] + }, + { + "id": 10346, + "url": "https://cdn.azul.com/zulu/bin/zulu8.21.0.1-jdk8.0.131-macosx_x64.tar.gz", + "name": "zulu8.21.0.1-jdk8.0.131-macosx_x64.tar.gz", + "zulu_version": [8, 21, 0, 1], + "jdk_version": [8, 0, 131, 11] + }, + { + "id": 10362, + "url": "https://cdn.azul.com/zulu/bin/zulu8.23.0.3-jdk8.0.144-macosx_x64.tar.gz", + "name": "zulu8.23.0.3-jdk8.0.144-macosx_x64.tar.gz", + "zulu_version": [8, 23, 0, 3], + "jdk_version": [8, 0, 144, 1] + }, + { + "id": 10399, + "url": "https://cdn.azul.com/zulu/bin/zulu8.25.0.1-jdk8.0.152-macosx_x64.tar.gz", + "name": "zulu8.25.0.1-jdk8.0.152-macosx_x64.tar.gz", + "zulu_version": [8, 25, 0, 1], + "jdk_version": [8, 0, 152, 16] + }, + { + "id": 11355, + "url": "https://cdn.azul.com/zulu/bin/zulu8.46.0.19-ca-jdk8.0.252-macosx_x64.tar.gz", + "name": "zulu8.46.0.19-ca-jdk8.0.252-macosx_x64.tar.gz", + "zulu_version": [8, 46, 0, 19], + "jdk_version": [8, 0, 252, 14] + }, + { + "id": 11481, + "url": "https://cdn.azul.com/zulu/bin/zulu8.48.0.47-ca-jdk8.0.262-macosx_x64.tar.gz", + "name": "zulu8.48.0.47-ca-jdk8.0.262-macosx_x64.tar.gz", + "zulu_version": [8, 48, 0, 47], + "jdk_version": [8, 0, 262, 17] + }, + { + "id": 11622, + "url": "https://cdn.azul.com/zulu/bin/zulu8.48.0.51-ca-jdk8.0.262-macosx_x64.tar.gz", + "name": "zulu8.48.0.51-ca-jdk8.0.262-macosx_x64.tar.gz", + "zulu_version": [8, 48, 0, 51], + "jdk_version": [8, 0, 262, 19] + }, + { + "id": 11535, + "url": "https://cdn.azul.com/zulu/bin/zulu8.48.0.49-ca-jdk8.0.262-macosx_x64.tar.gz", + "name": "zulu8.48.0.49-ca-jdk8.0.262-macosx_x64.tar.gz", + "zulu_version": [8, 48, 0, 49], + "jdk_version": [8, 0, 262, 18] + }, + { + "id": 12424, + "url": "https://cdn.azul.com/zulu/bin/zulu8.52.0.23-ca-jdk8.0.282-macosx_x64.tar.gz", + "name": "zulu8.52.0.23-ca-jdk8.0.282-macosx_x64.tar.gz", + "zulu_version": [8, 52, 0, 23], + "jdk_version": [8, 0, 282, 8] + }, + { + "id": 10383, + "url": "https://cdn.azul.com/zulu/bin/zulu9.0.0.15-jdk9.0.0-macosx_x64.tar.gz", + "name": "zulu9.0.0.15-jdk9.0.0-macosx_x64.tar.gz", + "zulu_version": [9, 0, 0, 15], + "jdk_version": [9, 0, 0, 0] + }, + { + "id": 10413, + "url": "https://cdn.azul.com/zulu/bin/zulu9.0.1.3-jdk9.0.1-macosx_x64.tar.gz", + "name": "zulu9.0.1.3-jdk9.0.1-macosx_x64.tar.gz", + "zulu_version": [9, 0, 1, 3], + "jdk_version": [9, 0, 1, 0] + }, + { + "id": 10503, + "url": "https://cdn.azul.com/zulu/bin/zulu10.2+3-jdk10.0.1-macosx_x64.tar.gz", + "name": "zulu10.2+3-jdk10.0.1-macosx_x64.tar.gz", + "zulu_version": [10, 2, 3, 0], + "jdk_version": [10, 0, 1, 9] + }, + { + "id": 10541, + "url": "https://cdn.azul.com/zulu/bin/zulu10.3+5-jdk10.0.2-macosx_x64.tar.gz", + "name": "zulu10.3+5-jdk10.0.2-macosx_x64.tar.gz", + "zulu_version": [10, 3, 5, 0], + "jdk_version": [10, 0, 2, 13] + }, + { + "id": 10576, + "url": "https://cdn.azul.com/zulu/bin/zulu11.2.3-jdk11.0.1-macosx_x64.tar.gz", + "name": "zulu11.2.3-jdk11.0.1-macosx_x64.tar.gz", + "zulu_version": [11, 2, 3, 0], + "jdk_version": [11, 0, 1, 13] + }, + { + "id": 10604, + "url": "https://cdn.azul.com/zulu/bin/zulu11.29.3-ca-jdk11.0.2-macosx_x64.tar.gz", + "name": "zulu11.29.3-ca-jdk11.0.2-macosx_x64.tar.gz", + "zulu_version": [11, 29, 3, 0], + "jdk_version": [11, 0, 2, 7] + }, + { + "id": 10687, + "url": "https://cdn.azul.com/zulu/bin/zulu11.31.11-ca-jdk11.0.3-macosx_x64.tar.gz", + "name": "zulu11.31.11-ca-jdk11.0.3-macosx_x64.tar.gz", + "zulu_version": [11, 31, 11, 0], + "jdk_version": [11, 0, 3, 7] + }, + { + "id": 10856, + "url": "https://cdn.azul.com/zulu/bin/zulu11.35.13-ca-jdk11.0.5-macosx_x64.tar.gz", + "name": "zulu11.35.13-ca-jdk11.0.5-macosx_x64.tar.gz", + "zulu_version": [11, 35, 13, 0], + "jdk_version": [11, 0, 5, 10] + }, + { + "id": 10933, + "url": "https://cdn.azul.com/zulu/bin/zulu11.35.15-ca-jdk11.0.5-macosx_x64.tar.gz", + "name": "zulu11.35.15-ca-jdk11.0.5-macosx_x64.tar.gz", + "zulu_version": [11, 35, 15, 0], + "jdk_version": [11, 0, 5, 10] + }, + { + "id": 10933, + "url": "https://cdn.azul.com/zulu/bin/zulu11.35.11-ca-jdk11.0.5-macosx_x64.tar.gz", + "name": "zulu11.35.15-ca-jdk11.0.5-macosx_x64.tar.gz", + "zulu_version": [11, 35, 11, 0], + "jdk_version": [11, 0, 5, 10] + }, + { + "id": 12397, + "url": "https://cdn.azul.com/zulu/bin/zulu11.45.27-ca-jdk11.0.10-macosx_x64.tar.gz", + "name": "zulu11.45.27-ca-jdk11.0.10-macosx_x64.tar.gz", + "zulu_version": [11, 45, 27, 0], + "jdk_version": [11, 0, 10, 9] + }, + { + "id": 10667, + "url": "https://cdn.azul.com/zulu/bin/zulu12.1.3-ca-jdk12.0.0-macosx_x64.tar.gz", + "name": "zulu12.1.3-ca-jdk12.0.0-macosx_x64.tar.gz", + "zulu_version": [12, 1, 3, 0], + "jdk_version": [12, 0, 0, 33] + }, + { + "id": 10710, + "url": "https://cdn.azul.com/zulu/bin/zulu12.2.3-ca-jdk12.0.1-macosx_x64.tar.gz", + "name": "zulu12.2.3-ca-jdk12.0.1-macosx_x64.tar.gz", + "zulu_version": [12, 2, 3, 0], + "jdk_version": [12, 0, 1, 12] + }, + { + "id": 10780, + "url": "https://cdn.azul.com/zulu/bin/zulu12.3.11-ca-jdk12.0.2-macosx_x64.tar.gz", + "name": "zulu12.3.11-ca-jdk12.0.2-macosx_x64.tar.gz", + "zulu_version": [12, 3, 11, 0], + "jdk_version": [12, 0, 2, 3] + }, + { + "id": 10846, + "url": "https://cdn.azul.com/zulu/bin/zulu13.27.9-ca-jdk13.0.0-macosx_x64.tar.gz", + "name": "zulu13.27.9-ca-jdk13.0.0-macosx_x64.tar.gz", + "zulu_version": [13, 27, 9, 0], + "jdk_version": [13, 0, 0, 33] + }, + { + "id": 10888, + "url": "https://cdn.azul.com/zulu/bin/zulu13.28.11-ca-jdk13.0.1-macosx_x64.tar.gz", + "name": "zulu13.28.11-ca-jdk13.0.1-macosx_x64.tar.gz", + "zulu_version": [13, 28, 11, 0], + "jdk_version": [13, 0, 1, 10] + }, + { + "id": 11073, + "url": "https://cdn.azul.com/zulu/bin/zulu13.29.9-ca-jdk13.0.2-macosx_x64.tar.gz", + "name": "zulu13.29.9-ca-jdk13.0.2-macosx_x64.tar.gz", + "zulu_version": [13, 29, 9, 0], + "jdk_version": [13, 0, 2, 6] + }, + { + "id": 12408, + "url": "https://cdn.azul.com/zulu/bin/zulu13.37.21-ca-jdk13.0.6-macosx_x64.tar.gz", + "name": "zulu13.37.21-ca-jdk13.0.6-macosx_x64.tar.gz", + "zulu_version": [13, 37, 21, 0], + "jdk_version": [13, 0, 6, 5] + }, + { + "id": 11236, + "url": "https://cdn.azul.com/zulu/bin/zulu14.27.1-ca-jdk14.0.0-macosx_x64.tar.gz", + "name": "zulu14.27.1-ca-jdk14.0.0-macosx_x64.tar.gz", + "zulu_version": [14, 27, 1, 0], + "jdk_version": [14, 0, 0, 36] + }, + { + "id": 11349, + "url": "https://cdn.azul.com/zulu/bin/zulu14.28.21-ca-jdk14.0.1-macosx_x64.tar.gz", + "name": "zulu14.28.21-ca-jdk14.0.1-macosx_x64.tar.gz", + "zulu_version": [14, 28, 21, 0], + "jdk_version": [14, 0, 1, 8] + }, + { + "id": 11513, + "url": "https://cdn.azul.com/zulu/bin/zulu14.29.23-ca-jdk14.0.2-macosx_x64.tar.gz", + "name": "zulu14.29.23-ca-jdk14.0.2-macosx_x64.tar.gz", + "zulu_version": [14, 29, 23, 0], + "jdk_version": [14, 0, 2, 12] + }, + { + "id": 11780, + "url": "https://cdn.azul.com/zulu/bin/zulu15.27.17-ca-jdk15.0.0-macosx_x64.tar.gz", + "name": "zulu15.27.17-ca-jdk15.0.0-macosx_x64.tar.gz", + "zulu_version": [15, 27, 17, 0], + "jdk_version": [15, 0, 0, 36] + }, + { + "id": 11924, + "url": "https://cdn.azul.com/zulu/bin/zulu15.28.13-ca-jdk15.0.1-macosx_x64.tar.gz", + "name": "zulu15.28.13-ca-jdk15.0.1-macosx_x64.tar.gz", + "zulu_version": [15, 28, 13, 0], + "jdk_version": [15, 0, 1, 8] + }, + { + "id": 12101, + "url": "https://cdn.azul.com/zulu/bin/zulu15.28.51-ca-jdk15.0.1-macosx_x64.tar.gz", + "name": "zulu15.28.51-ca-jdk15.0.1-macosx_x64.tar.gz", + "zulu_version": [15, 28, 51, 0], + "jdk_version": [15, 0, 1, 9] + }, + { + "id": 12445, + "url": "https://cdn.azul.com/zulu/bin/zulu15.29.15-ca-jdk15.0.2-macosx_x64.tar.gz", + "name": "zulu15.29.15-ca-jdk15.0.2-macosx_x64.tar.gz", + "zulu_version": [15, 29, 15, 0], + "jdk_version": [15, 0, 2, 7] + } +] diff --git a/__tests__/distributors/adoptium-installer.test.ts b/__tests__/distributors/adoptium-installer.test.ts new file mode 100644 index 000000000..0408535f4 --- /dev/null +++ b/__tests__/distributors/adoptium-installer.test.ts @@ -0,0 +1,146 @@ +import { HttpClient } from '@actions/http-client'; + +import * as semver from 'semver'; + +import { AdoptiumDistribution } from '../../src/distributions/adoptium/installer'; +import { JavaInstallerOptions } from '../../src/distributions/base-models'; + +let manifestData = require('../data/adoptium.json') as []; + +describe('getAvailableVersions', () => { + let spyHttpClient: jest.SpyInstance; + + beforeEach(() => { + spyHttpClient = jest.spyOn(HttpClient.prototype, 'getJson'); + spyHttpClient.mockReturnValue({ + statusCode: 200, + headers: {}, + result: [] + }); + }); + + afterEach(() => { + jest.resetAllMocks(); + jest.clearAllMocks(); + jest.restoreAllMocks(); + }); + + it.each([ + [ + { version: '11', arch: 'x64', packageType: 'jdk' }, + 'os=mac&architecture=x64&image_type=jdk&release_type=ga&page_size=20&page=0' + ], + [ + { version: '11', arch: 'x86', packageType: 'jdk' }, + 'os=mac&architecture=x86&image_type=jdk&release_type=ga&page_size=20&page=0' + ], + [ + { version: '11', arch: 'x64', packageType: 'jre' }, + 'os=mac&architecture=x64&image_type=jre&release_type=ga&page_size=20&page=0' + ], + [ + { version: '11-ea', arch: 'x64', packageType: 'jdk' }, + 'os=mac&architecture=x64&image_type=jdk&release_type=ea&page_size=20&page=0' + ] + ])( + 'build correct url for %s', + async (installerOptions: JavaInstallerOptions, expectedParameters) => { + const distribution = new AdoptiumDistribution(installerOptions); + const baseUrl = 'https://api.adoptopenjdk.net/v3/assets/version/%5B1.0,100.0%5D'; + const expectedUrl = `${baseUrl}?project=jdk&vendor=adoptopenjdk&heap_size=normal&jvm_impl=hotspot&sort_method=DEFAULT&sort_order=DESC&${expectedParameters}`; + distribution['getPlatformOption'] = () => 'mac'; + + await distribution['getAvailableVersions'](); + + expect(spyHttpClient.mock.calls).toHaveLength(1); + expect(spyHttpClient.mock.calls[0][0]).toBe(expectedUrl); + } + ); + + it('load available versions', async () => { + spyHttpClient = jest.spyOn(HttpClient.prototype, 'getJson'); + spyHttpClient + .mockReturnValueOnce({ + statusCode: 200, + headers: {}, + result: manifestData + }) + .mockReturnValueOnce({ + statusCode: 200, + headers: {}, + result: manifestData + }) + .mockReturnValueOnce({ + statusCode: 200, + headers: {}, + result: [] + }); + + const distribution = new AdoptiumDistribution({ + version: '11', + arch: 'x64', + packageType: 'jdk' + }); + const availableVersions = await distribution['getAvailableVersions'](); + expect(availableVersions).not.toBeNull(); + expect(availableVersions.length).toBe(manifestData.length * 2); + }); +}); + +describe('findPackageForDownload', () => { + it.each([ + ['9', '9.0.7+10'], + ['15', '15.0.2+7'], + ['15.0', '15.0.2+7'], + ['15.0.2', '15.0.2+7'], + ['15.0.1', '15.0.1+9.1'], + ['11.x', '11.0.10+9'], + ['x', '15.0.2+7'], + ['12', '12.0.2+10.3'] // make sure that '12.0.2+10.1', '12.0.2+10.3', '12.0.2+10.2' are sorted correctly + ])('version is resolved correctly %s -> %s', async (input, expected) => { + const distribution = new AdoptiumDistribution({ + version: '11', + arch: 'x64', + packageType: 'jdk' + }); + distribution['getAvailableVersions'] = async () => manifestData; + const resolvedVersion = await distribution['findPackageForDownload'](new semver.Range(input)); + expect(resolvedVersion.version).toBe(expected); + }); + + it('version is found but binaries list is empty', async () => { + const distribution = new AdoptiumDistribution({ + version: '11', + arch: 'x64', + packageType: 'jdk' + }); + distribution['getAvailableVersions'] = async () => manifestData; + await expect( + distribution['findPackageForDownload'](new semver.Range('9.0.8')) + ).rejects.toThrowError(/Could not find satisfied version for SemVer */); + }); + + it('version is not found', async () => { + const distribution = new AdoptiumDistribution({ + version: '11', + arch: 'x64', + packageType: 'jdk' + }); + distribution['getAvailableVersions'] = async () => manifestData; + await expect( + distribution['findPackageForDownload'](new semver.Range('7.x')) + ).rejects.toThrowError(/Could not find satisfied version for SemVer */); + }); + + it('version list is empty', async () => { + const distribution = new AdoptiumDistribution({ + version: '11', + arch: 'x64', + packageType: 'jdk' + }); + distribution['getAvailableVersions'] = async () => []; + await expect( + distribution['findPackageForDownload'](new semver.Range('11')) + ).rejects.toThrowError(/Could not find satisfied version for SemVer */); + }); +}); diff --git a/__tests__/distributors/base-installer.test.ts b/__tests__/distributors/base-installer.test.ts new file mode 100644 index 000000000..f623f5f22 --- /dev/null +++ b/__tests__/distributors/base-installer.test.ts @@ -0,0 +1,246 @@ +import * as tc from '@actions/tool-cache'; +import * as core from '@actions/core'; + +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'; + +class EmptyJavaBase extends JavaBase { + constructor(installerOptions: JavaInstallerOptions) { + super('Empty', installerOptions); + } + + protected async downloadTool(javaRelease: JavaDownloadRelease): Promise { + return { + version: '11.0.8', + path: `/toolcache/${this.toolcacheFolderName}/11.0.8/${this.architecture}` + }; + } + + protected async findPackageForDownload(range: semver.Range): Promise { + const availableVersion = '11.0.8'; + if (!semver.satisfies(availableVersion, range)) { + throw new Error('Available version not found'); + } + + return { + version: availableVersion, + url: `some/random_url/java/${availableVersion}` + }; + } +} + +describe('findInToolcache', () => { + const actualJavaVersion = '11.1.10'; + const javaPath = path.join('Java_Empty_jdk', actualJavaVersion, 'x64'); + + let mockJavaBase: EmptyJavaBase; + let spyTcFind: jest.SpyInstance; + let spyTcFindAllVersions: jest.SpyInstance; + + beforeEach(() => { + spyTcFind = jest.spyOn(tc, 'find'); + spyTcFindAllVersions = jest.spyOn(tc, 'findAllVersions'); + }); + + afterEach(() => { + jest.resetAllMocks(); + jest.clearAllMocks(); + jest.restoreAllMocks(); + }); + + it.each([ + [ + { version: '11', arch: 'x64', packageType: 'jdk' }, + { version: actualJavaVersion, path: javaPath } + ], + [ + { version: '11.1', arch: 'x64', packageType: 'jdk' }, + { version: actualJavaVersion, path: javaPath } + ], + [ + { version: '11.1.10', arch: 'x64', packageType: 'jdk' }, + { version: actualJavaVersion, path: javaPath } + ], + [{ version: '11', arch: 'x64', packageType: 'jre' }, null], + [{ version: '8', arch: 'x64', packageType: 'jdk' }, null], + [{ version: '11', arch: 'x86', packageType: 'jdk' }, null], + [{ version: '11', arch: 'x86', packageType: 'jre' }, null] + ])(`should find java for path %s -> %s`, (input, expected) => { + spyTcFindAllVersions.mockReturnValue([actualJavaVersion]); + spyTcFind.mockImplementation((toolname: string, javaVersion: string, architecture: string) => { + const semverVersion = new semver.Range(javaVersion); + + if (path.basename(javaPath) !== architecture || !javaPath.includes(toolname)) { + return ''; + } + + return semver.satisfies(actualJavaVersion, semverVersion) ? javaPath : ''; + }); + mockJavaBase = new EmptyJavaBase(input); + expect(mockJavaBase['findInToolcache']()).toEqual(expected); + }); + + it.each([ + ['11', '11.0.3'], + ['11.0', '11.0.3'], + ['11.0.1', '11.0.1'], + ['11.0.3', '11.0.3'], + ['15', '15.0.2'], + ['x', '15.0.2'], + ['x-ea', '17.4.4-ea'], + ['11-ea', '11.3.2-ea'], + ['11.2-ea', '11.2.1-ea'], + ['11.2.1-ea', '11.2.1-ea'] + ])('should choose correct java from tool-cache for input %s', (input, expected) => { + spyTcFindAllVersions.mockReturnValue([ + '17.4.4-ea', + '11.0.2', + '15.0.2', + '11.0.3', + '11.2.1-ea', + '11.3.2-ea', + '11.0.1' + ]); + spyTcFind.mockImplementation( + (toolname: string, javaVersion: string, architecture: string) => + `/hostedtoolcache/${toolname}/${javaVersion}/${architecture}` + ); + mockJavaBase = new EmptyJavaBase({ version: input, arch: 'x64', packageType: 'jdk' }); + const foundVersion = mockJavaBase['findInToolcache'](); + expect(foundVersion?.version).toEqual(expected); + }); +}); + +describe('setupJava', () => { + const actualJavaVersion = '11.1.10'; + const javaPath = path.join('Java_Empty_jdk', actualJavaVersion, 'x86'); + + let mockJavaBase: EmptyJavaBase; + + let spyTcFind: 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; + + beforeEach(() => { + spyTcFind = jest.spyOn(tc, 'find'); + spyTcFind.mockImplementation((toolname: string, javaVersion: string, architecture: string) => { + const semverVersion = new semver.Range(javaVersion); + + if (path.basename(javaPath) !== architecture || !javaPath.includes(toolname)) { + return ''; + } + + return semver.satisfies(actualJavaVersion, semverVersion) ? javaPath : ''; + }); + + spyTcFindAllVersions = jest.spyOn(tc, 'findAllVersions'); + spyTcFindAllVersions.mockReturnValue([actualJavaVersion]); + + // Spy on core methods + spyCoreDebug = jest.spyOn(core, 'debug'); + spyCoreDebug.mockImplementation(() => undefined); + + spyCoreInfo = jest.spyOn(core, 'info'); + spyCoreInfo.mockImplementation(() => undefined); + + spyCoreAddPath = jest.spyOn(core, 'addPath'); + spyCoreAddPath.mockImplementation(() => undefined); + + spyCoreExportVariable = jest.spyOn(core, 'exportVariable'); + spyCoreExportVariable.mockImplementation(() => undefined); + + spyCoreSetOutput = jest.spyOn(core, 'setOutput'); + spyCoreSetOutput.mockImplementation(() => undefined); + }); + + afterEach(() => { + jest.resetAllMocks(); + jest.clearAllMocks(); + jest.restoreAllMocks(); + }); + + it.each([ + [ + { version: '11', arch: 'x86', packageType: 'jdk' }, + { version: actualJavaVersion, path: javaPath } + ], + [ + { version: '11.1', arch: 'x86', packageType: 'jdk' }, + { version: actualJavaVersion, path: javaPath } + ], + [ + { version: '11.1.10', arch: 'x86', packageType: 'jdk' }, + { version: actualJavaVersion, path: javaPath } + ] + ])('should find java locally for %s', (input, expected) => { + mockJavaBase = new EmptyJavaBase(input); + expect(mockJavaBase.setupJava()).resolves.toEqual(expected); + expect(spyTcFind).toHaveBeenCalled(); + }); + + it.each([ + [ + { version: '11', arch: 'x86', packageType: 'jre' }, + { path: `/toolcache/Java_Empty_jre/11.0.8/x86`, version: '11.0.8' } + ], + [ + { version: '11', arch: 'x64', packageType: 'jdk' }, + { path: `/toolcache/Java_Empty_jdk/11.0.8/x64`, version: '11.0.8' } + ], + [ + { version: '11', arch: 'x64', packageType: 'jre' }, + { path: `/toolcache/Java_Empty_jre/11.0.8/x64`, version: '11.0.8' } + ] + ])('download java with configuration %s', async (input, expected) => { + mockJavaBase = new EmptyJavaBase(input); + await expect(mockJavaBase.setupJava()).resolves.toEqual(expected); + expect(spyTcFind).toHaveBeenCalled(); + expect(spyCoreAddPath).toHaveBeenCalled(); + expect(spyCoreExportVariable).toHaveBeenCalled(); + expect(spyCoreSetOutput).toHaveBeenCalled(); + }); + + it.each([ + [{ version: '15', arch: 'x86', packageType: 'jre' }], + [{ version: '11.0.7', arch: 'x64', packageType: 'jre' }] + ])('should throw an error for Available version not found for %s', async input => { + mockJavaBase = new EmptyJavaBase(input); + await expect(mockJavaBase.setupJava()).rejects.toThrowError('Available version not found'); + expect(spyTcFindAllVersions).toHaveBeenCalled(); + expect(spyCoreAddPath).not.toHaveBeenCalled(); + expect(spyCoreExportVariable).not.toHaveBeenCalled(); + expect(spyCoreSetOutput).not.toHaveBeenCalled(); + }); +}); + +describe('normalizeVersion', () => { + const DummyJavaBase = JavaBase as any; + + it.each([ + ['11', { version: new semver.Range('11'), stable: true }], + ['11.0', { version: new semver.Range('11.0'), stable: true }], + ['11.0.10', { version: new semver.Range('11.0.10'), stable: true }], + ['11-ea', { version: new semver.Range('11'), stable: false }], + ['11.0.2-ea', { version: new semver.Range('11.0.2'), stable: false }] + ])('normalizeVersion from %s to %s', (input, expected) => { + expect(DummyJavaBase.prototype.normalizeVersion.call(null, input)).toEqual(expected); + }); + + it('normalizeVersion should throw an error for non semver', () => { + const version = '11g'; + expect(DummyJavaBase.prototype.normalizeVersion.bind(null, version)).toThrowError( + `The string '${version}' is not valid SemVer notation for Java version. Please check README file for code snippets and more detailed information` + ); + }); +}); diff --git a/__tests__/distributors/local-installer.test.ts b/__tests__/distributors/local-installer.test.ts new file mode 100644 index 000000000..c485eee3f --- /dev/null +++ b/__tests__/distributors/local-installer.test.ts @@ -0,0 +1,195 @@ +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 utils from '../../src/util'; + +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: LocalDistribution; + + let spyTcFind: 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 expectedJdkFile = 'JavaLocalJdkFile'; + + beforeEach(() => { + spyTcFind = jest.spyOn(tc, 'find'); + spyTcFind.mockImplementation((toolname: string, javaVersion: string, architecture: string) => { + const semverVersion = new semver.Range(javaVersion); + + if (path.basename(javaPath) !== architecture || !javaPath.includes(toolname)) { + return ''; + } + + return semver.satisfies(actualJavaVersion, semverVersion) ? javaPath : ''; + }); + + spyTcCacheDir = jest.spyOn(tc, 'cacheDir'); + spyTcCacheDir.mockImplementation( + (archivePath: string, toolcacheFolderName: string, version: string, architecture: string) => + path.join(toolcacheFolderName, version, architecture) + ); + + spyTcFindAllVersions = jest.spyOn(tc, 'findAllVersions'); + spyTcFindAllVersions.mockReturnValue([actualJavaVersion]); + + // Spy on core methods + spyCoreDebug = jest.spyOn(core, 'debug'); + spyCoreDebug.mockImplementation(() => undefined); + + spyCoreInfo = jest.spyOn(core, 'info'); + spyCoreInfo.mockImplementation(() => undefined); + + spyCoreAddPath = jest.spyOn(core, 'addPath'); + spyCoreAddPath.mockImplementation(() => undefined); + + spyCoreExportVariable = jest.spyOn(core, 'exportVariable'); + spyCoreExportVariable.mockImplementation(() => undefined); + + spyCoreSetOutput = jest.spyOn(core, 'setOutput'); + spyCoreSetOutput.mockImplementation(() => undefined); + + // Spy on fs methods + spyFsReadDir = jest.spyOn(fs, 'readdirSync'); + spyFsReadDir.mockImplementation(() => ['JavaTest']); + + spyFsStat = jest.spyOn(fs, 'statSync'); + spyFsStat.mockImplementation((file: string) => { + return { isFile: () => file === expectedJdkFile }; + }); + + // Spy on util methods + spyUtilsExtractJdkFile = jest.spyOn(utils, 'extractJdkFile'); + spyUtilsExtractJdkFile.mockImplementation(() => 'some/random/path/'); + + // Spy on path methods + spyPathResolve = jest.spyOn(path, 'resolve'); + spyPathResolve.mockImplementation((path: string) => path); + }); + + afterEach(() => { + jest.resetAllMocks(); + jest.clearAllMocks(); + jest.restoreAllMocks(); + }); + + it('java is resolved from toolcache, jdkfile is untouched', async () => { + const inputs = { version: actualJavaVersion, arch: 'x86', packageType: 'jdk' }; + const jdkFile = 'not_existing_one'; + const expected = { + version: actualJavaVersion, + path: path.join('Java_jdkfile_jdk', inputs.version, inputs.arch) + }; + + mockJavaBase = new LocalDistribution(inputs, jdkFile); + await expect(mockJavaBase.setupJava()).resolves.toEqual(expected); + expect(spyTcFind).toHaveBeenCalled(); + expect(spyCoreInfo).toHaveBeenCalledWith(`Resolved Java ${actualJavaVersion} from tool-cache`); + expect(spyCoreInfo).not.toHaveBeenCalledWith( + `Java ${inputs.version} is not found in tool-cache. Trying to unpack JDK file...` + ); + }); + + it("java is resolved from toolcache, jdkfile doesn't exist", async () => { + const inputs = { version: actualJavaVersion, arch: 'x86', packageType: 'jdk' }; + const jdkFile = undefined; + const expected = { + version: actualJavaVersion, + path: path.join('Java_jdkfile_jdk', inputs.version, inputs.arch) + }; + + mockJavaBase = new LocalDistribution(inputs, jdkFile); + await expect(mockJavaBase.setupJava()).resolves.toEqual(expected); + expect(spyTcFind).toHaveBeenCalled(); + expect(spyCoreInfo).toHaveBeenCalledWith(`Resolved Java ${actualJavaVersion} from tool-cache`); + expect(spyCoreInfo).not.toHaveBeenCalledWith( + `Java ${inputs.version} is not found in tool-cache. Trying to unpack JDK file...` + ); + }); + + it('java is unpacked from jdkfile', async () => { + const inputs = { version: '11.0.289', arch: 'x86', packageType: 'jdk' }; + const jdkFile = expectedJdkFile; + const expected = { + version: '11.0.289', + path: path.join('Java_jdkfile_jdk', inputs.version, inputs.arch) + }; + + mockJavaBase = new LocalDistribution(inputs, jdkFile); + await expect(mockJavaBase.setupJava()).resolves.toEqual(expected); + expect(spyTcFindAllVersions).toHaveBeenCalled(); + expect(spyCoreInfo).not.toHaveBeenCalledWith( + `Resolved Java ${actualJavaVersion} from tool-cache` + ); + expect(spyCoreInfo).toHaveBeenCalledWith(`Extracting Java from '${jdkFile}'`); + expect(spyCoreInfo).toHaveBeenCalledWith( + `Java ${inputs.version} is not found in tool-cache. Trying to unpack JDK file...` + ); + }); + + it('jdk file is not found', async () => { + const inputs = { version: '11.0.289', arch: 'x86', packageType: 'jdk' }; + const jdkFile = 'not_existing_one'; + const expected = { + javaVersion: '11.0.289', + javaPath: path.join('Java_jdkfile_jdk', inputs.version, inputs.arch) + }; + + mockJavaBase = new LocalDistribution(inputs, jdkFile); + expected.javaPath = path.join('Java_jdkfile_jdk', inputs.version, inputs.arch); + await expect(mockJavaBase.setupJava()).rejects.toThrowError( + "JDK file is not found in path 'not_existing_one'" + ); + expect(spyTcFindAllVersions).toHaveBeenCalled(); + expect(spyCoreInfo).not.toHaveBeenCalledWith( + `Resolved Java ${actualJavaVersion} from tool-cache` + ); + expect(spyCoreInfo).not.toHaveBeenCalledWith(`Extracting Java from '${jdkFile}'`); + expect(spyCoreInfo).toHaveBeenCalledWith( + `Java ${inputs.version} is not found in tool-cache. Trying to unpack JDK file...` + ); + }); + + it.each([ + [{ version: '8.0.289', arch: 'x64', packageType: 'jdk' }, 'otherJdkFile'], + [{ version: '11.0.289', arch: 'x64', packageType: 'jdk' }, 'otherJdkFile'], + [{ version: '12.0.289', arch: 'x64', packageType: 'jdk' }, 'otherJdkFile'], + [{ version: '11.1.11', arch: 'x64', packageType: 'jdk' }, 'not_existing_one'] + ])( + `Throw an error if jdkfile has wrong path, inputs %s, jdkfile %s, real name ${expectedJdkFile}`, + async (inputs, jdkFile) => { + mockJavaBase = new LocalDistribution(inputs, jdkFile); + await expect(mockJavaBase.setupJava()).rejects.toThrowError( + /JDK file is not found in path */ + ); + expect(spyTcFindAllVersions).toHaveBeenCalled(); + } + ); + + it.each([ + [{ version: '8.0.289', arch: 'x64', packageType: 'jdk' }, ''], + [{ version: '7.0.289', arch: 'x64', packageType: 'jdk' }, undefined], + [{ version: '11.0.289', arch: 'x64', packageType: 'jdk' }, undefined] + ])('Throw an error if jdkfile is not specified, inputs %s', async (inputs, jdkFile) => { + mockJavaBase = new LocalDistribution(inputs, jdkFile); + await expect(mockJavaBase.setupJava()).rejects.toThrowError("'jdkFile' is not specified"); + expect(spyTcFindAllVersions).toHaveBeenCalled(); + }); +}); diff --git a/__tests__/distributors/zulu-installer.test.ts b/__tests__/distributors/zulu-installer.test.ts new file mode 100644 index 000000000..eb310b06b --- /dev/null +++ b/__tests__/distributors/zulu-installer.test.ts @@ -0,0 +1,140 @@ +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'; + +const manifestData = require('../data/zulu-releases-default.json') as []; + +describe('getAvailableVersions', () => { + let spyHttpClient: jest.SpyInstance; + let spyUtilGetDownloadArchiveExtension: jest.SpyInstance; + + beforeEach(() => { + spyHttpClient = jest.spyOn(HttpClient.prototype, 'getJson'); + spyHttpClient.mockReturnValue({ + statusCode: 200, + headers: {}, + result: manifestData as IZuluVersions[] + }); + + spyUtilGetDownloadArchiveExtension = jest.spyOn(utils, 'getDownloadArchiveExtension'); + spyUtilGetDownloadArchiveExtension.mockReturnValue('tar.gz'); + }); + + afterEach(() => { + jest.resetAllMocks(); + jest.clearAllMocks(); + jest.restoreAllMocks(); + }); + + it.each([ + [ + { version: '11', arch: 'x86', packageType: 'jdk' }, + '?os=macos&ext=tar.gz&bundle_type=jdk&javafx=false&arch=x86&hw_bitness=32&release_status=ga' + ], + [ + { version: '11-ea', arch: 'x86', packageType: 'jdk' }, + '?os=macos&ext=tar.gz&bundle_type=jdk&javafx=false&arch=x86&hw_bitness=32&release_status=ea' + ], + [ + { version: '8', arch: 'x64', packageType: 'jdk' }, + '?os=macos&ext=tar.gz&bundle_type=jdk&javafx=false&arch=x86&hw_bitness=64&release_status=ga' + ], + [ + { version: '8', arch: 'x64', packageType: 'jre' }, + '?os=macos&ext=tar.gz&bundle_type=jre&javafx=false&arch=x86&hw_bitness=64&release_status=ga' + ], + [ + { version: '8', arch: 'x64', packageType: 'jdk+fx' }, + '?os=macos&ext=tar.gz&bundle_type=jdk&javafx=true&arch=x86&hw_bitness=64&release_status=ga&features=fx' + ], + [ + { version: '8', arch: 'x64', packageType: 'jre+fx' }, + '?os=macos&ext=tar.gz&bundle_type=jre&javafx=true&arch=x86&hw_bitness=64&release_status=ga&features=fx' + ] + ])('build correct url for %s -> %s', async (input, parsedUrl) => { + const distribution = new ZuluDistribution(input); + distribution['getPlatformOption'] = () => 'macos'; + const buildUrl = `https://api.azul.com/zulu/download/community/v1.0/bundles/${parsedUrl}`; + + await distribution['getAvailableVersions'](); + + expect(spyHttpClient.mock.calls).toHaveLength(1); + expect(spyHttpClient.mock.calls[0][0]).toBe(buildUrl); + }); + + it('load available versions', async () => { + const distribution = new ZuluDistribution({ version: '11', arch: 'x86', packageType: 'jdk' }); + const availableVersions = await distribution['getAvailableVersions'](); + expect(availableVersions).toHaveLength(manifestData.length); + }); +}); + +describe('getArchitectureOptions', () => { + it.each([ + [{ architecture: 'x64' }, { arch: 'x86', hw_bitness: '64', abi: '' }], + [{ architecture: 'x86' }, { arch: 'x86', hw_bitness: '32', abi: '' }], + [{ architecture: 'x32' }, { arch: 'x32', hw_bitness: '', abi: '' }], + [{ architecture: 'arm' }, { arch: 'arm', hw_bitness: '', abi: '' }] + ])('%s -> %s', (input, expected) => { + const distribution = new ZuluDistribution({ + version: '11', + arch: input.architecture, + packageType: 'jdk' + }); + expect(distribution['getArchitectureOptions']()).toEqual(expected); + }); +}); + +describe('findPackageForDownload', () => { + it.each([ + ['8', '8.0.282+8'], + ['11.x', '11.0.10+9'], + ['8.0', '8.0.282+8'], + ['11.0.x', '11.0.10+9'], + ['15', '15.0.2+7'], + ['9.0.0', '9.0.0+0'], + ['9.0', '9.0.1+0'], + ['8.0.262', '8.0.262+19'] // validate correct choise between [8.0.262.17, 8.0.262.19, 8.0.262.18] + ])('version is %s -> %s', async (input, expected) => { + const distribution = new ZuluDistribution({ + version: input, + arch: 'x86', + packageType: 'jdk' + }); + distribution['getAvailableVersions'] = async () => manifestData; + const result = await distribution['findPackageForDownload'](distribution['version']); + expect(result.version).toBe(expected); + }); + + it('select correct bundle if there are multiple items with the same jdk version but different zulu versions', async () => { + const distribution = new ZuluDistribution({ version: '', arch: 'x86', packageType: 'jdk' }); + distribution['getAvailableVersions'] = async () => manifestData; + const result = await distribution['findPackageForDownload'](new semver.Range('11.0.5')); + expect(result.url).toBe( + 'https://cdn.azul.com/zulu/bin/zulu11.35.15-ca-jdk11.0.5-macosx_x64.tar.gz' + ); + }); + + it('should throw an error', async () => { + const distribution = new ZuluDistribution({ version: '18', arch: 'x86', packageType: 'jdk' }); + await expect( + distribution['findPackageForDownload'](distribution['version']) + ).rejects.toThrowError(/Could not find satisfied version for semver */); + }); +}); + +describe('convertVersionToSemver', () => { + it.each([ + [[12], '12'], + [[12, 0], '12.0'], + [[12, 0, 2], '12.0.2'], + [[12, 0, 2, 1], '12.0.2+1'], + [[12, 0, 2, 1, 3], '12.0.2+1'] + ])('%s -> %s', (input: number[], expected: string) => { + const distribution = new ZuluDistribution({ version: '18', arch: 'x86', packageType: 'jdk' }); + const actual = distribution['convertVersionToSemver'](input); + expect(actual).toBe(expected); + }); +}); diff --git a/__tests__/gpg.test.ts b/__tests__/gpg.test.ts index f19e9a676..5288f9ee5 100644 --- a/__tests__/gpg.test.ts +++ b/__tests__/gpg.test.ts @@ -33,11 +33,7 @@ describe('gpg tests', () => { expect(keyId).toBeNull(); - expect(exec.exec).toHaveBeenCalledWith( - 'gpg', - expect.anything(), - expect.anything() - ); + expect(exec.exec).toHaveBeenCalledWith('gpg', expect.anything(), expect.anything()); }); }); @@ -46,11 +42,7 @@ describe('gpg tests', () => { const keyId = 'asdfhjkl'; await gpg.deleteKey(keyId); - expect(exec.exec).toHaveBeenCalledWith( - 'gpg', - expect.anything(), - expect.anything() - ); + expect(exec.exec).toHaveBeenCalledWith('gpg', expect.anything(), expect.anything()); }); }); }); diff --git a/__tests__/installer.test.ts b/__tests__/installer.test.ts deleted file mode 100644 index ff2d61b5b..000000000 --- a/__tests__/installer.test.ts +++ /dev/null @@ -1,159 +0,0 @@ -import io = require('@actions/io'); -import fs = require('fs'); -import path = require('path'); -import child_process = require('child_process'); - -const toolDir = path.join(__dirname, 'runner', 'tools'); -const tempDir = path.join(__dirname, 'runner', 'temp'); -const javaDir = path.join(__dirname, 'runner', 'java'); - -process.env['RUNNER_TOOL_CACHE'] = toolDir; -process.env['RUNNER_TEMP'] = tempDir; -import * as installer from '../src/installer'; - -let javaFilePath = ''; -let javaUrl = ''; -if (process.platform === 'win32') { - javaFilePath = path.join(javaDir, 'java_win.zip'); - javaUrl = - 'https://download.java.net/java/GA/jdk12/33/GPL/openjdk-12_windows-x64_bin.zip'; -} else if (process.platform === 'darwin') { - javaFilePath = path.join(javaDir, 'java_mac.tar.gz'); - javaUrl = - 'https://download.java.net/java/GA/jdk12/33/GPL/openjdk-12_osx-x64_bin.tar.gz'; -} else { - javaFilePath = path.join(javaDir, 'java_linux.tar.gz'); - javaUrl = - 'https://download.java.net/java/GA/jdk12/33/GPL/openjdk-12_linux-x64_bin.tar.gz'; -} - -describe('installer tests', () => { - beforeAll(async () => { - await io.rmRF(toolDir); - await io.rmRF(tempDir); - if (!fs.existsSync(`${javaFilePath}.complete`)) { - // Download java - await io.mkdirP(javaDir); - - console.log('Downloading java'); - child_process.execSync(`curl "${javaUrl}" > "${javaFilePath}"`); - // Write complete file so we know it was successful - fs.writeFileSync(`${javaFilePath}.complete`, 'content'); - } - }, 300000); - - afterAll(async () => { - try { - await io.rmRF(toolDir); - await io.rmRF(tempDir); - } catch { - console.log('Failed to remove test directories'); - } - }, 100000); - - it('Installs version of Java from jdkFile if no matching version is installed', async () => { - await installer.getJava('12', 'x64', javaFilePath, 'jdk'); - const JavaDir = path.join(toolDir, 'jdk', '12.0.0', 'x64'); - - expect(fs.existsSync(`${JavaDir}.complete`)).toBe(true); - expect(fs.existsSync(path.join(JavaDir, 'bin'))).toBe(true); - }, 100000); - - it('Throws if invalid directory to jdk', async () => { - let thrown = false; - try { - await installer.getJava('1000', 'x64', 'bad path', 'jdk'); - } catch { - thrown = true; - } - expect(thrown).toBe(true); - }); - - it('Downloads java if no file given', async () => { - await installer.getJava('8.0.102', 'x64', '', 'jdk'); - const JavaDir = path.join(toolDir, 'jdk', '8.0.102', 'x64'); - - expect(fs.existsSync(`${JavaDir}.complete`)).toBe(true); - expect(fs.existsSync(path.join(JavaDir, 'bin'))).toBe(true); - }, 100000); - - it('Downloads java with 1.x syntax', async () => { - await installer.getJava('1.10', 'x64', '', 'jdk'); - const JavaDir = path.join(toolDir, 'jdk', '10.0.2', 'x64'); - - expect(fs.existsSync(`${JavaDir}.complete`)).toBe(true); - expect(fs.existsSync(path.join(JavaDir, 'bin'))).toBe(true); - }, 100000); - - it('Downloads java with normal semver syntax', async () => { - await installer.getJava('9.0.x', 'x64', '', 'jdk'); - const JavaDir = path.join(toolDir, 'jdk', '9.0.7', 'x64'); - - expect(fs.existsSync(`${JavaDir}.complete`)).toBe(true); - expect(fs.existsSync(path.join(JavaDir, 'bin'))).toBe(true); - }, 100000); - - it('Downloads java if package is jre', async () => { - await installer.getJava('8.0.222', 'x64', '', 'jre'); - const JavaDir = path.join(toolDir, 'jre', '8.0.222', 'x64'); - - expect(fs.existsSync(`${JavaDir}.complete`)).toBe(true); - expect(fs.existsSync(path.join(JavaDir, 'bin'))).toBe(true); - }, 100000); - - it('Downloads java if package is jdk+fx', async () => { - await installer.getJava('8.0.222', 'x64', '', 'jdk+fx'); - const JavaDir = path.join(toolDir, 'jdk+fx', '8.0.222', 'x64'); - - expect(fs.existsSync(`${JavaDir}.complete`)).toBe(true); - expect(fs.existsSync(path.join(JavaDir, 'bin'))).toBe(true); - }, 100000); - - it('Throws if invalid java package is specified', async () => { - let thrown = false; - try { - await installer.getJava('8.0.222', 'x64', '', 'bad jdk'); - } catch { - thrown = true; - } - expect(thrown).toBe(true); - }); - - it('Throws if invalid directory to jdk', async () => { - let thrown = false; - try { - await installer.getJava('1000', 'x64', 'bad path', 'jdk'); - } catch { - thrown = true; - } - expect(thrown).toBe(true); - }); - - it('Uses version of Java installed in cache', async () => { - const JavaDir: string = path.join(toolDir, 'jdk', '250.0.0', 'x64'); - await io.mkdirP(JavaDir); - fs.writeFileSync(`${JavaDir}.complete`, 'hello'); - // This will throw if it doesn't find it in the cache (because no such version exists) - await installer.getJava( - '250', - 'x64', - 'path shouldnt matter, found in cache', - 'jdk' - ); - return; - }); - - it('Doesnt use version of Java that was only partially installed in cache', async () => { - const JavaDir: string = path.join(toolDir, 'jdk', '251.0.0', 'x64'); - await io.mkdirP(JavaDir); - let thrown = false; - try { - // This will throw if it doesn't find it in the cache (because no such version exists) - await installer.getJava('251', 'x64', 'bad path', 'jdk'); - } catch { - thrown = true; - } - expect(thrown).toBe(true); - return; - }); -}); diff --git a/__tests__/util.test.ts b/__tests__/util.test.ts deleted file mode 100644 index 4ef37cfe8..000000000 --- a/__tests__/util.test.ts +++ /dev/null @@ -1,61 +0,0 @@ -import path = require('path'); - -const env = process.env; - -describe('util tests', () => { - beforeEach(() => { - const tempEnv = Object.assign({}, env); - delete tempEnv.RUNNER_TEMP; - delete tempEnv.USERPROFILE; - process.env = tempEnv; - Object.defineProperty(process, 'platform', {value: 'linux'}); - }); - - describe('getTempDir', () => { - it('gets temp dir using env', () => { - process.env['RUNNER_TEMP'] = 'defaulttmp'; - const util = require('../src/util'); - - const tempDir = util.getTempDir(); - - expect(tempDir).toEqual(process.env['RUNNER_TEMP']); - }); - - it('gets temp dir for windows using userprofile', () => { - Object.defineProperty(process, 'platform', {value: 'win32'}); - process.env['USERPROFILE'] = 'winusertmp'; - const util = require('../src/util'); - - const tempDir = util.getTempDir(); - - expect(tempDir).toEqual( - path.join(process.env['USERPROFILE'], 'actions', 'temp') - ); - }); - - it('gets temp dir for windows using c drive', () => { - Object.defineProperty(process, 'platform', {value: 'win32'}); - const util = require('../src/util'); - - const tempDir = util.getTempDir(); - - expect(tempDir).toEqual(path.join('C:\\', 'actions', 'temp')); - }); - - it('gets temp dir for mac', () => { - Object.defineProperty(process, 'platform', {value: 'darwin'}); - const util = require('../src/util'); - - const tempDir = util.getTempDir(); - - expect(tempDir).toEqual(path.join('/Users', 'actions', 'temp')); - }); - - it('gets temp dir for linux', () => { - const util = require('../src/util'); - const tempDir = util.getTempDir(); - - expect(tempDir).toEqual(path.join('/home', 'actions', 'temp')); - }); - }); -}); diff --git a/__tests__/verify-java.ps1 b/__tests__/verify-java.ps1 deleted file mode 100644 index 359f2915a..000000000 --- a/__tests__/verify-java.ps1 +++ /dev/null @@ -1,31 +0,0 @@ -if (!$args.Count -or !$args[0]) -{ - throw "Must supply java version argument" -} - -$java_version = & cmd.exe /c "java -version 2>&1" | Out-String -Write-Host "Found java version: $java_version" -if (!$java_version.Contains($args[0])) -{ - throw "Unexpected version" -} - -if ($args.Count -lt 2 -or !$args[1]) -{ - throw "Must supply java path argument" -} - -if ($args[1] -ne $Env:JAVA_HOME) -{ - throw "Unexpected path" -} - -if ($args.Count -lt 3 -or !$args[2]) -{ - throw "Must supply java version argument" -} - -if ($args[0] -ne $args[2]) -{ - throw "Unexpected version" -} diff --git a/__tests__/verify-java.sh b/__tests__/verify-java.sh index e0da7d3a9..130ae36bb 100755 --- a/__tests__/verify-java.sh +++ b/__tests__/verify-java.sh @@ -5,29 +5,31 @@ if [ -z "$1" ]; then exit 1 fi -java_version="$(java -version 2>&1)" -echo "Found java version: $java_version" -if [ -z "$(echo $java_version | grep --fixed-strings $1)" ]; then - echo "::error::Unexpected version" - exit 1 -fi - if [ -z "$2" ]; then echo "::error::Must supply java path argument" exit 1 fi -if [ "$2" != "$JAVA_HOME" ]; then - echo "::error::Unexpected path" - exit 1 +EXPECTED_JAVA_VERSION=${1/-ea/} +EXPECTED_PATH=$2 + +if [[ $EXPECTED_JAVA_VERSION == 8 ]] || [[ $EXPECTED_JAVA_VERSION == 8.* ]]; then + EXPECTED_JAVA_VERSION="1.${EXPECTED_JAVA_VERSION}" fi -if [ -z "$3" ]; then - echo "::error::Must supply java version argument" +ACTUAL_JAVA_VERSION="$(java -version 2>&1)" +echo "Found java version: $ACTUAL_JAVA_VERSION" + +GREP_RESULT=$(echo $ACTUAL_JAVA_VERSION | grep "^openjdk version \"$EXPECTED_JAVA_VERSION") +if [ -z "$GREP_RESULT" ]; then + echo "::error::Unexpected version" + echo "Expected version: $EXPECTED_JAVA_VERSION" exit 1 fi -if [ "$1" != "$3" ]; then - echo "::error::Unexpected version" +if [ "$EXPECTED_PATH" != "$JAVA_HOME" ]; then + echo "::error::Unexpected path" + echo "Actual path: $JAVA_HOME" + echo "Expected path: $EXPECTED_PATH" exit 1 fi diff --git a/__tests__/verify-no-unstaged-changes.sh b/__tests__/verify-no-unstaged-changes.sh new file mode 100644 index 000000000..c99e2265c --- /dev/null +++ b/__tests__/verify-no-unstaged-changes.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +if [[ "$(git status --porcelain)" != "" ]]; then + echo ---------------------------------------- + echo git status + echo ---------------------------------------- + git status + echo ---------------------------------------- + echo git diff + echo ---------------------------------------- + git diff + echo ---------------------------------------- + echo Troubleshooting + echo ---------------------------------------- + echo "::error::Unstaged changes detected. Locally try running: git clean -ffdx && npm ci && npm run pre-checkin" + exit 1 +fi \ No newline at end of file From 9979ab33134548ab3ce02a1512b6dc181c08b72e Mon Sep 17 00:00:00 2001 From: Maxim Lobanov Date: Mon, 8 Mar 2021 18:52:25 +0300 Subject: [PATCH 2/6] regenerate dist --- dist/cleanup/index.js | 12 ++---------- dist/setup/index.js | 26 ++++++-------------------- 2 files changed, 8 insertions(+), 30 deletions(-) diff --git a/dist/cleanup/index.js b/dist/cleanup/index.js index a533d2651..dbcef343f 100644 --- a/dist/cleanup/index.js +++ b/dist/cleanup/index.js @@ -1549,9 +1549,7 @@ exports.getVersionFromToolcachePath = getVersionFromToolcachePath; function extractJdkFile(toolPath, extension) { return __awaiter(this, void 0, void 0, function* () { if (!extension) { - extension = toolPath.endsWith('.tar.gz') - ? 'tar.gz' - : path_1.default.extname(toolPath); + extension = toolPath.endsWith('.tar.gz') ? 'tar.gz' : path_1.default.extname(toolPath); if (extension.startsWith('.')) { extension = extension.substring(1); } @@ -5091,13 +5089,7 @@ function importKey(privateKey) { } } }; - yield exec.exec('gpg', [ - '--batch', - '--import-options', - 'import-show', - '--import', - exports.PRIVATE_KEY_FILE - ], options); + yield exec.exec('gpg', ['--batch', '--import-options', 'import-show', '--import', exports.PRIVATE_KEY_FILE], options); yield io.rmRF(exports.PRIVATE_KEY_FILE); const match = output.match(PRIVATE_KEY_FINGERPRINT_REGEX); return match && match[0]; diff --git a/dist/setup/index.js b/dist/setup/index.js index 7248575ee..24fb42398 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -12944,9 +12944,7 @@ exports.getVersionFromToolcachePath = getVersionFromToolcachePath; function extractJdkFile(toolPath, extension) { return __awaiter(this, void 0, void 0, function* () { if (!extension) { - extension = toolPath.endsWith('.tar.gz') - ? 'tar.gz' - : path_1.default.extname(toolPath); + extension = toolPath.endsWith('.tar.gz') ? 'tar.gz' : path_1.default.extname(toolPath); if (extension.startsWith('.')) { extension = extension.substring(1); } @@ -13230,8 +13228,7 @@ function configureAuthentication() { const id = core.getInput(constants.INPUT_SERVER_ID); const username = core.getInput(constants.INPUT_SERVER_USERNAME); const password = core.getInput(constants.INPUT_SERVER_PASSWORD); - const gpgPrivateKey = core.getInput(constants.INPUT_GPG_PRIVATE_KEY) || - constants.INPUT_DEFAULT_GPG_PRIVATE_KEY; + const gpgPrivateKey = core.getInput(constants.INPUT_GPG_PRIVATE_KEY) || constants.INPUT_DEFAULT_GPG_PRIVATE_KEY; const gpgPassphrase = core.getInput(constants.INPUT_GPG_PASSPHRASE) || (gpgPrivateKey ? constants.INPUT_DEFAULT_GPG_PASSPHRASE : undefined); if (gpgPrivateKey) { @@ -13774,9 +13771,7 @@ class AdoptiumDistribution extends base_installer_1.JavaBase { }); const resolvedFullVersion = satisfiedVersions.length > 0 ? satisfiedVersions[0] : null; if (!resolvedFullVersion) { - const availableOptions = availableVersionsWithBinaries - .map(item => item.version) - .join(', '); + const availableOptions = availableVersionsWithBinaries.map(item => item.version).join(', '); const availableOptionsMessage = availableOptions ? `\nAvailable versions: ${availableOptions}` : ''; @@ -14103,9 +14098,7 @@ class ZuluDistribution extends base_installer_1.JavaBase { }); const resolvedFullVersion = satisfiedVersions.length > 0 ? satisfiedVersions[0] : null; if (!resolvedFullVersion) { - const availableOptions = availableVersions - .map(item => item.version) - .join(', '); + const availableOptions = availableVersions.map(item => item.version).join(', '); const availableOptionsMessage = availableOptions ? `\nAvailable versions: ${availableOptions}` : ''; @@ -14155,8 +14148,7 @@ class ZuluDistribution extends base_installer_1.JavaBase { if (core.isDebug()) { core.debug(`Gathering available versions from '${availableVersionsUrl}'`); } - const availableVersions = (_b = (yield this.http.getJson(availableVersionsUrl)) - .result) !== null && _b !== void 0 ? _b : []; + const availableVersions = (_b = (yield this.http.getJson(availableVersionsUrl)).result) !== null && _b !== void 0 ? _b : []; if (core.isDebug()) { core.startGroup('Print information about available versions'); console.timeEnd('azul-retrieve-available-versions'); @@ -41118,13 +41110,7 @@ function importKey(privateKey) { } } }; - yield exec.exec('gpg', [ - '--batch', - '--import-options', - 'import-show', - '--import', - exports.PRIVATE_KEY_FILE - ], options); + yield exec.exec('gpg', ['--batch', '--import-options', 'import-show', '--import', exports.PRIVATE_KEY_FILE], options); yield io.rmRF(exports.PRIVATE_KEY_FILE); const match = output.match(PRIVATE_KEY_FINGERPRINT_REGEX); return match && match[0]; From 87febe147ab5c06abcec657b2e37e7ff3bc2c05d Mon Sep 17 00:00:00 2001 From: Maxim Lobanov Date: Tue, 9 Mar 2021 10:57:43 +0300 Subject: [PATCH 3/6] resolve comments --- .github/workflows/build.yml | 1 + .github/workflows/e2e-local-file.yml | 7 +++++-- .github/workflows/e2e-publishing.yml | 7 +++++-- .github/workflows/e2e-versions.yml | 1 + 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9eb0e32ae..5d51129ee 100755 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -5,6 +5,7 @@ on: branches: - main - releases/* + - v2-preview paths-ignore: - '**.md' pull_request: diff --git a/.github/workflows/e2e-local-file.yml b/.github/workflows/e2e-local-file.yml index 3bf6553de..39a09d2d0 100644 --- a/.github/workflows/e2e-local-file.yml +++ b/.github/workflows/e2e-local-file.yml @@ -4,6 +4,7 @@ on: branches: - main - releases/* + - v2-preview paths-ignore: - '**.md' pull_request: @@ -21,7 +22,8 @@ jobs: steps: - name: Checkout uses: actions/checkout@v2 - - run: | + - name: Download Adopt OpenJDK file + run: | if ($IsLinux) { $downloadUrl = "https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.10%2B9/OpenJDK11U-jdk_x64_linux_hotspot_11.0.10_9.tar.gz" $localFilename = "java_package.tar.gz" @@ -57,7 +59,8 @@ jobs: steps: - name: Checkout uses: actions/checkout@v2 - - run: | + - name: Download Zulu OpenJDK file + run: | if ($IsLinux) { $downloadUrl = "https://cdn.azul.com/zulu/bin/zulu11.2.3-jdk11.0.1-linux_x64.tar.gz" $localFilename = "java_package.tar.gz" diff --git a/.github/workflows/e2e-publishing.yml b/.github/workflows/e2e-publishing.yml index 3ebd4a545..28e631e11 100644 --- a/.github/workflows/e2e-publishing.yml +++ b/.github/workflows/e2e-publishing.yml @@ -4,6 +4,7 @@ on: branches: - main - releases/* + - v2-preview paths-ignore: - '**.md' pull_request: @@ -29,7 +30,8 @@ jobs: server-username: MAVEN_USERNAME server-password: MAVEN_CENTRAL_TOKEN gpg-passphrase: MAVEN_GPG_PASSPHRASE - - run: | + - name: Validate settings.xml + run: | $homePath = $env:USERPROFILE if (-not $homePath) { $homePath = $env:HOME @@ -68,7 +70,8 @@ jobs: server-password: MAVEN_CENTRAL_TOKEN gpg-passphrase: MAVEN_GPG_PASSPHRASE settings-path: ${{ runner.temp }} - - run: | + - name: Validate settings.xml location + run: | $path = Join-Path $env:RUNNER_TEMP "settings.xml" if (-not (Test-Path $path)) { throw "settings.xml file is not found in expected location" diff --git a/.github/workflows/e2e-versions.yml b/.github/workflows/e2e-versions.yml index 02aa80dc6..1c17692eb 100644 --- a/.github/workflows/e2e-versions.yml +++ b/.github/workflows/e2e-versions.yml @@ -4,6 +4,7 @@ on: branches: - main - releases/* + - v2-preview paths-ignore: - '**.md' pull_request: From 54adc8612cf7393c106e6e92c3c3e1f4828b5675 Mon Sep 17 00:00:00 2001 From: Maxim Lobanov Date: Tue, 9 Mar 2021 11:36:53 +0300 Subject: [PATCH 4/6] fix tests --- __tests__/distributors/base-installer.test.ts | 2 +- __tests__/distributors/local-installer.test.ts | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/__tests__/distributors/base-installer.test.ts b/__tests__/distributors/base-installer.test.ts index f623f5f22..37cd13f36 100644 --- a/__tests__/distributors/base-installer.test.ts +++ b/__tests__/distributors/base-installer.test.ts @@ -240,7 +240,7 @@ describe('normalizeVersion', () => { it('normalizeVersion should throw an error for non semver', () => { const version = '11g'; expect(DummyJavaBase.prototype.normalizeVersion.bind(null, version)).toThrowError( - `The string '${version}' is not valid SemVer notation for Java version. Please check README file for code snippets and more detailed information` + `The string '${version}' is not valid SemVer notation for a Java version. Please check README file for code snippets and more detailed information` ); }); }); diff --git a/__tests__/distributors/local-installer.test.ts b/__tests__/distributors/local-installer.test.ts index c485eee3f..95c12f937 100644 --- a/__tests__/distributors/local-installer.test.ts +++ b/__tests__/distributors/local-installer.test.ts @@ -103,7 +103,7 @@ describe('setupJava', () => { expect(spyTcFind).toHaveBeenCalled(); expect(spyCoreInfo).toHaveBeenCalledWith(`Resolved Java ${actualJavaVersion} from tool-cache`); expect(spyCoreInfo).not.toHaveBeenCalledWith( - `Java ${inputs.version} is not found in tool-cache. Trying to unpack JDK file...` + `Java ${inputs.version} was not found in tool-cache. Trying to unpack JDK file...` ); }); @@ -120,7 +120,7 @@ describe('setupJava', () => { expect(spyTcFind).toHaveBeenCalled(); expect(spyCoreInfo).toHaveBeenCalledWith(`Resolved Java ${actualJavaVersion} from tool-cache`); expect(spyCoreInfo).not.toHaveBeenCalledWith( - `Java ${inputs.version} is not found in tool-cache. Trying to unpack JDK file...` + `Java ${inputs.version} was not found in tool-cache. Trying to unpack JDK file...` ); }); @@ -140,7 +140,7 @@ describe('setupJava', () => { ); expect(spyCoreInfo).toHaveBeenCalledWith(`Extracting Java from '${jdkFile}'`); expect(spyCoreInfo).toHaveBeenCalledWith( - `Java ${inputs.version} is not found in tool-cache. Trying to unpack JDK file...` + `Java ${inputs.version} was not found in tool-cache. Trying to unpack JDK file...` ); }); @@ -155,7 +155,7 @@ describe('setupJava', () => { mockJavaBase = new LocalDistribution(inputs, jdkFile); expected.javaPath = path.join('Java_jdkfile_jdk', inputs.version, inputs.arch); await expect(mockJavaBase.setupJava()).rejects.toThrowError( - "JDK file is not found in path 'not_existing_one'" + "JDK file was not found in path 'not_existing_one'" ); expect(spyTcFindAllVersions).toHaveBeenCalled(); expect(spyCoreInfo).not.toHaveBeenCalledWith( @@ -163,7 +163,7 @@ describe('setupJava', () => { ); expect(spyCoreInfo).not.toHaveBeenCalledWith(`Extracting Java from '${jdkFile}'`); expect(spyCoreInfo).toHaveBeenCalledWith( - `Java ${inputs.version} is not found in tool-cache. Trying to unpack JDK file...` + `Java ${inputs.version} was not found in tool-cache. Trying to unpack JDK file...` ); }); @@ -177,7 +177,7 @@ describe('setupJava', () => { async (inputs, jdkFile) => { mockJavaBase = new LocalDistribution(inputs, jdkFile); await expect(mockJavaBase.setupJava()).rejects.toThrowError( - /JDK file is not found in path */ + /JDK file was not found in path */ ); expect(spyTcFindAllVersions).toHaveBeenCalled(); } From e9a0f2c6853ca6f4063f4bcae3630de6b0e62053 Mon Sep 17 00:00:00 2001 From: Maxim Lobanov Date: Wed, 10 Mar 2021 20:00:10 +0300 Subject: [PATCH 5/6] pull latest main --- .github/workflows/e2e-versions.yml | 74 +++++++++---------- __tests__/data/adoptium.json | 41 ++++++++++ .../distributors/adoptium-installer.test.ts | 25 ++++--- __tests__/distributors/base-installer.test.ts | 59 ++++++++------- .../distributors/local-installer.test.ts | 28 +++---- __tests__/distributors/zulu-installer.test.ts | 7 +- __tests__/util.test.ts | 22 ++++++ __tests__/verify-java.sh | 6 +- 8 files changed, 171 insertions(+), 91 deletions(-) create mode 100644 __tests__/util.test.ts diff --git a/.github/workflows/e2e-versions.yml b/.github/workflows/e2e-versions.yml index 1c17692eb..619e4628f 100644 --- a/.github/workflows/e2e-versions.yml +++ b/.github/workflows/e2e-versions.yml @@ -29,7 +29,6 @@ jobs: id: setup-java with: java-version: ${{ matrix.version }} - java-package: 'jdk' distribution: ${{ matrix.distribution }} - name: Verify Java run: bash __tests__/verify-java.sh "${{ matrix.version }}" "${{ steps.setup-java.outputs.path }}" @@ -45,17 +44,19 @@ jobs: os: [macos-latest, windows-latest, ubuntu-latest] distribution: ['adoptium', 'zulu'] version: - - '8.0.282' - '11.0' - - '11.0.10' - - '15.0' - exclude: - - os: windows-latest - distribution: 'zulu' - version: '8.0.282' - - os: windows-latest - distribution: 'zulu' - version: '11.0.10' + - '8.0.282' + - '11.0.2+7' + include: + - distribution: 'adoptium' + version: '12.0.2+10.1' + os: macos-latest + - distribution: 'adoptium' + version: '12.0.2+10.1' + os: windows-latest + - distribution: 'adoptium' + version: '12.0.2+10.1' + os: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v2 @@ -64,22 +65,39 @@ jobs: id: setup-java with: java-version: ${{ matrix.version }} - java-package: jdk distribution: ${{ matrix.distribution }} - name: Verify Java run: bash __tests__/verify-java.sh "${{ matrix.version }}" "${{ steps.setup-java.outputs.path }}" shell: bash + + setup-java-ea-versions-zulu: + name: zulu ${{ matrix.version }} (jdk-x64) - ${{ matrix.os }} + needs: setup-java-major-minor-versions + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [macos-latest, windows-latest, ubuntu-latest] + version: ['17-ea', '15.0.0-ea.14'] + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: setup-java + uses: ./ + id: setup-java + with: + java-version: ${{ matrix.version }} + distribution: zulu - setup-java-ea-versions: - name: ${{ matrix.distribution }} ${{ matrix.version }} (jdk-x64) - ${{ matrix.os }} + setup-java-ea-versions-adoptium: + name: adoptium ${{ matrix.version }} (jdk-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] - distribution: ['adoptium', 'zulu'] - version: ['14-ea', '15-ea'] + version: ['17-ea', '15.0.0-ea.14.1.202003160455'] steps: - name: Checkout uses: actions/checkout@v2 @@ -88,11 +106,7 @@ jobs: id: setup-java with: java-version: ${{ matrix.version }} - java-package: jdk - distribution: ${{ matrix.distribution }} - - name: Verify Java - run: bash __tests__/verify-java.sh "${{ matrix.version }}" "${{ steps.setup-java.outputs.path }}" - shell: bash + distribution: adoptium setup-java-custom-package-type: name: ${{ matrix.distribution }} ${{ matrix.version }} (${{ matrix.java-package }}-x64) - ${{ matrix.os }} @@ -105,18 +119,7 @@ jobs: distribution: ['adoptium', 'zulu'] java-package: ['jre'] version: - - '8.0.282' - - '11.0.10' - '15.0' - exclude: - - os: windows-latest - distribution: 'zulu' - java-package: 'jre' - version: '8.0.282' - - os: windows-latest - java-package: 'jre' - distribution: 'zulu' - version: '11.0.10' include: - distribution: 'zulu' java-package: jre+fx @@ -150,7 +153,7 @@ jobs: # Only Zulu provides x86 arch for now and only for windows / ubuntu os: [windows-latest, ubuntu-latest] distribution: ['zulu'] - version: ['8', '11'] + version: ['11'] steps: - name: Checkout uses: actions/checkout@v2 @@ -160,7 +163,4 @@ jobs: with: distribution: ${{ matrix.distribution }} java-version: ${{ matrix.version }} - architecture: x86 - - name: Verify Java - run: bash __tests__/verify-java.sh "${{ matrix.version }}" "${{ steps.setup-java.outputs.path }}" - shell: bash \ No newline at end of file + architecture: x86 \ No newline at end of file diff --git a/__tests__/data/adoptium.json b/__tests__/data/adoptium.json index 631b1380c..bcf140309 100644 --- a/__tests__/data/adoptium.json +++ b/__tests__/data/adoptium.json @@ -528,6 +528,47 @@ "semver": "12.0.2+10.2" } }, + { + "binaries": [ + { + "architecture": "x64", + "download_count": 24493, + "heap_size": "normal", + "image_type": "jdk", + "jvm_impl": "hotspot", + "os": "mac", + "package": { + "checksum": "9919eee037554d40c7d2f219bbd654f2bf119e16a2f4d284d8dedaf525ee59e6", + "checksum_link": "https://github.com/AdoptOpenJDK/openjdk12-binaries/releases/download/jdk-12.0.2%2B10/OpenJDK12U-jdk_x64_mac_hotspot_12.0.2_10.tar.gz.sha256.txt", + "download_count": 22907, + "link": "https://github.com/AdoptOpenJDK/openjdk12-binaries/releases/download/jdk-12.0.2%2B10/OpenJDK12U-jdk_x64_mac_hotspot_12.0.2_10.tar.gz", + "metadata_link": "https://github.com/AdoptOpenJDK/openjdk12-binaries/releases/download/jdk-12.0.2%2B10/OpenJDK12U-jdk_x64_mac_hotspot_12.0.2_10.tar.gz.json", + "name": "OpenJDK12U-jdk_x64_mac_hotspot_12.0.2_10.tar.gz", + "size": 198392994 + }, + "project": "jdk", + "scm_ref": "jdk-12.0.2+9_adopt", + "updated_at": "2019-07-18T20:27:24Z" + } + ], + "download_count": 396318, + "id": "MDc6UmVsZWFzZTE4NzE2Mzk5.S/VUFSgnrVIv8A==", + "release_link": "https://github.com/AdoptOpenJDK/openjdk12-binaries/releases/tag/jdk-12.0.2%2B10", + "release_name": "jdk-12.0.2+9", + "release_type": "ga", + "timestamp": "2019-07-18T20:26:29Z", + "updated_at": "2019-07-18T20:26:29Z", + "vendor": "adoptopenjdk", + "version_data": { + "adopt_build_number": 1, + "build": 10, + "major": 12, + "minor": 0, + "openjdk_version": "12.0.2+9", + "security": 2, + "semver": "12.0.2+9.1" + } + }, { "binaries": [ { diff --git a/__tests__/distributors/adoptium-installer.test.ts b/__tests__/distributors/adoptium-installer.test.ts index 0408535f4..4a180ad86 100644 --- a/__tests__/distributors/adoptium-installer.test.ts +++ b/__tests__/distributors/adoptium-installer.test.ts @@ -96,7 +96,10 @@ describe('findPackageForDownload', () => { ['15.0.1', '15.0.1+9.1'], ['11.x', '11.0.10+9'], ['x', '15.0.2+7'], - ['12', '12.0.2+10.3'] // make sure that '12.0.2+10.1', '12.0.2+10.3', '12.0.2+10.2' are sorted correctly + ['12', '12.0.2+10.3'], // make sure that '12.0.2+10.1', '12.0.2+10.3', '12.0.2+10.2' are sorted correctly + ['12.0.2+10.1', '12.0.2+10.1'], + ['15.0.1+9', '15.0.1+9'], + ['15.0.1+9.1', '15.0.1+9.1'] ])('version is resolved correctly %s -> %s', async (input, expected) => { const distribution = new AdoptiumDistribution({ version: '11', @@ -104,7 +107,7 @@ describe('findPackageForDownload', () => { packageType: 'jdk' }); distribution['getAvailableVersions'] = async () => manifestData; - const resolvedVersion = await distribution['findPackageForDownload'](new semver.Range(input)); + const resolvedVersion = await distribution['findPackageForDownload'](input); expect(resolvedVersion.version).toBe(expected); }); @@ -115,9 +118,9 @@ describe('findPackageForDownload', () => { packageType: 'jdk' }); distribution['getAvailableVersions'] = async () => manifestData; - await expect( - distribution['findPackageForDownload'](new semver.Range('9.0.8')) - ).rejects.toThrowError(/Could not find satisfied version for SemVer */); + await expect(distribution['findPackageForDownload']('9.0.8')).rejects.toThrowError( + /Could not find satisfied version for SemVer */ + ); }); it('version is not found', async () => { @@ -127,9 +130,9 @@ describe('findPackageForDownload', () => { packageType: 'jdk' }); distribution['getAvailableVersions'] = async () => manifestData; - await expect( - distribution['findPackageForDownload'](new semver.Range('7.x')) - ).rejects.toThrowError(/Could not find satisfied version for SemVer */); + await expect(distribution['findPackageForDownload']('7.x')).rejects.toThrowError( + /Could not find satisfied version for SemVer */ + ); }); it('version list is empty', async () => { @@ -139,8 +142,8 @@ describe('findPackageForDownload', () => { packageType: 'jdk' }); distribution['getAvailableVersions'] = async () => []; - await expect( - distribution['findPackageForDownload'](new semver.Range('11')) - ).rejects.toThrowError(/Could not find satisfied version for SemVer */); + await expect(distribution['findPackageForDownload']('11')).rejects.toThrowError( + /Could not find satisfied version for SemVer */ + ); }); }); diff --git a/__tests__/distributors/base-installer.test.ts b/__tests__/distributors/base-installer.test.ts index 37cd13f36..ddd1d2db7 100644 --- a/__tests__/distributors/base-installer.test.ts +++ b/__tests__/distributors/base-installer.test.ts @@ -1,5 +1,6 @@ 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'; @@ -23,7 +24,7 @@ class EmptyJavaBase extends JavaBase { }; } - protected async findPackageForDownload(range: semver.Range): Promise { + protected async findPackageForDownload(range: string): Promise { const availableVersion = '11.0.8'; if (!semver.satisfies(availableVersion, range)) { throw new Error('Available version not found'); @@ -41,11 +42,11 @@ describe('findInToolcache', () => { const javaPath = path.join('Java_Empty_jdk', actualJavaVersion, 'x64'); let mockJavaBase: EmptyJavaBase; - let spyTcFind: jest.SpyInstance; + let spyGetToolcachePath: jest.SpyInstance; let spyTcFindAllVersions: jest.SpyInstance; beforeEach(() => { - spyTcFind = jest.spyOn(tc, 'find'); + spyGetToolcachePath = jest.spyOn(util, 'getToolcachePath'); spyTcFindAllVersions = jest.spyOn(tc, 'findAllVersions'); }); @@ -74,15 +75,17 @@ describe('findInToolcache', () => { [{ version: '11', arch: 'x86', packageType: 'jre' }, null] ])(`should find java for path %s -> %s`, (input, expected) => { spyTcFindAllVersions.mockReturnValue([actualJavaVersion]); - spyTcFind.mockImplementation((toolname: string, javaVersion: string, architecture: string) => { - const semverVersion = new semver.Range(javaVersion); + spyGetToolcachePath.mockImplementation( + (toolname: string, javaVersion: string, architecture: string) => { + const semverVersion = new semver.Range(javaVersion); - if (path.basename(javaPath) !== architecture || !javaPath.includes(toolname)) { - return ''; - } + if (path.basename(javaPath) !== architecture || !javaPath.includes(toolname)) { + return ''; + } - return semver.satisfies(actualJavaVersion, semverVersion) ? javaPath : ''; - }); + return semver.satisfies(actualJavaVersion, semverVersion) ? javaPath : ''; + } + ); mockJavaBase = new EmptyJavaBase(input); expect(mockJavaBase['findInToolcache']()).toEqual(expected); }); @@ -108,7 +111,7 @@ describe('findInToolcache', () => { '11.3.2-ea', '11.0.1' ]); - spyTcFind.mockImplementation( + spyGetToolcachePath.mockImplementation( (toolname: string, javaVersion: string, architecture: string) => `/hostedtoolcache/${toolname}/${javaVersion}/${architecture}` ); @@ -124,7 +127,7 @@ describe('setupJava', () => { let mockJavaBase: EmptyJavaBase; - let spyTcFind: jest.SpyInstance; + let spyGetToolcachePath: jest.SpyInstance; let spyTcFindAllVersions: jest.SpyInstance; let spyCoreDebug: jest.SpyInstance; let spyCoreInfo: jest.SpyInstance; @@ -133,16 +136,18 @@ describe('setupJava', () => { let spyCoreSetOutput: jest.SpyInstance; beforeEach(() => { - spyTcFind = jest.spyOn(tc, 'find'); - spyTcFind.mockImplementation((toolname: string, javaVersion: string, architecture: string) => { - const semverVersion = new semver.Range(javaVersion); + spyGetToolcachePath = jest.spyOn(util, 'getToolcachePath'); + spyGetToolcachePath.mockImplementation( + (toolname: string, javaVersion: string, architecture: string) => { + const semverVersion = new semver.Range(javaVersion); - if (path.basename(javaPath) !== architecture || !javaPath.includes(toolname)) { - return ''; - } + if (path.basename(javaPath) !== architecture || !javaPath.includes(toolname)) { + return ''; + } - return semver.satisfies(actualJavaVersion, semverVersion) ? javaPath : ''; - }); + return semver.satisfies(actualJavaVersion, semverVersion) ? javaPath : ''; + } + ); spyTcFindAllVersions = jest.spyOn(tc, 'findAllVersions'); spyTcFindAllVersions.mockReturnValue([actualJavaVersion]); @@ -186,7 +191,7 @@ describe('setupJava', () => { ])('should find java locally for %s', (input, expected) => { mockJavaBase = new EmptyJavaBase(input); expect(mockJavaBase.setupJava()).resolves.toEqual(expected); - expect(spyTcFind).toHaveBeenCalled(); + expect(spyGetToolcachePath).toHaveBeenCalled(); }); it.each([ @@ -205,7 +210,7 @@ describe('setupJava', () => { ])('download java with configuration %s', async (input, expected) => { mockJavaBase = new EmptyJavaBase(input); await expect(mockJavaBase.setupJava()).resolves.toEqual(expected); - expect(spyTcFind).toHaveBeenCalled(); + expect(spyGetToolcachePath).toHaveBeenCalled(); expect(spyCoreAddPath).toHaveBeenCalled(); expect(spyCoreExportVariable).toHaveBeenCalled(); expect(spyCoreSetOutput).toHaveBeenCalled(); @@ -228,11 +233,11 @@ describe('normalizeVersion', () => { const DummyJavaBase = JavaBase as any; it.each([ - ['11', { version: new semver.Range('11'), stable: true }], - ['11.0', { version: new semver.Range('11.0'), stable: true }], - ['11.0.10', { version: new semver.Range('11.0.10'), stable: true }], - ['11-ea', { version: new semver.Range('11'), stable: false }], - ['11.0.2-ea', { version: new semver.Range('11.0.2'), stable: false }] + ['11', { version: '11', stable: true }], + ['11.0', { version: '11.0', stable: true }], + ['11.0.10', { version: '11.0.10', stable: true }], + ['11-ea', { version: '11', stable: false }], + ['11.0.2-ea', { version: '11.0.2', stable: false }] ])('normalizeVersion from %s to %s', (input, expected) => { expect(DummyJavaBase.prototype.normalizeVersion.call(null, input)).toEqual(expected); }); diff --git a/__tests__/distributors/local-installer.test.ts b/__tests__/distributors/local-installer.test.ts index 95c12f937..96f02f4d5 100644 --- a/__tests__/distributors/local-installer.test.ts +++ b/__tests__/distributors/local-installer.test.ts @@ -5,7 +5,7 @@ import * as core from '@actions/core'; import path from 'path'; import * as semver from 'semver'; -import * as utils from '../../src/util'; +import * as util from '../../src/util'; import { LocalDistribution } from '../../src/distributions/local/installer'; @@ -15,7 +15,7 @@ describe('setupJava', () => { let mockJavaBase: LocalDistribution; - let spyTcFind: jest.SpyInstance; + let spyGetToolcachePath: jest.SpyInstance; let spyTcCacheDir: jest.SpyInstance; let spyTcFindAllVersions: jest.SpyInstance; let spyCoreDebug: jest.SpyInstance; @@ -30,16 +30,18 @@ describe('setupJava', () => { let expectedJdkFile = 'JavaLocalJdkFile'; beforeEach(() => { - spyTcFind = jest.spyOn(tc, 'find'); - spyTcFind.mockImplementation((toolname: string, javaVersion: string, architecture: string) => { - const semverVersion = new semver.Range(javaVersion); + spyGetToolcachePath = jest.spyOn(util, 'getToolcachePath'); + spyGetToolcachePath.mockImplementation( + (toolname: string, javaVersion: string, architecture: string) => { + const semverVersion = new semver.Range(javaVersion); - if (path.basename(javaPath) !== architecture || !javaPath.includes(toolname)) { - return ''; - } + if (path.basename(javaPath) !== architecture || !javaPath.includes(toolname)) { + return ''; + } - return semver.satisfies(actualJavaVersion, semverVersion) ? javaPath : ''; - }); + return semver.satisfies(actualJavaVersion, semverVersion) ? javaPath : ''; + } + ); spyTcCacheDir = jest.spyOn(tc, 'cacheDir'); spyTcCacheDir.mockImplementation( @@ -76,7 +78,7 @@ describe('setupJava', () => { }); // Spy on util methods - spyUtilsExtractJdkFile = jest.spyOn(utils, 'extractJdkFile'); + spyUtilsExtractJdkFile = jest.spyOn(util, 'extractJdkFile'); spyUtilsExtractJdkFile.mockImplementation(() => 'some/random/path/'); // Spy on path methods @@ -100,7 +102,7 @@ describe('setupJava', () => { mockJavaBase = new LocalDistribution(inputs, jdkFile); await expect(mockJavaBase.setupJava()).resolves.toEqual(expected); - expect(spyTcFind).toHaveBeenCalled(); + expect(spyGetToolcachePath).toHaveBeenCalled(); expect(spyCoreInfo).toHaveBeenCalledWith(`Resolved Java ${actualJavaVersion} from tool-cache`); expect(spyCoreInfo).not.toHaveBeenCalledWith( `Java ${inputs.version} was not found in tool-cache. Trying to unpack JDK file...` @@ -117,7 +119,7 @@ describe('setupJava', () => { mockJavaBase = new LocalDistribution(inputs, jdkFile); await expect(mockJavaBase.setupJava()).resolves.toEqual(expected); - expect(spyTcFind).toHaveBeenCalled(); + expect(spyGetToolcachePath).toHaveBeenCalled(); expect(spyCoreInfo).toHaveBeenCalledWith(`Resolved Java ${actualJavaVersion} from tool-cache`); expect(spyCoreInfo).not.toHaveBeenCalledWith( `Java ${inputs.version} was not found in tool-cache. Trying to unpack JDK file...` diff --git a/__tests__/distributors/zulu-installer.test.ts b/__tests__/distributors/zulu-installer.test.ts index eb310b06b..c4f4783ca 100644 --- a/__tests__/distributors/zulu-installer.test.ts +++ b/__tests__/distributors/zulu-installer.test.ts @@ -96,7 +96,10 @@ describe('findPackageForDownload', () => { ['15', '15.0.2+7'], ['9.0.0', '9.0.0+0'], ['9.0', '9.0.1+0'], - ['8.0.262', '8.0.262+19'] // validate correct choise between [8.0.262.17, 8.0.262.19, 8.0.262.18] + ['8.0.262', '8.0.262+19'], // validate correct choise between [8.0.262.17, 8.0.262.19, 8.0.262.18] + ['8.0.262+17', '8.0.262+17'], + ['15.0.1+8', '15.0.1+8'], + ['15.0.1+9', '15.0.1+9'] ])('version is %s -> %s', async (input, expected) => { const distribution = new ZuluDistribution({ version: input, @@ -111,7 +114,7 @@ describe('findPackageForDownload', () => { it('select correct bundle if there are multiple items with the same jdk version but different zulu versions', async () => { const distribution = new ZuluDistribution({ version: '', arch: 'x86', packageType: 'jdk' }); distribution['getAvailableVersions'] = async () => manifestData; - const result = await distribution['findPackageForDownload'](new semver.Range('11.0.5')); + const result = await distribution['findPackageForDownload']('11.0.5'); expect(result.url).toBe( 'https://cdn.azul.com/zulu/bin/zulu11.35.15-ca-jdk11.0.5-macosx_x64.tar.gz' ); diff --git a/__tests__/util.test.ts b/__tests__/util.test.ts new file mode 100644 index 000000000..6509917e2 --- /dev/null +++ b/__tests__/util.test.ts @@ -0,0 +1,22 @@ +import { isVersionSatisfies } from '../src/util'; + +describe('isVersionSatisfies', () => { + it.each([ + ['x', '11.0.0', true], + ['3', '3.7.1', true], + ['3', '3.7.2', true], + ['3', '3.7.2+4', true], + ['2.5', '2.5.0', true], + ['2.5', '2.5.0+1', true], + ['2.5', '2.6.1', false], + ['2.5.1', '2.5.0', false], + ['2.5.1+3', '2.5.0', false], + ['2.5.1+3', '2.5.1+3', true], + ['2.5.1+3', '2.5.1+2', false], + ['15.0.0+14', '15.0.0+14.1.202003190635', false], + ['15.0.0+14.1.202003190635', '15.0.0+14.1.202003190635', true] + ])('%s, %s -> %s', (inputRange: string, inputVersion: string, expected: boolean) => { + const actual = isVersionSatisfies(inputRange, inputVersion); + expect(actual).toBe(expected); + }); +}); diff --git a/__tests__/verify-java.sh b/__tests__/verify-java.sh index 130ae36bb..1bad5d357 100755 --- a/__tests__/verify-java.sh +++ b/__tests__/verify-java.sh @@ -10,12 +10,16 @@ if [ -z "$2" ]; then exit 1 fi -EXPECTED_JAVA_VERSION=${1/-ea/} +EXPECTED_JAVA_VERSION=$1 EXPECTED_PATH=$2 +EXPECTED_JAVA_VERSION=$(echo $EXPECTED_JAVA_VERSION | cut -d'+' -f1) if [[ $EXPECTED_JAVA_VERSION == 8 ]] || [[ $EXPECTED_JAVA_VERSION == 8.* ]]; then EXPECTED_JAVA_VERSION="1.${EXPECTED_JAVA_VERSION}" fi +if [[ $EXPECTED_JAVA_VERSION == *-ea* ]]; then + EXPECTED_JAVA_VERSION=$(echo $EXPECTED_JAVA_VERSION | cut -d'-' -f1 | cut -d'.' -f1) +fi ACTUAL_JAVA_VERSION="$(java -version 2>&1)" echo "Found java version: $ACTUAL_JAVA_VERSION" From 491094cc4c21fdc67343ecfda2d4e393ae137084 Mon Sep 17 00:00:00 2001 From: Maxim Lobanov Date: Thu, 11 Mar 2021 10:55:59 +0300 Subject: [PATCH 6/6] rename adoptium to adopt --- .github/workflows/e2e-versions.yml | 18 +++++++++--------- __tests__/data/{adoptium.json => adopt.json} | 0 ...staller.test.ts => adopt-installer.test.ts} | 16 ++++++++-------- 3 files changed, 17 insertions(+), 17 deletions(-) rename __tests__/data/{adoptium.json => adopt.json} (100%) rename __tests__/distributors/{adoptium-installer.test.ts => adopt-installer.test.ts} (90%) diff --git a/.github/workflows/e2e-versions.yml b/.github/workflows/e2e-versions.yml index 619e4628f..40b2b473f 100644 --- a/.github/workflows/e2e-versions.yml +++ b/.github/workflows/e2e-versions.yml @@ -19,7 +19,7 @@ jobs: fail-fast: false matrix: os: [macos-latest, windows-latest, ubuntu-latest] - distribution: ['adoptium', 'zulu'] + distribution: ['adopt', 'zulu'] version: ['8', '11', '15'] steps: - name: Checkout @@ -42,19 +42,19 @@ jobs: fail-fast: false matrix: os: [macos-latest, windows-latest, ubuntu-latest] - distribution: ['adoptium', 'zulu'] + distribution: ['adopt', 'zulu'] version: - '11.0' - '8.0.282' - '11.0.2+7' include: - - distribution: 'adoptium' + - distribution: 'adopt' version: '12.0.2+10.1' os: macos-latest - - distribution: 'adoptium' + - distribution: 'adopt' version: '12.0.2+10.1' os: windows-latest - - distribution: 'adoptium' + - distribution: 'adopt' version: '12.0.2+10.1' os: ubuntu-latest steps: @@ -89,8 +89,8 @@ jobs: java-version: ${{ matrix.version }} distribution: zulu - setup-java-ea-versions-adoptium: - name: adoptium ${{ matrix.version }} (jdk-x64) - ${{ matrix.os }} + setup-java-ea-versions-adopt: + name: adopt ${{ matrix.version }} (jdk-x64) - ${{ matrix.os }} needs: setup-java-major-minor-versions runs-on: ${{ matrix.os }} strategy: @@ -106,7 +106,7 @@ jobs: id: setup-java with: java-version: ${{ matrix.version }} - distribution: adoptium + distribution: adopt setup-java-custom-package-type: name: ${{ matrix.distribution }} ${{ matrix.version }} (${{ matrix.java-package }}-x64) - ${{ matrix.os }} @@ -116,7 +116,7 @@ jobs: fail-fast: false matrix: os: [macos-latest, windows-latest, ubuntu-latest] - distribution: ['adoptium', 'zulu'] + distribution: ['adopt', 'zulu'] java-package: ['jre'] version: - '15.0' diff --git a/__tests__/data/adoptium.json b/__tests__/data/adopt.json similarity index 100% rename from __tests__/data/adoptium.json rename to __tests__/data/adopt.json diff --git a/__tests__/distributors/adoptium-installer.test.ts b/__tests__/distributors/adopt-installer.test.ts similarity index 90% rename from __tests__/distributors/adoptium-installer.test.ts rename to __tests__/distributors/adopt-installer.test.ts index 4a180ad86..61f16dad7 100644 --- a/__tests__/distributors/adoptium-installer.test.ts +++ b/__tests__/distributors/adopt-installer.test.ts @@ -2,10 +2,10 @@ import { HttpClient } from '@actions/http-client'; import * as semver from 'semver'; -import { AdoptiumDistribution } from '../../src/distributions/adoptium/installer'; +import { AdoptDistribution } from '../../src/distributions/adopt/installer'; import { JavaInstallerOptions } from '../../src/distributions/base-models'; -let manifestData = require('../data/adoptium.json') as []; +let manifestData = require('../data/adopt.json') as []; describe('getAvailableVersions', () => { let spyHttpClient: jest.SpyInstance; @@ -45,7 +45,7 @@ describe('getAvailableVersions', () => { ])( 'build correct url for %s', async (installerOptions: JavaInstallerOptions, expectedParameters) => { - const distribution = new AdoptiumDistribution(installerOptions); + const distribution = new AdoptDistribution(installerOptions); const baseUrl = 'https://api.adoptopenjdk.net/v3/assets/version/%5B1.0,100.0%5D'; const expectedUrl = `${baseUrl}?project=jdk&vendor=adoptopenjdk&heap_size=normal&jvm_impl=hotspot&sort_method=DEFAULT&sort_order=DESC&${expectedParameters}`; distribution['getPlatformOption'] = () => 'mac'; @@ -76,7 +76,7 @@ describe('getAvailableVersions', () => { result: [] }); - const distribution = new AdoptiumDistribution({ + const distribution = new AdoptDistribution({ version: '11', arch: 'x64', packageType: 'jdk' @@ -101,7 +101,7 @@ describe('findPackageForDownload', () => { ['15.0.1+9', '15.0.1+9'], ['15.0.1+9.1', '15.0.1+9.1'] ])('version is resolved correctly %s -> %s', async (input, expected) => { - const distribution = new AdoptiumDistribution({ + const distribution = new AdoptDistribution({ version: '11', arch: 'x64', packageType: 'jdk' @@ -112,7 +112,7 @@ describe('findPackageForDownload', () => { }); it('version is found but binaries list is empty', async () => { - const distribution = new AdoptiumDistribution({ + const distribution = new AdoptDistribution({ version: '11', arch: 'x64', packageType: 'jdk' @@ -124,7 +124,7 @@ describe('findPackageForDownload', () => { }); it('version is not found', async () => { - const distribution = new AdoptiumDistribution({ + const distribution = new AdoptDistribution({ version: '11', arch: 'x64', packageType: 'jdk' @@ -136,7 +136,7 @@ describe('findPackageForDownload', () => { }); it('version list is empty', async () => { - const distribution = new AdoptiumDistribution({ + const distribution = new AdoptDistribution({ version: '11', arch: 'x64', packageType: 'jdk'