mirror of
https://github.com/golangci/golangci-lint-action.git
synced 2026-04-16 16:55:47 +00:00
reimplement github action in typescript
This commit is contained in:
parent
666cc9164e
commit
853ade09ed
22 changed files with 67641 additions and 49 deletions
29
src/cache.ts
Normal file
29
src/cache.ts
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
import * as core from "@actions/core"
|
||||
import restore from "cache/lib/restore"
|
||||
import save from "cache/lib/save"
|
||||
|
||||
// TODO: ensure dir exists, have access, etc
|
||||
const getCacheDir = (): string => `${process.env.HOME}/.cache/golangci-lint`
|
||||
|
||||
const setCacheInputs = (): void => {
|
||||
process.env.INPUT_KEY = `golangci-lint.analysis-cache`
|
||||
process.env.INPUT_PATH = getCacheDir()
|
||||
}
|
||||
|
||||
export async function restoreCache(): Promise<void> {
|
||||
const startedAt = Date.now()
|
||||
setCacheInputs()
|
||||
|
||||
// Tell golangci-lint to use our cache directory.
|
||||
process.env.GOLANGCI_LINT_CACHE = getCacheDir()
|
||||
|
||||
await restore()
|
||||
core.info(`Restored golangci-lint analysis cache in ${Date.now() - startedAt}ms`)
|
||||
}
|
||||
|
||||
export async function saveCache(): Promise<void> {
|
||||
const startedAt = Date.now()
|
||||
setCacheInputs()
|
||||
await save()
|
||||
core.info(`Saved golangci-lint analysis cache in ${Date.now() - startedAt}ms`)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue