feat: use OS and working-directory as cache key (#1032)
This commit is contained in:
committed by
GitHub
parent
dbe4fc23f1
commit
21e9e6b47f
17
src/cache.ts
17
src/cache.ts
@ -38,15 +38,22 @@ const getIntervalKey = (invalidationIntervalDays: number): string => {
|
||||
async function buildCacheKeys(): Promise<string[]> {
|
||||
const keys = []
|
||||
|
||||
const invalidationIntervalDays = parseInt(core.getInput(`cache-invalidation-interval`, { required: true }).trim())
|
||||
|
||||
// Periodically invalidate a cache because a new code being added.
|
||||
let cacheKey = `golangci-lint.cache-${getIntervalKey(invalidationIntervalDays)}-`
|
||||
keys.push(cacheKey)
|
||||
// Cache by OS.
|
||||
let cacheKey = `golangci-lint.cache-${process.env?.RUNNER_OS}-`
|
||||
|
||||
// Get working directory from input
|
||||
const workingDirectory = core.getInput(`working-directory`)
|
||||
|
||||
if (workingDirectory) {
|
||||
cacheKey += `${workingDirectory}-`
|
||||
}
|
||||
|
||||
// Periodically invalidate a cache because a new code being added.
|
||||
const invalidationIntervalDays = parseInt(core.getInput(`cache-invalidation-interval`, { required: true }).trim())
|
||||
cacheKey += `${getIntervalKey(invalidationIntervalDays)}-`
|
||||
|
||||
keys.push(cacheKey)
|
||||
|
||||
// create path to go.mod prepending the workingDirectory if it exists
|
||||
const goModPath = path.join(workingDirectory, `go.mod`)
|
||||
|
||||
|
Reference in New Issue
Block a user