Add options to skip caching of folders. (#154)

Add option to skip caching the Go package directory (~/go/pkg).
Add option to skip caching the Go build directory (~/.cache/go-build).
Update README to mention new options.
This commit is contained in:
Sindre Røkenes Myren
2021-02-14 17:59:58 +01:00
committed by GitHub
parent e1ae6cf354
commit 0dd30832fc
5 changed files with 63 additions and 4 deletions

View File

@ -25,7 +25,22 @@ const getLintCacheDir = (): string => {
const getCacheDirs = (): string[] => {
// Not existing dirs are ok here: it works.
return [getLintCacheDir(), path.resolve(`${process.env.HOME}/.cache/go-build`), path.resolve(`${process.env.HOME}/go/pkg`)]
const skipPkgCache = core.getInput(`skip-pkg-cache`, { required: true }).trim()
const skipBuildCache = core.getInput(`skip-build-cache`, { required: true }).trim()
const dirs = [getLintCacheDir()]
if (skipBuildCache.toLowerCase() == "true") {
core.info(`Omitting ~/.cache/go-build from cache directories`)
} else {
dirs.push(path.resolve(`${process.env.HOME}/.cache/go-build`))
}
if (skipPkgCache.toLowerCase() == "true") {
core.info(`Omitting ~/go/pkg from cache directories`)
} else {
dirs.push(path.resolve(`${process.env.HOME}/go/pkg`))
}
return dirs
}
const getIntervalKey = (invalidationIntervalDays: number): string => {