Compare commits

...

7 Commits

Author SHA1 Message Date
Sergey Dolin
23f8c03983
Merge 28cfea2580 into 883490dfd0 2023-08-30 05:59:01 -07:00
Marko Zivic
883490dfd0
Merge pull request #417 from artemgavrilov/main
Improve documentation regarding dependencies caching
2023-08-30 09:35:35 +02:00
Artem Gavrilov
d45ebba0ce
Rephrase sentence
Co-authored-by: Ivan <98037481+IvanZosimov@users.noreply.github.com>
2023-08-29 15:43:02 +02:00
Artem Gavrilov
317c6617fa
Replace wildcards term with globs. 2023-08-28 12:47:43 +02:00
Artem Gavrilov
f90673ad64
Merge pull request #1 from artemgavrilov/caching-docs-improvement
Improve documentation regarding dependencies caching
2023-08-25 12:37:15 +02:00
Artem Gavrilov
8018234347
Improve documentation regarding dependencies cachin 2023-08-25 12:31:19 +02:00
Sergey Dolin
28cfea2580 cache-restore-only 2023-07-26 09:25:11 +02:00
7 changed files with 36 additions and 3 deletions

View File

@ -159,7 +159,7 @@ The `cache` input is optional, and caching is turned on by default.
The action defaults to search for the dependency file - go.sum in the repository root, and uses its hash as a part of
the cache key. Use `cache-dependency-path` input for cases when multiple dependency files are used, or they are located
in different subdirectories.
in different subdirectories. The input supports glob patterns.
If some problem that prevents success caching happens then the action issues the warning in the log and continues the execution of the pipeline.
@ -172,7 +172,11 @@ steps:
with:
go-version: '1.17'
check-latest: true
cache-dependency-path: subdir/go.sum
cache-dependency-path: |
subdir/go.sum
tools/go.sum
# cache-dependency-path: "**/*.sum"
- run: go run hello.go
```

View File

@ -17,6 +17,9 @@ inputs:
default: true
cache-dependency-path:
description: 'Used to specify the path to a dependency file - go.sum'
cache-restore-only:
description: Used to specify the cache . Set to true, if you'd like to reuse existing cache but did not update it
default: false
architecture:
description: 'Target architecture for Go to use. Examples: x86, x64. Will use system architecture by default.'
outputs:

View File

@ -58504,6 +58504,10 @@ process.on('uncaughtException', e => {
});
function run() {
return __awaiter(this, void 0, void 0, function* () {
if (core.getState(constants_1.State.CacheRestoreOnly) === constants_1.State.True) {
core.info('"cache-restore-only" set to true, skip caching');
return;
}
try {
yield cachePackages();
}
@ -58669,6 +58673,9 @@ var State;
(function (State) {
State["CachePrimaryKey"] = "CACHE_KEY";
State["CacheMatchedKey"] = "CACHE_RESULT";
State["CacheRestoreOnly"] = "CACHE_RESTORE_ONLY";
State["True"] = "true";
State["False"] = "false";
})(State = exports.State || (exports.State = {}));
var Outputs;
(function (Outputs) {

6
dist/setup/index.js vendored
View File

@ -61339,6 +61339,9 @@ var State;
(function (State) {
State["CachePrimaryKey"] = "CACHE_KEY";
State["CacheMatchedKey"] = "CACHE_RESULT";
State["CacheRestoreOnly"] = "CACHE_RESTORE_ONLY";
State["True"] = "true";
State["False"] = "false";
})(State = exports.State || (exports.State = {}));
var Outputs;
(function (Outputs) {
@ -61781,6 +61784,7 @@ const cache_utils_1 = __nccwpck_require__(1678);
const child_process_1 = __importDefault(__nccwpck_require__(2081));
const fs_1 = __importDefault(__nccwpck_require__(7147));
const os_1 = __importDefault(__nccwpck_require__(2037));
const constants_1 = __nccwpck_require__(9042);
function run() {
return __awaiter(this, void 0, void 0, function* () {
try {
@ -61818,6 +61822,8 @@ function run() {
core.debug(`add bin ${added}`);
const goPath = yield io.which('go');
const goVersion = (child_process_1.default.execSync(`${goPath} version`) || '').toString();
const cacheRestoreOnly = core.getBooleanInput('cache-restore-only');
core.saveState(constants_1.State.CacheRestoreOnly, cacheRestoreOnly ? constants_1.State.True : constants_1.State.False);
if (cache && cache_utils_1.isCacheFeatureAvailable()) {
const packageManager = 'default';
const cacheDependencyPath = core.getInput('cache-dependency-path');

View File

@ -13,6 +13,10 @@ process.on('uncaughtException', e => {
});
export async function run() {
if (core.getState(State.CacheRestoreOnly) === State.True) {
core.info('"cache-restore-only" set to true, skip caching');
return;
}
try {
await cachePackages();
} catch (error) {

View File

@ -1,6 +1,9 @@
export enum State {
CachePrimaryKey = 'CACHE_KEY',
CacheMatchedKey = 'CACHE_RESULT'
CacheMatchedKey = 'CACHE_RESULT',
CacheRestoreOnly = 'CACHE_RESTORE_ONLY',
True = 'true',
False = 'false'
}
export enum Outputs {

View File

@ -8,6 +8,7 @@ import {isCacheFeatureAvailable} from './cache-utils';
import cp from 'child_process';
import fs from 'fs';
import os from 'os';
import {State} from './constants';
export async function run() {
try {
@ -64,6 +65,11 @@ export async function run() {
const goPath = await io.which('go');
const goVersion = (cp.execSync(`${goPath} version`) || '').toString();
const cacheRestoreOnly = core.getBooleanInput('cache-restore-only');
core.saveState(
State.CacheRestoreOnly,
cacheRestoreOnly ? State.True : State.False
);
if (cache && isCacheFeatureAvailable()) {
const packageManager = 'default';
const cacheDependencyPath = core.getInput('cache-dependency-path');