@ -83,8 +83,6 @@ export async function restoreCache(): Promise<void> {
|
||||
}
|
||||
// Store the matched cache key
|
||||
utils.setCacheState(cacheKey)
|
||||
const isExactKeyMatch = utils.isExactKeyMatch(primaryKey, cacheKey)
|
||||
utils.setCacheHitOutput(isExactKeyMatch)
|
||||
core.info(`Restored cache for golangci-lint from key '${primaryKey}' in ${Date.now() - startedAt}ms`)
|
||||
} catch (error) {
|
||||
if (error.name === cache.ValidationError.name) {
|
||||
|
@ -4,10 +4,6 @@ export enum Inputs {
|
||||
RestoreKeys = "restore-keys",
|
||||
}
|
||||
|
||||
export enum Outputs {
|
||||
CacheHit = "cache-hit",
|
||||
}
|
||||
|
||||
export enum State {
|
||||
CachePrimaryKey = "CACHE_KEY",
|
||||
CacheMatchedKey = "CACHE_RESULT",
|
||||
|
@ -1,6 +1,6 @@
|
||||
import * as core from "@actions/core"
|
||||
|
||||
import { Outputs, RefKey, State } from "../constants"
|
||||
import { RefKey, State } from "../constants"
|
||||
|
||||
export function isExactKeyMatch(key: string, cacheKey?: string): boolean {
|
||||
return !!(
|
||||
@ -15,16 +15,6 @@ export function setCacheState(state: string): void {
|
||||
core.saveState(State.CacheMatchedKey, state)
|
||||
}
|
||||
|
||||
export function setCacheHitOutput(isCacheHit: boolean): void {
|
||||
core.setOutput(Outputs.CacheHit, isCacheHit.toString())
|
||||
}
|
||||
|
||||
export function setOutputAndState(key: string, cacheKey?: string): void {
|
||||
setCacheHitOutput(isExactKeyMatch(key, cacheKey))
|
||||
// Store the matched cache key if it exists
|
||||
cacheKey && setCacheState(cacheKey)
|
||||
}
|
||||
|
||||
export function getCacheState(): string | undefined {
|
||||
const cacheKey = core.getState(State.CacheMatchedKey)
|
||||
if (cacheKey) {
|
||||
|
Reference in New Issue
Block a user