Unverified Commit 3fc1c6e6 authored by Bruno Borges's avatar Bruno Borges Committed by GitHub
Browse files

Add daily latest JDK versions report workflow (#1329)

* Add daily latest JDK versions report workflow

Add a scheduled workflow that resolves, without downloading, the exact
version each distribution currently provides for the LTS majors, the
newest feature release, and `latest` on Linux, macOS, and Windows for
x64 and aarch64. Resolution reuses each installer's metadata lookup, so
the report matches what setup-java installs on a tool-cache miss or with
`check-latest: true`. Results are combined into a job summary with a
per-platform breakdown and a section for distributions needing
attention. Link the report from the README.

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

* Report every supported platform in latest JDK versions report

Resolve each distribution on every OS and architecture in the capability
map, including Alpine Linux, and render a full per-platform table for each
distribution instead of a merged overview. Platform differences are
expected and no longer flagged; only lookup errors and distributions that
resolve nothing are listed under "Needs attention".

Share HEAD responses per distribution so JetBrains lookups no longer
re-probe every release URL, cutting a Linux run from ~7 min to ~1 min.

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

* Complete JDK report platform and major coverage

Resolve every major from Java 6 through the newest GA release, including non-LTS versions. Query Liberica Solaris metadata through its installer and include Solaris in the workflow matrix. Preserve exact per-platform versions without flagging normal differences.

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

---------

Co-authored-by: default avatarCopilot App <[email protected]>
parent 3c7a6295
Loading
Loading
Loading
Loading
+157
Changes for .github/workflows/latest-jdk-versions.yml: 157 added lines, 0 removed lines.
Original line number Diff line number Diff line
# Daily report of the exact JDK version each distribution currently resolves
# for every major from Java 6 through the newest GA release, and `latest`, on every operating
# system and architecture setup-java supports for it. Versions are resolved
# from vendor metadata only; no JDK is downloaded.
name: Latest JDK versions report

on:
  schedule:
    - cron: '30 6 * * *'
  workflow_dispatch:
    inputs:
      java-versions:
        description: 'Comma-separated java-version values (default: every major from Java 6 through the newest GA release, and latest)'
        required: false
        default: ''
  pull_request:
    paths:
      - 'src/reports/**'
      - '.github/workflows/latest-jdk-versions.yml'

permissions:
  contents: read

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

defaults:
  run:
    shell: bash

jobs:
  build:
    name: Build report tool
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v7
        with:
          persist-credentials: false
      - name: Setup Node.js
        uses: actions/setup-node@v7
        with:
          node-version: '24.x'
          cache: npm
      - name: Install dependencies
        run: npm ci
      - name: Bundle report tool
        run: npm run build:latest-versions-report
      - name: Upload report tool
        uses: actions/upload-artifact@v7
        with:
          name: latest-versions-report-tool
          path: lib/latest-versions-report/
          retention-days: 1

  resolve:
    name: Resolve versions (${{ matrix.platform }})
    needs: build
    runs-on: ${{ matrix.os }}
    timeout-minutes: 30
    strategy:
      fail-fast: false
      matrix:
        include:
          - os: ubuntu-latest
            platform: linux
          - os: macos-latest
            platform: macos
          - os: windows-latest
            platform: windows
          # Liberica's Solaris metadata is queried without running a Solaris JDK.
          - os: ubuntu-latest
            platform: solaris
    steps:
      - name: Setup Node.js
        uses: actions/setup-node@v7
        with:
          node-version: '24.x'
      - name: Download report tool
        uses: actions/download-artifact@v8
        with:
          name: latest-versions-report-tool
          path: tool
      - name: Resolve latest versions without downloading
        run: node tool/index.js resolve "results/$REPORT_PLATFORM.json"
        env:
          GITHUB_TOKEN: ${{ github.token }}
          REPORT_VERSIONS: ${{ inputs.java-versions }}
          REPORT_PLATFORM: ${{ matrix.platform }}
      - name: Upload resolved versions
        uses: actions/upload-artifact@v7
        with:
          name: latest-jdk-versions-${{ matrix.platform }}
          path: results/
          retention-days: 1

  # Installers pick musl builds on Alpine, which can resolve to other versions.
  resolve-alpine:
    name: Resolve versions (alpine)
    needs: build
    runs-on: ubuntu-latest
    timeout-minutes: 30
    container:
      image: node:24-alpine
    defaults:
      run:
        shell: sh
    steps:
      - name: Download report tool
        uses: actions/download-artifact@v8
        with:
          name: latest-versions-report-tool
          path: tool
      - name: Resolve latest versions without downloading
        run: node tool/index.js resolve results/alpine.json
        env:
          GITHUB_TOKEN: ${{ github.token }}
          REPORT_VERSIONS: ${{ inputs.java-versions }}
      - name: Upload resolved versions
        uses: actions/upload-artifact@v7
        with:
          name: latest-jdk-versions-alpine
          path: results/
          retention-days: 1

  report:
    name: Report
    needs: [build, resolve, resolve-alpine]
    if: ${{ !cancelled() && needs.build.result == 'success' }}
    runs-on: ubuntu-latest
    steps:
      - name: Setup Node.js
        uses: actions/setup-node@v7
        with:
          node-version: '24.x'
      - name: Download report tool
        uses: actions/download-artifact@v8
        with:
          name: latest-versions-report-tool
          path: tool
      - name: Download resolved versions
        uses: actions/download-artifact@v8
        with:
          pattern: latest-jdk-versions-*
          path: results
          merge-multiple: true
      - name: Write report
        run: node tool/index.js summarize results latest-jdk-versions.md
      - name: Upload report
        uses: actions/upload-artifact@v7
        with:
          name: latest-jdk-versions-report
          path: |
            latest-jdk-versions.md
            results/
          retention-days: 30
+3
Changes for README.md: 3 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -3,6 +3,7 @@
[![Basic validation](https://github.com/actions/setup-java/actions/workflows/basic-validation.yml/badge.svg?branch=main)](https://github.com/actions/setup-java/actions/workflows/basic-validation.yml)
[![Validate Java e2e](https://github.com/actions/setup-java/actions/workflows/e2e-versions.yml/badge.svg?branch=main)](https://github.com/actions/setup-java/actions/workflows/e2e-versions.yml)
[![Validate cache](https://github.com/actions/setup-java/actions/workflows/e2e-cache.yml/badge.svg?branch=main)](https://github.com/actions/setup-java/actions/workflows/e2e-cache.yml)
[![Latest JDK versions report](https://github.com/actions/setup-java/actions/workflows/latest-jdk-versions.yml/badge.svg?branch=main)](https://github.com/actions/setup-java/actions/workflows/latest-jdk-versions.yml)

Set up Java for GitHub Actions workflows. `setup-java` installs a requested Java distribution, adds it to `PATH`, configures `JAVA_HOME`, and can optionally cache build dependencies for Apache Maven, Gradle, and sbt; generate Maven publishing configuration, verify JDK package signatures, manage multiple JDKs, and manage Maven toolchains.

@@ -245,6 +246,8 @@ When `check-latest` is `false`, the action first tries the runner tool cache for

GitHub-hosted runners primarily pre-cache Eclipse Temurin JDKs. See the installed Java versions for [Ubuntu](https://github.com/actions/runner-images/blob/main/images/ubuntu/Ubuntu2404-Readme.md#java), [Windows](https://github.com/actions/runner-images/blob/main/images/windows/Windows2025-Readme.md#java), and [macOS](https://github.com/actions/runner-images/blob/main/images/macos/macos-15-Readme.md#java). On a fresh GitHub-hosted runner, requests for other distributions usually miss the tool cache and resolve from remote metadata. For broad version ranges such as a major version (`21`, `25`), this often behaves similarly to `check-latest: true` because the action downloads the latest available release that satisfies the range.

To see which exact version a request resolves to today, open the summary of the latest run of the daily [Latest JDK versions report](https://github.com/actions/setup-java/actions/workflows/latest-jdk-versions.yml) workflow. For every supported distribution, it lists the version that `setup-java` currently resolves from vendor metadata for every major from Java 6 through the newest stable GA release (including non-LTS releases), plus `latest`, on every operating system and architecture the action supports for that distribution, including Alpine Linux and Solaris. Because vendors publish builds per platform, the same request can resolve to different versions on different platforms. The report doesn't download any JDKs. Floating vendor URLs are marked when their exact version cannot be established from metadata alone. It shows what a job installs on a tool-cache miss or with `check-latest: true`.

## Download integrity and signatures

`setup-java` automatically verifies downloaded archive checksums when a selected distribution publishes an authoritative checksum. Automatic checksum verification currently applies to `temurin`, `semeru`, `corretto`, `dragonwell`, `kona`, `sapmachine`, `graalvm`, `graalvm-community`, `zulu`, `oracle`, `oracle-openjdk`, `microsoft`, and `jetbrains`.
+361
Changes for __tests__/latest-versions-report.test.ts: 361 added lines, 0 removed lines.
Original line number Diff line number Diff line
import {afterEach, describe, expect, it, jest} from '@jest/globals';
import {HttpClient} from '@actions/http-client';
import {JavaBase} from '../src/distributions/base-installer.js';
import {
  classifyResolutionError,
  getDefaultVersions,
  getSupportedArchitectures,
  renderMarkdownReport,
  ResolutionReport,
  resolveLatestVersions,
  VersionResolution
} from '../src/reports/latest-versions.js';

function result(
  overrides: Partial<VersionResolution> &
    Pick<VersionResolution, 'distribution' | 'versionSpec'>
): VersionResolution {
  return {
    platform: 'linux',
    architecture: 'x64',
    status: 'resolved',
    ...overrides
  };
}

function report(
  platform: string,
  results: VersionResolution[]
): ResolutionReport {
  return {platform, generatedAt: '2026-11-18T06:30:00.000Z', results};
}

function tableRows(markdown: string, distribution: string): string[] {
  const section = markdown.split(`## \`${distribution}\``)[1].split('\n## ')[0];
  return section.split('\n').filter(line => /^\| (?!Platform|---)/.test(line));
}

describe('latest versions report', () => {
  afterEach(() => {
    jest.restoreAllMocks();
  });

  it('includes every major from Java 6 through GA, including non-LTS releases but not EA', async () => {
    jest.spyOn(HttpClient.prototype, 'getJson').mockResolvedValue({
      statusCode: 200,
      headers: {},
      result: {
        most_recent_feature_release: 27,
        most_recent_feature_version: 28,
        most_recent_lts: 25
      }
    });

    await expect(getDefaultVersions(new HttpClient())).resolves.toEqual([
      '6',
      '7',
      '8',
      '9',
      '10',
      '11',
      '12',
      '13',
      '14',
      '15',
      '16',
      '17',
      '18',
      '19',
      '20',
      '21',
      '22',
      '23',
      '24',
      '25',
      '26',
      '27',
      'latest'
    ]);
  });

  it('fails rather than publishing incomplete defaults when discovery fails', async () => {
    jest
      .spyOn(HttpClient.prototype, 'getJson')
      .mockRejectedValue(new Error('Java release metadata is unavailable'));

    await expect(getDefaultVersions(new HttpClient())).rejects.toThrow(
      'Java release metadata is unavailable'
    );
  });

  it.each([5, 27.5, Infinity])(
    'rejects invalid newest major %s',
    async major => {
      jest.spyOn(HttpClient.prototype, 'getJson').mockResolvedValue({
        statusCode: 200,
        headers: {},
        result: {most_recent_feature_release: major}
      });

      await expect(getDefaultVersions(new HttpClient())).rejects.toThrow(
        'Invalid newest Java feature release'
      );
    }
  );

  it('resolves Solaris metadata and combines its exact builds with every other platform', async () => {
    const getJson = jest
      .spyOn(HttpClient.prototype, 'getJson')
      .mockResolvedValue({
        statusCode: 200,
        headers: {},
        result: [
          {
            downloadUrl: 'https://example.com/solaris-jdk8-old.tar.gz',
            version: '8.0.452+9',
            featureVersion: 8,
            interimVersion: 0,
            updateVersion: 452,
            buildVersion: 9
          },
          {
            downloadUrl: 'https://example.com/solaris-jdk8.tar.gz',
            version: '8.0.462+10',
            featureVersion: 8,
            interimVersion: 0,
            updateVersion: 462,
            buildVersion: 10
          },
          {
            downloadUrl: 'https://example.com/solaris-jdk9.tar.gz',
            version: '9.0.4+11',
            featureVersion: 9,
            interimVersion: 0,
            updateVersion: 4,
            buildVersion: 11
          }
        ]
      });
    const install = jest
      .spyOn(JavaBase.prototype, 'setupJava')
      .mockRejectedValue(new Error('The report must not install a JDK'));
    const network = jest
      .spyOn(HttpClient.prototype, 'request')
      .mockRejectedValue(
        new Error('Only the mocked metadata request is permitted')
      );
    const hostPlatform = process.platform;
    const solaris = await resolveLatestVersions({
      distributions: ['liberica'],
      versions: ['8', '9', '11', 'latest'],
      platform: 'solaris'
    });

    expect(solaris.platform).toBe('solaris');
    expect(solaris.results).toEqual([
      result({
        distribution: 'liberica',
        platform: 'solaris',
        versionSpec: '8',
        version: '8.0.462+10'
      }),
      result({
        distribution: 'liberica',
        platform: 'solaris',
        versionSpec: '9',
        version: '9.0.4+11'
      }),
      expect.objectContaining({
        platform: 'solaris',
        versionSpec: '11',
        status: 'unavailable'
      }),
      result({
        distribution: 'liberica',
        platform: 'solaris',
        versionSpec: 'latest',
        version: '9.0.4+11'
      })
    ]);
    expect(getJson).toHaveBeenCalledTimes(1);
    const url = new URL(getJson.mock.calls[0][0]);
    expect(url.origin).toBe('https://api.bell-sw.com');
    expect(Object.fromEntries(url.searchParams)).toMatchObject({
      os: 'solaris',
      arch: 'x86',
      bitness: '64',
      'bundle-type': 'jdk',
      'installation-type': 'archive'
    });
    expect(install).not.toHaveBeenCalled();
    expect(network).not.toHaveBeenCalled();
    expect(process.platform).toBe(hostPlatform);

    const otherReports = ['linux', 'linux-musl', 'macos', 'windows'].map(
      (platform, index) =>
        report(
          platform,
          ['8', '9', '11', 'latest'].map(versionSpec =>
            result({
              distribution: 'liberica',
              platform,
              versionSpec,
              version: `${versionSpec === 'latest' ? '11' : versionSpec}.0.1+${index + 1}`
            })
          )
        )
    );
    const markdown = renderMarkdownReport([solaris, ...otherReports]);
    expect(tableRows(markdown, 'liberica')).toEqual([
      '| Linux x64 | `8.0.1+1` | `9.0.1+1` | `11.0.1+1` | `11.0.1+1` |',
      '| Alpine Linux x64 | `8.0.1+2` | `9.0.1+2` | `11.0.1+2` | `11.0.1+2` |',
      '| macOS x64 | `8.0.1+3` | `9.0.1+3` | `11.0.1+3` | `11.0.1+3` |',
      '| Windows x64 | `8.0.1+4` | `9.0.1+4` | `11.0.1+4` | `11.0.1+4` |',
      '| Solaris x64 | `8.0.462+10` | `9.0.4+11` | — | `9.0.4+11` |'
    ]);
    expect(markdown).not.toContain('Needs attention');
    expect(markdown).not.toContain('Not checked');
  });

  it('classifies missing releases separately from lookup failures', () => {
    const notFound = new Error("No matching version found for SemVer '8'.");
    notFound.name = 'VersionNotFoundError';

    expect(classifyResolutionError(notFound)).toBe('unavailable');
    expect(
      classifyResolutionError(
        new Error('Oracle JDK is only supported for JDK 17 and later')
      )
    ).toBe('unavailable');
    expect(
      classifyResolutionError(
        new Error(
          'No Kona release for the specified version "27" on OS "macos" and arch "aarch64".'
        )
      )
    ).toBe('unavailable');
    expect(classifyResolutionError(new Error('socket hang up'))).toBe('error');
  });

  it('resolves Alpine with the Linux architectures, including version-restricted ones', () => {
    expect(getSupportedArchitectures('redhat', 'linux-musl')).toEqual([
      'x64',
      'aarch64',
      'ppc64le'
    ]);
    expect(getSupportedArchitectures('dragonwell', 'macos')).toEqual([]);
  });

  it('lists the exact version for every platform, ordered by operating system and architecture', () => {
    const markdown = renderMarkdownReport([
      report('macos', [
        result({
          distribution: 'temurin',
          versionSpec: '21',
          platform: 'macos',
          architecture: 'aarch64',
          version: '21.0.13+100000002.0.LTS'
        })
      ]),
      report('linux', [
        result({
          distribution: 'temurin',
          versionSpec: '21',
          architecture: 's390x',
          version: '21.0.12+7'
        }),
        result({
          distribution: 'temurin',
          versionSpec: '21',
          version: '21.0.13+9'
        })
      ]),
      report('linux-musl', [
        result({
          distribution: 'temurin',
          versionSpec: '21',
          platform: 'linux-musl',
          version: '21.0.13+9'
        })
      ])
    ]);

    expect(tableRows(markdown, 'temurin')).toEqual([
      '| Linux x64 | `21.0.13+9` |',
      '| Linux s390x | `21.0.12+7` |',
      '| Alpine Linux x64 | `21.0.13+9` |',
      '| macOS aarch64 | `21.0.13+100000002.0.LTS` |'
    ]);
    expect(markdown).not.toContain('Needs attention');
    expect(markdown).toContain(
      'Not checked, because no runner reported these platforms: Windows (x64, x86, aarch64).'
    );
  });

  it('distinguishes unsupported, unpublished, and floating releases', () => {
    const markdown = renderMarkdownReport([
      report('linux', [
        result({
          distribution: 'redhat',
          versionSpec: '11',
          architecture: 'aarch64',
          version: '11.0.29'
        }),
        result({
          distribution: 'redhat',
          versionSpec: '25',
          architecture: 'aarch64',
          status: 'unsupported'
        }),
        result({
          distribution: 'oracle',
          versionSpec: '11',
          status: 'unavailable'
        }),
        result({
          distribution: 'oracle',
          versionSpec: '25',
          version: '25',
          floating: true,
          advertisedVersion: '25.0.5.1',
          publishedAt: '2026-10-27'
        })
      ])
    ]);

    expect(tableRows(markdown, 'redhat')).toEqual([
      '| Linux aarch64 | `11.0.29` | n/a |'
    ]);
    expect(tableRows(markdown, 'oracle')).toEqual([
      '| Linux x64 | — | `25.0.5.1` ¹ (published 2026-10-27) |'
    ]);
    expect(markdown).toContain('¹ Major-only requests download');
  });

  it('reports lookup errors and distributions that resolved nothing', () => {
    const markdown = renderMarkdownReport([
      report('linux', [
        result({
          distribution: 'oracle-openjdk',
          versionSpec: '25',
          status: 'unavailable'
        }),
        result({
          distribution: 'zulu',
          versionSpec: '25',
          status: 'error',
          message: 'socket hang up\nstack'
        })
      ])
    ]);

    expect(markdown).toContain('## `oracle-openjdk` ❗');
    expect(tableRows(markdown, 'zulu')).toEqual(['| Linux x64 | ❗ error |']);
    expect(markdown).toContain(
      '| `oracle-openjdk` | all | all | No release matched any requested version'
    );
    expect(markdown).toContain(
      '| `zulu` | `25` | Linux x64 | socket hang up |'
    );
  });
});
+1
Changes for package.json: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
@@ -14,6 +14,7 @@
    "format-check": "prettier --no-error-on-unmatched-pattern --check \"**/*.{ts,yml,yaml}\"",
    "lint": "eslint \"**/*.ts\"",
    "lint:fix": "eslint \"**/*.ts\" --fix",
    "build:latest-versions-report": "ncc build -o lib/latest-versions-report src/reports/latest-versions.ts",
    "check": "npm run format-check && npm run lint && npm run build && npm test",
    "fix": "npm run format && npm run lint:fix && npm run build",
    "prepare": "husky install",
+1 −1
Changes for src/distributions/liberica/installer.ts: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -203,7 +203,7 @@ export class LibericaDistributions extends JavaBase {
    }
  }

  private getPlatformOption(
  protected getPlatformOption(
    platform: NodeJS.Platform = process.platform
  ): OsVersions {
    switch (platform) {
Loading