Skip to content
Next Next commit
Add microsoft distribution of the JDK.
  • Loading branch information
brendanburns authored and brendandburns committed Nov 30, 2021
commit 1bc25281d61a80fc9b4118a1ac7a0f948c6a3ebb
16 changes: 13 additions & 3 deletions .github/workflows/e2e-versions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@ on:
workflow_dispatch:
jobs:
setup-java-major-versions:
if: ${{ matrix.distribution != 'microsoft' || matrix.version != '8' }}
Comment thread
brcrista marked this conversation as resolved.
Resolved
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: ['temurin', 'adopt', 'adopt-openj9', 'zulu', 'liberica'] # internally 'adopt-hotspot' is the same as 'adopt'
distribution: ['temurin', 'adopt', 'adopt-openj9', 'zulu', 'liberica', 'microsoft' ] # internally 'adopt-hotspot' is the same as 'adopt'
version: ['8', '11', '16']

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we replace 16 with 17 here, since 17 is the latest LTS now?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably worth doing in a different PR since it is unrelated to adding MSFT.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, yes. That'd be better indeed.

steps:
- name: Checkout
Expand Down Expand Up @@ -175,16 +176,25 @@ jobs:
shell: bash

setup-java-custom-architecture:
name: ${{ matrix.distribution }} ${{ matrix.version }} (jdk-x86) - ${{ matrix.os }}
# Only Zulu provides x86 arch for now and only for windows / ubuntu
# Only Microsoft provides arm64 for windows / ubuntu / os x
if: ${{ (matrix.distribution == 'zulu' && matrix.architecture == 'x86' && matrix.os != 'macos-latest' ) || (matrix.distribution == 'microsoft' && matrix.architecture == 'arm64') }}
Comment thread
brcrista marked this conversation as resolved.
Resolved
name: ${{ matrix.distribution }} ${{ matrix.version }} (jdk-${{ matrix.architecture }}) - ${{ matrix.os }}
needs: setup-java-major-minor-versions
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
<<<<<<< HEAD
# Only Zulu and Liberica provides x86 arch for now and only for windows / ubuntu
os: [windows-latest, ubuntu-latest]
distribution: ['zulu', 'liberica']
=======
os: [macos-latest, windows-latest, ubuntu-latest]
distribution: ['zulu', 'microsoft']
>>>>>>> Add microsoft distribution of the JDK.
Comment thread
brcrista marked this conversation as resolved.
Resolved
version: ['11']

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we move up to 17?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As above.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noted.

architecture: [ 'x86', 'arm64' ]
steps:
- name: Checkout
uses: actions/checkout@v2
Expand All @@ -194,7 +204,7 @@ jobs:
with:
distribution: ${{ matrix.distribution }}
java-version: ${{ matrix.version }}
architecture: x86
architecture: ${{ matrix.architecture }}
- name: Verify Java
run: bash __tests__/verify-java.sh "${{ matrix.version }}" "${{ steps.setup-java.outputs.path }}"
shell: bash
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ Currently, the following distributions are supported:
| `adopt` or `adopt-hotspot` | Adopt OpenJDK Hotspot | [Link](https://adoptopenjdk.net/) | [Link](https://adoptopenjdk.net/about.html) |
| `adopt-openj9` | Adopt OpenJDK OpenJ9 | [Link](https://adoptopenjdk.net/) | [Link](https://adoptopenjdk.net/about.html) |
| `liberica` | Liberica JDK | [Link](https://bell-sw.com/) | [Link](https://bell-sw.com/liberica_eula/) |
| `microsoft` | Microsoft OpenJDK | [Link](https://www.microsoft.com/openjdk) | [Link](https://docs.microsoft.com/java/openjdk/faq)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct name is Microsoft Build of OpenJDK

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done (apologies, this got lost in my rebasing)


**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.

Expand Down
100 changes: 100 additions & 0 deletions __tests__/distributors/microsoft-installer.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
import { MicrosoftDistributions } from '../../src/distributions/microsoft/installer';
import { ArchitectureOptions } from '../../src/distributions/microsoft/models';

describe('getArchitectureOptions', () => {
it.each([
['x64', { bitness: '64', arch: 'x86' }],
['aarch64', { bitness: '64', arch: 'arm' }],
] as [string, ArchitectureOptions][])('parse architecture %s -> %s', (input, expected) => {
const distributions = new MicrosoftDistributions({
architecture: input,
checkLatest: false,
packageType: '',
version: ''
});

expect(distributions['getArchitectureOptions']()).toEqual(expected);
});

it.each(['armv6', 's390x'])('not support architecture %s', input => {
const distributions = new MicrosoftDistributions({
architecture: input,
checkLatest: false,
packageType: '',
version: ''
});

expect(() => distributions['getArchitectureOptions']()).toThrow(
/Architecture '\w+' is not supported\. Supported architectures: .*/
);
});
});

describe('findPackageForDownload', () => {
let distribution: MicrosoftDistributions;

beforeEach(() => {
distribution = new MicrosoftDistributions({
version: '',
architecture: 'x64',
packageType: 'jdk',
checkLatest: false
});
});

it.each([
['17.x', '17.0.1', 'https://aka.ms/download-jdk/microsoft-jdk-17.0.1.12.1-{{OS_TYPE}}-x64.tar.gz'],
['16.0.x', '16.0.2', 'https://aka.ms/download-jdk/microsoft-jdk-16.0.2.7.1-{{OS_TYPE}}-x64.tar.gz'],
['11.0.13', '11.0.13', 'https://aka.ms/download-jdk/microsoft-jdk-11.0.13.8.1-{{OS_TYPE}}-x64.tar.gz'],
])('version is %s -> %s', async (input, expectedVersion, expectedUrl) => {
const result = await distribution['findPackageForDownload'](input);
expect(result.version).toBe(expectedVersion);
var os: string;
switch (process.platform) {
case 'darwin':
os = 'macos';
break;
case 'win32':
os = 'windows';
break;
default:
os = process.platform.toString();
break;
}
expect(result.url).toBe(expectedUrl.replace('{{OS_TYPE}}', os));
});

it('should throw an error', async () => {
await expect(distribution['findPackageForDownload']('8')).rejects.toThrow(
/Could not find satisfied version for semver */
);
});
});

describe('getPlatformOption', () => {
const distributions = new MicrosoftDistributions({
architecture: 'x64',
version: '11',
packageType: 'jdk',
checkLatest: false
});

it.each([
['linux', 'linux'],
['darwin', 'macos'],
['win32', 'windows'],
])('os version %s -> %s', (input, expected) => {
const actual = distributions['getPlatformOption'](input as NodeJS.Platform);

expect(actual).toEqual(expected);
});

it.each(['aix', 'android', 'freebsd', 'openbsd', 'netbsd', 'solaris', 'cygwin'])(
'not support os version %s',
input => {
expect(() => distributions['getPlatformOption'](input as NodeJS.Platform)).toThrow(
/Platform '\w+' is not supported\. Supported platforms: .+/
);
}
);
});
Loading