mirror of
https://github.com/golangci/golangci-lint-action.git
synced 2025-12-14 23:11:14 +00:00
feat: remove Go cache management
This commit is contained in:
parent
c683728f10
commit
07468db4ce
3 changed files with 3 additions and 37 deletions
|
|
@ -49,7 +49,7 @@ jobs:
|
||||||
# Require: The version of golangci-lint to use.
|
# Require: The version of golangci-lint to use.
|
||||||
# When `install-mode` is `binary` (default) the value can be v1.2 or v1.2.3 or `latest` to use the latest version.
|
# When `install-mode` is `binary` (default) the value can be v1.2 or v1.2.3 or `latest` to use the latest version.
|
||||||
# When `install-mode` is `goinstall` the value can be v1.2.3, `latest`, or the hash of a commit.
|
# When `install-mode` is `goinstall` the value can be v1.2.3, `latest`, or the hash of a commit.
|
||||||
version: v1.54
|
version: v1.57
|
||||||
|
|
||||||
# Optional: working directory, useful for monorepos
|
# Optional: working directory, useful for monorepos
|
||||||
# working-directory: somedir
|
# working-directory: somedir
|
||||||
|
|
@ -71,12 +71,6 @@ jobs:
|
||||||
# subject to other options
|
# subject to other options
|
||||||
# skip-save-cache: true
|
# skip-save-cache: true
|
||||||
|
|
||||||
# Optional: if set to true, then the action won't cache or restore ~/go/pkg.
|
|
||||||
# skip-pkg-cache: true
|
|
||||||
|
|
||||||
# Optional: if set to true, then the action won't cache or restore ~/.cache/go-build.
|
|
||||||
# skip-build-cache: true
|
|
||||||
|
|
||||||
# Optional: The mode to install golangci-lint. It can be 'binary' or 'goinstall'.
|
# Optional: The mode to install golangci-lint. It can be 'binary' or 'goinstall'.
|
||||||
# install-mode: "goinstall"
|
# install-mode: "goinstall"
|
||||||
```
|
```
|
||||||
|
|
|
||||||
|
|
@ -35,14 +35,6 @@ inputs:
|
||||||
restore existing caches, subject to other options.
|
restore existing caches, subject to other options.
|
||||||
default: 'false'
|
default: 'false'
|
||||||
required: false
|
required: false
|
||||||
skip-pkg-cache:
|
|
||||||
description: "if set to true then the action doesn't cache or restore ~/go/pkg."
|
|
||||||
default: 'false'
|
|
||||||
required: false
|
|
||||||
skip-build-cache:
|
|
||||||
description: "if set to true then the action doesn't cache or restore ~/.cache/go-build."
|
|
||||||
default: 'false'
|
|
||||||
required: false
|
|
||||||
install-mode:
|
install-mode:
|
||||||
description: "The mode to install golangci-lint. It can be 'binary' or 'goinstall'."
|
description: "The mode to install golangci-lint. It can be 'binary' or 'goinstall'."
|
||||||
default: "binary"
|
default: "binary"
|
||||||
|
|
|
||||||
24
src/cache.ts
24
src/cache.ts
|
|
@ -23,26 +23,6 @@ const getLintCacheDir = (): string => {
|
||||||
return path.resolve(`${process.env.HOME}/.cache/golangci-lint`)
|
return path.resolve(`${process.env.HOME}/.cache/golangci-lint`)
|
||||||
}
|
}
|
||||||
|
|
||||||
const getCacheDirs = (): string[] => {
|
|
||||||
// Not existing dirs are ok here: it works.
|
|
||||||
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 => {
|
const getIntervalKey = (invalidationIntervalDays: number): string => {
|
||||||
const now = new Date()
|
const now = new Date()
|
||||||
const secondsSinceEpoch = now.getTime() / 1000
|
const secondsSinceEpoch = now.getTime() / 1000
|
||||||
|
|
@ -97,7 +77,7 @@ export async function restoreCache(): Promise<void> {
|
||||||
}
|
}
|
||||||
core.saveState(State.CachePrimaryKey, primaryKey)
|
core.saveState(State.CachePrimaryKey, primaryKey)
|
||||||
try {
|
try {
|
||||||
const cacheKey = await cache.restoreCache(getCacheDirs(), primaryKey, restoreKeys)
|
const cacheKey = await cache.restoreCache([getLintCacheDir()], primaryKey, restoreKeys)
|
||||||
if (!cacheKey) {
|
if (!cacheKey) {
|
||||||
core.info(`Cache not found for input keys: ${[primaryKey, ...restoreKeys].join(", ")}`)
|
core.info(`Cache not found for input keys: ${[primaryKey, ...restoreKeys].join(", ")}`)
|
||||||
return
|
return
|
||||||
|
|
@ -128,7 +108,7 @@ export async function saveCache(): Promise<void> {
|
||||||
|
|
||||||
const startedAt = Date.now()
|
const startedAt = Date.now()
|
||||||
|
|
||||||
const cacheDirs = getCacheDirs()
|
const cacheDirs = [getLintCacheDir()]
|
||||||
const primaryKey = core.getState(State.CachePrimaryKey)
|
const primaryKey = core.getState(State.CachePrimaryKey)
|
||||||
if (!primaryKey) {
|
if (!primaryKey) {
|
||||||
utils.logWarning(`Error retrieving key from state.`)
|
utils.logWarning(`Error retrieving key from state.`)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue