Skip to content

Commit 3f36c21

Browse files
committed
feat: remove Go cache management
1 parent bf6479d commit 3f36c21

File tree

3 files changed

+3
-37
lines changed

3 files changed

+3
-37
lines changed

README.md

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ jobs:
4949
# Require: The version of golangci-lint to use.
5050
# When `install-mode` is `binary` (default) the value can be v1.2 or v1.2.3 or `latest` to use the latest version.
5151
# When `install-mode` is `goinstall` the value can be v1.2.3, `latest`, or the hash of a commit.
52-
version: v1.54
52+
version: v1.57
5353

5454
# Optional: working directory, useful for monorepos
5555
# working-directory: somedir
@@ -67,12 +67,6 @@ jobs:
6767
# takes precedence over all other caching options.
6868
# skip-cache: true
6969

70-
# Optional: if set to true, then the action won't cache or restore ~/go/pkg.
71-
# skip-pkg-cache: true
72-
73-
# Optional: if set to true, then the action won't cache or restore ~/.cache/go-build.
74-
# skip-build-cache: true
75-
7670
# Optional: The mode to install golangci-lint. It can be 'binary' or 'goinstall'.
7771
# install-mode: "goinstall"
7872
```

action.yml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,6 @@ inputs:
2929
takes precedence over all other caching options.
3030
default: 'false'
3131
required: false
32-
skip-pkg-cache:
33-
description: "if set to true then the action doesn't cache or restore ~/go/pkg."
34-
default: 'false'
35-
required: false
36-
skip-build-cache:
37-
description: "if set to true then the action doesn't cache or restore ~/.cache/go-build."
38-
default: 'false'
39-
required: false
4032
install-mode:
4133
description: "The mode to install golangci-lint. It can be 'binary' or 'goinstall'."
4234
default: "binary"

src/cache.ts

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -23,26 +23,6 @@ const getLintCacheDir = (): string => {
2323
return path.resolve(`${process.env.HOME}/.cache/golangci-lint`)
2424
}
2525

26-
const getCacheDirs = (): string[] => {
27-
// Not existing dirs are ok here: it works.
28-
const skipPkgCache = core.getInput(`skip-pkg-cache`, { required: true }).trim()
29-
const skipBuildCache = core.getInput(`skip-build-cache`, { required: true }).trim()
30-
const dirs = [getLintCacheDir()]
31-
32-
if (skipBuildCache.toLowerCase() == "true") {
33-
core.info(`Omitting ~/.cache/go-build from cache directories`)
34-
} else {
35-
dirs.push(path.resolve(`${process.env.HOME}/.cache/go-build`))
36-
}
37-
if (skipPkgCache.toLowerCase() == "true") {
38-
core.info(`Omitting ~/go/pkg from cache directories`)
39-
} else {
40-
dirs.push(path.resolve(`${process.env.HOME}/go/pkg`))
41-
}
42-
43-
return dirs
44-
}
45-
4626
const getIntervalKey = (invalidationIntervalDays: number): string => {
4727
const now = new Date()
4828
const secondsSinceEpoch = now.getTime() / 1000
@@ -97,7 +77,7 @@ export async function restoreCache(): Promise<void> {
9777
}
9878
core.saveState(State.CachePrimaryKey, primaryKey)
9979
try {
100-
const cacheKey = await cache.restoreCache(getCacheDirs(), primaryKey, restoreKeys)
80+
const cacheKey = await cache.restoreCache([getLintCacheDir()], primaryKey, restoreKeys)
10181
if (!cacheKey) {
10282
core.info(`Cache not found for input keys: ${[primaryKey, ...restoreKeys].join(", ")}`)
10383
return
@@ -127,7 +107,7 @@ export async function saveCache(): Promise<void> {
127107

128108
const startedAt = Date.now()
129109

130-
const cacheDirs = getCacheDirs()
110+
const cacheDirs = [getLintCacheDir()]
131111
const primaryKey = core.getState(State.CachePrimaryKey)
132112
if (!primaryKey) {
133113
utils.logWarning(`Error retrieving key from state.`)

0 commit comments

Comments
 (0)