Skip to content

Commit 1626f2b

Browse files
authored
Support Caching in Mono Repo (#629)
1 parent b56f6f5 commit 1626f2b

File tree

3 files changed

+21
-7
lines changed

3 files changed

+21
-7
lines changed

dist/post_run/index.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -67482,9 +67482,14 @@ function buildCacheKeys() {
6748267482
// TODO: configure it via inputs.
6748367483
let cacheKey = `golangci-lint.cache-${getIntervalKey(7)}-`;
6748467484
keys.push(cacheKey);
67485-
if (yield pathExists(`go.mod`)) {
67485+
// Get working directory from input
67486+
const workingDirectory = core.getInput(`working-directory`);
67487+
// create path to go.mod prepending the workingDirectory if it exists
67488+
const goModPath = path_1.default.join(workingDirectory, `go.mod`);
67489+
core.info(`Checking for go.mod: ${goModPath}`);
67490+
if (yield pathExists(goModPath)) {
6748667491
// Add checksum to key to invalidate a cache when dependencies change.
67487-
cacheKey += yield checksumFile(`sha1`, `go.mod`);
67492+
cacheKey += yield checksumFile(`sha1`, goModPath);
6748867493
}
6748967494
else {
6749067495
cacheKey += `nogomod`;

dist/run/index.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -67482,9 +67482,14 @@ function buildCacheKeys() {
6748267482
// TODO: configure it via inputs.
6748367483
let cacheKey = `golangci-lint.cache-${getIntervalKey(7)}-`;
6748467484
keys.push(cacheKey);
67485-
if (yield pathExists(`go.mod`)) {
67485+
// Get working directory from input
67486+
const workingDirectory = core.getInput(`working-directory`);
67487+
// create path to go.mod prepending the workingDirectory if it exists
67488+
const goModPath = path_1.default.join(workingDirectory, `go.mod`);
67489+
core.info(`Checking for go.mod: ${goModPath}`);
67490+
if (yield pathExists(goModPath)) {
6748667491
// Add checksum to key to invalidate a cache when dependencies change.
67487-
cacheKey += yield checksumFile(`sha1`, `go.mod`);
67492+
cacheKey += yield checksumFile(`sha1`, goModPath);
6748867493
}
6748967494
else {
6749067495
cacheKey += `nogomod`;

src/cache.ts

+7-3
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,14 @@ async function buildCacheKeys(): Promise<string[]> {
5656
// TODO: configure it via inputs.
5757
let cacheKey = `golangci-lint.cache-${getIntervalKey(7)}-`
5858
keys.push(cacheKey)
59-
60-
if (await pathExists(`go.mod`)) {
59+
// Get working directory from input
60+
const workingDirectory = core.getInput(`working-directory`)
61+
// create path to go.mod prepending the workingDirectory if it exists
62+
const goModPath = path.join(workingDirectory, `go.mod`)
63+
core.info(`Checking for go.mod: ${goModPath}`)
64+
if (await pathExists(goModPath)) {
6165
// Add checksum to key to invalidate a cache when dependencies change.
62-
cacheKey += await checksumFile(`sha1`, `go.mod`)
66+
cacheKey += await checksumFile(`sha1`, goModPath)
6367
} else {
6468
cacheKey += `nogomod`
6569
}

0 commit comments

Comments
 (0)