From 0cd606abc4462bd5fa234fa56e583c7a86082928 Mon Sep 17 00:00:00 2001 From: Bruno Borges Date: Wed, 18 Nov 2026 14:44:05 -0800 Subject: [PATCH 1/3] 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: Copilot App <223556219+Copilot@users.noreply.github.com> --- .github/workflows/latest-jdk-versions.yml | 116 +++++ README.md | 3 + __tests__/latest-versions-report.test.ts | 136 +++++ package.json | 1 + src/reports/latest-versions.ts | 576 ++++++++++++++++++++++ 5 files changed, 832 insertions(+) create mode 100644 .github/workflows/latest-jdk-versions.yml create mode 100644 __tests__/latest-versions-report.test.ts create mode 100644 src/reports/latest-versions.ts diff --git a/.github/workflows/latest-jdk-versions.yml b/.github/workflows/latest-jdk-versions.yml new file mode 100644 index 000000000..f97accccb --- /dev/null +++ b/.github/workflows/latest-jdk-versions.yml @@ -0,0 +1,116 @@ +# Daily report of the exact JDK version each distribution currently resolves +# for LTS majors, the newest feature release, and `latest`. 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 to resolve (default: LTS majors, newest feature 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.os }}) + needs: build + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, macos-latest, windows-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: Resolve latest versions without downloading + run: node tool/index.js resolve "results/$RUNNER_OS.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-${{ matrix.os }} + path: results/ + retention-days: 1 + + report: + name: Report + needs: [build, resolve] + 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 diff --git a/README.md b/README.md index 028ec49b5..ea2cf40d4 100644 --- a/README.md +++ b/README.md @@ -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 each LTS major, the newest feature release, and `latest`, on Linux, macOS, and Windows for `x64` and `aarch64`. The report doesn't download any JDKs. 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`. diff --git a/__tests__/latest-versions-report.test.ts b/__tests__/latest-versions-report.test.ts new file mode 100644 index 000000000..2793916ab --- /dev/null +++ b/__tests__/latest-versions-report.test.ts @@ -0,0 +1,136 @@ +import {describe, expect, it} from '@jest/globals'; +import { + classifyResolutionError, + renderMarkdownReport, + ResolutionReport, + VersionResolution +} from '../src/reports/latest-versions.js'; + +function result( + overrides: Partial & + Pick +): VersionResolution { + return { + platform: 'linux', + architecture: 'x64', + status: 'resolved', + ...overrides + }; +} + +function report(results: VersionResolution[]): ResolutionReport { + return {platform: 'linux', generatedAt: '2026-11-18T06:30:00.000Z', results}; +} + +function overviewRow(markdown: string, distribution: string): string { + return markdown + .split('\n') + .find(line => line.startsWith(`| \`${distribution}\``))!; +} + +describe('latest versions report', () => { + 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('shows one version when every platform agrees and flags differences', () => { + const markdown = renderMarkdownReport([ + report([ + result({distribution: 'zulu', versionSpec: '21', version: '21.0.9'}), + result({ + distribution: 'zulu', + versionSpec: '21', + architecture: 'aarch64', + version: '21.0.9' + }), + result({distribution: 'temurin', versionSpec: '21', version: '21.0.9'}), + result({ + distribution: 'temurin', + versionSpec: '21', + architecture: 'aarch64', + version: '21.0.8' + }) + ]) + ]); + + expect(overviewRow(markdown, 'zulu')).toBe('| `zulu` | `21.0.9` |'); + expect(overviewRow(markdown, 'temurin')).toBe( + '| `temurin` | `21.0.9` / `21.0.8` ⚠️ |' + ); + expect(markdown).toContain( + '
temurin ⚠️' + ); + }); + + it('marks floating releases and prefers the vendor-advertised version', () => { + const markdown = renderMarkdownReport([ + report([ + result({ + distribution: 'oracle', + versionSpec: '25', + version: '25', + floating: true, + advertisedVersion: '25.0.5.1', + publishedAt: '2026-10-27' + }) + ]) + ]); + + expect(overviewRow(markdown, 'oracle')).toBe('| `oracle` | `25.0.5.1` ¹ |'); + expect(markdown).toContain('`25.0.5.1` ¹ (published 2026-10-27)'); + }); + + it('reports lookup errors and distributions that resolved nothing', () => { + const markdown = renderMarkdownReport([ + report([ + result({ + distribution: 'oracle-openjdk', + versionSpec: '25', + status: 'unavailable', + message: "No matching version found for SemVer '25'." + }), + result({ + distribution: 'redhat', + versionSpec: '25', + platform: 'macos', + status: 'unsupported', + message: "Distribution 'redhat' does not support operating system" + }), + result({ + distribution: 'zulu', + versionSpec: '25', + status: 'error', + message: 'socket hang up\nstack' + }) + ]) + ]); + + expect(overviewRow(markdown, 'oracle-openjdk')).toBe( + '| `oracle-openjdk` ❗ | — |' + ); + expect(overviewRow(markdown, 'redhat')).toBe('| `redhat` | — |'); + expect(overviewRow(markdown, 'zulu')).toBe('| `zulu` | ❗ error |'); + expect(markdown).toContain( + '| `oracle-openjdk` | all | all | No release matched any requested version' + ); + expect(markdown).toContain( + '| `zulu` | `25` | linux x64 | socket hang up |' + ); + }); +}); diff --git a/package.json b/package.json index ae682a207..f1ffd184e 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/reports/latest-versions.ts b/src/reports/latest-versions.ts new file mode 100644 index 000000000..e8d825dee --- /dev/null +++ b/src/reports/latest-versions.ts @@ -0,0 +1,576 @@ +import * as core from '@actions/core'; +import * as httpm from '@actions/http-client'; +import fs from 'fs'; +import path from 'path'; +import {getJavaDistribution} from '../distributions/distribution-factory.js'; +import type {JavaBase} from '../distributions/base-installer.js'; +import type {JavaDownloadRelease} from '../distributions/base-models.js'; +import {JavaDistribution} from '../distributions/package-types.js'; +import {isMainModule} from '../is-main-module.js'; +import {RetryingHttpClient} from '../retrying-http-client.js'; +import {getLatestMajorVersion} from '../util.js'; + +/** + * Reports the exact JDK version each distribution currently resolves for a set + * of version specs, using the installers' own metadata resolution. Nothing is + * downloaded: resolution stops where `setup-java` would start the download. + */ + +export const LTS_VERSIONS = ['8', '11', '17', '21', '25']; +export const DEFAULT_ARCHITECTURES = ['x64', 'aarch64']; +export const REPORTED_DISTRIBUTIONS: string[] = Object.values( + JavaDistribution +).filter(distribution => distribution !== JavaDistribution.JdkFile); + +const PACKAGE_TYPE = 'jdk'; +const CONCURRENCY = 6; +const ORACLE_RELEASES_URL = 'https://java.oraclecloud.com/currentJavaReleases'; + +/** + * - `unsupported`: excluded by the action's package/platform capability maps. + * - `unavailable`: the vendor's metadata has no matching release. + * - `error`: the metadata lookup failed. + */ +export type ResolutionStatus = + 'resolved' | 'unsupported' | 'unavailable' | 'error'; + +export interface VersionResolution { + distribution: string; + versionSpec: string; + platform: string; + architecture: string; + status: ResolutionStatus; + version?: string; + /** The release URL serves whatever build the vendor last published. */ + floating?: boolean; + /** `Last-Modified` date of a floating artifact, from a HEAD request. */ + publishedAt?: string; + /** Version the vendor currently advertises for a floating artifact. */ + advertisedVersion?: string; + message?: string; +} + +export interface ResolutionReport { + platform: string; + generatedAt: string; + results: VersionResolution[]; +} + +interface ReleaseResolver { + version: string; + http: httpm.HttpClient; + findPackageForDownload(range: string): Promise; +} + +export function getReportPlatform( + platform: NodeJS.Platform = process.platform +): string { + switch (platform) { + case 'darwin': + return 'macos'; + case 'win32': + return 'windows'; + default: + return platform; + } +} + +export function classifyResolutionError(error: unknown): ResolutionStatus { + const message = error instanceof Error ? error.message : String(error); + if ( + (error instanceof Error && error.name === 'VersionNotFoundError') || + /no matching version|no \w+ release for|not supported|only supported|does not support|not available|could not find|unsupported/i.test( + message + ) + ) { + return 'unavailable'; + } + return 'error'; +} + +/** + * Shares JSON metadata responses between installer instances. Most installers + * fetch a vendor's whole release list for every request, so resolving many + * version/architecture combinations would otherwise refetch identical + * documents and exhaust API rate limits. + */ +function shareJsonResponses( + http: httpm.HttpClient, + cache: Map> +): void { + const getJson = http.getJson.bind(http); + http.getJson = (async (requestUrl: string, additionalHeaders?: object) => { + const key = `${requestUrl}\n${JSON.stringify(additionalHeaders ?? {})}`; + let response = cache.get(key); + if (!response) { + response = getJson(requestUrl, additionalHeaders as never); + cache.set(key, response); + response.catch(() => cache.delete(key)); + } + return structuredClone(await response); + }) as typeof http.getJson; +} + +async function describeFloatingRelease( + http: httpm.HttpClient, + distribution: string, + release: JavaDownloadRelease +): Promise> { + const details: Pick = + {}; + try { + const response = await http.head(release.url); + const lastModified = response.message.headers['last-modified']; + if (lastModified && !Number.isNaN(Date.parse(lastModified))) { + details.publishedAt = new Date(lastModified).toISOString().slice(0, 10); + } + } catch (error) { + core.debug(`HEAD ${release.url} failed: ${error}`); + } + + // Oracle's `/latest/` artifacts carry the NFTC license; only then is the + // release advertised by the Java Releases API the one being served. + if (distribution === JavaDistribution.Oracle) { + try { + const response = await http.getJson<{ + releaseVersion?: string; + licenseDetails?: {licenseType?: string}; + }>(`${ORACLE_RELEASES_URL}/${release.version.split('.')[0]}`); + if ( + response.result?.releaseVersion && + response.result.licenseDetails?.licenseType === 'NFTC' + ) { + details.advertisedVersion = response.result.releaseVersion; + } + } catch (error) { + core.debug(`Oracle Java Releases API lookup failed: ${error}`); + } + } + return details; +} + +async function resolveOne( + distributionName: string, + versionSpec: string, + architecture: string, + cache: Map>, + http: httpm.HttpClient +): Promise { + const base = { + distribution: distributionName, + versionSpec, + platform: getReportPlatform(), + architecture + }; + + let installer: JavaBase | null; + try { + installer = await getJavaDistribution(distributionName, { + version: versionSpec, + architecture, + packageType: PACKAGE_TYPE, + checkLatest: true + }); + } catch (error) { + return { + ...base, + status: 'unsupported', + message: error instanceof Error ? error.message : String(error) + }; + } + if (!installer) { + return {...base, status: 'error', message: 'Unknown distribution'}; + } + + // `findPackageForDownload` is the metadata step `setupJava` runs right + // before downloading; it is protected because the action never needs it on + // its own. + const resolver = installer as unknown as ReleaseResolver; + shareJsonResponses(resolver.http, cache); + try { + const release = await resolver.findPackageForDownload(resolver.version); + return { + ...base, + status: 'resolved', + version: release.version, + ...(release.floating + ? { + floating: true, + ...(await describeFloatingRelease(http, distributionName, release)) + } + : {}) + }; + } catch (error) { + return { + ...base, + status: classifyResolutionError(error), + message: error instanceof Error ? error.message : String(error) + }; + } +} + +async function runWithConcurrency( + tasks: (() => Promise)[], + limit: number +): Promise { + const results: T[] = new Array(tasks.length); + let next = 0; + const worker = async () => { + while (next < tasks.length) { + const index = next++; + results[index] = await tasks[index](); + } + }; + await Promise.all( + Array.from({length: Math.min(limit, tasks.length)}, worker) + ); + return results; +} + +/** LTS majors, the newest feature release, and the `latest` alias. */ +export async function getDefaultVersions( + http: httpm.HttpClient +): Promise { + const versions = [...LTS_VERSIONS]; + try { + const featureRelease = String(await getLatestMajorVersion(http)); + if (!versions.includes(featureRelease)) { + versions.push(featureRelease); + } + } catch (error) { + core.warning( + `Could not determine the newest Java feature release: ${error}` + ); + } + return [...versions, 'latest']; +} + +/** + * Distributions for which vendor metadata matched nothing at all. Missing + * every requested version on every platform signals an unreachable or changed + * metadata source rather than genuinely unavailable releases. + */ +export function findSilentDistributions( + results: VersionResolution[] +): string[] { + const distributions = [...new Set(results.map(r => r.distribution))]; + return distributions.filter(distribution => { + const distributionResults = results.filter( + r => r.distribution === distribution + ); + return ( + !distributionResults.some(r => r.status === 'resolved') && + distributionResults.some(r => r.status === 'unavailable') + ); + }); +} + +export async function resolveLatestVersions(options: { + distributions: string[]; + versions: string[]; + architectures: string[]; +}): Promise { + const http = new RetryingHttpClient('actions/setup-java'); + const tasks = options.distributions.map(distribution => async () => { + // Each distribution resolves sequentially so its shared metadata is + // fetched once and requests to a single vendor API are not bursty. + const cache = new Map>(); + const results: VersionResolution[] = []; + for (const versionSpec of options.versions) { + for (const architecture of options.architectures) { + const result = await resolveOne( + distribution, + versionSpec, + architecture, + cache, + http + ); + core.info( + `${distribution} ${versionSpec} (${result.platform}-${architecture}): ${ + result.status === 'resolved' + ? `${result.version}${result.floating ? ' (floating)' : ''}` + : `${result.status} - ${result.message?.split('\n')[0]}` + }` + ); + results.push(result); + } + } + return results; + }); + + const results = (await runWithConcurrency(tasks, CONCURRENCY)).flat(); + return { + platform: getReportPlatform(), + generatedAt: new Date().toISOString(), + results + }; +} + +function formatResolvedVersion(result: VersionResolution): string { + if (!result.floating) { + return `\`${result.version}\``; + } + return `\`${result.advertisedVersion ?? result.version}\` ¹`; +} + +function formatCell(results: VersionResolution[]): string { + if (results.length === 0) { + return ''; + } + const resolved = results.filter(result => result.status === 'resolved'); + const hasErrors = results.some(result => result.status === 'error'); + if (resolved.length === 0) { + return hasErrors ? '❗ error' : '—'; + } + + const counts = new Map(); + for (const result of resolved) { + const formatted = formatResolvedVersion(result); + counts.set(formatted, (counts.get(formatted) ?? 0) + 1); + } + const versions = [...counts.entries()] + .sort((a, b) => b[1] - a[1]) + .map(([version]) => version); + + let cell = versions.join(' / '); + if (versions.length > 1) { + cell += ' ⚠️'; + } + if (hasErrors) { + cell += ' ❗'; + } + return cell; +} + +interface Problem { + distribution: string; + versionSpec?: string; + platform?: string; + message: string; +} + +function getProblems(results: VersionResolution[]): Problem[] { + return [ + ...findSilentDistributions(results).map(distribution => ({ + distribution, + message: + 'No release matched any requested version on any platform. The vendor metadata may be unreachable or its format may have changed.' + })), + ...results + .filter(r => r.status === 'error') + .map(r => ({ + distribution: r.distribution, + versionSpec: r.versionSpec, + platform: `${r.platform} ${r.architecture}`, + message: r.message?.split('\n')[0] ?? 'Unknown error' + })) + ]; +} + +function escapeTableText(text: string): string { + return text.replace(/\|/g, '\\|').replace(/\r?\n/g, ' '); +} + +function renderTableHeader(firstColumn: string, versionSpecs: string[]) { + return [ + `| ${firstColumn} | ${versionSpecs.map(v => `\`${v}\``).join(' | ')} |`, + `| --- | ${versionSpecs.map(() => '---').join(' | ')} |` + ]; +} + +export function renderMarkdownReport( + reports: ResolutionReport[], + options: {runUrl?: string} = {} +): string { + const results = reports.flatMap(report => report.results); + const distributions = [...new Set(results.map(r => r.distribution))].sort(); + const versionSpecs = [...new Set(results.map(r => r.versionSpec))]; + const platforms = [ + ...new Set(results.map(r => `${r.platform} ${r.architecture}`)) + ].sort(); + const generatedAt = reports + .map(report => report.generatedAt) + .sort() + .at(-1); + + const silentDistributions = findSilentDistributions(results); + + const lines: string[] = ['# Latest JDK versions resolved by setup-java', '']; + lines.push( + `Generated ${generatedAt ? `${generatedAt.replace('T', ' ').slice(0, 16)} UTC` : 'now'} for package type \`${PACKAGE_TYPE}\` on ${platforms.map(p => `\`${p}\``).join(', ')}.` + + (options.runUrl ? ` [Workflow run](${options.runUrl}).` : ''), + '', + 'Each cell shows the exact version `setup-java` resolves from the distribution’s metadata today for the requested `java-version`. That is what a job installs on a tool-cache miss or with `check-latest: true`. No JDK was downloaded to produce this report.', + '' + ); + + lines.push(...renderTableHeader('Distribution', versionSpecs)); + for (const distribution of distributions) { + const cells = versionSpecs.map(versionSpec => + formatCell( + results.filter( + r => r.distribution === distribution && r.versionSpec === versionSpec + ) + ) + ); + const marker = silentDistributions.includes(distribution) ? ' ❗' : ''; + lines.push(`| \`${distribution}\`${marker} | ${cells.join(' | ')} |`); + } + lines.push( + '', + '— not offered for this version or platform · ⚠️ differs by platform (see details) · ❗ needs attention (see below)', + '', + '¹ Major-only requests download the vendor’s mutable `/latest/` artifact, so the exact version is only known after download. The vendor-advertised release is shown when available.', + '' + ); + + lines.push('## Details by platform', ''); + for (const distribution of distributions) { + const distributionResults = results.filter( + r => r.distribution === distribution + ); + const needsAttention = + silentDistributions.includes(distribution) || + versionSpecs.some(versionSpec => + /[⚠❗]/u.test( + formatCell( + distributionResults.filter(r => r.versionSpec === versionSpec) + ) + ) + ); + lines.push( + `${distribution}${needsAttention ? ' ⚠️' : ''}`, + '', + ...renderTableHeader('Platform', versionSpecs) + ); + for (const platform of platforms) { + const cells = versionSpecs.map(versionSpec => { + const result = distributionResults.find( + r => + r.versionSpec === versionSpec && + `${r.platform} ${r.architecture}` === platform + ); + if (!result) { + return ''; + } + if (result.status === 'resolved') { + return ( + formatResolvedVersion(result) + + (result.publishedAt ? ` (published ${result.publishedAt})` : '') + ); + } + return result.status === 'error' ? '❗ error' : '—'; + }); + lines.push(`| ${platform} | ${cells.join(' | ')} |`); + } + lines.push('', '
', ''); + } + + const problems = getProblems(results); + if (problems.length > 0) { + lines.push( + '## Needs attention', + '', + '| Distribution | Version | Platform | Problem |', + '| --- | --- | --- | --- |' + ); + for (const problem of problems) { + lines.push( + `| \`${problem.distribution}\` | ${problem.versionSpec ? `\`${problem.versionSpec}\`` : 'all'} | ${problem.platform ?? 'all'} | ${escapeTableText(problem.message)} |` + ); + } + lines.push(''); + } + + return lines.join('\n'); +} + +function parseList(value: string | undefined, fallback: string[]): string[] { + const items = (value ?? '') + .split(/[,\s]+/) + .map(item => item.trim()) + .filter(Boolean); + return items.length > 0 ? items : fallback; +} + +function readReports(inputDir: string): ResolutionReport[] { + return fs + .readdirSync(inputDir, {recursive: true, encoding: 'utf8'}) + .filter(file => file.endsWith('.json')) + .sort() + .map( + file => + JSON.parse( + fs.readFileSync(path.join(inputDir, file), 'utf8') + ) as ResolutionReport + ); +} + +export async function run(args: string[]): Promise { + const [command, target, markdownOutput] = args; + if (command === 'resolve' && target) { + const versions = parseList(process.env.REPORT_VERSIONS, []); + const report = await resolveLatestVersions({ + distributions: parseList( + process.env.REPORT_DISTRIBUTIONS, + REPORTED_DISTRIBUTIONS + ), + versions: + versions.length > 0 + ? versions + : await getDefaultVersions( + new RetryingHttpClient('actions/setup-java') + ), + architectures: parseList( + process.env.REPORT_ARCHITECTURES, + DEFAULT_ARCHITECTURES + ) + }); + fs.mkdirSync(path.dirname(path.resolve(target)), {recursive: true}); + fs.writeFileSync(target, JSON.stringify(report, null, 2)); + return; + } + + if (command === 'summarize' && target) { + const reports = readReports(target); + if (reports.length === 0) { + throw new Error(`No resolution reports found in '${target}'.`); + } + const {GITHUB_SERVER_URL, GITHUB_REPOSITORY, GITHUB_RUN_ID} = process.env; + const runUrl = + GITHUB_SERVER_URL && GITHUB_REPOSITORY && GITHUB_RUN_ID + ? `${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}` + : undefined; + const markdown = renderMarkdownReport(reports, {runUrl}); + if (markdownOutput) { + fs.writeFileSync(markdownOutput, markdown); + } + if (process.env.GITHUB_STEP_SUMMARY) { + await core.summary.addRaw(markdown).write(); + } else { + core.info(markdown); + } + + for (const problem of getProblems( + reports.flatMap(report => report.results) + )) { + const scope = [problem.versionSpec, problem.platform] + .filter(Boolean) + .join(', '); + core.warning( + `${problem.distribution}${scope ? ` (${scope})` : ''}: ${problem.message}` + ); + } + return; + } + + throw new Error( + 'Usage: resolve | summarize [output.md]' + ); +} + +if (isMainModule(import.meta.url)) { + run(process.argv.slice(2)).catch(error => { + core.setFailed(error instanceof Error ? error.message : String(error)); + }); +} From d08bc08d79d55d6fe53bf032ea527b3a48397903 Mon Sep 17 00:00:00 2001 From: Bruno Borges Date: Wed, 18 Nov 2026 15:21:40 -0800 Subject: [PATCH 2/3] 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: Copilot App <223556219+Copilot@users.noreply.github.com> --- .github/workflows/latest-jdk-versions.yml | 37 ++- README.md | 2 +- __tests__/latest-versions-report.test.ts | 118 ++++--- src/reports/latest-versions.ts | 357 ++++++++++++++-------- 4 files changed, 336 insertions(+), 178 deletions(-) diff --git a/.github/workflows/latest-jdk-versions.yml b/.github/workflows/latest-jdk-versions.yml index f97accccb..494c4bdcd 100644 --- a/.github/workflows/latest-jdk-versions.yml +++ b/.github/workflows/latest-jdk-versions.yml @@ -1,6 +1,7 @@ # Daily report of the exact JDK version each distribution currently resolves -# for LTS majors, the newest feature release, and `latest`. Versions are -# resolved from vendor metadata only; no JDK is downloaded. +# for LTS majors, the newest feature 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: @@ -57,6 +58,7 @@ jobs: name: Resolve versions (${{ matrix.os }}) needs: build runs-on: ${{ matrix.os }} + timeout-minutes: 30 strategy: fail-fast: false matrix: @@ -83,9 +85,38 @@ jobs: 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] + needs: [build, resolve, resolve-alpine] if: ${{ !cancelled() && needs.build.result == 'success' }} runs-on: ubuntu-latest steps: diff --git a/README.md b/README.md index ea2cf40d4..457013116 100644 --- a/README.md +++ b/README.md @@ -246,7 +246,7 @@ 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 each LTS major, the newest feature release, and `latest`, on Linux, macOS, and Windows for `x64` and `aarch64`. The report doesn't download any JDKs. It shows what a job installs on a tool-cache miss or with `check-latest: true`. +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 each LTS major, the newest feature release, and `latest`, on every operating system and architecture the action supports for that distribution, including Alpine Linux. Because vendors publish builds per platform, the same request can resolve to different versions on different platforms. The report doesn't download any JDKs. It shows what a job installs on a tool-cache miss or with `check-latest: true`. ## Download integrity and signatures diff --git a/__tests__/latest-versions-report.test.ts b/__tests__/latest-versions-report.test.ts index 2793916ab..52762ad73 100644 --- a/__tests__/latest-versions-report.test.ts +++ b/__tests__/latest-versions-report.test.ts @@ -1,6 +1,7 @@ import {describe, expect, it} from '@jest/globals'; import { classifyResolutionError, + getSupportedArchitectures, renderMarkdownReport, ResolutionReport, VersionResolution @@ -18,14 +19,16 @@ function result( }; } -function report(results: VersionResolution[]): ResolutionReport { - return {platform: 'linux', generatedAt: '2026-11-18T06:30:00.000Z', results}; +function report( + platform: string, + results: VersionResolution[] +): ResolutionReport { + return {platform, generatedAt: '2026-11-18T06:30:00.000Z', results}; } -function overviewRow(markdown: string, distribution: string): string { - return markdown - .split('\n') - .find(line => line.startsWith(`| \`${distribution}\``))!; +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', () => { @@ -49,38 +52,81 @@ describe('latest versions report', () => { expect(classifyResolutionError(new Error('socket hang up'))).toBe('error'); }); - it('shows one version when every platform agrees and flags differences', () => { + 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([ - result({distribution: 'zulu', versionSpec: '21', version: '21.0.9'}), + report('macos', [ result({ - distribution: 'zulu', + distribution: 'temurin', versionSpec: '21', + platform: 'macos', architecture: 'aarch64', - version: '21.0.9' + 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.9'}), result({ distribution: 'temurin', versionSpec: '21', - architecture: 'aarch64', - version: '21.0.8' + version: '21.0.13+9' + }) + ]), + report('linux-musl', [ + result({ + distribution: 'temurin', + versionSpec: '21', + platform: 'linux-musl', + version: '21.0.13+9' }) ]) ]); - expect(overviewRow(markdown, 'zulu')).toBe('| `zulu` | `21.0.9` |'); - expect(overviewRow(markdown, 'temurin')).toBe( - '| `temurin` | `21.0.9` / `21.0.8` ⚠️ |' - ); + 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( - '
temurin ⚠️' + 'Not checked, because no runner reported these platforms: Windows (x64, x86, aarch64).' ); }); - it('marks floating releases and prefers the vendor-advertised version', () => { + it('distinguishes unsupported, unpublished, and floating releases', () => { const markdown = renderMarkdownReport([ - report([ + 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', @@ -92,25 +138,22 @@ describe('latest versions report', () => { ]) ]); - expect(overviewRow(markdown, 'oracle')).toBe('| `oracle` | `25.0.5.1` ¹ |'); - expect(markdown).toContain('`25.0.5.1` ¹ (published 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([ + report('linux', [ result({ distribution: 'oracle-openjdk', versionSpec: '25', - status: 'unavailable', - message: "No matching version found for SemVer '25'." - }), - result({ - distribution: 'redhat', - versionSpec: '25', - platform: 'macos', - status: 'unsupported', - message: "Distribution 'redhat' does not support operating system" + status: 'unavailable' }), result({ distribution: 'zulu', @@ -121,16 +164,13 @@ describe('latest versions report', () => { ]) ]); - expect(overviewRow(markdown, 'oracle-openjdk')).toBe( - '| `oracle-openjdk` ❗ | — |' - ); - expect(overviewRow(markdown, 'redhat')).toBe('| `redhat` | — |'); - expect(overviewRow(markdown, 'zulu')).toBe('| `zulu` | ❗ error |'); + 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 |' + '| `zulu` | `25` | Linux x64 | socket hang up |' ); }); }); diff --git a/src/reports/latest-versions.ts b/src/reports/latest-versions.ts index e8d825dee..d76fa3606 100644 --- a/src/reports/latest-versions.ts +++ b/src/reports/latest-versions.ts @@ -6,6 +6,12 @@ import {getJavaDistribution} from '../distributions/distribution-factory.js'; import type {JavaBase} from '../distributions/base-installer.js'; import type {JavaDownloadRelease} from '../distributions/base-models.js'; import {JavaDistribution} from '../distributions/package-types.js'; +import { + isAlpineLinux, + JAVA_PLATFORM_CAPABILITIES, + JavaPlatform, + normalizePlatform +} from '../distributions/platform-types.js'; import {isMainModule} from '../is-main-module.js'; import {RetryingHttpClient} from '../retrying-http-client.js'; import {getLatestMajorVersion} from '../util.js'; @@ -17,7 +23,6 @@ import {getLatestMajorVersion} from '../util.js'; */ export const LTS_VERSIONS = ['8', '11', '17', '21', '25']; -export const DEFAULT_ARCHITECTURES = ['x64', 'aarch64']; export const REPORTED_DISTRIBUTIONS: string[] = Object.values( JavaDistribution ).filter(distribution => distribution !== JavaDistribution.JdkFile); @@ -25,6 +30,25 @@ export const REPORTED_DISTRIBUTIONS: string[] = Object.values( const PACKAGE_TYPE = 'jdk'; const CONCURRENCY = 6; const ORACLE_RELEASES_URL = 'https://java.oraclecloud.com/currentJavaReleases'; +const MUSL_PLATFORM = 'linux-musl'; +const PLATFORM_LABELS: Record = { + linux: 'Linux', + [MUSL_PLATFORM]: 'Alpine Linux', + macos: 'macOS', + windows: 'Windows', + solaris: 'Solaris' +}; +const PLATFORM_ORDER = Object.keys(PLATFORM_LABELS); +const ARCHITECTURE_ORDER = [ + 'x64', + 'aarch64', + 'x86', + 'armv7', + 'ppc64le', + 'ppc64', + 'riscv64', + 's390x' +]; /** * - `unsupported`: excluded by the action's package/platform capability maps. @@ -62,24 +86,45 @@ interface ReleaseResolver { findPackageForDownload(range: string): Promise; } +/** Alpine is reported separately because installers pick musl builds there. */ export function getReportPlatform( - platform: NodeJS.Platform = process.platform + platform: NodeJS.Platform = process.platform, + alpine = isAlpineLinux(platform) ): string { - switch (platform) { - case 'darwin': - return 'macos'; - case 'win32': - return 'windows'; - default: - return platform; + if (alpine) { + return MUSL_PLATFORM; } + return normalizePlatform(platform) ?? platform; +} + +/** + * Architectures `setup-java` supports for a distribution on a report + * platform, including ones restricted to some Java versions. + */ +export function getSupportedArchitectures( + distribution: string, + platform: string +): string[] { + const capability = + JAVA_PLATFORM_CAPABILITIES[distribution as JavaDistribution]; + if (!capability || capability.unrestricted) { + return []; + } + const os = (platform === MUSL_PLATFORM ? 'linux' : platform) as JavaPlatform; + return [ + ...new Set( + (capability.platforms[os] ?? []).map(item => + typeof item === 'string' ? item : item.architecture + ) + ) + ]; } export function classifyResolutionError(error: unknown): ResolutionStatus { const message = error instanceof Error ? error.message : String(error); if ( (error instanceof Error && error.name === 'VersionNotFoundError') || - /no matching version|no \w+ release for|not supported|only supported|does not support|not available|could not find|unsupported/i.test( + /no matching version|no \w+ release for|could not determine the latest available|not supported|only supported|does not support|not available|could not find|unsupported/i.test( message ) ) { @@ -89,26 +134,41 @@ export function classifyResolutionError(error: unknown): ResolutionStatus { } /** - * Shares JSON metadata responses between installer instances. Most installers - * fetch a vendor's whole release list for every request, so resolving many - * version/architecture combinations would otherwise refetch identical - * documents and exhaust API rate limits. + * Shares metadata responses between installer instances. Most installers + * fetch a vendor's whole release list for every request, and JetBrains probes + * each release URL with HEAD, so resolving many version/architecture + * combinations would otherwise repeat identical requests and exhaust API rate + * limits. Installers only read the status and headers of HEAD responses. */ -function shareJsonResponses( +function shareMetadataResponses( http: httpm.HttpClient, cache: Map> ): void { - const getJson = http.getJson.bind(http); - http.getJson = (async (requestUrl: string, additionalHeaders?: object) => { - const key = `${requestUrl}\n${JSON.stringify(additionalHeaders ?? {})}`; - let response = cache.get(key); + const share = (key: string, request: () => Promise): Promise => { + let response = cache.get(key) as Promise | undefined; if (!response) { - response = getJson(requestUrl, additionalHeaders as never); + response = request(); cache.set(key, response); response.catch(() => cache.delete(key)); } - return structuredClone(await response); - }) as typeof http.getJson; + return response; + }; + + const getJson = http.getJson.bind(http); + http.getJson = (async (requestUrl: string, additionalHeaders?: object) => + structuredClone( + await share( + `GET ${requestUrl}\n${JSON.stringify(additionalHeaders ?? {})}`, + () => getJson(requestUrl, additionalHeaders as never) + ) + )) as typeof http.getJson; + + const head = http.head.bind(http); + http.head = (requestUrl, additionalHeaders) => + share( + `HEAD ${requestUrl}\n${JSON.stringify(additionalHeaders ?? {})}`, + () => head(requestUrl, additionalHeaders) + ); } async function describeFloatingRelease( @@ -152,6 +212,7 @@ async function describeFloatingRelease( async function resolveOne( distributionName: string, versionSpec: string, + platform: string, architecture: string, cache: Map>, http: httpm.HttpClient @@ -159,7 +220,7 @@ async function resolveOne( const base = { distribution: distributionName, versionSpec, - platform: getReportPlatform(), + platform, architecture }; @@ -186,7 +247,7 @@ async function resolveOne( // before downloading; it is protected because the action never needs it on // its own. const resolver = installer as unknown as ReleaseResolver; - shareJsonResponses(resolver.http, cache); + shareMetadataResponses(resolver.http, cache); try { const release = await resolver.findPackageForDownload(resolver.version); return { @@ -268,25 +329,37 @@ export function findSilentDistributions( export async function resolveLatestVersions(options: { distributions: string[]; versions: string[]; - architectures: string[]; + /** Restricts the architectures; defaults to all supported ones. */ + architectures?: string[]; }): Promise { const http = new RetryingHttpClient('actions/setup-java'); + const platform = getReportPlatform(); const tasks = options.distributions.map(distribution => async () => { + const architectures = getSupportedArchitectures( + distribution, + platform + ).filter( + architecture => + !options.architectures?.length || + options.architectures.includes(architecture) + ); // Each distribution resolves sequentially so its shared metadata is // fetched once and requests to a single vendor API are not bursty. const cache = new Map>(); const results: VersionResolution[] = []; + const startedAt = Date.now(); for (const versionSpec of options.versions) { - for (const architecture of options.architectures) { + for (const architecture of architectures) { const result = await resolveOne( distribution, versionSpec, + platform, architecture, cache, http ); core.info( - `${distribution} ${versionSpec} (${result.platform}-${architecture}): ${ + `${distribution} ${versionSpec} (${formatPlatform(result)}): ${ result.status === 'resolved' ? `${result.version}${result.floating ? ' (floating)' : ''}` : `${result.status} - ${result.message?.split('\n')[0]}` @@ -295,51 +368,62 @@ export async function resolveLatestVersions(options: { results.push(result); } } + core.info( + `${distribution}: ${results.length} lookups in ${Math.round((Date.now() - startedAt) / 1000)}s` + ); return results; }); const results = (await runWithConcurrency(tasks, CONCURRENCY)).flat(); return { - platform: getReportPlatform(), + platform, generatedAt: new Date().toISOString(), results }; } -function formatResolvedVersion(result: VersionResolution): string { - if (!result.floating) { - return `\`${result.version}\``; - } - return `\`${result.advertisedVersion ?? result.version}\` ¹`; +function formatPlatform( + result: Pick +): string { + return `${PLATFORM_LABELS[result.platform] ?? result.platform} ${result.architecture}`; } -function formatCell(results: VersionResolution[]): string { - if (results.length === 0) { - return ''; - } - const resolved = results.filter(result => result.status === 'resolved'); - const hasErrors = results.some(result => result.status === 'error'); - if (resolved.length === 0) { - return hasErrors ? '❗ error' : '—'; - } - - const counts = new Map(); - for (const result of resolved) { - const formatted = formatResolvedVersion(result); - counts.set(formatted, (counts.get(formatted) ?? 0) + 1); - } - const versions = [...counts.entries()] - .sort((a, b) => b[1] - a[1]) - .map(([version]) => version); +function comparePlatforms( + a: Pick, + b: Pick +): number { + const rank = (order: string[], value: string) => { + const index = order.indexOf(value); + return index === -1 ? order.length : index; + }; + return ( + rank(PLATFORM_ORDER, a.platform) - rank(PLATFORM_ORDER, b.platform) || + a.platform.localeCompare(b.platform) || + rank(ARCHITECTURE_ORDER, a.architecture) - + rank(ARCHITECTURE_ORDER, b.architecture) || + a.architecture.localeCompare(b.architecture) + ); +} - let cell = versions.join(' / '); - if (versions.length > 1) { - cell += ' ⚠️'; - } - if (hasErrors) { - cell += ' ❗'; +function formatCell(result: VersionResolution | undefined): string { + switch (result?.status) { + case undefined: + return ''; + case 'resolved': + if (!result.floating) { + return `\`${result.version}\``; + } + return ( + `\`${result.advertisedVersion ?? result.version}\` ¹` + + (result.publishedAt ? ` (published ${result.publishedAt})` : '') + ); + case 'unavailable': + return '—'; + case 'unsupported': + return 'n/a'; + case 'error': + return '❗ error'; } - return cell; } interface Problem { @@ -361,21 +445,32 @@ function getProblems(results: VersionResolution[]): Problem[] { .map(r => ({ distribution: r.distribution, versionSpec: r.versionSpec, - platform: `${r.platform} ${r.architecture}`, + platform: formatPlatform(r), message: r.message?.split('\n')[0] ?? 'Unknown error' })) ]; } -function escapeTableText(text: string): string { - return text.replace(/\|/g, '\\|').replace(/\r?\n/g, ' '); +/** Supported operating systems for which no runner produced a report. */ +function getUncheckedPlatforms( + distribution: string, + reportedPlatforms: Set +): string[] { + const capability = + JAVA_PLATFORM_CAPABILITIES[distribution as JavaDistribution]; + if (!capability || capability.unrestricted) { + return []; + } + return Object.keys(capability.platforms) + .filter(platform => !reportedPlatforms.has(platform)) + .map( + platform => + `${PLATFORM_LABELS[platform] ?? platform} (${getSupportedArchitectures(distribution, platform).join(', ')})` + ); } -function renderTableHeader(firstColumn: string, versionSpecs: string[]) { - return [ - `| ${firstColumn} | ${versionSpecs.map(v => `\`${v}\``).join(' | ')} |`, - `| --- | ${versionSpecs.map(() => '---').join(' | ')} |` - ]; +function escapeTableText(text: string): string { + return text.replace(/\|/g, '\\|').replace(/\r?\n/g, ' '); } export function renderMarkdownReport( @@ -385,101 +480,96 @@ export function renderMarkdownReport( const results = reports.flatMap(report => report.results); const distributions = [...new Set(results.map(r => r.distribution))].sort(); const versionSpecs = [...new Set(results.map(r => r.versionSpec))]; - const platforms = [ - ...new Set(results.map(r => `${r.platform} ${r.architecture}`)) - ].sort(); + const reportedPlatforms = new Set(reports.map(report => report.platform)); const generatedAt = reports .map(report => report.generatedAt) .sort() .at(-1); - const silentDistributions = findSilentDistributions(results); const lines: string[] = ['# Latest JDK versions resolved by setup-java', '']; lines.push( - `Generated ${generatedAt ? `${generatedAt.replace('T', ' ').slice(0, 16)} UTC` : 'now'} for package type \`${PACKAGE_TYPE}\` on ${platforms.map(p => `\`${p}\``).join(', ')}.` + + `Generated ${generatedAt ? `${generatedAt.replace('T', ' ').slice(0, 16)} UTC` : 'now'} for package type \`${PACKAGE_TYPE}\` on ${PLATFORM_ORDER.filter( + p => reportedPlatforms.has(p) + ) + .map(p => PLATFORM_LABELS[p]) + .join(', ')}.` + (options.runUrl ? ` [Workflow run](${options.runUrl}).` : ''), '', - 'Each cell shows the exact version `setup-java` resolves from the distribution’s metadata today for the requested `java-version`. That is what a job installs on a tool-cache miss or with `check-latest: true`. No JDK was downloaded to produce this report.', + 'For each distribution, the table lists every operating system and architecture `setup-java` supports and the exact version it resolves from the distribution’s metadata today for each `java-version`. That is what a job installs on a tool-cache miss or with `check-latest: true`. Vendors publish builds per platform, so the same request can resolve to different versions on different platforms. No JDK was downloaded to produce this report.', + '', + '`—` no matching release is published for this platform · `n/a` `setup-java` does not support this version on this platform · ❗ the lookup failed', '' ); - lines.push(...renderTableHeader('Distribution', versionSpecs)); - for (const distribution of distributions) { - const cells = versionSpecs.map(versionSpec => - formatCell( - results.filter( - r => r.distribution === distribution && r.versionSpec === versionSpec - ) - ) + const problems = getProblems(results); + if (problems.length > 0) { + lines.push( + '## Needs attention', + '', + '| Distribution | Version | Platform | Problem |', + '| --- | --- | --- | --- |' ); - const marker = silentDistributions.includes(distribution) ? ' ❗' : ''; - lines.push(`| \`${distribution}\`${marker} | ${cells.join(' | ')} |`); + for (const problem of problems) { + lines.push( + `| \`${problem.distribution}\` | ${problem.versionSpec ? `\`${problem.versionSpec}\`` : 'all'} | ${problem.platform ?? 'all'} | ${escapeTableText(problem.message)} |` + ); + } + lines.push(''); } - lines.push( - '', - '— not offered for this version or platform · ⚠️ differs by platform (see details) · ❗ needs attention (see below)', - '', - '¹ Major-only requests download the vendor’s mutable `/latest/` artifact, so the exact version is only known after download. The vendor-advertised release is shown when available.', - '' - ); - lines.push('## Details by platform', ''); for (const distribution of distributions) { const distributionResults = results.filter( r => r.distribution === distribution ); - const needsAttention = - silentDistributions.includes(distribution) || - versionSpecs.some(versionSpec => - /[⚠❗]/u.test( - formatCell( - distributionResults.filter(r => r.versionSpec === versionSpec) - ) - ) - ); + const platforms = distributionResults + .filter( + (result, index) => + distributionResults.findIndex( + other => + other.platform === result.platform && + other.architecture === result.architecture + ) === index + ) + .sort(comparePlatforms); + lines.push( - `${distribution}${needsAttention ? ' ⚠️' : ''}`, + `## \`${distribution}\`${silentDistributions.includes(distribution) ? ' ❗' : ''}`, '', - ...renderTableHeader('Platform', versionSpecs) + `| Platform | ${versionSpecs.map(v => `\`${v}\``).join(' | ')} |`, + `| --- | ${versionSpecs.map(() => '---').join(' | ')} |` ); for (const platform of platforms) { - const cells = versionSpecs.map(versionSpec => { - const result = distributionResults.find( - r => - r.versionSpec === versionSpec && - `${r.platform} ${r.architecture}` === platform - ); - if (!result) { - return ''; - } - if (result.status === 'resolved') { - return ( - formatResolvedVersion(result) + - (result.publishedAt ? ` (published ${result.publishedAt})` : '') - ); - } - return result.status === 'error' ? '❗ error' : '—'; - }); - lines.push(`| ${platform} | ${cells.join(' | ')} |`); + const cells = versionSpecs.map(versionSpec => + formatCell( + distributionResults.find( + r => + r.versionSpec === versionSpec && + r.platform === platform.platform && + r.architecture === platform.architecture + ) + ) + ); + lines.push(`| ${formatPlatform(platform)} | ${cells.join(' | ')} |`); + } + lines.push(''); + + const unchecked = getUncheckedPlatforms(distribution, reportedPlatforms); + if (unchecked.length > 0) { + lines.push( + `Not checked, because no runner reported these platforms: ${unchecked.join(', ')}.`, + '' + ); } - lines.push('', '
', ''); } - const problems = getProblems(results); - if (problems.length > 0) { + if (results.some(r => r.status === 'resolved' && r.floating)) { lines.push( - '## Needs attention', + '---', '', - '| Distribution | Version | Platform | Problem |', - '| --- | --- | --- | --- |' + '¹ Major-only requests download the vendor’s mutable `/latest/` artifact, so the exact version is only known after download. The version the vendor advertises is shown when available.', + '' ); - for (const problem of problems) { - lines.push( - `| \`${problem.distribution}\` | ${problem.versionSpec ? `\`${problem.versionSpec}\`` : 'all'} | ${problem.platform ?? 'all'} | ${escapeTableText(problem.message)} |` - ); - } - lines.push(''); } return lines.join('\n'); @@ -521,10 +611,7 @@ export async function run(args: string[]): Promise { : await getDefaultVersions( new RetryingHttpClient('actions/setup-java') ), - architectures: parseList( - process.env.REPORT_ARCHITECTURES, - DEFAULT_ARCHITECTURES - ) + architectures: parseList(process.env.REPORT_ARCHITECTURES, []) }); fs.mkdirSync(path.dirname(path.resolve(target)), {recursive: true}); fs.writeFileSync(target, JSON.stringify(report, null, 2)); From 7383ddfd9f21d42ddd7c953ac522619b68596189 Mon Sep 17 00:00:00 2001 From: Bruno Borges Date: Wed, 18 Nov 2026 15:31:19 -0800 Subject: [PATCH 3/3] 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: Copilot App <223556219+Copilot@users.noreply.github.com> --- .github/workflows/latest-jdk-versions.yml | 22 ++- README.md | 2 +- __tests__/latest-versions-report.test.ts | 187 +++++++++++++++++++++- src/distributions/liberica/installer.ts | 2 +- src/reports/latest-versions.ts | 74 +++++++-- 5 files changed, 261 insertions(+), 26 deletions(-) diff --git a/.github/workflows/latest-jdk-versions.yml b/.github/workflows/latest-jdk-versions.yml index 494c4bdcd..eb140c5ea 100644 --- a/.github/workflows/latest-jdk-versions.yml +++ b/.github/workflows/latest-jdk-versions.yml @@ -1,5 +1,5 @@ # Daily report of the exact JDK version each distribution currently resolves -# for LTS majors, the newest feature release, and `latest`, on every operating +# 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 @@ -10,7 +10,7 @@ on: workflow_dispatch: inputs: java-versions: - description: 'Comma-separated java-version values to resolve (default: LTS majors, newest feature release, and latest)' + description: 'Comma-separated java-version values (default: every major from Java 6 through the newest GA release, and latest)' required: false default: '' pull_request: @@ -55,14 +55,23 @@ jobs: retention-days: 1 resolve: - name: Resolve versions (${{ matrix.os }}) + name: Resolve versions (${{ matrix.platform }}) needs: build runs-on: ${{ matrix.os }} timeout-minutes: 30 strategy: fail-fast: false matrix: - os: [ubuntu-latest, macos-latest, windows-latest] + 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 @@ -74,14 +83,15 @@ jobs: name: latest-versions-report-tool path: tool - name: Resolve latest versions without downloading - run: node tool/index.js resolve "results/$RUNNER_OS.json" + 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.os }} + name: latest-jdk-versions-${{ matrix.platform }} path: results/ retention-days: 1 diff --git a/README.md b/README.md index 457013116..ea57bc807 100644 --- a/README.md +++ b/README.md @@ -246,7 +246,7 @@ 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 each LTS major, the newest feature release, and `latest`, on every operating system and architecture the action supports for that distribution, including Alpine Linux. Because vendors publish builds per platform, the same request can resolve to different versions on different platforms. The report doesn't download any JDKs. It shows what a job installs on a tool-cache miss or with `check-latest: true`. +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 diff --git a/__tests__/latest-versions-report.test.ts b/__tests__/latest-versions-report.test.ts index 52762ad73..1f2cba123 100644 --- a/__tests__/latest-versions-report.test.ts +++ b/__tests__/latest-versions-report.test.ts @@ -1,9 +1,13 @@ -import {describe, expect, it} from '@jest/globals'; +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'; @@ -32,6 +36,187 @@ function tableRows(markdown: string, distribution: string): string[] { } 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'; diff --git a/src/distributions/liberica/installer.ts b/src/distributions/liberica/installer.ts index 461850028..ad56c565c 100644 --- a/src/distributions/liberica/installer.ts +++ b/src/distributions/liberica/installer.ts @@ -203,7 +203,7 @@ export class LibericaDistributions extends JavaBase { } } - private getPlatformOption( + protected getPlatformOption( platform: NodeJS.Platform = process.platform ): OsVersions { switch (platform) { diff --git a/src/reports/latest-versions.ts b/src/reports/latest-versions.ts index d76fa3606..40fc7a6ce 100644 --- a/src/reports/latest-versions.ts +++ b/src/reports/latest-versions.ts @@ -5,12 +5,14 @@ import path from 'path'; import {getJavaDistribution} from '../distributions/distribution-factory.js'; import type {JavaBase} from '../distributions/base-installer.js'; import type {JavaDownloadRelease} from '../distributions/base-models.js'; +import {LibericaDistributions} from '../distributions/liberica/installer.js'; import {JavaDistribution} from '../distributions/package-types.js'; import { isAlpineLinux, JAVA_PLATFORM_CAPABILITIES, JavaPlatform, - normalizePlatform + normalizePlatform, + validateJavaPlatform } from '../distributions/platform-types.js'; import {isMainModule} from '../is-main-module.js'; import {RetryingHttpClient} from '../retrying-http-client.js'; @@ -22,7 +24,8 @@ import {getLatestMajorVersion} from '../util.js'; * downloaded: resolution stops where `setup-java` would start the download. */ -export const LTS_VERSIONS = ['8', '11', '17', '21', '25']; +// Zulu's supported JDK catalog starts at Java 6, including non-LTS releases. +const FIRST_MAJOR_VERSION = 6; export const REPORTED_DISTRIBUTIONS: string[] = Object.values( JavaDistribution ).filter(distribution => distribution !== JavaDistribution.JdkFile); @@ -86,6 +89,13 @@ interface ReleaseResolver { findPackageForDownload(range: string): Promise; } +// Metadata resolution does not require a Solaris runner or executing its JDK. +class SolarisLibericaDistribution extends LibericaDistributions { + protected override getPlatformOption() { + return super.getPlatformOption('sunos'); + } +} + /** Alpine is reported separately because installers pick musl builds there. */ export function getReportPlatform( platform: NodeJS.Platform = process.platform, @@ -226,12 +236,30 @@ async function resolveOne( let installer: JavaBase | null; try { - installer = await getJavaDistribution(distributionName, { + const installerOptions = { version: versionSpec, architecture, packageType: PACKAGE_TYPE, checkLatest: true - }); + }; + if (platform === 'solaris') { + if (distributionName !== JavaDistribution.Liberica) { + return { + ...base, + status: 'error', + message: `No Solaris metadata resolver for '${distributionName}'.` + }; + } + validateJavaPlatform( + distributionName, + 'sunos', + architecture, + versionSpec + ); + installer = new SolarisLibericaDistribution(installerOptions); + } else { + installer = await getJavaDistribution(distributionName, installerOptions); + } } catch (error) { return { ...base, @@ -288,21 +316,20 @@ async function runWithConcurrency( return results; } -/** LTS majors, the newest feature release, and the `latest` alias. */ +/** Every supported stable major through the newest GA release, plus `latest`. */ export async function getDefaultVersions( http: httpm.HttpClient ): Promise { - const versions = [...LTS_VERSIONS]; - try { - const featureRelease = String(await getLatestMajorVersion(http)); - if (!versions.includes(featureRelease)) { - versions.push(featureRelease); - } - } catch (error) { - core.warning( - `Could not determine the newest Java feature release: ${error}` + const latestMajor = await getLatestMajorVersion(http); + if (!Number.isSafeInteger(latestMajor) || latestMajor < FIRST_MAJOR_VERSION) { + throw new Error( + `Invalid newest Java feature release in vendor metadata: ${latestMajor}` ); } + const versions = Array.from( + {length: latestMajor - FIRST_MAJOR_VERSION + 1}, + (_, index) => String(FIRST_MAJOR_VERSION + index) + ); return [...versions, 'latest']; } @@ -331,9 +358,17 @@ export async function resolveLatestVersions(options: { versions: string[]; /** Restricts the architectures; defaults to all supported ones. */ architectures?: string[]; + /** Solaris metadata can be resolved on any host; other targets use the host. */ + platform?: string; }): Promise { const http = new RetryingHttpClient('actions/setup-java'); - const platform = getReportPlatform(); + const hostPlatform = getReportPlatform(); + const platform = options.platform || hostPlatform; + if (platform !== hostPlatform && platform !== 'solaris') { + throw new Error( + `Cannot resolve '${platform}' metadata on '${hostPlatform}'; use a matching runner.` + ); + } const tasks = options.distributions.map(distribution => async () => { const architectures = getSupportedArchitectures( distribution, @@ -461,7 +496,11 @@ function getUncheckedPlatforms( if (!capability || capability.unrestricted) { return []; } - return Object.keys(capability.platforms) + const platforms = Object.keys(capability.platforms); + if (platforms.includes('linux')) { + platforms.push(MUSL_PLATFORM); + } + return platforms .filter(platform => !reportedPlatforms.has(platform)) .map( platform => @@ -611,7 +650,8 @@ export async function run(args: string[]): Promise { : await getDefaultVersions( new RetryingHttpClient('actions/setup-java') ), - architectures: parseList(process.env.REPORT_ARCHITECTURES, []) + architectures: parseList(process.env.REPORT_ARCHITECTURES, []), + platform: process.env.REPORT_PLATFORM }); fs.mkdirSync(path.dirname(path.resolve(target)), {recursive: true}); fs.writeFileSync(target, JSON.stringify(report, null, 2));