Uh oh!
There was an error while loading. Please reload this page.
Centralize OS/architecture capability validation - #1178
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 10e35b75-928f-4ef7-984e-605895c5d88e
There was a problem hiding this comment.
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: falseexplicitly (the type allows that). Check that the value is actuallytruebefore 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
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
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>
Uh oh!
There was an error while loading. Please reload this page.
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
src/distributions/platform-types.tswith:amd64->x64,ia32->x86,arm64->aarch64,arm->armv7)distribution-factoryto run package + platform validation before installer construction and pass normalized architecture downstream.JavaBaseand kept vendor translation separate by mapping canonical values only inside vendor installers (for examplearmv7->arm, Zulux86->i686).__tests__/java-platform-contract.test.tsand expanded distribution/factory tests for normalization and compatibility edge cases.README.md,docs/advanced-usage.md,action.yml) and added an E2E workflow assertion for an expected unsupported combination.dist/setup/index.js.Notes
util.ts, keeping this change compatible with upcoming lazy-load/cache fast-path work.Fixes: #1176