From cab99b362baa5afbbd8c7c78234e6b071b80687d Mon Sep 17 00:00:00 2001 From: Sergey Dolin Date: Fri, 11 Aug 2023 00:31:51 +0200 Subject: [PATCH 1/2] fix typo proceeded/processed --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d2c2acc3..06c2a472 100644 --- a/README.md +++ b/README.md @@ -29,8 +29,8 @@ You can find more information about the required permissions under the correspon ## Statefulness If the action ends because of [operations-per-run](#operations-per-run) then the next run will start from the first -unprocessed issue skipping the issues proceeded during the previous run(s). The state is reset when all the issues are -proceeded. This should be considered for scheduling workflow runs. +unprocessed issue skipping the issues processed during the previous run(s). The state is reset when all the issues are +processed. This should be considered for scheduling workflow runs. The saved state lifetime is the same as the [actions cache](https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#usage-limits-and-eviction-policy) From 8986f6218b4935e254d5b844e8c36b4d953f2643 Mon Sep 17 00:00:00 2001 From: Sergey Dolin Date: Tue, 22 Aug 2023 10:07:11 +0200 Subject: [PATCH 2/2] Don not try to delete cache if it does not exists --- dist/index.js | 7 +++++-- src/classes/state/state-cache-storage.ts | 11 +++++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/dist/index.js b/dist/index.js index 343c8313..cfcb005d 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1636,7 +1636,7 @@ const resetCacheWithOctokit = (cacheKey) => __awaiter(void 0, void 0, void 0, fu } catch (error) { if (error.status) { - core.debug(`Cache ${cacheKey} does not exist`); + core.warning(`Error delete ${cacheKey}: [${error.status}] ${error.message || 'Unknown reason'}`); } else { throw error; @@ -1650,7 +1650,10 @@ class StateCacheStorage { const filePath = path_1.default.join(tmpDir, STATE_FILE); fs_1.default.writeFileSync(filePath, serializedState); try { - yield resetCacheWithOctokit(CACHE_KEY); + const cacheExists = yield checkIfCacheExists(CACHE_KEY); + if (cacheExists) { + yield resetCacheWithOctokit(CACHE_KEY); + } const fileSize = fs_1.default.statSync(filePath).size; if (fileSize === 0) { core.info(`the state will be removed`); diff --git a/src/classes/state/state-cache-storage.ts b/src/classes/state/state-cache-storage.ts index 848872a3..b30b503b 100644 --- a/src/classes/state/state-cache-storage.ts +++ b/src/classes/state/state-cache-storage.ts @@ -54,7 +54,11 @@ const resetCacheWithOctokit = async (cacheKey: string): Promise => { ); } catch (error) { if (error.status) { - core.debug(`Cache ${cacheKey} does not exist`); + core.warning( + `Error delete ${cacheKey}: [${error.status}] ${ + error.message || 'Unknown reason' + }` + ); } else { throw error; } @@ -67,7 +71,10 @@ export class StateCacheStorage implements IStateStorage { fs.writeFileSync(filePath, serializedState); try { - await resetCacheWithOctokit(CACHE_KEY); + const cacheExists = await checkIfCacheExists(CACHE_KEY); + if (cacheExists) { + await resetCacheWithOctokit(CACHE_KEY); + } const fileSize = fs.statSync(filePath).size; if (fileSize === 0) {