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

Add options to skip caching of folders. #154

Merged
merged 1 commit into from Feb 14, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 7 additions & 1 deletion README.md
Expand Up @@ -48,8 +48,14 @@ jobs:
# Optional: show only new issues if it's a pull request. The default value is `false`.
# only-new-issues: true

# Optional: if set to true then the action will use pre-installed Go
# Optional: if set to true then the action will use pre-installed Go.
# skip-go-installation: true

# Optional: if set to true then the action don't cache or restore ~/go/pkg.
# skip-pkg-cache: true

# Optional: if set to true then the action don't cache or restore ~/.cache/go-build.
# skip-build-cache: true
```

We recommend running this action in a job separate from other jobs (`go test`, etc)
Expand Down
8 changes: 8 additions & 0 deletions action.yml
Expand Up @@ -24,6 +24,14 @@ inputs:
description: "if set to true then action uses pre-installed Go"
default: false
required: true
skip-pkg-cache:
description: "if set to true then the action don't cache or restore ~/go/pkg."
default: false
required: true
skip-build-cache:
description: "if set to true then the action don't cache or restore ~/.cache/go-build."
default: false
required: true
runs:
using: "node12"
main: "dist/run/index.js"
Expand Down
17 changes: 16 additions & 1 deletion dist/post_run/index.js
Expand Up @@ -49992,7 +49992,22 @@ const getLintCacheDir = () => {
};
const getCacheDirs = () => {
// Not existing dirs are ok here: it works.
return [getLintCacheDir(), path_1.default.resolve(`${process.env.HOME}/.cache/go-build`), path_1.default.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_1.default.resolve(`${process.env.HOME}/.cache/go-build`));
}
if (skipPkgCache.toLowerCase() == "true") {
core.info(`Omitting ~/go/pkg from cache directories`);
}
else {
dirs.push(path_1.default.resolve(`${process.env.HOME}/go/pkg`));
}
return dirs;
};
const getIntervalKey = (invalidationIntervalDays) => {
const now = new Date();
Expand Down
17 changes: 16 additions & 1 deletion dist/run/index.js
Expand Up @@ -50002,7 +50002,22 @@ const getLintCacheDir = () => {
};
const getCacheDirs = () => {
// Not existing dirs are ok here: it works.
return [getLintCacheDir(), path_1.default.resolve(`${process.env.HOME}/.cache/go-build`), path_1.default.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_1.default.resolve(`${process.env.HOME}/.cache/go-build`));
}
if (skipPkgCache.toLowerCase() == "true") {
core.info(`Omitting ~/go/pkg from cache directories`);
}
else {
dirs.push(path_1.default.resolve(`${process.env.HOME}/go/pkg`));
}
return dirs;
};
const getIntervalKey = (invalidationIntervalDays) => {
const now = new Date();
Expand Down
17 changes: 16 additions & 1 deletion src/cache.ts
Expand Up @@ -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 => {
Expand Down