Skip to content

Commit b90ed1b

Browse files
committed
cache-restore-only
1 parent db8764c commit b90ed1b

File tree

6 files changed

+28
-4
lines changed

6 files changed

+28
-4
lines changed

action.yml

+3
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ inputs:
1717
default: true
1818
cache-dependency-path:
1919
description: 'Used to specify the path to a dependency file - go.sum'
20+
cache-restore-only:
21+
description: Used to specify the cache . Set to true, if you'd like to reuse existing cache but did not update it
22+
default: false
2023
architecture:
2124
description: 'Target architecture for Go to use. Examples: x86, x64. Will use system architecture by default.'
2225
outputs:

dist/cache-save/index.js

+9-2
Original file line numberDiff line numberDiff line change
@@ -58442,7 +58442,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5844258442
return (mod && mod.__esModule) ? mod : { "default": mod };
5844358443
};
5844458444
Object.defineProperty(exports, "__esModule", ({ value: true }));
58445-
exports.run = void 0;
58445+
exports.cachePackages = exports.run = void 0;
5844658446
const core = __importStar(__nccwpck_require__(2186));
5844758447
const cache = __importStar(__nccwpck_require__(7799));
5844858448
const fs_1 = __importDefault(__nccwpck_require__(7147));
@@ -58457,8 +58457,12 @@ process.on('uncaughtException', e => {
5845758457
});
5845858458
function run() {
5845958459
return __awaiter(this, void 0, void 0, function* () {
58460+
if (core.getState(constants_1.State.CacheRestoreOnly) === constants_1.State.True) {
58461+
core.info('"cache-restore-only" set to true, skip caching');
58462+
return;
58463+
}
5846058464
try {
58461-
yield cachePackages();
58465+
yield exports.cachePackages();
5846258466
}
5846358467
catch (error) {
5846458468
let message = 'Unknown error!';
@@ -58505,6 +58509,7 @@ const cachePackages = () => __awaiter(void 0, void 0, void 0, function* () {
5850558509
}
5850658510
core.info(`Cache saved with the key: ${primaryKey}`);
5850758511
});
58512+
exports.cachePackages = cachePackages;
5850858513
function logWarning(message) {
5850958514
const warningPrefix = '[warning]';
5851058515
core.info(`${warningPrefix}${message}`);
@@ -58622,6 +58627,8 @@ var State;
5862258627
(function (State) {
5862358628
State["CachePrimaryKey"] = "CACHE_KEY";
5862458629
State["CacheMatchedKey"] = "CACHE_RESULT";
58630+
State["CacheRestoreOnly"] = "CACHE_RESTORE_ONLY";
58631+
State["True"] = "true";
5862558632
})(State = exports.State || (exports.State = {}));
5862658633
var Outputs;
5862758634
(function (Outputs) {

dist/setup/index.js

+5
Original file line numberDiff line numberDiff line change
@@ -61292,6 +61292,8 @@ var State;
6129261292
(function (State) {
6129361293
State["CachePrimaryKey"] = "CACHE_KEY";
6129461294
State["CacheMatchedKey"] = "CACHE_RESULT";
61295+
State["CacheRestoreOnly"] = "CACHE_RESTORE_ONLY";
61296+
State["True"] = "true";
6129561297
})(State = exports.State || (exports.State = {}));
6129661298
var Outputs;
6129761299
(function (Outputs) {
@@ -61690,6 +61692,7 @@ const cache_utils_1 = __nccwpck_require__(1678);
6169061692
const child_process_1 = __importDefault(__nccwpck_require__(2081));
6169161693
const fs_1 = __importDefault(__nccwpck_require__(7147));
6169261694
const os_1 = __importDefault(__nccwpck_require__(2037));
61695+
const constants_1 = __nccwpck_require__(9042);
6169361696
function run() {
6169461697
return __awaiter(this, void 0, void 0, function* () {
6169561698
try {
@@ -61727,6 +61730,8 @@ function run() {
6172761730
core.debug(`add bin ${added}`);
6172861731
const goPath = yield io.which('go');
6172961732
const goVersion = (child_process_1.default.execSync(`${goPath} version`) || '').toString();
61733+
const cacheRestoreOnly = core.getBooleanInput('cache-dependency-path');
61734+
core.saveState(constants_1.State.CacheRestoreOnly, cacheRestoreOnly ? constants_1.State.True : '');
6173061735
if (cache && cache_utils_1.isCacheFeatureAvailable()) {
6173161736
const packageManager = 'default';
6173261737
const cacheDependencyPath = core.getInput('cache-dependency-path');

src/cache-save.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ process.on('uncaughtException', e => {
1313
});
1414

1515
export async function run() {
16+
if (core.getState(State.CacheRestoreOnly) === State.True) {
17+
core.info('"cache-restore-only" set to true, skip caching');
18+
return;
19+
}
1620
try {
1721
await cachePackages();
1822
} catch (error) {
@@ -27,7 +31,7 @@ export async function run() {
2731
}
2832
}
2933

30-
const cachePackages = async () => {
34+
export const cachePackages = async () => {
3135
const cacheInput = core.getBooleanInput('cache');
3236
if (!cacheInput) {
3337
return;

src/constants.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
export enum State {
22
CachePrimaryKey = 'CACHE_KEY',
3-
CacheMatchedKey = 'CACHE_RESULT'
3+
CacheMatchedKey = 'CACHE_RESULT',
4+
CacheRestoreOnly = 'CACHE_RESTORE_ONLY',
5+
True = 'true'
46
}
57

68
export enum Outputs {

src/main.ts

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {isCacheFeatureAvailable} from './cache-utils';
88
import cp from 'child_process';
99
import fs from 'fs';
1010
import os from 'os';
11+
import {State} from './constants';
1112

1213
export async function run() {
1314
try {
@@ -64,6 +65,8 @@ export async function run() {
6465
const goPath = await io.which('go');
6566
const goVersion = (cp.execSync(`${goPath} version`) || '').toString();
6667

68+
const cacheRestoreOnly = core.getBooleanInput('cache-dependency-path');
69+
core.saveState(State.CacheRestoreOnly, cacheRestoreOnly ? State.True : '');
6770
if (cache && isCacheFeatureAvailable()) {
6871
const packageManager = 'default';
6972
const cacheDependencyPath = core.getInput('cache-dependency-path');

0 commit comments

Comments
 (0)