From b69ad351aa3daed07de3f4d0e62a057b6f8c4132 Mon Sep 17 00:00:00 2001 From: Oran Avraham Date: Sat, 24 Dec 2022 16:29:40 +0200 Subject: [PATCH] poetry: Bump cache primary key --- __tests__/cache-restore.test.ts | 4 ++++ dist/setup/index.js | 3 ++- src/cache-distributions/poetry-cache.ts | 3 ++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/__tests__/cache-restore.test.ts b/__tests__/cache-restore.test.ts index 44b400eef..d6ed8320b 100644 --- a/__tests__/cache-restore.test.ts +++ b/__tests__/cache-restore.test.ts @@ -183,6 +183,10 @@ virtualenvs.path = "{cache-dir}/virtualenvs" # /Users/patrick/Library/Caches/py expect(infoSpy).toHaveBeenCalledWith( `Cache restored from key: setup-python-${process.env['RUNNER_OS']}-20.04-Ubuntu-python-${pythonVersion}-${packageManager}-${fileHash}` ); + } else if (packageManager === 'poetry') { + expect(infoSpy).toHaveBeenCalledWith( + `Cache restored from key: setup-python-${process.env['RUNNER_OS']}-python-${pythonVersion}-${packageManager}-v2-${fileHash}` + ); } else { expect(infoSpy).toHaveBeenCalledWith( `Cache restored from key: setup-python-${process.env['RUNNER_OS']}-python-${pythonVersion}-${packageManager}-${fileHash}` diff --git a/dist/setup/index.js b/dist/setup/index.js index 41ed58a1f..266dce5f4 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -66141,7 +66141,8 @@ class PoetryCache extends cache_distributor_1.default { computeKeys() { return __awaiter(this, void 0, void 0, function* () { const hash = yield glob.hashFiles(this.patterns); - const primaryKey = `${this.CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-python-${this.pythonVersion}-${this.packageManager}-${hash}`; + // "v2" is here to invalidate old caches of this cache distributor, which were created broken: + const primaryKey = `${this.CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-python-${this.pythonVersion}-${this.packageManager}-v2-${hash}`; const restoreKey = undefined; return { primaryKey, diff --git a/src/cache-distributions/poetry-cache.ts b/src/cache-distributions/poetry-cache.ts index ebbffbacf..c31fb05d4 100644 --- a/src/cache-distributions/poetry-cache.ts +++ b/src/cache-distributions/poetry-cache.ts @@ -46,7 +46,8 @@ class PoetryCache extends CacheDistributor { protected async computeKeys() { const hash = await glob.hashFiles(this.patterns); - const primaryKey = `${this.CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-python-${this.pythonVersion}-${this.packageManager}-${hash}`; + // "v2" is here to invalidate old caches of this cache distributor, which were created broken: + const primaryKey = `${this.CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-python-${this.pythonVersion}-${this.packageManager}-v2-${hash}`; const restoreKey = undefined; return { primaryKey,