Unverified Commit 0ab45967 authored by Accelerator1996's avatar Accelerator1996 Committed by GitHub
Browse files

add support for dragonwell (#532)

* add support for dragonwell

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

* build: rebuild action

* chore: update error message

* build: rebuild action

* tests: fix unit tests, add e2e tests

* chore: prettier, lint and rebuild solution

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

* tests: update e2e tests

* tests: remove excess entries from e2e tests

* feat: update logic of getting json file

* feat: add logic for backuping getting json

* chore: update wordings

* chore: fix typos, add additional logs

* fix: fix review points

* chore: rebuild solution

* chore: update wordings

* chore: refactor code

---------

Co-authored-by: default avatarIvan Zosimov <[email protected]>
Co-authored-by: default avatarIvan <[email protected]>
parent 4075bfc1
Loading
Loading
Loading
Loading
+19 −3
Changes for .github/workflows/e2e-versions.yml: 19 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -29,12 +29,15 @@ jobs:
            'liberica',
            'microsoft',
            'semeru',
            'corretto'
            'corretto',
            'dragonwell'
          ] # internally 'adopt-hotspot' is the same as 'adopt'
        version: ['8', '11', '17']
        exclude:
          - distribution: microsoft
            version: 8
          - distribution: dragonwell
            os: macos-latest
        include:
          - distribution: oracle
            os: macos-latest
@@ -45,6 +48,7 @@ jobs:
          - distribution: oracle
            os: ubuntu-latest
            version: 20

    steps:
      - name: Checkout
        uses: actions/checkout@v3
@@ -75,6 +79,12 @@ jobs:
          - distribution: oracle
            os: ubuntu-latest
            version: '20.0.1'
          - distribution: dragonwell
            os: ubuntu-latest
            version: '11.0'
          - distribution: dragonwell
            os: ubuntu-latest
            version: '11.0.13+9'
    steps:
      - name: Checkout
        uses: actions/checkout@v3
@@ -96,7 +106,10 @@ jobs:
      fail-fast: false
      matrix:
        os: [macos-latest, windows-latest, ubuntu-latest]
        distribution: ['temurin', 'zulu', 'liberica']
        distribution: ['temurin', 'zulu', 'liberica', 'dragonwell']
        exclude:
          - distribution: dragonwell
            os: macos-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v3
@@ -119,7 +132,10 @@ jobs:
      fail-fast: false
      matrix:
        os: [macos-latest, windows-latest, ubuntu-latest]
        distribution: ['temurin', 'zulu', 'liberica']
        distribution: ['temurin', 'zulu', 'liberica', 'dragonwell']
        exclude:
          - distribution: dragonwell
            os: macos-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v3
+2
Changes for README.md: 2 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -105,6 +105,7 @@ Currently, the following distributions are supported:
| `corretto` | Amazon Corretto Build of OpenJDK | [Link](https://aws.amazon.com/corretto/) | [Link](https://aws.amazon.com/corretto/faqs/)
| `semeru` | IBM Semeru Runtime Open Edition | [Link](https://developer.ibm.com/languages/java/semeru-runtimes/downloads/) | [Link](https://openjdk.java.net/legal/gplv2+ce.html) |
| `oracle` | Oracle JDK | [Link](https://www.oracle.com/java/technologies/downloads/) | [Link](https://java.com/freeuselicense)
| `dragonwell` | Alibaba Dragonwell JDK | [Link](https://dragonwell-jdk.io/) | [Link](https://www.aliyun.com/product/dragonwell/)

**NOTE:** The different distributors can provide discrepant list of available versions / supported configurations. Please refer to the official documentation to see the list of supported versions.

@@ -227,6 +228,7 @@ In the example above multiple JDKs are installed for the same job. The result af
  - [Microsoft](docs/advanced-usage.md#Microsoft)
  - [Amazon Corretto](docs/advanced-usage.md#Amazon-Corretto)
  - [Oracle](docs/advanced-usage.md#Oracle)
  - [Alibaba Dragonwell](docs/advanced-usage.md#Alibaba-Dragonwell)
- [Installing custom Java package type](docs/advanced-usage.md#Installing-custom-Java-package-type)
- [Installing custom Java architecture](docs/advanced-usage.md#Installing-custom-Java-architecture)
- [Installing custom Java distribution from local file](docs/advanced-usage.md#Installing-Java-from-local-file)
+1138

File added.

Preview size limit exceeded, changes collapsed.

+226
Changes for __tests__/distributors/dragonwell-installer.test.ts: 226 added lines, 0 removed lines.
Original line number Diff line number Diff line
import {HttpClient} from '@actions/http-client';
import {DragonwellDistribution} from '../../src/distributions/dragonwell/installer';
import * as utils from '../../src/util';

import manifestData from '../data/dragonwell.json';

describe('getAvailableVersions', () => {
  let spyHttpClient: jest.SpyInstance;
  let spyUtilGetDownloadArchiveExtension: jest.SpyInstance;

  beforeEach(() => {
    spyHttpClient = jest.spyOn(HttpClient.prototype, 'getJson');
    spyHttpClient.mockReturnValue({
      statusCode: 200,
      headers: {},
      result: manifestData
    });

    spyUtilGetDownloadArchiveExtension = jest.spyOn(
      utils,
      'getDownloadArchiveExtension'
    );
    spyUtilGetDownloadArchiveExtension.mockReturnValue('tar.gz');
  });

  afterEach(() => {
    jest.resetAllMocks();
    jest.clearAllMocks();
    jest.restoreAllMocks();
  });

  const mockPlatform = (
    distribution: DragonwellDistribution,
    platform: string
  ) => {
    distribution['getPlatformOption'] = () => platform;
    const mockedExtension = platform == 'windows' ? 'zip' : 'tar.gz';
    spyUtilGetDownloadArchiveExtension.mockReturnValue(mockedExtension);
  };

  describe('getAvailableVersions', () => {
    it.each([
      ['8', 'x86', 'linux', 0],
      ['8', 'aarch64', 'linux', 24],
      ['8.6.6', 'x64', 'linux', 27],
      ['8', 'x86', 'anolis', 0],
      ['8', 'x86', 'windows', 0],
      ['8', 'x86', 'mac', 0],
      ['11', 'x64', 'linux', 27],
      ['11', 'aarch64', 'linux', 24],
      ['17', 'riscv', 'linux', 0],
      ['16.0.1', 'x64', 'linux', 27]
    ])(
      'should get right number of available versions from JSON',
      async (
        jdkVersion: string,
        arch: string,
        platform: string,
        len: number
      ) => {
        const distribution = new DragonwellDistribution({
          version: jdkVersion,
          architecture: arch,
          packageType: 'jdk',
          checkLatest: false
        });
        mockPlatform(distribution, platform);

        const availableVersions = await distribution['getAvailableVersions']();
        expect(availableVersions).not.toBeNull();
        expect(availableVersions.length).toBe(len);
      }
    );
  });

  describe('findPackageForDownload', () => {
    it.each([
      [
        '8',
        'linux',
        'x64',
        'https://github.com/alibaba/dragonwell8/releases/download/dragonwell-extended-8.13.14_jdk8u352-ga/Alibaba_Dragonwell_Extended_8.13.14_x64_linux.tar.gz'
      ],
      [
        '8',
        'linux',
        'aarch64',
        'https://github.com/alibaba/dragonwell8/releases/download/dragonwell-extended-8.13.14_jdk8u352-ga/Alibaba_Dragonwell_Extended_8.13.14_aarch64_linux.tar.gz'
      ],
      [
        '8',
        'windows',
        'x64',
        'https://github.com/alibaba/dragonwell8/releases/download/dragonwell-extended-8.13.14_jdk8u352-ga/Alibaba_Dragonwell_Extended_8.13.14_x64_windows.zip'
      ],
      [
        '8.13.14',
        'linux',
        'x64',
        'https://github.com/alibaba/dragonwell8/releases/download/dragonwell-extended-8.13.14_jdk8u352-ga/Alibaba_Dragonwell_Extended_8.13.14_x64_linux.tar.gz'
      ],
      [
        '11',
        'linux',
        'x64',
        'https://github.com/alibaba/dragonwell11/releases/download/dragonwell-extended-11.0.17.13_jdk-11.0.17-ga/Alibaba_Dragonwell_Extended_11.0.17.13.8_x64_linux.tar.gz'
      ],
      [
        '11',
        'linux',
        'aarch64',
        'https://github.com/alibaba/dragonwell11/releases/download/dragonwell-extended-11.0.17.13_jdk-11.0.17-ga/Alibaba_Dragonwell_Extended_11.0.17.13.8_aarch64_linux.tar.gz'
      ],
      [
        '11',
        'windows',
        'x64',
        'https://github.com/alibaba/dragonwell11/releases/download/dragonwell-extended-11.0.17.13_jdk-11.0.17-ga/Alibaba_Dragonwell_Extended_11.0.17.13.8_x64_windows.zip'
      ],
      [
        '11',
        'alpine-linux',
        'x64',
        'https://github.com/alibaba/dragonwell11/releases/download/dragonwell-extended-11.0.17.13_jdk-11.0.17-ga/Alibaba_Dragonwell_Extended_11.0.17.13.8_x64_alpine-linux.tar.gz'
      ],
      [
        '11.0.17',
        'linux',
        'x64',
        'https://github.com/alibaba/dragonwell11/releases/download/dragonwell-extended-11.0.17.13_jdk-11.0.17-ga/Alibaba_Dragonwell_Extended_11.0.17.13.8_x64_linux.tar.gz'
      ],
      [
        '17',
        'linux',
        'x64',
        'https://github.com/alibaba/dragonwell17/releases/download/dragonwell-standard-17.0.5.0.5%2B8_jdk-17.0.5-ga/Alibaba_Dragonwell_Standard_17.0.5.0.5.8_x64_linux.tar.gz'
      ],
      [
        '17',
        'linux',
        'aarch64',
        'https://github.com/alibaba/dragonwell17/releases/download/dragonwell-standard-17.0.5.0.5%2B8_jdk-17.0.5-ga/Alibaba_Dragonwell_Standard_17.0.5.0.5.8_aarch64_linux.tar.gz'
      ],
      [
        '17',
        'windows',
        'x64',
        'https://github.com/alibaba/dragonwell17/releases/download/dragonwell-standard-17.0.5.0.5%2B8_jdk-17.0.5-ga/Alibaba_Dragonwell_Standard_17.0.5.0.5.8_x64_windows.zip'
      ],
      [
        '17',
        'alpine-linux',
        'x64',
        'https://github.com/alibaba/dragonwell17/releases/download/dragonwell-standard-17.0.5.0.5%2B8_jdk-17.0.5-ga/Alibaba_Dragonwell_Standard_17.0.5.0.5.8_x64_alpine-linux.tar.gz'
      ],
      [
        '17.0.4',
        'linux',
        'x64',
        'https://github.com/alibaba/dragonwell17/releases/download/dragonwell-standard-17.0.4.0.4%2B8_jdk-17.0.4-ga/Alibaba_Dragonwell_Standard_17.0.4.0.4%2B8_x64_linux.tar.gz'
      ]
    ])(
      'should return proper link according to the specified java-version, platform and arch',
      async (
        jdkVersion: string,
        platform: string,
        arch: string,
        expectedLink: string
      ) => {
        const distribution = new DragonwellDistribution({
          version: jdkVersion,
          architecture: arch,
          packageType: 'jdk',
          checkLatest: false
        });
        mockPlatform(distribution, platform);

        const availableVersion = await distribution['findPackageForDownload'](
          jdkVersion
        );
        expect(availableVersion).not.toBeNull();
        expect(availableVersion.url).toBe(expectedLink);
      }
    );

    it.each([
      ['8', 'alpine-linux', 'x64'],
      ['8', 'macos', 'aarch64'],
      ['11', 'macos', 'aarch64'],
      ['17', 'linux', 'riscv']
    ])(
      'should throw when required version of JDK can not be found in the JSON',
      async (jdkVersion: string, platform: string, arch: string) => {
        const distribution = new DragonwellDistribution({
          version: jdkVersion,
          architecture: arch,
          packageType: 'jdk',
          checkLatest: false
        });
        mockPlatform(distribution, platform);

        await expect(
          distribution['findPackageForDownload'](jdkVersion)
        ).rejects.toThrow(
          `Couldn't find any satisfied version for the specified java-version: "${jdkVersion}" and architecture: "${arch}".`
        );
      }
    );

    it('should throw when required package type is not jdk', async () => {
      const jdkVersion = '17';
      const arch = 'x64';
      const platform = 'linux';
      const distribution = new DragonwellDistribution({
        version: jdkVersion,
        architecture: arch,
        packageType: 'jre',
        checkLatest: false
      });
      mockPlatform(distribution, platform);
      await expect(
        distribution['findPackageForDownload'](jdkVersion)
      ).rejects.toThrow('Dragonwell provides only the `jdk` package type');
    });
  });
});
+11 −1
Changes for dist/cleanup/index.js: 11 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -67020,7 +67020,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.convertVersionToSemver = exports.getVersionFromFileContent = exports.isCacheFeatureAvailable = exports.isGhes = exports.isJobStatusSuccess = exports.getToolcachePath = exports.isVersionSatisfies = exports.getDownloadArchiveExtension = exports.extractJdkFile = exports.getVersionFromToolcachePath = exports.getBooleanInput = exports.getTempDir = void 0;
exports.getGitHubHttpHeaders = exports.convertVersionToSemver = exports.getVersionFromFileContent = exports.isCacheFeatureAvailable = exports.isGhes = exports.isJobStatusSuccess = exports.getToolcachePath = exports.isVersionSatisfies = exports.getDownloadArchiveExtension = exports.extractJdkFile = exports.getVersionFromToolcachePath = exports.getBooleanInput = exports.getTempDir = void 0;
const os_1 = __importDefault(__nccwpck_require__(2037));
const path_1 = __importDefault(__nccwpck_require__(1017));
const fs = __importStar(__nccwpck_require__(7147));
@@ -67157,6 +67157,16 @@ function convertVersionToSemver(version) {
    return mainVersion;
}
exports.convertVersionToSemver = convertVersionToSemver;
function getGitHubHttpHeaders() {
    const token = core.getInput('token');
    const auth = !token ? undefined : `token ${token}`;
    const headers = {
        authorization: auth,
        accept: 'application/vnd.github.VERSION.raw'
    };
    return headers;
}
exports.getGitHubHttpHeaders = getGitHubHttpHeaders;
/***/ }),
Loading