Compare commits

...

5 Commits

Author SHA1 Message Date
a8dcf7856e adding save-only and restore-only entry points 2022-12-08 10:35:19 +00:00
d463e30c26 test 2022-12-08 08:24:08 +00:00
790b78c6b6 removing required
removing required
2022-12-07 17:25:00 +00:00
7520a6a3a9 altering require 2022-12-07 17:22:59 +00:00
a5fbe79711 adding outputs 2022-12-07 17:07:30 +00:00
11 changed files with 122828 additions and 3 deletions

61377
dist/restore-only/index.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

@ -47582,6 +47582,8 @@ var Inputs;
var Outputs;
(function (Outputs) {
Outputs["CacheHit"] = "cache-hit";
Outputs["Key"] = "key";
Outputs["MatchedKey"] = "matched-key";
})(Outputs = exports.Outputs || (exports.Outputs = {}));
var State;
(function (State) {
@ -50704,6 +50706,7 @@ function restoreImpl(stateProvider) {
}
// Store the matched cache key in states
stateProvider.setState(constants_1.State.CacheMatchedKey, cacheKey);
core.debug("setState: " + constants_1.State.CacheMatchedKey + " " + cacheKey);
const isExactKeyMatch = utils.isExactKeyMatch(core.getInput(constants_1.Inputs.Key, { required: true }), cacheKey);
core.setOutput(constants_1.Outputs.CacheHit, isExactKeyMatch.toString());
core.info(`Cache restored from key: ${cacheKey}`);

61382
dist/save-only/index.js vendored Normal file

File diff suppressed because one or more lines are too long

2
dist/save/index.js vendored
View File

@ -4975,6 +4975,8 @@ var Inputs;
var Outputs;
(function (Outputs) {
Outputs["CacheHit"] = "cache-hit";
Outputs["Key"] = "key";
Outputs["MatchedKey"] = "matched-key";
})(Outputs = exports.Outputs || (exports.Outputs = {}));
var State;
(function (State) {

View File

@ -5,7 +5,7 @@
"description": "Cache dependencies and build outputs",
"main": "dist/restore/index.js",
"scripts": {
"build": "tsc && ncc build -o dist/restore src/restore.ts && ncc build -o dist/save src/save.ts",
"build": "tsc && ncc build -o dist/restore src/restore.ts && ncc build -o dist/save src/save.ts && ncc build -o dist/restore-only src/restoreOnly.ts && ncc build -o dist/save-only src/saveOnly.ts",
"test": "tsc --noEmit && jest --coverage",
"lint": "eslint **/*.ts --cache",
"format": "prettier --write **/*.ts",

27
restore-only/action.yml Normal file
View File

@ -0,0 +1,27 @@
name: 'Restore Only Cache'
description: 'Restore Cache artifacts like dependencies and build outputs to improve workflow execution time'
author: 'GitHub'
inputs:
path:
description: 'The same list of files, directories, and wildcard patterns to restore cache that were used while saving it'
required: true
key:
description: 'An explicit key for restoring the cache'
required: true
restore-keys:
description: 'An ordered list of keys to use for restoring stale cache if no cache hit occurred for key. Note `cache-hit` returns false in this case.'
required: false
outputs:
cache-hit:
description: 'A boolean value to indicate an exact match was found for the primary key'
key:
description: 'Key passed in the input to use in subsequent steps of the workflow'
matched-key:
description: 'Cache key restored'
runs:
using: 'node16'
main: '../dist/restore-only/index.js'
branding:
icon: 'archive'
color: 'gray-dark'

View File

@ -14,6 +14,10 @@ inputs:
outputs:
cache-hit:
description: 'A boolean value to indicate an exact match was found for the primary key'
key:
description: 'Key passed in the input to use in subsequent steps of the workflow'
matched-key:
description: 'Cache key restored'
runs:
using: 'node16'
main: '../dist/restore/index.js'

22
save-only/action.yml Normal file
View File

@ -0,0 +1,22 @@
name: 'Save Only Cache'
description: 'Save Cache artifacts like dependencies and build outputs to improve workflow execution time'
author: 'GitHub'
inputs:
path:
description: 'A list of files, directories, and wildcard patterns to cache'
required: true
key:
description: 'An explicit key for saving the cache'
required: true
upload-chunk-size:
description: 'The chunk size used to split up large files during upload, in bytes'
required: false
matched-key:
description: 'Cache key restored from the restore action'
required: false
runs:
using: 'node16'
main: '../dist/save-only/index.js'
branding:
icon: 'archive'
color: 'gray-dark'

View File

@ -11,6 +11,9 @@ inputs:
upload-chunk-size:
description: 'The chunk size used to split up large files during upload, in bytes'
required: false
matched-key:
description: 'Cache key restored from the restore action'
required: false
runs:
using: 'node16'
main: '../dist/save/index.js'

View File

@ -6,7 +6,9 @@ export enum Inputs {
}
export enum Outputs {
CacheHit = "cache-hit"
CacheHit = "cache-hit",
Key = "key",
MatchedKey = "matched-key"
}
export enum State {

View File

@ -5,7 +5,9 @@ import { Events, Inputs, Outputs, State } from "./constants";
import { IStateProvider } from "./stateProvider";
import * as utils from "./utils/actionUtils";
async function restoreImpl(stateProvider: IStateProvider): Promise<string | undefined> {
async function restoreImpl(
stateProvider: IStateProvider
): Promise<string | undefined> {
try {
if (!utils.isCacheFeatureAvailable()) {
utils.setCacheHitOutput(false);
@ -49,6 +51,7 @@ async function restoreImpl(stateProvider: IStateProvider): Promise<string | unde
// Store the matched cache key in states
stateProvider.setState(State.CacheMatchedKey, cacheKey);
core.debug("setState: " + State.CacheMatchedKey + " " + cacheKey);
const isExactKeyMatch = utils.isExactKeyMatch(
core.getInput(Inputs.Key, { required: true }),