From fca93898f96e578ec04a69c2e3729af44c9b81f3 Mon Sep 17 00:00:00 2001 From: Dmitry Shibanov Date: Mon, 3 Apr 2023 16:13:04 +0200 Subject: [PATCH 1/2] fix previous logic --- __tests__/cache-save.test.ts | 7 +++++++ dist/cache-save/index.js | 7 ++++++- src/cache-save.ts | 11 ++++++++++- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/__tests__/cache-save.test.ts b/__tests__/cache-save.test.ts index 1cf7f89a8..26f7da24b 100644 --- a/__tests__/cache-save.test.ts +++ b/__tests__/cache-save.test.ts @@ -87,6 +87,7 @@ describe('run', () => { describe('Validate unchanged cache is not saved', () => { it('should not save cache for pip', async () => { inputs['cache'] = 'pip'; + inputs['python-version'] = '3.10.0'; await run(); @@ -103,6 +104,7 @@ describe('run', () => { it('should not save cache for pipenv', async () => { inputs['cache'] = 'pipenv'; + inputs['python-version'] = '3.10.0'; await run(); @@ -121,6 +123,7 @@ describe('run', () => { describe('action saves the cache', () => { it('saves cache from pip', async () => { inputs['cache'] = 'pip'; + inputs['python-version'] = '3.10.0'; getStateSpy.mockImplementation((name: string) => { if (name === State.CACHE_MATCHED_KEY) { return requirementsHash; @@ -147,6 +150,7 @@ describe('run', () => { it('saves cache from pipenv', async () => { inputs['cache'] = 'pipenv'; + inputs['python-version'] = '3.10.0'; getStateSpy.mockImplementation((name: string) => { if (name === State.CACHE_MATCHED_KEY) { return pipFileLockHash; @@ -173,6 +177,7 @@ describe('run', () => { it('saves cache from poetry', async () => { inputs['cache'] = 'poetry'; + inputs['python-version'] = '3.10.0'; getStateSpy.mockImplementation((name: string) => { if (name === State.CACHE_MATCHED_KEY) { return poetryLockHash; @@ -199,6 +204,7 @@ describe('run', () => { it('saves with -1 cacheId , should not fail workflow', async () => { inputs['cache'] = 'poetry'; + inputs['python-version'] = '3.10.0'; getStateSpy.mockImplementation((name: string) => { if (name === State.STATE_CACHE_PRIMARY_KEY) { return poetryLockHash; @@ -227,6 +233,7 @@ describe('run', () => { it('saves with error from toolkit, should not fail the workflow', async () => { inputs['cache'] = 'npm'; + inputs['python-version'] = '3.10.0'; getStateSpy.mockImplementation((name: string) => { if (name === State.STATE_CACHE_PRIMARY_KEY) { return poetryLockHash; diff --git a/dist/cache-save/index.js b/dist/cache-save/index.js index cf6d38f58..6375d4bb8 100644 --- a/dist/cache-save/index.js +++ b/dist/cache-save/index.js @@ -59628,7 +59628,12 @@ function run() { exports.run = run; function saveCache(packageManager) { return __awaiter(this, void 0, void 0, function* () { - const cachePaths = JSON.parse(core.getState(cache_distributor_1.State.CACHE_PATHS)); + const cachePathState = core.getState(cache_distributor_1.State.CACHE_PATHS); + if (!cachePathState) { + core.warning('State paths for saving/restoring is empty. Could you please check previous logs and verify that the version python is specified version?'); + return; + } + const cachePaths = JSON.parse(cachePathState); core.debug(`paths for caching are ${cachePaths.join(', ')}`); if (!isCacheDirectoryExists(cachePaths)) { throw new Error(`Cache folder path is retrieved for ${packageManager} but doesn't exist on disk: ${cachePaths.join(', ')}`); diff --git a/src/cache-save.ts b/src/cache-save.ts index 711bccd93..64cbe64de 100644 --- a/src/cache-save.ts +++ b/src/cache-save.ts @@ -17,7 +17,16 @@ export async function run() { } async function saveCache(packageManager: string) { - const cachePaths = JSON.parse(core.getState(State.CACHE_PATHS)) as string[]; + const cachePathState = core.getState(State.CACHE_PATHS); + + if (!cachePathState) { + core.warning( + 'State paths for saving/restoring is empty. Could you please check previous logs and verify that the version python is specified version?' + ); + return; + } + + const cachePaths = JSON.parse(cachePathState) as string[]; core.debug(`paths for caching are ${cachePaths.join(', ')}`); From 1b4fbf71a09b95a90597e438c5a18ac4eb829bbf Mon Sep 17 00:00:00 2001 From: Dmitry Shibanov Date: Tue, 4 Apr 2023 12:22:43 +0200 Subject: [PATCH 2/2] fix comment --- dist/cache-save/index.js | 2 +- src/cache-save.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dist/cache-save/index.js b/dist/cache-save/index.js index 6375d4bb8..d5f534db1 100644 --- a/dist/cache-save/index.js +++ b/dist/cache-save/index.js @@ -59630,7 +59630,7 @@ function saveCache(packageManager) { return __awaiter(this, void 0, void 0, function* () { const cachePathState = core.getState(cache_distributor_1.State.CACHE_PATHS); if (!cachePathState) { - core.warning('State paths for saving/restoring is empty. Could you please check previous logs and verify that the version python is specified version?'); + core.warning('Cache paths are empty. Please check the previous logs and make sure that the python version is specified'); return; } const cachePaths = JSON.parse(cachePathState); diff --git a/src/cache-save.ts b/src/cache-save.ts index 64cbe64de..1017ef11d 100644 --- a/src/cache-save.ts +++ b/src/cache-save.ts @@ -21,7 +21,7 @@ async function saveCache(packageManager: string) { if (!cachePathState) { core.warning( - 'State paths for saving/restoring is empty. Could you please check previous logs and verify that the version python is specified version?' + 'Cache paths are empty. Please check the previous logs and make sure that the python version is specified' ); return; } pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy