mirror of
https://github.com/actions/setup-java.git
synced 2026-06-23 09:48:21 +01:00
fix: tidy graalvm community validation follow-ups
This commit is contained in:
committed by
GitHub
parent
6929a11922
commit
a263f84254
@@ -1053,21 +1053,21 @@ describe('GraalVMDistribution', () => {
|
|||||||
).rejects.toThrow('GraalVM Community does not provide early access builds');
|
).rejects.toThrow('GraalVM Community does not provide early access builds');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('distribution factory', () => {
|
});
|
||||||
const defaultOptions: JavaInstallerOptions = {
|
|
||||||
version: '17',
|
|
||||||
architecture: 'x64',
|
|
||||||
packageType: 'jdk',
|
|
||||||
checkLatest: false
|
|
||||||
};
|
|
||||||
|
|
||||||
it('should map graalvm-community to the community installer', () => {
|
describe('distribution factory', () => {
|
||||||
const community = getJavaDistribution('graalvm-community', defaultOptions);
|
const defaultOptions: JavaInstallerOptions = {
|
||||||
|
version: '17',
|
||||||
|
architecture: 'x64',
|
||||||
|
packageType: 'jdk',
|
||||||
|
checkLatest: false
|
||||||
|
};
|
||||||
|
|
||||||
expect(community).toBeInstanceOf(GraalVMCommunityDistribution);
|
it('should map graalvm-community to the community installer', () => {
|
||||||
});
|
const community = getJavaDistribution('graalvm-community', defaultOptions);
|
||||||
|
|
||||||
|
expect(community).toBeInstanceOf(GraalVMCommunityDistribution);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
14
dist/setup/index.js
vendored
14
dist/setup/index.js
vendored
@@ -79151,7 +79151,6 @@ class GraalVMDistribution extends base_installer_1.JavaBase {
|
|||||||
return arch;
|
return arch;
|
||||||
}
|
}
|
||||||
validateStableBuildRequest(range) {
|
validateStableBuildRequest(range) {
|
||||||
const arch = this.getSupportedArchitecture();
|
|
||||||
if (this.packageType !== 'jdk') {
|
if (this.packageType !== 'jdk') {
|
||||||
throw new Error(`${this.distribution} provides only the \`jdk\` package type`);
|
throw new Error(`${this.distribution} provides only the \`jdk\` package type`);
|
||||||
}
|
}
|
||||||
@@ -79166,7 +79165,6 @@ class GraalVMDistribution extends base_installer_1.JavaBase {
|
|||||||
throw new Error(`${this.distribution} is only supported for JDK ${GRAALVM_MIN_VERSION} and later. Requested version: ${major}`);
|
throw new Error(`${this.distribution} is only supported for JDK ${GRAALVM_MIN_VERSION} and later. Requested version: ${major}`);
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
arch,
|
|
||||||
platform,
|
platform,
|
||||||
major,
|
major,
|
||||||
extension
|
extension
|
||||||
@@ -79275,7 +79273,8 @@ class GraalVMCommunityDistribution extends GraalVMDistribution {
|
|||||||
if (!this.stable) {
|
if (!this.stable) {
|
||||||
throw new Error('GraalVM Community does not provide early access builds');
|
throw new Error('GraalVM Community does not provide early access builds');
|
||||||
}
|
}
|
||||||
const { arch, platform, extension } = this.validateStableBuildRequest(range);
|
const arch = this.getSupportedArchitecture();
|
||||||
|
const { platform, extension } = this.validateStableBuildRequest(range);
|
||||||
const availableVersions = yield this.getAvailableVersionsForPlatform(platform, arch, extension);
|
const availableVersions = yield this.getAvailableVersionsForPlatform(platform, arch, extension);
|
||||||
const satisfiedVersion = availableVersions
|
const satisfiedVersion = availableVersions
|
||||||
.filter(item => (0, util_1.isVersionSatisfies)(range, item.version))
|
.filter(item => (0, util_1.isVersionSatisfies)(range, item.version))
|
||||||
@@ -79289,7 +79288,7 @@ class GraalVMCommunityDistribution extends GraalVMDistribution {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
getAvailableVersionsForPlatform(platform, arch, extension) {
|
getAvailableVersionsForPlatform(platform, arch, extension) {
|
||||||
var _a, _b;
|
var _a;
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
const headers = (0, util_1.getGitHubHttpHeaders)();
|
const headers = (0, util_1.getGitHubHttpHeaders)();
|
||||||
const availableVersions = new Map();
|
const availableVersions = new Map();
|
||||||
@@ -79298,11 +79297,12 @@ class GraalVMCommunityDistribution extends GraalVMDistribution {
|
|||||||
while (releasesUrl) {
|
while (releasesUrl) {
|
||||||
pageCount++;
|
pageCount++;
|
||||||
const response = yield this.http.getJson(releasesUrl, headers);
|
const response = yield this.http.getJson(releasesUrl, headers);
|
||||||
for (const release of (_a = response.result) !== null && _a !== void 0 ? _a : []) {
|
const releases = Array.isArray(response.result) ? response.result : [];
|
||||||
|
for (const release of releases) {
|
||||||
if (release.draft || release.prerelease) {
|
if (release.draft || release.prerelease) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
for (const asset of (_b = release.assets) !== null && _b !== void 0 ? _b : []) {
|
for (const asset of (_a = release.assets) !== null && _a !== void 0 ? _a : []) {
|
||||||
const releaseForPlatform = this.toCommunityReleaseForPlatform(asset, platform, arch, extension);
|
const releaseForPlatform = this.toCommunityReleaseForPlatform(asset, platform, arch, extension);
|
||||||
if (releaseForPlatform) {
|
if (releaseForPlatform) {
|
||||||
availableVersions.set(releaseForPlatform.version, releaseForPlatform);
|
availableVersions.set(releaseForPlatform.version, releaseForPlatform);
|
||||||
@@ -79316,7 +79316,7 @@ class GraalVMCommunityDistribution extends GraalVMDistribution {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
releasesUrl = nextUrl;
|
releasesUrl = nextUrl;
|
||||||
if (!response.result || response.result.length === 0) {
|
if (releases.length === 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (pageCount >= util_1.MAX_PAGINATION_PAGES) {
|
if (pageCount >= util_1.MAX_PAGINATION_PAGES) {
|
||||||
|
|||||||
@@ -151,13 +151,10 @@ export class GraalVMDistribution extends JavaBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected validateStableBuildRequest(range: string): {
|
protected validateStableBuildRequest(range: string): {
|
||||||
arch: SupportedArchitecture;
|
|
||||||
platform: OsVersions;
|
platform: OsVersions;
|
||||||
extension: string;
|
extension: string;
|
||||||
major: string;
|
major: string;
|
||||||
} {
|
} {
|
||||||
const arch = this.getSupportedArchitecture();
|
|
||||||
|
|
||||||
if (this.packageType !== 'jdk') {
|
if (this.packageType !== 'jdk') {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`${this.distribution} provides only the \`jdk\` package type`
|
`${this.distribution} provides only the \`jdk\` package type`
|
||||||
@@ -180,7 +177,6 @@ export class GraalVMDistribution extends JavaBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
arch,
|
|
||||||
platform,
|
platform,
|
||||||
major,
|
major,
|
||||||
extension
|
extension
|
||||||
@@ -352,7 +348,8 @@ export class GraalVMCommunityDistribution extends GraalVMDistribution {
|
|||||||
throw new Error('GraalVM Community does not provide early access builds');
|
throw new Error('GraalVM Community does not provide early access builds');
|
||||||
}
|
}
|
||||||
|
|
||||||
const {arch, platform, extension} = this.validateStableBuildRequest(range);
|
const arch = this.getSupportedArchitecture();
|
||||||
|
const {platform, extension} = this.validateStableBuildRequest(range);
|
||||||
const availableVersions = await this.getAvailableVersionsForPlatform(
|
const availableVersions = await this.getAvailableVersionsForPlatform(
|
||||||
platform,
|
platform,
|
||||||
arch,
|
arch,
|
||||||
@@ -393,7 +390,9 @@ export class GraalVMCommunityDistribution extends GraalVMDistribution {
|
|||||||
headers
|
headers
|
||||||
);
|
);
|
||||||
|
|
||||||
for (const release of response.result ?? []) {
|
const releases = Array.isArray(response.result) ? response.result : [];
|
||||||
|
|
||||||
|
for (const release of releases) {
|
||||||
if (release.draft || release.prerelease) {
|
if (release.draft || release.prerelease) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -427,7 +426,7 @@ export class GraalVMCommunityDistribution extends GraalVMDistribution {
|
|||||||
|
|
||||||
releasesUrl = nextUrl;
|
releasesUrl = nextUrl;
|
||||||
|
|
||||||
if (!response.result || response.result.length === 0) {
|
if (releases.length === 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user