mirror of
https://gitea.com/actions/setup-java.git
synced 2026-08-07 02:31:20 +00:00
Report concrete versions for floating Oracle JDK downloads (#1213)
* Fix floating Oracle JDK version resolution Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> * Update generated distribution bundles Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> * Harden floating artifact cache identity Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> * Regenerate setup bundle after cache hardening Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> * Temporarily enable hosted full validation Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> * Export hosted formatting results Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> * Apply repository formatting Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> * Run hosted validation after formatting Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> * Correct floating version regression tests Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> * Remove temporary validation wiring Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> * Cache checksum-less floating artifacts by their response fingerprint Oracle and Oracle GraalVM do not always publish a `.sha256` sibling next to a `/latest/` artifact. Those floating releases were excluded from both the resolution cache and the JDK cache, so `cache-jdk` users lost caching entirely for them. A floating URL is a constant string, so it cannot serve as a cache identity on its own — a stale entry would be reused forever. Instead, derive a validator from the headers of the HEAD request that already resolves the artifact: the ETag when present, otherwise `Last-Modified` combined with `Content-Length`. Republishing changes the validator, which changes the cache key, so a new build is downloaded rather than masked. `getJdkReleaseIdentity` now falls back to that fingerprint before the URL, and the floating cache gates ask whether the release has a stable identity (checksum or fingerprint) rather than a checksum specifically. A floating release with neither is still left uncached. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Co-authored-by: Bruno Borges <brborges@microsoft.com>
This commit is contained in:
@@ -72,6 +72,7 @@ jest.unstable_mockModule('../../src/util.js', () => ({
|
||||
...realUtil,
|
||||
extractJdkFile: jest.fn(),
|
||||
getDownloadArchiveExtension: jest.fn(),
|
||||
getJavaVersionFromReleaseFile: jest.fn(),
|
||||
renameWinArchive: jest.fn(),
|
||||
getGitHubHttpHeaders: jest.fn().mockReturnValue({Accept: 'application/json'})
|
||||
}));
|
||||
@@ -363,6 +364,30 @@ describe('GraalVMDistribution', () => {
|
||||
path: '/cached/java/path'
|
||||
});
|
||||
});
|
||||
|
||||
it('caches Oracle GraalVM floating artifacts under their installed version', async () => {
|
||||
(util.getJavaVersionFromReleaseFile as jest.Mock<any>).mockReturnValue(
|
||||
'21.0.9+7'
|
||||
);
|
||||
const floatingRelease = {
|
||||
version: '21',
|
||||
url: 'https://example.com/graalvm/latest/graalvm-jdk-21.tar.gz',
|
||||
floating: true
|
||||
};
|
||||
|
||||
const result = await (distribution as any).downloadTool(floatingRelease);
|
||||
|
||||
expect(tc.cacheDir).toHaveBeenCalledWith(
|
||||
path.join('/tmp/extracted', 'graalvm-jdk-17.0.5'),
|
||||
'Java_GraalVM_jdk',
|
||||
'21.0.9+7',
|
||||
'x64'
|
||||
);
|
||||
expect(result).toEqual({
|
||||
version: '21.0.9+7',
|
||||
path: '/cached/java/path'
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('findPackageForDownload', () => {
|
||||
@@ -451,6 +476,33 @@ describe('GraalVMDistribution', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it.each([
|
||||
['21', 'etag:"graalvm-latest"'],
|
||||
['17.0.5', undefined]
|
||||
])(
|
||||
'fingerprints only the floating artifact for version %s',
|
||||
async (input, expected) => {
|
||||
mockHttpClient.head.mockResolvedValue({
|
||||
message: {statusCode: 200, headers: {etag: '"graalvm-latest"'}}
|
||||
} as any);
|
||||
|
||||
const result = await (distribution as any).findPackageForDownload(
|
||||
input
|
||||
);
|
||||
|
||||
// Without a fingerprint the constant `/latest/` URL would key a cache
|
||||
// entry that never invalidates when Oracle republishes the artifact.
|
||||
expect(result.fingerprint).toBe(expected);
|
||||
}
|
||||
);
|
||||
|
||||
it('always resolves Oracle GraalVM major-only requests remotely', () => {
|
||||
expect((distribution as any).requiresRemoteResolution()).toBe(true);
|
||||
expect((communityDistribution as any).requiresRemoteResolution()).toBe(
|
||||
false
|
||||
);
|
||||
});
|
||||
|
||||
it('should throw error for unsupported architecture', async () => {
|
||||
distribution = new GraalVMDistribution({
|
||||
...defaultOptions,
|
||||
|
||||
Reference in New Issue
Block a user