From 6f5b5ee7292482e1a430a02aa545bd3f446712fe Mon Sep 17 00:00:00 2001 From: Ryo Mimura Date: Fri, 21 Jun 2024 00:09:16 +0900 Subject: [PATCH] fix: Output chache hit timing --- __tests__/restore.test.ts | 2 +- src/restoreImpl.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/__tests__/restore.test.ts b/__tests__/restore.test.ts index 250f7ef..9b066eb 100644 --- a/__tests__/restore.test.ts +++ b/__tests__/restore.test.ts @@ -260,7 +260,7 @@ test("Fail restore when fail on cache miss is enabled and primary + restore keys ); expect(stateMock).toHaveBeenCalledWith("CACHE_KEY", key); - expect(setCacheHitOutputMock).toHaveBeenCalledTimes(0); + expect(setCacheHitOutputMock).toHaveBeenCalledTimes(1); expect(failedMock).toHaveBeenCalledWith( `Failed to restore cache entry. Exiting as fail-on-cache-miss is set. Input key: ${key}` diff --git a/src/restoreImpl.ts b/src/restoreImpl.ts index b71abd1..bb302ac 100644 --- a/src/restoreImpl.ts +++ b/src/restoreImpl.ts @@ -51,6 +51,7 @@ export async function restoreImpl( ); if (!cacheKey) { + core.setOutput(Outputs.CacheHit, false.toString()); if (failOnCacheMiss) { throw new Error( `Failed to restore cache entry. Exiting as fail-on-cache-miss is set. Input key: ${primaryKey}` @@ -62,7 +63,6 @@ export async function restoreImpl( ...restoreKeys ].join(", ")}` ); - core.setOutput(Outputs.CacheHit, false.toString()); return; }