Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Caching in Mono Repo #629

Merged
merged 1 commit into from
Jan 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions dist/post_run/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -67348,9 +67348,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 @@ -67348,9 +67348,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