From 1626f2bd943cd202b1338d967340eb6c987e5067 Mon Sep 17 00:00:00 2001 From: bbernays Date: Sat, 14 Jan 2023 10:43:01 -0500 Subject: [PATCH] Support Caching in Mono Repo (#629) --- dist/post_run/index.js | 9 +++++++-- dist/run/index.js | 9 +++++++-- src/cache.ts | 10 +++++++--- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/dist/post_run/index.js b/dist/post_run/index.js index 40c8157edf..0b35b2b3ab 100644 --- a/dist/post_run/index.js +++ b/dist/post_run/index.js @@ -67482,9 +67482,14 @@ function buildCacheKeys() { // TODO: configure it via inputs. let cacheKey = `golangci-lint.cache-${getIntervalKey(7)}-`; keys.push(cacheKey); - if (yield pathExists(`go.mod`)) { + // Get working directory from input + const workingDirectory = core.getInput(`working-directory`); + // create path to go.mod prepending the workingDirectory if it exists + const goModPath = path_1.default.join(workingDirectory, `go.mod`); + core.info(`Checking for go.mod: ${goModPath}`); + if (yield pathExists(goModPath)) { // Add checksum to key to invalidate a cache when dependencies change. - cacheKey += yield checksumFile(`sha1`, `go.mod`); + cacheKey += yield checksumFile(`sha1`, goModPath); } else { cacheKey += `nogomod`; diff --git a/dist/run/index.js b/dist/run/index.js index 6ebddf47d7..29fda28ff7 100644 --- a/dist/run/index.js +++ b/dist/run/index.js @@ -67482,9 +67482,14 @@ function buildCacheKeys() { // TODO: configure it via inputs. let cacheKey = `golangci-lint.cache-${getIntervalKey(7)}-`; keys.push(cacheKey); - if (yield pathExists(`go.mod`)) { + // Get working directory from input + const workingDirectory = core.getInput(`working-directory`); + // create path to go.mod prepending the workingDirectory if it exists + const goModPath = path_1.default.join(workingDirectory, `go.mod`); + core.info(`Checking for go.mod: ${goModPath}`); + if (yield pathExists(goModPath)) { // Add checksum to key to invalidate a cache when dependencies change. - cacheKey += yield checksumFile(`sha1`, `go.mod`); + cacheKey += yield checksumFile(`sha1`, goModPath); } else { cacheKey += `nogomod`; diff --git a/src/cache.ts b/src/cache.ts index a06f33f5e6..cb8f828ac9 100644 --- a/src/cache.ts +++ b/src/cache.ts @@ -56,10 +56,14 @@ async function buildCacheKeys(): Promise { // TODO: configure it via inputs. let cacheKey = `golangci-lint.cache-${getIntervalKey(7)}-` keys.push(cacheKey) - - if (await pathExists(`go.mod`)) { + // Get working directory from input + const workingDirectory = core.getInput(`working-directory`) + // create path to go.mod prepending the workingDirectory if it exists + const goModPath = path.join(workingDirectory, `go.mod`) + core.info(`Checking for go.mod: ${goModPath}`) + if (await pathExists(goModPath)) { // Add checksum to key to invalidate a cache when dependencies change. - cacheKey += await checksumFile(`sha1`, `go.mod`) + cacheKey += await checksumFile(`sha1`, goModPath) } else { cacheKey += `nogomod` }