Skip to content

Centralize OS/architecture capability validation - #1178

Merged
brunoborges merged 3 commits into
mainfrom
brunoborges-centralize-platform-validation
Jul 29, 2026
Merged

Centralize OS/architecture capability validation#1178
brunoborges merged 3 commits into
mainfrom
brunoborges-centralize-platform-validation

Conversation

@brunoborges

Copy link
Copy Markdown
Contributor

This makes platform compatibility checks deterministic and consistent across distributions, so unsupported OS/architecture requests fail before cache lookup or vendor network calls. It addresses drift risk by moving capability rules into a shared contract that tests and docs can validate.

What changed

  • Added a typed shared capability contract in src/distributions/platform-types.ts with:
    • per-distribution OS/architecture matrices
    • alias normalization (amd64 -> x64, ia32 -> x86, arm64 -> aarch64, arm -> armv7)
    • version-gated capability entries where needed
    • one consistent unsupported-combination error format
  • Updated distribution-factory to run package + platform validation before installer construction and pass normalized architecture downstream.
  • Simplified base architecture handling in JavaBase and kept vendor translation separate by mapping canonical values only inside vendor installers (for example armv7 -> arm, Zulu x86 -> i686).
  • Added contract coverage in __tests__/java-platform-contract.test.ts and expanded distribution/factory tests for normalization and compatibility edge cases.
  • Updated docs and action input text (README.md, docs/advanced-usage.md, action.yml) and added an E2E workflow assertion for an expected unsupported combination.
  • Rebuilt dist/setup/index.js.

Notes

  • The validation module intentionally does not import util.ts, keeping this change compatible with upcoming lazy-load/cache fast-path work.
  • Tool-cache and vendor request behavior for supported combinations is preserved; only unsupported combinations are rejected earlier with clearer diagnostics.

Fixes: #1176

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 10e35b75-928f-4ef7-984e-605895c5d88e
Copilot AI review requested due to automatic review settings July 29, 2026 19:29
@brunoborges
brunoborges requested a review from a team as a code owner July 29, 2026 19:29

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

This pull request centralizes OS/architecture capability validation for Java distributions, normalizes architecture aliases consistently, and updates installers/tests/docs so unsupported platform combinations fail early (before cache lookup or network calls).

Changes:

  • Added a shared platform capability contract + normalization/validation helpers (src/distributions/platform-types.ts).
  • Updated distribution factory and base installer plumbing to validate + pass normalized architectures downstream, with vendor-specific translations handled in per-distribution installers.
  • Added/updated contract tests, distribution/factory tests, docs/action input text, and an E2E workflow assertion for an unsupported combination.
Show a summary per file
File Description
src/distributions/platform-types.ts Introduces shared platform capability matrices, arch alias normalization, and centralized validation logic.
src/distributions/distribution-factory.ts Validates package + platform earlier and passes normalized architecture into installer construction.
src/distributions/base-installer.ts Normalizes architecture at the base level and simplifies default distribution architecture mapping.
src/distributions/adopt/installer.ts Translates canonical armv7 to vendor arm.
src/distributions/temurin/installer.ts Translates canonical armv7 to vendor arm.
src/distributions/corretto/installer.ts Translates canonical armv7 to vendor arm.
src/distributions/zulu/installer.ts Extends vendor mapping to translate canonical armv7 to vendor arm.
tests/java-platform-contract.test.ts Adds contract tests to keep capability tables aligned with docs and consistent diagnostics.
tests/distributors/distribution-factory.test.ts Updates factory tests to reflect platform validation and normalized architecture behavior.
tests/distributors/adopt-installer.test.ts Updates normalization expectations for ARM-related cases.
tests/distributors/temurin-installer.test.ts Updates normalization expectations for ARM-related cases.
tests/distributors/corretto-installer.test.ts Adds coverage ensuring canonical vs vendor architecture values remain distinct.
docs/advanced-usage.md Documents the up-front platform/architecture compatibility matrix and validation behavior.
README.md Updates architecture input documentation and alias normalization description.
action.yml Updates the architecture input description to reflect canonical values + aliases.
.github/workflows/e2e-versions.yml Adds an E2E assertion that an unsupported combination is rejected.
dist/setup/index.js Rebuilt bundled output to include the new platform validation logic.

Review details

Tip

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

Comments suppressed due to low confidence (4)

src/distributions/platform-types.ts:112

  • The semver range "<=11" only matches up to 11.0.0, so it would incorrectly reject Windows x86 for 11.x patch releases. Use "<12" to represent "Java 11 or earlier".
      windows: ['x64', {architecture: 'x86', versionRange: '<=11'}]

src/distributions/platform-types.ts:45

  • The semver range "<=17" only matches up to 17.0.0, so it would incorrectly reject common 17.x patch releases (e.g., 17.0.10). Use "<18" to include all 17.* versions.
      linux: [...STANDARD_LINUX, {architecture: 'armv7', versionRange: '<=17'}],

src/distributions/platform-types.ts:59

  • The semver range "<=17" only matches up to 17.0.0, so it would incorrectly reject common 17.x patch releases even though the intent is "through Java 17". Use "<18" to include all 17.* versions.
      linux: [...STANDARD_LINUX, {architecture: 'armv7', versionRange: '<=17'}],

src/distributions/platform-types.ts:230

  • Checking only for the presence of the "unrestricted" property can misclassify a restricted capability if it ever sets unrestricted: false explicitly (the type allows that). Check that the value is actually true before skipping platform validation.
  const capability = JAVA_PLATFORM_CAPABILITIES[distributionName];
  if ('unrestricted' in capability) {
    return normalizedArchitecture;
  }
  • Files reviewed: 16/17 changed files
  • Comments generated: 5
  • Review effort level: Low

Comment thread src/distributions/platform-types.ts Outdated
Comment thread src/distributions/platform-types.ts Outdated
Comment thread __tests__/distributors/distribution-factory.test.ts Outdated
Comment thread __tests__/java-platform-contract.test.ts
Comment thread __tests__/java-platform-contract.test.ts Outdated
brunoborges and others added 2 commits July 29, 2026 15:38
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 10e35b75-928f-4ef7-984e-605895c5d88e
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@brunoborges
brunoborges merged commit 6937f5e into main Jul 29, 2026
88 checks passed
@brunoborges
brunoborges deleted the brunoborges-centralize-platform-validation branch July 29, 2026 19:46
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.

Centralize OS and architecture capability validation

2 participants