Compare commits

...

6 Commits

Author SHA1 Message Date
AKB0700
d41feb8330
Merge b349a828a8 into b24df5bba5 2026-06-14 21:31:17 -07:00
AKB0700
b349a828a8
Merge pull request #2 from AKB0700/copilot/update-screen-capture-2026-04-20
Use a globally unique action name to unblock Marketplace publishing
2026-04-20 23:29:05 +08:00
copilot-swe-agent[bot]
d65fe6df44
Use unique Marketplace action name
Agent-Logs-Url: https://github.com/AKB0700/setup-java/sessions/5c91e70c-9d6a-4d53-9edf-bdcce4847900

Co-authored-by: AKB0700 <157992575+AKB0700@users.noreply.github.com>
2026-04-20 15:10:23 +00:00
AKB0700
f71fefd01a
Merge pull request #1 from AKB0700/copilot/fix-issues-and-automate-tasks
Stabilize JetBrains installer tests by removing external network dependency
2026-04-20 23:03:57 +08:00
copilot-swe-agent[bot]
3ffaf5bec1
Add JetBrains fallback tests and tighten URL assertions
Agent-Logs-Url: https://github.com/AKB0700/setup-java/sessions/b5ff7a8f-7d53-4825-9148-a3d7b9163aac

Co-authored-by: AKB0700 <157992575+AKB0700@users.noreply.github.com>
2026-04-20 14:59:12 +00:00
copilot-swe-agent[bot]
219e4ee775
Stabilize JetBrains tests by removing external network dependency
Agent-Logs-Url: https://github.com/AKB0700/setup-java/sessions/b5ff7a8f-7d53-4825-9148-a3d7b9163aac

Co-authored-by: AKB0700 <157992575+AKB0700@users.noreply.github.com>
2026-04-20 14:54:35 +00:00
2 changed files with 64 additions and 10 deletions

View File

@ -1,4 +1,3 @@
import https from 'https';
import {HttpClient} from '@actions/http-client';
import {JetBrainsDistribution} from '../../src/distributions/jetbrains/installer';
@ -17,6 +16,11 @@ describe('getAvailableVersions', () => {
headers: {},
result: []
});
jest.spyOn(HttpClient.prototype, 'head').mockResolvedValue({
message: {
statusCode: 200
}
} as any);
// Mock core.error to suppress error logs
spyCoreError = jest.spyOn(core, 'error');
@ -50,6 +54,61 @@ describe('getAvailableVersions', () => {
os.platform() === 'win32' ? manifestData.length : manifestData.length + 2;
expect(availableVersions.length).toBe(length);
}, 10_000);
it('uses _nomod package URL when base package is unavailable', async () => {
spyHttpClient.mockReturnValueOnce({
statusCode: 200,
headers: {},
result: [{tag_name: 'jbr-release-21.0.3b465.3', prerelease: true}] as any
});
spyHttpClient.mockReturnValueOnce({
statusCode: 200,
headers: {},
result: []
});
jest
.spyOn(HttpClient.prototype, 'head')
.mockResolvedValueOnce({message: {statusCode: 404}} as any)
.mockResolvedValueOnce({message: {statusCode: 200}} as any);
const distribution = new JetBrainsDistribution({
version: '21-ea',
architecture: 'x64',
packageType: 'jdk',
checkLatest: false
});
const availableVersions = await distribution['getAvailableVersions']();
expect(availableVersions).toHaveLength(1);
expect(availableVersions[0].url).toContain('_nomod-21.0.3-linux-x64-b465.3');
});
it('filters out versions when both package URLs are unavailable', async () => {
spyHttpClient.mockReturnValueOnce({
statusCode: 200,
headers: {},
result: [{tag_name: 'jbr-release-21.0.3b465.3', prerelease: true}] as any
});
spyHttpClient.mockReturnValueOnce({
statusCode: 200,
headers: {},
result: []
});
jest
.spyOn(HttpClient.prototype, 'head')
.mockResolvedValueOnce({message: {statusCode: 404}} as any)
.mockResolvedValueOnce({message: {statusCode: 404}} as any);
const distribution = new JetBrainsDistribution({
version: '21-ea',
architecture: 'x64',
packageType: 'jdk',
checkLatest: false
});
const availableVersions = await distribution['getAvailableVersions']();
expect(availableVersions).toHaveLength(0);
});
});
describe('findPackageForDownload', () => {
@ -84,14 +143,9 @@ describe('findPackageForDownload', () => {
distribution['getAvailableVersions'] = async () => manifestData as any;
const resolvedVersion =
await distribution['findPackageForDownload'](input);
const url = resolvedVersion.url;
const options = {method: 'HEAD'};
https.request(url, options, res => {
// JetBrains uses 403 for inexistent packages
expect(res.statusCode).not.toBe(403);
res.resume();
});
expect(resolvedVersion.url).toMatch(
/^https:\/\/cache-redirector\.jetbrains\.com\/intellij-jbr\/.+-b\d+(\.\d+)?\.tar\.gz$/
);
}
);

View File

@ -1,4 +1,4 @@
name: 'Setup Java JDK'
name: 'AKB0700 Setup Java JDK'
description: 'Set up a specific version of the Java JDK and add the
command-line tools to the PATH'
author: 'GitHub'