From 555aead9ed6181791d6f98d1f7a8d330cef08386 Mon Sep 17 00:00:00 2001 From: rak Date: Tue, 18 Mar 2025 21:06:18 +0100 Subject: [PATCH] Fix for Gitea --- dist/cleanup/index.js | 8 +++++--- dist/setup/index.js | 8 +++++--- src/cache.ts | 8 +++++--- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/dist/cleanup/index.js b/dist/cleanup/index.js index b4dd99a4..703a626b 100644 --- a/dist/cleanup/index.js +++ b/dist/cleanup/index.js @@ -96552,6 +96552,7 @@ const cache = __importStar(__nccwpck_require__(7799)); const core = __importStar(__nccwpck_require__(2186)); const glob = __importStar(__nccwpck_require__(8090)); const STATE_CACHE_PRIMARY_KEY = 'cache-primary-key'; +const STATE_CACHE_HIT = 'cache-hit'; const CACHE_MATCHED_KEY = 'cache-matched-key'; const CACHE_KEY_PREFIX = 'setup-java'; const supportedPackageManager = [ @@ -96624,7 +96625,7 @@ function computeCacheKey(packageManager, cacheDependencyPath) { if (!fileHash) { throw new Error(`No file in ${process.cwd()} matched to [${pattern}], make sure you have checked out the target repository`); } - return `${CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-${process.arch}-${packageManager.id}-${fileHash}`; + return `${CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-ABC-${process.arch}-${packageManager.id}-${fileHash}`; }); } /** @@ -96642,7 +96643,7 @@ function restore(id, cacheDependencyPath) { const matchedKey = yield cache.restoreCache(packageManager.path, primaryKey); if (matchedKey) { core.saveState(CACHE_MATCHED_KEY, matchedKey); - core.setOutput('cache-hit', matchedKey === primaryKey); + core.setOutput('cache-hit', true); core.info(`Cache restored from key: ${matchedKey}`); } else { @@ -96662,11 +96663,12 @@ function save(id) { const matchedKey = core.getState(CACHE_MATCHED_KEY); // Inputs are re-evaluated before the post action, so we want the original key used for restore const primaryKey = core.getState(STATE_CACHE_PRIMARY_KEY); + const cacheHit = core.getState(STATE_CACHE_HIT); if (!primaryKey) { core.warning('Error retrieving key from state.'); return; } - else if (matchedKey === primaryKey) { + else if (matchedKey === primaryKey || cacheHit) { // no change in target directories core.info(`Cache hit occurred on the primary key ${primaryKey}, not saving cache.`); return; diff --git a/dist/setup/index.js b/dist/setup/index.js index 74b3ff1a..3ed99fbf 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -131801,6 +131801,7 @@ const cache = __importStar(__nccwpck_require__(27799)); const core = __importStar(__nccwpck_require__(42186)); const glob = __importStar(__nccwpck_require__(28090)); const STATE_CACHE_PRIMARY_KEY = 'cache-primary-key'; +const STATE_CACHE_HIT = 'cache-hit'; const CACHE_MATCHED_KEY = 'cache-matched-key'; const CACHE_KEY_PREFIX = 'setup-java'; const supportedPackageManager = [ @@ -131873,7 +131874,7 @@ function computeCacheKey(packageManager, cacheDependencyPath) { if (!fileHash) { throw new Error(`No file in ${process.cwd()} matched to [${pattern}], make sure you have checked out the target repository`); } - return `${CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-${process.arch}-${packageManager.id}-${fileHash}`; + return `${CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-ABC-${process.arch}-${packageManager.id}-${fileHash}`; }); } /** @@ -131891,7 +131892,7 @@ function restore(id, cacheDependencyPath) { const matchedKey = yield cache.restoreCache(packageManager.path, primaryKey); if (matchedKey) { core.saveState(CACHE_MATCHED_KEY, matchedKey); - core.setOutput('cache-hit', matchedKey === primaryKey); + core.setOutput('cache-hit', true); core.info(`Cache restored from key: ${matchedKey}`); } else { @@ -131911,11 +131912,12 @@ function save(id) { const matchedKey = core.getState(CACHE_MATCHED_KEY); // Inputs are re-evaluated before the post action, so we want the original key used for restore const primaryKey = core.getState(STATE_CACHE_PRIMARY_KEY); + const cacheHit = core.getState(STATE_CACHE_HIT); if (!primaryKey) { core.warning('Error retrieving key from state.'); return; } - else if (matchedKey === primaryKey) { + else if (matchedKey === primaryKey || cacheHit) { // no change in target directories core.info(`Cache hit occurred on the primary key ${primaryKey}, not saving cache.`); return; diff --git a/src/cache.ts b/src/cache.ts index 7d13839e..65f40c4e 100644 --- a/src/cache.ts +++ b/src/cache.ts @@ -9,6 +9,7 @@ import * as core from '@actions/core'; import * as glob from '@actions/glob'; const STATE_CACHE_PRIMARY_KEY = 'cache-primary-key'; +const STATE_CACHE_HIT = 'cache-hit'; const CACHE_MATCHED_KEY = 'cache-matched-key'; const CACHE_KEY_PREFIX = 'setup-java'; @@ -98,7 +99,7 @@ async function computeCacheKey( `No file in ${process.cwd()} matched to [${pattern}], make sure you have checked out the target repository` ); } - return `${CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-${process.arch}-${packageManager.id}-${fileHash}`; + return `${CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-ABC-${process.arch}-${packageManager.id}-${fileHash}`; } /** @@ -116,7 +117,7 @@ export async function restore(id: string, cacheDependencyPath: string) { const matchedKey = await cache.restoreCache(packageManager.path, primaryKey); if (matchedKey) { core.saveState(CACHE_MATCHED_KEY, matchedKey); - core.setOutput('cache-hit', matchedKey === primaryKey); + core.setOutput('cache-hit', true); core.info(`Cache restored from key: ${matchedKey}`); } else { core.setOutput('cache-hit', false); @@ -134,11 +135,12 @@ export async function save(id: string) { // Inputs are re-evaluated before the post action, so we want the original key used for restore const primaryKey = core.getState(STATE_CACHE_PRIMARY_KEY); + const cacheHit = core.getState(STATE_CACHE_HIT); if (!primaryKey) { core.warning('Error retrieving key from state.'); return; - } else if (matchedKey === primaryKey) { + } else if (matchedKey === primaryKey || cacheHit) { // no change in target directories core.info( `Cache hit occurred on the primary key ${primaryKey}, not saving cache.`