Skip to content

fix: select musl JDK artifacts on Alpine for Dragonwell, Corretto, Zulu and Liberica - #1220

Merged
brunoborges merged 2 commits into
actions:mainfrom
brunoborges:brunoborges-alpine-artifact-selection
Aug 5, 2026
Merged

fix: select musl JDK artifacts on Alpine for Dragonwell, Corretto, Zulu and Liberica#1220
brunoborges merged 2 commits into
actions:mainfrom
brunoborges:brunoborges-alpine-artifact-selection

Conversation

@brunoborges

@brunoborges brunoborges commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Problem

On Alpine Linux, five distributions resolve the glibc artifact and install a JDK that cannot run under musl. getPlatformOption() maps process.platform === 'linux' to the vendor's glibc platform key with no libc check.

Temurin and SapMachine already probe /etc/alpine-release and select their musl artifacts. The remaining distributions do not.

This was found while reviewing #1209 / #1210. It is a separate, pre-existing bug: #1210 makes the resolution cache distinguish glibc from musl, which is necessary but not sufficient — these five distributions resolve the wrong artifact whether or not the cache is involved.

Change

Adds a shared isAlpineLinux() helper in src/distributions/platform-types.ts and uses it in each affected getPlatformOption().

distribution glibc key musl key
Dragonwell linux alpine-linux
Corretto linux alpine
Zulu linux_glibc linux_musl
Liberica linux linux-musl
Liberica NIK linux linux-musl

Every key verified against live vendor metadata

Not inferred from naming conventions — each was confirmed to return real artifacts:

  • Dragonwelldragonwell-jdk.io/map_with_checksum.json platform keys are alpine-linux, linux, windows. alpine-linux covers majors 11/17/21/25, x64 only.
  • Correttocorretto-downloads/latest_links/indexmap_with_checksum.json top-level keys include alpine, with x64 and aarch64, image types jdk and debugsymbols. There is no jre under alpine, but there is none under linux either, so no regression.
  • Zuluapi.azul.com/metadata/v1/zulu/packages/?os=linux_musl returns e.g. zulu21.52.15-ca-jdk21.0.12-linux_musl_x64.tar.gz.
  • Liberica / NIKapi.bell-sw.com with os=linux-musl returns e.g. bellsoft-jdk21+37-linux-x64-musl.tar.gz.
  • Microsoft publishes no musl builds, so it is intentionally untouched.

Scope note

The gap was originally reported to me as Dragonwell + Corretto. Verifying it showed the same root cause in five distributions, with the same one-line shape in each. Shipping a partial fix for a systemic bug would leave three distributions silently broken, so all five are fixed together.

No silent glibc fallback — deliberate

Where a vendor has no musl build for the requested version/architecture (for example Dragonwell on aarch64, or Corretto's arm-musl variant which this platform-key mapping does not reach), the existing "could not find a version that satisfies" error fires instead of quietly installing a glibc JDK.

This matches what Temurin and SapMachine already do, and a glibc JDK generally will not run on musl regardless. Users on Alpine images with gcompat/libc6-compat who were relying on the glibc build will now get an explicit error rather than a working-by-accident install; an explicit error is the better failure mode and is consistent with the rest of the action.

Tests

19 new tests. For each distribution: musl on Alpine, glibc on other Linux runners, and an assertion that the filesystem is not probed off Linux. Plus direct isAlpineLinux() coverage.

The existing Liberica/NIK getPlatformOption tables had a linux → linux row that would have become machine-dependent once linux branches on libc; they now pin the Alpine probe explicitly.

All assertions were mutation-verified: forcing isAlpineLinux() to always return false fails 6 tests, always true fails 10. Full suite: 41 suites / 1373 tests green.

Relationship to #1210

#1210 has landed. It added the shared isAlpineLinux() helper, and because this branch used an identical name, signature and semantics, the merge resolved by simply deleting this branch's copy — no behavioural reconciliation was needed.

As a result src/distributions/platform-types.ts and __tests__/java-platform-contract.test.ts are now untouched by this PR. The diff is exactly the five getPlatformOption() implementations plus their tests.

#1210 was necessary but not sufficient: it makes the resolution cache distinguish glibc from musl, while this PR fixes the five distributions that resolve the wrong artifact in the first place, cache or no cache.

Related: #1209, #1210

On Alpine, `getPlatformOption()` returned the glibc platform key for
Dragonwell, Corretto, Zulu, Liberica and Liberica NIK, so the action
resolved and installed a glibc JDK that cannot run under musl.

Add a shared `isAlpineLinux()` helper and use it to select each vendor's
musl artifacts:

| distribution | glibc         | musl           |
| ------------ | ------------- | -------------- |
| Dragonwell   | `linux`       | `alpine-linux` |
| Corretto     | `linux`       | `alpine`       |
| Zulu         | `linux_glibc` | `linux_musl`   |
| Liberica     | `linux`       | `linux-musl`   |
| Liberica NIK | `linux`       | `linux-musl`   |

Each key was verified against the vendor's live metadata API or manifest.

There is deliberately no silent fallback to glibc when a vendor has no
musl build for the requested version or architecture: the existing "could
not find a version that satisfies" error fires instead. This matches the
behaviour Temurin and SapMachine already have, and a glibc JDK would not
run on musl anyway.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 74248bb0-72af-41d8-b85d-b0f5836e68db
Copilot AI lite review requested due to automatic review settings August 5, 2026 16:38
@brunoborges
brunoborges requested a review from a team as a code owner August 5, 2026 16:38

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Fixes incorrect JDK artifact selection on Alpine Linux by ensuring affected distributions choose musl-compatible vendor platform keys instead of defaulting to glibc artifacts.

Changes:

  • Added shared isAlpineLinux() helper in src/distributions/platform-types.ts (short-circuits off Linux and probes /etc/alpine-release only on Linux).
  • Updated getPlatformOption() for Dragonwell, Corretto, Zulu, Liberica, and Liberica NIK to select the vendor’s musl platform key on Alpine.
  • Added targeted unit tests covering musl vs glibc selection per distribution and direct coverage for isAlpineLinux() behavior (including “no filesystem probe off Linux”).
Show a summary per file
File Description
src/distributions/zulu/installer.ts Selects linux_musl on Alpine, otherwise linux_glibc.
src/distributions/platform-types.ts Adds isAlpineLinux() helper (Linux-gated /etc/alpine-release probe).
src/distributions/liberica/installer.ts Selects linux-musl on Alpine for Liberica artifacts.
src/distributions/liberica-nik/installer.ts Selects linux-musl on Alpine for Liberica NIK artifacts.
src/distributions/dragonwell/installer.ts Selects alpine-linux on Alpine for Dragonwell artifacts.
src/distributions/corretto/installer.ts Selects alpine on Alpine for Corretto artifacts.
dist/setup/index.js Regenerated bundle reflecting new helper export and logic changes.
dist/setup/978.index.js Regenerated bundle reflecting Zulu platform selection change.
dist/setup/675.index.js Regenerated bundle reflecting Dragonwell platform selection change.
dist/setup/63.index.js Regenerated bundle reflecting Liberica platform selection change.
dist/setup/524.index.js Regenerated bundle reflecting Liberica NIK platform selection change.
dist/setup/126.index.js Regenerated bundle reflecting Corretto platform selection change.
tests/java-platform-contract.test.ts Adds direct unit coverage for isAlpineLinux() semantics.
tests/distributors/zulu-installer.test.ts Adds tests for musl/glibc selection and “no probe off Linux”.
tests/distributors/liberica-nik-installer.test.ts Pins Alpine probe for existing cases and adds musl/glibc selection tests.
tests/distributors/liberica-installer.test.ts Pins Alpine probe for existing cases and adds musl/glibc selection tests.
tests/distributors/dragonwell-installer.test.ts Adds tests for musl/glibc selection and “no probe off Linux”.
tests/distributors/corretto-installer.test.ts Adds tests for musl/glibc selection and “no probe off Linux”.

Review details

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 12/18 changed files
  • Comments generated: 0
  • Review effort level: Lite

PR actions#1210 landed the shared `isAlpineLinux()` helper, so this branch drops
its own identical copy and imports main's. `platform-types.ts` and
`java-platform-contract.test.ts` are now untouched by this branch; the
duplicated `isAlpineLinux` test block was byte-identical to main's and
was removed.

Rebuilt dist/ to resolve the bundle conflict.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 74248bb0-72af-41d8-b85d-b0f5836e68db
@brunoborges
brunoborges merged commit 4fbd0bd into actions:main Aug 5, 2026
84 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants