Skip to content

Commit

Permalink
Support Caching in Mono Repo (#629)
Browse files Browse the repository at this point in the history
  • Loading branch information
bbernays authored Jan 14, 2023
1 parent b56f6f5 commit 1626f2b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
9 changes: 7 additions & 2 deletions dist/post_run/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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`;
Expand Down
9 changes: 7 additions & 2 deletions dist/run/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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`;
Expand Down
10 changes: 7 additions & 3 deletions src/cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,14 @@ async function buildCacheKeys(): Promise<string[]> {
// 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`
}
Expand Down

0 comments on commit 1626f2b

Please sign in to comment.