Add conditional JDK caching (#1201)
* Add JDK caching
Cache resolved JDK tool-cache entries by exact platform and release identity, with a default-on cache-jdk input and explicit opt-out.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* Apply batched suggestions from code review
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
* Fix JDK cache CI validation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* Update brace-expansion security fix
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* Refresh brace-expansion license metadata
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* Refine JDK cache semantics
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* Refine JDK cache documentation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* Simplify JDK cache identity
Use one normalized runner OS dimension, reset the internal cache key schema for the unreleased feature, and align documentation, tests, and bundles.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* Align JDK cache OS identity
Use the established RUNNER_OS value directly and retain process.platform only as a non-Actions fallback.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* Harden JDK cache saves and document tool-cache reuse
Bind each JDK cache key to the installation identity it was computed for,
keep post-job saves best-effort per entry, and state the real reuse and
verification guarantee in the documentation.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* docs: restructure README caching section
Rename '## Caching dependencies' to '## Caching' and add a what-gets-cached
overview table covering the dependency, wrapper, and JDK caches. Lead with the
common 'cache: maven' example and the dependency-cache material, and demote JDK
caching into its own subsection.
Also corrects the IMPORTANT callout, which implied JDK caching required an
explicit opt-in; it is enabled implicitly whenever 'cache' is set.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* docs: fix caching documentation defects
- Remove pull-request framing that compared behavior to `main`; state the
tool-cache and `jdkfile` behavior directly and unconditionally.
- Clarify that the JDK cache is a separate cache *entry* from the dependency
and wrapper caches, while its *enablement* is coupled to `cache`, so the
opening paragraph agrees with the enablement matrix.
- Cite the actions/setup-java-benchmarks repository instead of an open PR and
a self-referential PR comment, keeping the measured figures and caveats.
- Keep the `cache`/`cache-jdk` matrix only in docs/advanced-usage.md and
summarize the rules in prose in README.md to avoid divergence.
- Describe the guarantee that a cache key is only saved with the installation
it was computed for, instead of documenting inode/size/timestamp internals.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* docs: add V6 what's new entry for JDK caching
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: e2755464-4e83-47b6-ba71-731bb481b418
---------
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot-Session: e2755464-4e83-47b6-ba71-731bb481b418
2026-08-04 21:54:10 -04:00
export const id = 779 ;
export const ids = [ 779 , 394 ] ;
export const modules = {
/***/ 1394 :
/***/ ( ( _ _unused _webpack _module , _ _webpack _exports _ _ , _ _webpack _require _ _ ) => {
/* harmony export */ _ _webpack _require _ _ . d ( _ _webpack _exports _ _ , {
/* harmony export */ isCacheFeatureAvailable : ( ) => ( /* binding */ isCacheFeatureAvailable )
/* harmony export */ } ) ;
/* harmony import */ var _actions _cache _ _WEBPACK _IMPORTED _MODULE _0 _ _ = _ _webpack _require _ _ ( 6971 ) ;
/* harmony import */ var _actions _core _ _WEBPACK _IMPORTED _MODULE _1 _ _ = _ _webpack _require _ _ ( 3838 ) ;
/* harmony import */ var _util _js _ _WEBPACK _IMPORTED _MODULE _2 _ _ = _ _webpack _require _ _ ( 4527 ) ;
function isCacheFeatureAvailable ( ) {
if ( _actions _cache _ _WEBPACK _IMPORTED _MODULE _0 _ _ /* .isFeatureAvailable */ . w3 ( ) ) {
return true ;
}
if ( ( 0 , _util _js _ _WEBPACK _IMPORTED _MODULE _2 _ _ /* .isGhes */ . aT ) ( ) ) {
_actions _core _ _WEBPACK _IMPORTED _MODULE _1 _ _ /* .warning */ . $e ( 'Caching is only supported on GHES version >= 3.5. If you are on a version >= 3.5, please check with your GHES admin if the Actions cache service is enabled or not.' ) ;
return false ;
}
_actions _core _ _WEBPACK _IMPORTED _MODULE _1 _ _ /* .warning */ . $e ( 'The runner was not able to contact the cache service. Caching will be skipped' ) ;
return false ;
}
/***/ } ) ,
/***/ 5779 :
/***/ ( ( _ _unused _webpack _module , _ _webpack _exports _ _ , _ _webpack _require _ _ ) => {
_ _webpack _require _ _ . r ( _ _webpack _exports _ _ ) ;
/* harmony export */ _ _webpack _require _ _ . d ( _ _webpack _exports _ _ , {
/* harmony export */ buildJdkCacheKey : ( ) => ( /* binding */ buildJdkCacheKey ) ,
/* harmony export */ getJdkVerificationIdentity : ( ) => ( /* binding */ getJdkVerificationIdentity ) ,
/* harmony export */ registerJdk : ( ) => ( /* binding */ registerJdk ) ,
/* harmony export */ restoreJdk : ( ) => ( /* binding */ restoreJdk ) ,
/* harmony export */ saveJdkCaches : ( ) => ( /* binding */ saveJdkCaches )
/* harmony export */ } ) ;
/* harmony import */ var crypto _ _WEBPACK _IMPORTED _MODULE _0 _ _ = _ _webpack _require _ _ ( 6982 ) ;
/* harmony import */ var crypto _ _WEBPACK _IMPORTED _MODULE _0 _ _ _default = /*#__PURE__*/ _ _webpack _require _ _ . n ( crypto _ _WEBPACK _IMPORTED _MODULE _0 _ _ ) ;
/* harmony import */ var fs _ _WEBPACK _IMPORTED _MODULE _1 _ _ = _ _webpack _require _ _ ( 9896 ) ;
/* harmony import */ var fs _ _WEBPACK _IMPORTED _MODULE _1 _ _ _default = /*#__PURE__*/ _ _webpack _require _ _ . n ( fs _ _WEBPACK _IMPORTED _MODULE _1 _ _ ) ;
/* harmony import */ var path _ _WEBPACK _IMPORTED _MODULE _2 _ _ = _ _webpack _require _ _ ( 6928 ) ;
/* harmony import */ var path _ _WEBPACK _IMPORTED _MODULE _2 _ _ _default = /*#__PURE__*/ _ _webpack _require _ _ . n ( path _ _WEBPACK _IMPORTED _MODULE _2 _ _ ) ;
/* harmony import */ var _actions _cache _ _WEBPACK _IMPORTED _MODULE _3 _ _ = _ _webpack _require _ _ ( 6971 ) ;
/* harmony import */ var _actions _core _ _WEBPACK _IMPORTED _MODULE _4 _ _ = _ _webpack _require _ _ ( 3838 ) ;
/* harmony import */ var _cache _feature _js _ _WEBPACK _IMPORTED _MODULE _5 _ _ = _ _webpack _require _ _ ( 1394 ) ;
const STATE _JDK _CACHES = 'jdk-caches' ;
const JDK _CACHE _KEY _VERSION = 1 ;
const restoredCaches = [ ] ;
async function restoreJdk ( jdk ) {
if ( ! jdk . path || ! ( 0 , _cache _feature _js _ _WEBPACK _IMPORTED _MODULE _5 _ _ . isCacheFeatureAvailable ) ( ) ) {
return false ;
}
const key = buildJdkCacheKey ( jdk ) ;
let matchedKey ;
try {
matchedKey = await _actions _cache _ _WEBPACK _IMPORTED _MODULE _3 _ _ /* .restoreCache */ . P3 ( [ jdk . path ] , key ) ;
}
catch ( error ) {
_actions _core _ _WEBPACK _IMPORTED _MODULE _4 _ _ /* .warning */ . $e ( ` Failed to restore JDK cache: ${ error . message } ` ) ;
}
const architecturePath = path _ _WEBPACK _IMPORTED _MODULE _2 _ _ _default ( ) . join ( jdk . path , jdk . architecture ) ;
if ( matchedKey &&
( ! fs _ _WEBPACK _IMPORTED _MODULE _1 _ _ _default ( ) . existsSync ( architecturePath ) ||
! fs _ _WEBPACK _IMPORTED _MODULE _1 _ _ _default ( ) . existsSync ( ` ${ architecturePath } .complete ` ) ) ) {
_actions _core _ _WEBPACK _IMPORTED _MODULE _4 _ _ /* .warning */ . $e ( ` JDK cache key ${ matchedKey } was restored without the expected tool-cache path; downloading the JDK instead. ` ) ;
matchedKey = undefined ;
}
recordJdkCache ( {
key ,
path : jdk . path ,
architecture : jdk . architecture ,
matchedKey
} ) ;
if ( matchedKey ) {
_actions _core _ _WEBPACK _IMPORTED _MODULE _4 _ _ /* .info */ . pq ( ` JDK cache restored from key: ${ matchedKey } ` ) ;
return true ;
}
_actions _core _ _WEBPACK _IMPORTED _MODULE _4 _ _ /* .info */ . pq ( ` JDK cache is not found for ${ jdk . distribution } ${ jdk . version } ` ) ;
return false ;
}
function registerJdk ( jdk ) {
if ( ! jdk . path ) {
return ;
}
recordJdkCache ( {
key : buildJdkCacheKey ( jdk ) ,
path : jdk . path ,
architecture : jdk . architecture ,
installation : getInstallationIdentity ( jdk . path , jdk . architecture )
} ) ;
}
/ * *
* Cheap fingerprint of the installation stored at a tool - cache path . The
* ` <architecture>.complete ` marker is ( re ) created by ` tc.cacheDir ` every time an
* installation is written , so its inode and timestamps change whenever the
* installation is replaced . This avoids rehashing a multi - hundred - megabyte JDK
* directory while still detecting that the bytes behind a key were swapped .
* /
function getInstallationIdentity ( jdkPath , architecture ) {
const architecturePath = path _ _WEBPACK _IMPORTED _MODULE _2 _ _ _default ( ) . join ( jdkPath , architecture ) ;
try {
const marker = fs _ _WEBPACK _IMPORTED _MODULE _1 _ _ _default ( ) . statSync ( ` ${ architecturePath } .complete ` ) ;
const installation = fs _ _WEBPACK _IMPORTED _MODULE _1 _ _ _default ( ) . statSync ( architecturePath ) ;
return [
marker . ino ,
marker . mtimeMs ,
marker . ctimeMs ,
marker . size ,
installation . ino ,
installation . mtimeMs ,
installation . ctimeMs
] . join ( ':' ) ;
}
catch {
return undefined ;
}
}
2026-09-03 13:27:24 -04:00
function getJdkVerificationIdentity ( verifySignature , enforceSignatureVerification , publicKey ) {
Add conditional JDK caching (#1201)
* Add JDK caching
Cache resolved JDK tool-cache entries by exact platform and release identity, with a default-on cache-jdk input and explicit opt-out.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* Apply batched suggestions from code review
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
* Fix JDK cache CI validation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* Update brace-expansion security fix
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* Refresh brace-expansion license metadata
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* Refine JDK cache semantics
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* Refine JDK cache documentation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* Simplify JDK cache identity
Use one normalized runner OS dimension, reset the internal cache key schema for the unreleased feature, and align documentation, tests, and bundles.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* Align JDK cache OS identity
Use the established RUNNER_OS value directly and retain process.platform only as a non-Actions fallback.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* Harden JDK cache saves and document tool-cache reuse
Bind each JDK cache key to the installation identity it was computed for,
keep post-job saves best-effort per entry, and state the real reuse and
verification guarantee in the documentation.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* docs: restructure README caching section
Rename '## Caching dependencies' to '## Caching' and add a what-gets-cached
overview table covering the dependency, wrapper, and JDK caches. Lead with the
common 'cache: maven' example and the dependency-cache material, and demote JDK
caching into its own subsection.
Also corrects the IMPORTANT callout, which implied JDK caching required an
explicit opt-in; it is enabled implicitly whenever 'cache' is set.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* docs: fix caching documentation defects
- Remove pull-request framing that compared behavior to `main`; state the
tool-cache and `jdkfile` behavior directly and unconditionally.
- Clarify that the JDK cache is a separate cache *entry* from the dependency
and wrapper caches, while its *enablement* is coupled to `cache`, so the
opening paragraph agrees with the enablement matrix.
- Cite the actions/setup-java-benchmarks repository instead of an open PR and
a self-referential PR comment, keeping the measured figures and caveats.
- Keep the `cache`/`cache-jdk` matrix only in docs/advanced-usage.md and
summarize the rules in prose in README.md to avoid divergence.
- Describe the guarantee that a cache key is only saved with the installation
it was computed for, instead of documenting inode/size/timestamp internals.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* docs: add V6 what's new entry for JDK caching
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: e2755464-4e83-47b6-ba71-731bb481b418
---------
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot-Session: e2755464-4e83-47b6-ba71-731bb481b418
2026-08-04 21:54:10 -04:00
if ( ! verifySignature ) {
2026-09-03 13:27:24 -04:00
return 'disabled' ;
Add conditional JDK caching (#1201)
* Add JDK caching
Cache resolved JDK tool-cache entries by exact platform and release identity, with a default-on cache-jdk input and explicit opt-out.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* Apply batched suggestions from code review
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
* Fix JDK cache CI validation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* Update brace-expansion security fix
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* Refresh brace-expansion license metadata
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* Refine JDK cache semantics
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* Refine JDK cache documentation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* Simplify JDK cache identity
Use one normalized runner OS dimension, reset the internal cache key schema for the unreleased feature, and align documentation, tests, and bundles.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* Align JDK cache OS identity
Use the established RUNNER_OS value directly and retain process.platform only as a non-Actions fallback.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* Harden JDK cache saves and document tool-cache reuse
Bind each JDK cache key to the installation identity it was computed for,
keep post-job saves best-effort per entry, and state the real reuse and
verification guarantee in the documentation.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* docs: restructure README caching section
Rename '## Caching dependencies' to '## Caching' and add a what-gets-cached
overview table covering the dependency, wrapper, and JDK caches. Lead with the
common 'cache: maven' example and the dependency-cache material, and demote JDK
caching into its own subsection.
Also corrects the IMPORTANT callout, which implied JDK caching required an
explicit opt-in; it is enabled implicitly whenever 'cache' is set.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* docs: fix caching documentation defects
- Remove pull-request framing that compared behavior to `main`; state the
tool-cache and `jdkfile` behavior directly and unconditionally.
- Clarify that the JDK cache is a separate cache *entry* from the dependency
and wrapper caches, while its *enablement* is coupled to `cache`, so the
opening paragraph agrees with the enablement matrix.
- Cite the actions/setup-java-benchmarks repository instead of an open PR and
a self-referential PR comment, keeping the measured figures and caveats.
- Keep the `cache`/`cache-jdk` matrix only in docs/advanced-usage.md and
summarize the rules in prose in README.md to avoid divergence.
- Describe the guarantee that a cache key is only saved with the installation
it was computed for, instead of documenting inode/size/timestamp internals.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* docs: add V6 what's new entry for JDK caching
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: e2755464-4e83-47b6-ba71-731bb481b418
---------
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot-Session: e2755464-4e83-47b6-ba71-731bb481b418
2026-08-04 21:54:10 -04:00
}
2026-09-03 13:27:24 -04:00
const verificationPolicy = enforceSignatureVerification
? 'enforced'
: 'check-and-warn' ;
Add conditional JDK caching (#1201)
* Add JDK caching
Cache resolved JDK tool-cache entries by exact platform and release identity, with a default-on cache-jdk input and explicit opt-out.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* Apply batched suggestions from code review
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
* Fix JDK cache CI validation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* Update brace-expansion security fix
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* Refresh brace-expansion license metadata
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* Refine JDK cache semantics
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* Refine JDK cache documentation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* Simplify JDK cache identity
Use one normalized runner OS dimension, reset the internal cache key schema for the unreleased feature, and align documentation, tests, and bundles.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* Align JDK cache OS identity
Use the established RUNNER_OS value directly and retain process.platform only as a non-Actions fallback.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* Harden JDK cache saves and document tool-cache reuse
Bind each JDK cache key to the installation identity it was computed for,
keep post-job saves best-effort per entry, and state the real reuse and
verification guarantee in the documentation.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* docs: restructure README caching section
Rename '## Caching dependencies' to '## Caching' and add a what-gets-cached
overview table covering the dependency, wrapper, and JDK caches. Lead with the
common 'cache: maven' example and the dependency-cache material, and demote JDK
caching into its own subsection.
Also corrects the IMPORTANT callout, which implied JDK caching required an
explicit opt-in; it is enabled implicitly whenever 'cache' is set.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* docs: fix caching documentation defects
- Remove pull-request framing that compared behavior to `main`; state the
tool-cache and `jdkfile` behavior directly and unconditionally.
- Clarify that the JDK cache is a separate cache *entry* from the dependency
and wrapper caches, while its *enablement* is coupled to `cache`, so the
opening paragraph agrees with the enablement matrix.
- Cite the actions/setup-java-benchmarks repository instead of an open PR and
a self-referential PR comment, keeping the measured figures and caveats.
- Keep the `cache`/`cache-jdk` matrix only in docs/advanced-usage.md and
summarize the rules in prose in README.md to avoid divergence.
- Describe the guarantee that a cache key is only saved with the installation
it was computed for, instead of documenting inode/size/timestamp internals.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* docs: add V6 what's new entry for JDK caching
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: e2755464-4e83-47b6-ba71-731bb481b418
---------
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot-Session: e2755464-4e83-47b6-ba71-731bb481b418
2026-08-04 21:54:10 -04:00
if ( ! publicKey ) {
2026-09-03 13:27:24 -04:00
return ` ${ verificationPolicy } :bundled ` ;
Add conditional JDK caching (#1201)
* Add JDK caching
Cache resolved JDK tool-cache entries by exact platform and release identity, with a default-on cache-jdk input and explicit opt-out.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* Apply batched suggestions from code review
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
* Fix JDK cache CI validation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* Update brace-expansion security fix
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* Refresh brace-expansion license metadata
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* Refine JDK cache semantics
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* Refine JDK cache documentation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* Simplify JDK cache identity
Use one normalized runner OS dimension, reset the internal cache key schema for the unreleased feature, and align documentation, tests, and bundles.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* Align JDK cache OS identity
Use the established RUNNER_OS value directly and retain process.platform only as a non-Actions fallback.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* Harden JDK cache saves and document tool-cache reuse
Bind each JDK cache key to the installation identity it was computed for,
keep post-job saves best-effort per entry, and state the real reuse and
verification guarantee in the documentation.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* docs: restructure README caching section
Rename '## Caching dependencies' to '## Caching' and add a what-gets-cached
overview table covering the dependency, wrapper, and JDK caches. Lead with the
common 'cache: maven' example and the dependency-cache material, and demote JDK
caching into its own subsection.
Also corrects the IMPORTANT callout, which implied JDK caching required an
explicit opt-in; it is enabled implicitly whenever 'cache' is set.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* docs: fix caching documentation defects
- Remove pull-request framing that compared behavior to `main`; state the
tool-cache and `jdkfile` behavior directly and unconditionally.
- Clarify that the JDK cache is a separate cache *entry* from the dependency
and wrapper caches, while its *enablement* is coupled to `cache`, so the
opening paragraph agrees with the enablement matrix.
- Cite the actions/setup-java-benchmarks repository instead of an open PR and
a self-referential PR comment, keeping the measured figures and caveats.
- Keep the `cache`/`cache-jdk` matrix only in docs/advanced-usage.md and
summarize the rules in prose in README.md to avoid divergence.
- Describe the guarantee that a cache key is only saved with the installation
it was computed for, instead of documenting inode/size/timestamp internals.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* docs: add V6 what's new entry for JDK caching
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: e2755464-4e83-47b6-ba71-731bb481b418
---------
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot-Session: e2755464-4e83-47b6-ba71-731bb481b418
2026-08-04 21:54:10 -04:00
}
2026-09-03 13:27:24 -04:00
const publicKeys = Array . isArray ( publicKey ) ? publicKey : [ publicKey ] ;
const normalizedKeys = publicKeys . map ( key => key . replace ( /\r\n?/g , '\n' ) . trim ( ) ) ;
const fingerprintSource = Array . isArray ( publicKey )
? normalizedKeys . map ( key => ` ${ Buffer . byteLength ( key ) } : ${ key } ` ) . join ( '' )
: normalizedKeys [ 0 ] ;
const fingerprint = ( 0 , crypto _ _WEBPACK _IMPORTED _MODULE _0 _ _ . createHash ) ( 'sha256' )
. update ( fingerprintSource )
. digest ( 'hex' ) ;
return ` ${ verificationPolicy } :custom:sha256: ${ fingerprint } ` ;
Add conditional JDK caching (#1201)
* Add JDK caching
Cache resolved JDK tool-cache entries by exact platform and release identity, with a default-on cache-jdk input and explicit opt-out.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* Apply batched suggestions from code review
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
* Fix JDK cache CI validation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* Update brace-expansion security fix
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* Refresh brace-expansion license metadata
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* Refine JDK cache semantics
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* Refine JDK cache documentation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* Simplify JDK cache identity
Use one normalized runner OS dimension, reset the internal cache key schema for the unreleased feature, and align documentation, tests, and bundles.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* Align JDK cache OS identity
Use the established RUNNER_OS value directly and retain process.platform only as a non-Actions fallback.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* Harden JDK cache saves and document tool-cache reuse
Bind each JDK cache key to the installation identity it was computed for,
keep post-job saves best-effort per entry, and state the real reuse and
verification guarantee in the documentation.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* docs: restructure README caching section
Rename '## Caching dependencies' to '## Caching' and add a what-gets-cached
overview table covering the dependency, wrapper, and JDK caches. Lead with the
common 'cache: maven' example and the dependency-cache material, and demote JDK
caching into its own subsection.
Also corrects the IMPORTANT callout, which implied JDK caching required an
explicit opt-in; it is enabled implicitly whenever 'cache' is set.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* docs: fix caching documentation defects
- Remove pull-request framing that compared behavior to `main`; state the
tool-cache and `jdkfile` behavior directly and unconditionally.
- Clarify that the JDK cache is a separate cache *entry* from the dependency
and wrapper caches, while its *enablement* is coupled to `cache`, so the
opening paragraph agrees with the enablement matrix.
- Cite the actions/setup-java-benchmarks repository instead of an open PR and
a self-referential PR comment, keeping the measured figures and caveats.
- Keep the `cache`/`cache-jdk` matrix only in docs/advanced-usage.md and
summarize the rules in prose in README.md to avoid divergence.
- Describe the guarantee that a cache key is only saved with the installation
it was computed for, instead of documenting inode/size/timestamp internals.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
* docs: add V6 what's new entry for JDK caching
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: e2755464-4e83-47b6-ba71-731bb481b418
---------
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot-Session: e2755464-4e83-47b6-ba71-731bb481b418
2026-08-04 21:54:10 -04:00
}
async function saveJdkCaches ( ) {
const state = _actions _core _ _WEBPACK _IMPORTED _MODULE _4 _ _ /* .getState */ . Gu ( STATE _JDK _CACHES ) ;
if ( ! state ) {
return ;
}
const caches = parseJdkCacheState ( state ) ;
for ( const jdk of caches ) {
if ( jdk . matchedKey === jdk . key ) {
_actions _core _ _WEBPACK _IMPORTED _MODULE _4 _ _ /* .info */ . pq ( ` Cache hit occurred on the JDK primary key ${ jdk . key } , not saving cache. ` ) ;
continue ;
}
if ( ! fs _ _WEBPACK _IMPORTED _MODULE _1 _ _ _default ( ) . existsSync ( jdk . path ) ) {
_actions _core _ _WEBPACK _IMPORTED _MODULE _4 _ _ /* .debug */ . Yz ( ` JDK cache path does not exist, not saving: ${ jdk . path } ` ) ;
continue ;
}
if ( ! jdk . installation ) {
_actions _core _ _WEBPACK _IMPORTED _MODULE _4 _ _ /* .debug */ . Yz ( ` No JDK installation was registered for the key ${ jdk . key } , not saving cache. ` ) ;
continue ;
}
if ( getInstallationIdentity ( jdk . path , jdk . architecture ) !== jdk . installation ) {
_actions _core _ _WEBPACK _IMPORTED _MODULE _4 _ _ /* .warning */ . $e ( ` The JDK installation in ${ jdk . path } was replaced after it was registered for the key ${ jdk . key } ; not saving cache. ` ) ;
continue ;
}
try {
const cacheId = await _actions _cache _ _WEBPACK _IMPORTED _MODULE _3 _ _ /* .saveCache */ . Io ( [ jdk . path ] , jdk . key ) ;
if ( cacheId !== - 1 ) {
_actions _core _ _WEBPACK _IMPORTED _MODULE _4 _ _ /* .info */ . pq ( ` JDK cache saved with the key: ${ jdk . key } ` ) ;
}
}
catch ( error ) {
const err = error ;
if ( err . name === _actions _cache _ _WEBPACK _IMPORTED _MODULE _3 _ _ /* .ReserveCacheError */ . Zh . name ) {
_actions _core _ _WEBPACK _IMPORTED _MODULE _4 _ _ /* .info */ . pq ( err . message ) ;
}
else {
// Saving is best-effort and per entry: one failure must not suppress
// the remaining JDK caches.
_actions _core _ _WEBPACK _IMPORTED _MODULE _4 _ _ /* .warning */ . $e ( ` Failed to save the JDK cache with the key ${ jdk . key } : ${ err . message } ` ) ;
}
}
}
}
function buildJdkCacheKey ( jdk ) {
const runnerOs = process . env [ 'RUNNER_OS' ] ? ? process . platform ;
const normalizedArchitecture = jdk . architecture . toLowerCase ( ) ;
const identity = JSON . stringify ( {
keyVersion : JDK _CACHE _KEY _VERSION ,
runnerOs ,
distribution : jdk . distribution . toLowerCase ( ) ,
packageType : jdk . packageType . toLowerCase ( ) ,
architecture : normalizedArchitecture ,
version : jdk . version ,
source : jdk . source ,
verification : jdk . verification
} ) ;
const digest = ( 0 , crypto _ _WEBPACK _IMPORTED _MODULE _0 _ _ . createHash ) ( 'sha256' ) . update ( identity ) . digest ( 'hex' ) ;
return ` setup-java-jdk-v ${ JDK _CACHE _KEY _VERSION } - ${ runnerOs } - ${ normalizedArchitecture } - ${ digest } ` ;
}
function recordJdkCache ( jdk ) {
const existing = restoredCaches . findIndex ( item => item . key === jdk . key && item . path === jdk . path ) ;
if ( existing === - 1 ) {
restoredCaches . push ( jdk ) ;
}
else {
restoredCaches [ existing ] = { ... restoredCaches [ existing ] , ... jdk } ;
}
_actions _core _ _WEBPACK _IMPORTED _MODULE _4 _ _ /* .saveState */ . LZ ( STATE _JDK _CACHES , JSON . stringify ( restoredCaches ) ) ;
}
function parseJdkCacheState ( state ) {
const value = JSON . parse ( state ) ;
if ( ! Array . isArray ( value ) ||
! value . every ( item => typeof item === 'object' &&
item !== null &&
typeof item . key === 'string' &&
typeof item . path === 'string' &&
typeof item . architecture === 'string' &&
( item . matchedKey === undefined ||
typeof item . matchedKey === 'string' ) &&
( item . installation === undefined ||
typeof item . installation === 'string' ) ) ) {
throw new Error ( 'Invalid JDK cache information retrieved from state.' ) ;
}
return value ;
}
/***/ } )
} ;