Unverified Commit a1bf0b55 authored by Copilot's avatar Copilot Committed by GitHub
Browse files

Add Microsoft OpenJDK 25.0.5.0.2 support (#1320)

* Initial plan

* Support Microsoft OpenJDK 25.0.5.0.2 with bundled manifest fallback

* Fix Microsoft OpenJDK version matching

Co-authored-by: default avatarCopilot App <[email protected]>

---------

Co-authored-by: default avatarcopilot-swe-agent[bot] <[email protected]>
Co-authored-by: default avatarBruno Borges <[email protected]>
Co-authored-by: default avatarCopilot App <[email protected]>
parent a3c80683
Loading
Loading
Loading
Loading
+9
Changes for .github/workflows/e2e-versions.yml: 9 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -51,6 +51,15 @@ jobs:
          - distribution: microsoft
            os: macos-latest
            version: 25
          - distribution: microsoft
            os: windows-latest
            version: '25.0.5+0.2'
          - distribution: microsoft
            os: ubuntu-latest
            version: '25.0.5+0.2'
          - distribution: microsoft
            os: macos-latest
            version: '25.0.5+0.2'
          - distribution: kona
            os: windows-latest
            version: 25
+1
Changes for README.md: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
@@ -225,6 +225,7 @@ Additional distribution notes:

- Oracle OpenJDK builds are archived after a limited number of releases and no longer receive security updates. To continue receiving security patches, use Oracle JDK or another vendor.
- Azul Zulu maps `arm64` to `aarch64` when querying the Azul Metadata API.
- Microsoft Build of OpenJDK uses Microsoft's live version manifest, falling back to the bundled version list when no release matches. Version `25.0.5.0.2` can also be requested as `25.0.5+0.2`.
- GraalVM Community is available as `distribution: graalvm-community` for stable JDK 17 and later releases.
- On Ubuntu runners, commands executed with `sudo` do not inherit the `JAVA_HOME` and `PATH` set by `setup-java` and may fall back to the system-default JDK.

+166
Changes for __tests__/distributors/microsoft-installer.test.ts: 166 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -216,6 +216,172 @@ describe('findPackageForDownload', () => {
    expect(result.signatureUrl).toBe(`${url}.sig`);
  });

  describe.each(['25.0.5.0.2', '25.0.5+0.2', '25.0.5'])(
    'version %s missing from the live manifest',
    version => {
      it.each([
        ['darwin', 'x64', 'macos', 'tar.gz'],
        ['linux', 'x64', 'linux', 'tar.gz'],
        ['win32', 'x64', 'windows', 'zip'],
        ['darwin', 'aarch64', 'macos', 'tar.gz'],
        ['linux', 'aarch64', 'linux', 'tar.gz'],
        ['win32', 'aarch64', 'windows', 'zip']
      ])(
        'resolves the bundled release for %s/%s',
        async (platform, architecture, osType, extension) => {
          mockOsPlatform.mockReturnValue(platform);
          const distro = new MicrosoftDistributions({
            version,
            architecture,
            packageType: 'jdk',
            checkLatest: false
          });

          const result = await distro['findPackageForDownload'](
            distro['version']
          );
          const url = `https://aka.ms/download-jdk/microsoft-jdk-25.0.5.0.2-${osType}-${architecture}.${extension}`;

          expect(result).toEqual({
            version: '25.0.5+0.2',
            url,
            signatureUrl: `${url}.sig`,
            checksum: {
              algorithm: 'sha256',
              value: MICROSOFT_CHECKSUM,
              source: `${url}.sha256sum.txt`
            }
          });
          expect(spyHttpClientGet).toHaveBeenCalledWith(`${url}.sha256sum.txt`);
        }
      );
    }
  );

  it('prefers the live manifest when it contains the requested release', async () => {
    mockOsPlatform.mockReturnValue('linux');
    const url =
      'https://example.test/microsoft-jdk-25.0.5.0.2-linux-x64.tar.gz';
    spyGetManifestFromRepo.mockResolvedValue({
      result: [
        {
          version: '25.0.5+0.2',
          stable: true,
          release_url: 'https://aka.ms/download-jdk',
          files: [
            {
              filename: 'microsoft-jdk-25.0.5.0.2-linux-x64.tar.gz',
              arch: 'x64',
              platform: 'linux',
              download_url: url
            }
          ]
        }
      ],
      statusCode: 200,
      headers: {}
    });

    const result = await distribution['findPackageForDownload']('25.0.5+0.2');

    expect(result.version).toBe('25.0.5+0.2');
    expect(result.url).toBe(url);
    expect(spyGetManifestFromRepo).toHaveBeenCalledWith(
      'https://aka.ms/download-jdk/microsoft-openjdk-versions.json',
      {accept: 'application/json'}
    );
  });

  it('falls back to the bundled build when the live manifest has another build', async () => {
    mockOsPlatform.mockReturnValue('linux');
    spyGetManifestFromRepo.mockResolvedValue({
      result: [
        {
          version: '25.0.5+0.3',
          stable: true,
          release_url: 'https://aka.ms/download-jdk',
          files: [
            {
              filename: 'microsoft-jdk-25.0.5.0.3-linux-x64.tar.gz',
              arch: 'x64',
              platform: 'linux',
              download_url:
                'https://example.test/microsoft-jdk-25.0.5.0.3-linux-x64.tar.gz'
            }
          ]
        }
      ],
      statusCode: 200,
      headers: {}
    });

    const result = await distribution['findPackageForDownload']('25.0.5+0.2');

    expect(result.version).toBe('25.0.5+0.2');
    expect(result.url).toBe(
      'https://aka.ms/download-jdk/microsoft-jdk-25.0.5.0.2-linux-x64.tar.gz'
    );
  });

  it('matches dotted Java versions without falling back to the base release', async () => {
    mockOsPlatform.mockReturnValue('linux');
    spyGetManifestFromRepo.mockResolvedValue({
      result: [
        {
          version: '17.0.8',
          stable: true,
          release_url: 'https://aka.ms/download-jdk',
          files: [
            {
              filename: 'microsoft-jdk-17.0.8-linux-x64.tar.gz',
              arch: 'x64',
              platform: 'linux',
              download_url: 'https://example.test/microsoft-jdk-17.0.8.tar.gz'
            }
          ]
        },
        {
          version: '17.0.8.1',
          stable: true,
          release_url: 'https://aka.ms/download-jdk',
          files: [
            {
              filename: 'microsoft-jdk-17.0.8.1-linux-x64.tar.gz',
              arch: 'x64',
              platform: 'linux',
              download_url: 'https://example.test/microsoft-jdk-17.0.8.1.tar.gz'
            }
          ]
        }
      ],
      statusCode: 200,
      headers: {}
    });
    distribution = new MicrosoftDistributions({
      version: '17.0.8.1',
      architecture: 'x64',
      packageType: 'jdk',
      checkLatest: false
    });

    const result = await distribution['findPackageForDownload'](
      distribution['version']
    );

    expect(result.version).toBe('17.0.8+1');
    expect(result.url).toBe(
      'https://example.test/microsoft-jdk-17.0.8.1.tar.gz'
    );
  });

  it('preserves the error when the live manifest cannot be loaded', async () => {
    spyGetManifestFromRepo.mockRejectedValue(new Error('Network error'));

    await expect(
      distribution['findPackageForDownload']('25.0.5+0.2')
    ).rejects.toThrow('Could not load manifest for Microsoft Build of OpenJDK');
  });

  it.each([
    ['amd64', 'x64'],
    ['arm64', 'aarch64']
+7
Changes for __tests__/verify-java.sh: 7 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -15,6 +15,13 @@ EXPECTED_PATH=$2
SETUP_JAVA_VERSION=$3
REQUIRE_CONCRETE_VERSION=$4

if [[ $EXPECTED_JAVA_VERSION == *"+"* ]] && [ "$SETUP_JAVA_VERSION" != "$EXPECTED_JAVA_VERSION" ]; then
  echo "::error::The version output does not match the requested build"
  echo "Requested version: $EXPECTED_JAVA_VERSION"
  echo "Version output: $SETUP_JAVA_VERSION"
  exit 1
fi

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}"
−330

File deleted.

Loading