mirror of https://github.com/actions/cache.git
React to feeback and change to use 0.2.0 cache package
parent
249a22026d
commit
bcc23b930f
|
@ -4,11 +4,13 @@ on:
|
||||||
pull_request:
|
pull_request:
|
||||||
branches:
|
branches:
|
||||||
- master
|
- master
|
||||||
|
- releases/**
|
||||||
paths-ignore:
|
paths-ignore:
|
||||||
- '**.md'
|
- '**.md'
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- master
|
- master
|
||||||
|
- releases/**
|
||||||
paths-ignore:
|
paths-ignore:
|
||||||
- '**.md'
|
- '**.md'
|
||||||
|
|
||||||
|
@ -17,7 +19,7 @@ jobs:
|
||||||
build:
|
build:
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-latest, ubuntu-16.04]
|
os: [ubuntu-latest, ubuntu-16.04, windows-latest, macOS-latest]
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
steps:
|
steps:
|
||||||
|
@ -61,7 +63,7 @@ jobs:
|
||||||
test-save:
|
test-save:
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-latest, ubuntu-16.04]
|
os: [ubuntu-latest, ubuntu-16.04, windows-latest, macOS-latest]
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
steps:
|
steps:
|
||||||
|
@ -84,7 +86,7 @@ jobs:
|
||||||
needs: test-save
|
needs: test-save
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-latest, ubuntu-16.04]
|
os: [ubuntu-latest, ubuntu-16.04, windows-latest, macOS-latest]
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
steps:
|
steps:
|
||||||
|
|
|
@ -79,7 +79,7 @@ test("setOutputAndState with exact match to set cache-hit output and state", ()
|
||||||
expect(setOutputMock).toHaveBeenCalledWith(Outputs.CacheHit, "true");
|
expect(setOutputMock).toHaveBeenCalledWith(Outputs.CacheHit, "true");
|
||||||
expect(setOutputMock).toHaveBeenCalledTimes(1);
|
expect(setOutputMock).toHaveBeenCalledTimes(1);
|
||||||
|
|
||||||
expect(saveStateMock).toHaveBeenCalledWith(State.CacheResult, cacheKey);
|
expect(saveStateMock).toHaveBeenCalledWith(State.CacheMatchedKey, cacheKey);
|
||||||
expect(saveStateMock).toHaveBeenCalledTimes(1);
|
expect(saveStateMock).toHaveBeenCalledTimes(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -95,7 +95,7 @@ test("setOutputAndState with no exact match to set cache-hit output and state",
|
||||||
expect(setOutputMock).toHaveBeenCalledWith(Outputs.CacheHit, "false");
|
expect(setOutputMock).toHaveBeenCalledWith(Outputs.CacheHit, "false");
|
||||||
expect(setOutputMock).toHaveBeenCalledTimes(1);
|
expect(setOutputMock).toHaveBeenCalledTimes(1);
|
||||||
|
|
||||||
expect(saveStateMock).toHaveBeenCalledWith(State.CacheResult, cacheKey);
|
expect(saveStateMock).toHaveBeenCalledWith(State.CacheMatchedKey, cacheKey);
|
||||||
expect(saveStateMock).toHaveBeenCalledTimes(1);
|
expect(saveStateMock).toHaveBeenCalledTimes(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -109,7 +109,7 @@ test("getCacheState with no state returns undefined", () => {
|
||||||
|
|
||||||
expect(state).toBe(undefined);
|
expect(state).toBe(undefined);
|
||||||
|
|
||||||
expect(getStateMock).toHaveBeenCalledWith(State.CacheResult);
|
expect(getStateMock).toHaveBeenCalledWith(State.CacheMatchedKey);
|
||||||
expect(getStateMock).toHaveBeenCalledTimes(1);
|
expect(getStateMock).toHaveBeenCalledTimes(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -125,7 +125,7 @@ test("getCacheState with valid state", () => {
|
||||||
|
|
||||||
expect(state).toEqual(cacheKey);
|
expect(state).toEqual(cacheKey);
|
||||||
|
|
||||||
expect(getStateMock).toHaveBeenCalledWith(State.CacheResult);
|
expect(getStateMock).toHaveBeenCalledWith(State.CacheMatchedKey);
|
||||||
expect(getStateMock).toHaveBeenCalledTimes(1);
|
expect(getStateMock).toHaveBeenCalledTimes(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -26,7 +26,7 @@
|
||||||
"@actions/core": "^1.2.0",
|
"@actions/core": "^1.2.0",
|
||||||
"@actions/exec": "^1.0.1",
|
"@actions/exec": "^1.0.1",
|
||||||
"@actions/io": "^1.0.1",
|
"@actions/io": "^1.0.1",
|
||||||
"@actions/cache": "^0.1.0"
|
"@actions/cache": "^0.2.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/jest": "^24.0.13",
|
"@types/jest": "^24.0.13",
|
||||||
|
|
|
@ -9,8 +9,8 @@ export enum Outputs {
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum State {
|
export enum State {
|
||||||
CacheKey = "CACHE_KEY",
|
CachePrimaryKey = "CACHE_KEY",
|
||||||
CacheResult = "CACHE_RESULT"
|
CacheMatchedKey = "CACHE_RESULT"
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum Events {
|
export enum Events {
|
||||||
|
|
|
@ -17,7 +17,7 @@ async function run(): Promise<void> {
|
||||||
}
|
}
|
||||||
|
|
||||||
const primaryKey = core.getInput(Inputs.Key, { required: true });
|
const primaryKey = core.getInput(Inputs.Key, { required: true });
|
||||||
core.saveState(State.CacheKey, primaryKey);
|
core.saveState(State.CachePrimaryKey, primaryKey);
|
||||||
|
|
||||||
const restoreKeys = core
|
const restoreKeys = core
|
||||||
.getInput(Inputs.RestoreKeys)
|
.getInput(Inputs.RestoreKeys)
|
||||||
|
@ -45,7 +45,7 @@ async function run(): Promise<void> {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Store the cache result
|
// Store the matched cache key
|
||||||
utils.setCacheState(cacheKey);
|
utils.setCacheState(cacheKey);
|
||||||
|
|
||||||
const isExactKeyMatch = utils.isExactKeyMatch(primaryKey, cacheKey);
|
const isExactKeyMatch = utils.isExactKeyMatch(primaryKey, cacheKey);
|
||||||
|
|
|
@ -18,7 +18,7 @@ async function run(): Promise<void> {
|
||||||
const state = utils.getCacheState();
|
const state = utils.getCacheState();
|
||||||
|
|
||||||
// Inputs are re-evaluted before the post action, so we want the original key used for restore
|
// Inputs are re-evaluted before the post action, so we want the original key used for restore
|
||||||
const primaryKey = core.getState(State.CacheKey);
|
const primaryKey = core.getState(State.CachePrimaryKey);
|
||||||
if (!primaryKey) {
|
if (!primaryKey) {
|
||||||
utils.logWarning(`Error retrieving key from state.`);
|
utils.logWarning(`Error retrieving key from state.`);
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -12,7 +12,7 @@ export function isExactKeyMatch(key: string, cacheKey?: string): boolean {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function setCacheState(state: string): void {
|
export function setCacheState(state: string): void {
|
||||||
core.saveState(State.CacheResult, state);
|
core.saveState(State.CacheMatchedKey, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function setCacheHitOutput(isCacheHit: boolean): void {
|
export function setCacheHitOutput(isCacheHit: boolean): void {
|
||||||
|
@ -21,12 +21,12 @@ export function setCacheHitOutput(isCacheHit: boolean): void {
|
||||||
|
|
||||||
export function setOutputAndState(key: string, cacheKey?: string): void {
|
export function setOutputAndState(key: string, cacheKey?: string): void {
|
||||||
setCacheHitOutput(isExactKeyMatch(key, cacheKey));
|
setCacheHitOutput(isExactKeyMatch(key, cacheKey));
|
||||||
// Store the cache result if it exists
|
// Store the matched cache key if it exists
|
||||||
cacheKey && setCacheState(cacheKey);
|
cacheKey && setCacheState(cacheKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getCacheState(): string | undefined {
|
export function getCacheState(): string | undefined {
|
||||||
const cacheKey = core.getState(State.CacheResult);
|
const cacheKey = core.getState(State.CacheMatchedKey);
|
||||||
if (cacheKey) {
|
if (cacheKey) {
|
||||||
core.debug(`Cache state/key: ${cacheKey}`);
|
core.debug(`Cache state/key: ${cacheKey}`);
|
||||||
return cacheKey;
|
return cacheKey;
|
||||||
|
|
Loading…
Reference in New Issue