From d93ab869ca2779e4c2090725309bb49d18286b25 Mon Sep 17 00:00:00 2001 From: Eric Zimanyi Date: Sat, 7 May 2022 14:11:31 -0400 Subject: [PATCH] Expire cache periodically to avoid unbounded size The cache key includes a sequence number that rotates every 7 days but because we are also using the base `golangci-lint.cache` as a restore key, the new cache will always be seeded with the full contents of the old cache. In particular for the go module cache, this leads to an ever increasing number of cached packages that never get pruned. This commit updates it so we stop using `golangci-lint.cache` as a restore key, which will force a build from an empty cache once every 7 days. --- src/cache.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/cache.ts b/src/cache.ts index c29f295..a06f33f 100644 --- a/src/cache.ts +++ b/src/cache.ts @@ -52,12 +52,9 @@ const getIntervalKey = (invalidationIntervalDays: number): string => { async function buildCacheKeys(): Promise { const keys = [] - let cacheKey = `golangci-lint.cache-` - keys.push(cacheKey) - // Periodically invalidate a cache because a new code being added. // TODO: configure it via inputs. - cacheKey += `${getIntervalKey(7)}-` + let cacheKey = `golangci-lint.cache-${getIntervalKey(7)}-` keys.push(cacheKey) if (await pathExists(`go.mod`)) {