mirror of
https://code.forgejo.org/actions/cache.git
synced 2024-11-29 18:00:59 -05:00
Merge branch 'main' into snyk-upgrade-bd68638f493b08c4064281f3755de1ba
This commit is contained in:
commit
f039849120
16 changed files with 197 additions and 184 deletions
2
.github/auto_assign.yml
vendored
2
.github/auto_assign.yml
vendored
|
@ -6,7 +6,7 @@ addAssignees: false
|
||||||
|
|
||||||
# A list of reviewers to be added to pull requests (GitHub user name)
|
# A list of reviewers to be added to pull requests (GitHub user name)
|
||||||
reviewers:
|
reviewers:
|
||||||
- phantsure
|
- kotewar
|
||||||
- aparna-ravindra
|
- aparna-ravindra
|
||||||
- tiwarishub
|
- tiwarishub
|
||||||
- vsvipul
|
- vsvipul
|
||||||
|
|
2
.github/workflows/auto-assign-issues.yml
vendored
2
.github/workflows/auto-assign-issues.yml
vendored
|
@ -11,5 +11,5 @@ jobs:
|
||||||
- name: 'Auto-assign issue'
|
- name: 'Auto-assign issue'
|
||||||
uses: pozil/auto-assign-issue@v1.4.0
|
uses: pozil/auto-assign-issue@v1.4.0
|
||||||
with:
|
with:
|
||||||
assignees: phantsure,tiwarishub,aparna-ravindra,vsvipul,bishal-pdmsft
|
assignees: kotewar,tiwarishub,aparna-ravindra,vsvipul,bishal-pdmsft
|
||||||
numOfAssignee: 1
|
numOfAssignee: 1
|
||||||
|
|
2
.github/workflows/auto-assign.yml
vendored
2
.github/workflows/auto-assign.yml
vendored
|
@ -1,6 +1,6 @@
|
||||||
name: 'Auto Assign'
|
name: 'Auto Assign'
|
||||||
on:
|
on:
|
||||||
pull_request:
|
pull_request_target:
|
||||||
types: [opened, ready_for_review]
|
types: [opened, ready_for_review]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
|
BIN
.licenses/npm/@actions/cache.dep.yml
generated
BIN
.licenses/npm/@actions/cache.dep.yml
generated
Binary file not shown.
|
@ -14,6 +14,7 @@ See ["Caching dependencies to speed up workflows"](https://help.github.com/githu
|
||||||
* Fixed download issue for files > 2GB during restore.
|
* Fixed download issue for files > 2GB during restore.
|
||||||
* Updated the minimum runner version support from node 12 -> node 16.
|
* Updated the minimum runner version support from node 12 -> node 16.
|
||||||
* Fixed avoiding empty cache save when no files are available for caching.
|
* Fixed avoiding empty cache save when no files are available for caching.
|
||||||
|
* Fixed tar creation error while trying to create tar with path as `~/` home folder on `ubuntu-latest`.
|
||||||
|
|
||||||
Refer [here](https://github.com/actions/cache/blob/v2/README.md) for previous versions
|
Refer [here](https://github.com/actions/cache/blob/v2/README.md) for previous versions
|
||||||
|
|
||||||
|
@ -28,7 +29,8 @@ If you are using this inside a container, a POSIX-compliant `tar` needs to be in
|
||||||
|
|
||||||
* `path` - A list of files, directories, and wildcard patterns to cache and restore. See [`@actions/glob`](https://github.com/actions/toolkit/tree/main/packages/glob) for supported patterns.
|
* `path` - A list of files, directories, and wildcard patterns to cache and restore. See [`@actions/glob`](https://github.com/actions/toolkit/tree/main/packages/glob) for supported patterns.
|
||||||
* `key` - An explicit key for restoring and saving the cache
|
* `key` - An explicit key for restoring and saving the cache
|
||||||
* `restore-keys` - An ordered list of keys to use for restoring the cache if no cache hit occurred for key
|
* `restore-keys` - 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.
|
||||||
|
|
||||||
### Outputs
|
### Outputs
|
||||||
|
|
||||||
|
@ -70,6 +72,8 @@ jobs:
|
||||||
run: /primes.sh -d prime-numbers
|
run: /primes.sh -d prime-numbers
|
||||||
```
|
```
|
||||||
|
|
||||||
|
> Note: You must use the `cache` action in your workflow before you need to use the files that might be restored from the cache. If the provided `key` doesn't match an existing cache, a new cache is automatically created if the job completes successfully.
|
||||||
|
|
||||||
## Implementation Examples
|
## Implementation Examples
|
||||||
|
|
||||||
Every programming language and framework has its own way of caching.
|
Every programming language and framework has its own way of caching.
|
||||||
|
|
|
@ -12,3 +12,6 @@
|
||||||
|
|
||||||
### 3.0.3
|
### 3.0.3
|
||||||
- Fixed avoiding empty cache save when no files are available for caching. ([issue](https://github.com/actions/cache/issues/624))
|
- Fixed avoiding empty cache save when no files are available for caching. ([issue](https://github.com/actions/cache/issues/624))
|
||||||
|
|
||||||
|
### 3.0.4
|
||||||
|
- Fixed tar creation error while trying to create tar with path as `~/` home folder on `ubuntu-latest`. ([issue](https://github.com/actions/cache/issues/689))
|
|
@ -227,40 +227,6 @@ test("restore with no cache found", async () => {
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("restore with server error should fail", async () => {
|
|
||||||
const path = "node_modules";
|
|
||||||
const key = "node-test";
|
|
||||||
testUtils.setInputs({
|
|
||||||
path: path,
|
|
||||||
key
|
|
||||||
});
|
|
||||||
|
|
||||||
const logWarningMock = jest.spyOn(actionUtils, "logWarning");
|
|
||||||
const failedMock = jest.spyOn(core, "setFailed");
|
|
||||||
const stateMock = jest.spyOn(core, "saveState");
|
|
||||||
const restoreCacheMock = jest
|
|
||||||
.spyOn(cache, "restoreCache")
|
|
||||||
.mockImplementationOnce(() => {
|
|
||||||
throw new Error("HTTP Error Occurred");
|
|
||||||
});
|
|
||||||
const setCacheHitOutputMock = jest.spyOn(actionUtils, "setCacheHitOutput");
|
|
||||||
|
|
||||||
await run();
|
|
||||||
|
|
||||||
expect(restoreCacheMock).toHaveBeenCalledTimes(1);
|
|
||||||
expect(restoreCacheMock).toHaveBeenCalledWith([path], key, []);
|
|
||||||
|
|
||||||
expect(stateMock).toHaveBeenCalledWith("CACHE_KEY", key);
|
|
||||||
|
|
||||||
expect(logWarningMock).toHaveBeenCalledTimes(1);
|
|
||||||
expect(logWarningMock).toHaveBeenCalledWith("HTTP Error Occurred");
|
|
||||||
|
|
||||||
expect(setCacheHitOutputMock).toHaveBeenCalledTimes(1);
|
|
||||||
expect(setCacheHitOutputMock).toHaveBeenCalledWith(false);
|
|
||||||
|
|
||||||
expect(failedMock).toHaveBeenCalledTimes(0);
|
|
||||||
});
|
|
||||||
|
|
||||||
test("restore with restore keys and no cache found", async () => {
|
test("restore with restore keys and no cache found", async () => {
|
||||||
const path = "node_modules";
|
const path = "node_modules";
|
||||||
const key = "node-test";
|
const key = "node-test";
|
||||||
|
|
|
@ -267,7 +267,6 @@ test("save with large cache outputs warning", async () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
test("save with reserve cache failure outputs warning", async () => {
|
test("save with reserve cache failure outputs warning", async () => {
|
||||||
const infoMock = jest.spyOn(core, "info");
|
|
||||||
const logWarningMock = jest.spyOn(actionUtils, "logWarning");
|
const logWarningMock = jest.spyOn(actionUtils, "logWarning");
|
||||||
const failedMock = jest.spyOn(core, "setFailed");
|
const failedMock = jest.spyOn(core, "setFailed");
|
||||||
|
|
||||||
|
@ -306,10 +305,10 @@ test("save with reserve cache failure outputs warning", async () => {
|
||||||
expect.anything()
|
expect.anything()
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(infoMock).toHaveBeenCalledWith(
|
expect(logWarningMock).toHaveBeenCalledWith(
|
||||||
`Unable to reserve cache with key ${primaryKey}, another job may be creating this cache.`
|
`Unable to reserve cache with key ${primaryKey}, another job may be creating this cache.`
|
||||||
);
|
);
|
||||||
expect(logWarningMock).toHaveBeenCalledTimes(0);
|
expect(logWarningMock).toHaveBeenCalledTimes(1);
|
||||||
expect(failedMock).toHaveBeenCalledTimes(0);
|
expect(failedMock).toHaveBeenCalledTimes(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ inputs:
|
||||||
description: 'An explicit key for restoring and saving the cache'
|
description: 'An explicit key for restoring and saving the cache'
|
||||||
required: true
|
required: true
|
||||||
restore-keys:
|
restore-keys:
|
||||||
description: 'An ordered list of keys to use for restoring the cache if no cache hit occurred for key'
|
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
|
required: false
|
||||||
upload-chunk-size:
|
upload-chunk-size:
|
||||||
description: 'The chunk size used to split up large files during upload, in bytes'
|
description: 'The chunk size used to split up large files during upload, in bytes'
|
||||||
|
|
46
dist/restore/index.js
vendored
46
dist/restore/index.js
vendored
|
@ -37317,6 +37317,8 @@ function createTar(archiveFolder, sourceDirectories, compressionMethod) {
|
||||||
...getCompressionProgram(),
|
...getCompressionProgram(),
|
||||||
'-cf',
|
'-cf',
|
||||||
cacheFileName.replace(new RegExp(`\\${path.sep}`, 'g'), '/'),
|
cacheFileName.replace(new RegExp(`\\${path.sep}`, 'g'), '/'),
|
||||||
|
'--exclude',
|
||||||
|
cacheFileName.replace(new RegExp(`\\${path.sep}`, 'g'), '/'),
|
||||||
'-P',
|
'-P',
|
||||||
'-C',
|
'-C',
|
||||||
workingDirectory.replace(new RegExp(`\\${path.sep}`, 'g'), '/'),
|
workingDirectory.replace(new RegExp(`\\${path.sep}`, 'g'), '/'),
|
||||||
|
@ -46848,6 +46850,8 @@ function restoreCache(paths, primaryKey, restoreKeys, options) {
|
||||||
checkKey(key);
|
checkKey(key);
|
||||||
}
|
}
|
||||||
const compressionMethod = yield utils.getCompressionMethod();
|
const compressionMethod = yield utils.getCompressionMethod();
|
||||||
|
let archivePath = '';
|
||||||
|
try {
|
||||||
// path are needed to compute version
|
// path are needed to compute version
|
||||||
const cacheEntry = yield cacheHttpClient.getCacheEntry(keys, paths, {
|
const cacheEntry = yield cacheHttpClient.getCacheEntry(keys, paths, {
|
||||||
compressionMethod
|
compressionMethod
|
||||||
|
@ -46856,9 +46860,8 @@ function restoreCache(paths, primaryKey, restoreKeys, options) {
|
||||||
// Cache not found
|
// Cache not found
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
const archivePath = path.join(yield utils.createTempDirectory(), utils.getCacheFileName(compressionMethod));
|
archivePath = path.join(yield utils.createTempDirectory(), utils.getCacheFileName(compressionMethod));
|
||||||
core.debug(`Archive Path: ${archivePath}`);
|
core.debug(`Archive Path: ${archivePath}`);
|
||||||
try {
|
|
||||||
// Download the cache from the cache entry
|
// Download the cache from the cache entry
|
||||||
yield cacheHttpClient.downloadCache(cacheEntry.archiveLocation, archivePath, options);
|
yield cacheHttpClient.downloadCache(cacheEntry.archiveLocation, archivePath, options);
|
||||||
if (core.isDebug()) {
|
if (core.isDebug()) {
|
||||||
|
@ -46868,6 +46871,17 @@ function restoreCache(paths, primaryKey, restoreKeys, options) {
|
||||||
core.info(`Cache Size: ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B)`);
|
core.info(`Cache Size: ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B)`);
|
||||||
yield tar_1.extractTar(archivePath, compressionMethod);
|
yield tar_1.extractTar(archivePath, compressionMethod);
|
||||||
core.info('Cache restored successfully');
|
core.info('Cache restored successfully');
|
||||||
|
return cacheEntry.cacheKey;
|
||||||
|
}
|
||||||
|
catch (error) {
|
||||||
|
const typedError = error;
|
||||||
|
if (typedError.name === ValidationError.name) {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// Supress all non-validation cache related errors because caching should be optional
|
||||||
|
core.warning(`Failed to restore: ${error.message}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
// Try to delete the archive to save space
|
// Try to delete the archive to save space
|
||||||
|
@ -46878,7 +46892,7 @@ function restoreCache(paths, primaryKey, restoreKeys, options) {
|
||||||
core.debug(`Failed to delete archive: ${error}`);
|
core.debug(`Failed to delete archive: ${error}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return cacheEntry.cacheKey;
|
return undefined;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
exports.restoreCache = restoreCache;
|
exports.restoreCache = restoreCache;
|
||||||
|
@ -46896,7 +46910,7 @@ function saveCache(paths, key, options) {
|
||||||
checkPaths(paths);
|
checkPaths(paths);
|
||||||
checkKey(key);
|
checkKey(key);
|
||||||
const compressionMethod = yield utils.getCompressionMethod();
|
const compressionMethod = yield utils.getCompressionMethod();
|
||||||
let cacheId = null;
|
let cacheId = -1;
|
||||||
const cachePaths = yield utils.resolvePaths(paths);
|
const cachePaths = yield utils.resolvePaths(paths);
|
||||||
core.debug('Cache Paths:');
|
core.debug('Cache Paths:');
|
||||||
core.debug(`${JSON.stringify(cachePaths)}`);
|
core.debug(`${JSON.stringify(cachePaths)}`);
|
||||||
|
@ -46935,6 +46949,18 @@ function saveCache(paths, key, options) {
|
||||||
core.debug(`Saving Cache (ID: ${cacheId})`);
|
core.debug(`Saving Cache (ID: ${cacheId})`);
|
||||||
yield cacheHttpClient.saveCache(cacheId, archivePath, options);
|
yield cacheHttpClient.saveCache(cacheId, archivePath, options);
|
||||||
}
|
}
|
||||||
|
catch (error) {
|
||||||
|
const typedError = error;
|
||||||
|
if (typedError.name === ValidationError.name) {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
else if (typedError.name === ReserveCacheError.name) {
|
||||||
|
core.info(`Failed to save: ${typedError.message}`);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
core.warning(`Failed to save: ${typedError.message}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
finally {
|
finally {
|
||||||
// Try to delete the archive to save space
|
// Try to delete the archive to save space
|
||||||
try {
|
try {
|
||||||
|
@ -48994,7 +49020,6 @@ function run() {
|
||||||
const cachePaths = utils.getInputAsArray(constants_1.Inputs.Path, {
|
const cachePaths = utils.getInputAsArray(constants_1.Inputs.Path, {
|
||||||
required: true
|
required: true
|
||||||
});
|
});
|
||||||
try {
|
|
||||||
const cacheKey = yield cache.restoreCache(cachePaths, primaryKey, restoreKeys);
|
const cacheKey = yield cache.restoreCache(cachePaths, primaryKey, restoreKeys);
|
||||||
if (!cacheKey) {
|
if (!cacheKey) {
|
||||||
core.info(`Cache not found for input keys: ${[
|
core.info(`Cache not found for input keys: ${[
|
||||||
|
@ -49009,17 +49034,6 @@ function run() {
|
||||||
utils.setCacheHitOutput(isExactKeyMatch);
|
utils.setCacheHitOutput(isExactKeyMatch);
|
||||||
core.info(`Cache restored from key: ${cacheKey}`);
|
core.info(`Cache restored from key: ${cacheKey}`);
|
||||||
}
|
}
|
||||||
catch (error) {
|
|
||||||
const typedError = error;
|
|
||||||
if (typedError.name === cache.ValidationError.name) {
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
utils.logWarning(typedError.message);
|
|
||||||
utils.setCacheHitOutput(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (error) {
|
catch (error) {
|
||||||
core.setFailed(error.message);
|
core.setFailed(error.message);
|
||||||
}
|
}
|
||||||
|
|
50
dist/save/index.js
vendored
50
dist/save/index.js
vendored
|
@ -37317,6 +37317,8 @@ function createTar(archiveFolder, sourceDirectories, compressionMethod) {
|
||||||
...getCompressionProgram(),
|
...getCompressionProgram(),
|
||||||
'-cf',
|
'-cf',
|
||||||
cacheFileName.replace(new RegExp(`\\${path.sep}`, 'g'), '/'),
|
cacheFileName.replace(new RegExp(`\\${path.sep}`, 'g'), '/'),
|
||||||
|
'--exclude',
|
||||||
|
cacheFileName.replace(new RegExp(`\\${path.sep}`, 'g'), '/'),
|
||||||
'-P',
|
'-P',
|
||||||
'-C',
|
'-C',
|
||||||
workingDirectory.replace(new RegExp(`\\${path.sep}`, 'g'), '/'),
|
workingDirectory.replace(new RegExp(`\\${path.sep}`, 'g'), '/'),
|
||||||
|
@ -46790,24 +46792,12 @@ function run() {
|
||||||
const cachePaths = utils.getInputAsArray(constants_1.Inputs.Path, {
|
const cachePaths = utils.getInputAsArray(constants_1.Inputs.Path, {
|
||||||
required: true
|
required: true
|
||||||
});
|
});
|
||||||
try {
|
const cacheId = yield cache.saveCache(cachePaths, primaryKey, {
|
||||||
yield cache.saveCache(cachePaths, primaryKey, {
|
|
||||||
uploadChunkSize: utils.getInputAsInt(constants_1.Inputs.UploadChunkSize)
|
uploadChunkSize: utils.getInputAsInt(constants_1.Inputs.UploadChunkSize)
|
||||||
});
|
});
|
||||||
|
if (cacheId != -1) {
|
||||||
core.info(`Cache saved with key: ${primaryKey}`);
|
core.info(`Cache saved with key: ${primaryKey}`);
|
||||||
}
|
}
|
||||||
catch (error) {
|
|
||||||
const typedError = error;
|
|
||||||
if (typedError.name === cache.ValidationError.name) {
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
else if (typedError.name === cache.ReserveCacheError.name) {
|
|
||||||
core.info(typedError.message);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
utils.logWarning(typedError.message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
utils.logWarning(error.message);
|
utils.logWarning(error.message);
|
||||||
|
@ -46946,6 +46936,8 @@ function restoreCache(paths, primaryKey, restoreKeys, options) {
|
||||||
checkKey(key);
|
checkKey(key);
|
||||||
}
|
}
|
||||||
const compressionMethod = yield utils.getCompressionMethod();
|
const compressionMethod = yield utils.getCompressionMethod();
|
||||||
|
let archivePath = '';
|
||||||
|
try {
|
||||||
// path are needed to compute version
|
// path are needed to compute version
|
||||||
const cacheEntry = yield cacheHttpClient.getCacheEntry(keys, paths, {
|
const cacheEntry = yield cacheHttpClient.getCacheEntry(keys, paths, {
|
||||||
compressionMethod
|
compressionMethod
|
||||||
|
@ -46954,9 +46946,8 @@ function restoreCache(paths, primaryKey, restoreKeys, options) {
|
||||||
// Cache not found
|
// Cache not found
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
const archivePath = path.join(yield utils.createTempDirectory(), utils.getCacheFileName(compressionMethod));
|
archivePath = path.join(yield utils.createTempDirectory(), utils.getCacheFileName(compressionMethod));
|
||||||
core.debug(`Archive Path: ${archivePath}`);
|
core.debug(`Archive Path: ${archivePath}`);
|
||||||
try {
|
|
||||||
// Download the cache from the cache entry
|
// Download the cache from the cache entry
|
||||||
yield cacheHttpClient.downloadCache(cacheEntry.archiveLocation, archivePath, options);
|
yield cacheHttpClient.downloadCache(cacheEntry.archiveLocation, archivePath, options);
|
||||||
if (core.isDebug()) {
|
if (core.isDebug()) {
|
||||||
|
@ -46966,6 +46957,17 @@ function restoreCache(paths, primaryKey, restoreKeys, options) {
|
||||||
core.info(`Cache Size: ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B)`);
|
core.info(`Cache Size: ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B)`);
|
||||||
yield tar_1.extractTar(archivePath, compressionMethod);
|
yield tar_1.extractTar(archivePath, compressionMethod);
|
||||||
core.info('Cache restored successfully');
|
core.info('Cache restored successfully');
|
||||||
|
return cacheEntry.cacheKey;
|
||||||
|
}
|
||||||
|
catch (error) {
|
||||||
|
const typedError = error;
|
||||||
|
if (typedError.name === ValidationError.name) {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// Supress all non-validation cache related errors because caching should be optional
|
||||||
|
core.warning(`Failed to restore: ${error.message}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
// Try to delete the archive to save space
|
// Try to delete the archive to save space
|
||||||
|
@ -46976,7 +46978,7 @@ function restoreCache(paths, primaryKey, restoreKeys, options) {
|
||||||
core.debug(`Failed to delete archive: ${error}`);
|
core.debug(`Failed to delete archive: ${error}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return cacheEntry.cacheKey;
|
return undefined;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
exports.restoreCache = restoreCache;
|
exports.restoreCache = restoreCache;
|
||||||
|
@ -46994,7 +46996,7 @@ function saveCache(paths, key, options) {
|
||||||
checkPaths(paths);
|
checkPaths(paths);
|
||||||
checkKey(key);
|
checkKey(key);
|
||||||
const compressionMethod = yield utils.getCompressionMethod();
|
const compressionMethod = yield utils.getCompressionMethod();
|
||||||
let cacheId = null;
|
let cacheId = -1;
|
||||||
const cachePaths = yield utils.resolvePaths(paths);
|
const cachePaths = yield utils.resolvePaths(paths);
|
||||||
core.debug('Cache Paths:');
|
core.debug('Cache Paths:');
|
||||||
core.debug(`${JSON.stringify(cachePaths)}`);
|
core.debug(`${JSON.stringify(cachePaths)}`);
|
||||||
|
@ -47033,6 +47035,18 @@ function saveCache(paths, key, options) {
|
||||||
core.debug(`Saving Cache (ID: ${cacheId})`);
|
core.debug(`Saving Cache (ID: ${cacheId})`);
|
||||||
yield cacheHttpClient.saveCache(cacheId, archivePath, options);
|
yield cacheHttpClient.saveCache(cacheId, archivePath, options);
|
||||||
}
|
}
|
||||||
|
catch (error) {
|
||||||
|
const typedError = error;
|
||||||
|
if (typedError.name === ValidationError.name) {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
else if (typedError.name === ReserveCacheError.name) {
|
||||||
|
core.info(`Failed to save: ${typedError.message}`);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
core.warning(`Failed to save: ${typedError.message}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
finally {
|
finally {
|
||||||
// Try to delete the archive to save space
|
// Try to delete the archive to save space
|
||||||
try {
|
try {
|
||||||
|
|
36
examples.md
36
examples.md
|
@ -9,6 +9,7 @@
|
||||||
- [macOS](#macos)
|
- [macOS](#macos)
|
||||||
- [Windows](#windows-1)
|
- [Windows](#windows-1)
|
||||||
- [Elixir - Mix](#elixir---mix)
|
- [Elixir - Mix](#elixir---mix)
|
||||||
|
- [Erlang - Rebar3](#erlang--rebar3)
|
||||||
- [Go - Modules](#go---modules)
|
- [Go - Modules](#go---modules)
|
||||||
- [Linux](#linux-1)
|
- [Linux](#linux-1)
|
||||||
- [macOS](#macos-1)
|
- [macOS](#macos-1)
|
||||||
|
@ -151,6 +152,18 @@ steps:
|
||||||
${{ runner.os }}-mix-
|
${{ runner.os }}-mix-
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Erlang - Rebar3
|
||||||
|
```yaml
|
||||||
|
- uses: actions/cache@v2
|
||||||
|
with:
|
||||||
|
path: |
|
||||||
|
~/.cache/rebar3
|
||||||
|
_build
|
||||||
|
key: ${{ runner.os }}-erlang-${{ env.OTP_VERSION }}-${{ hashFiles('**/*rebar.lock') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-erlang-${{ env.OTP_VERSION }}-
|
||||||
|
```
|
||||||
|
|
||||||
## Go - Modules
|
## Go - Modules
|
||||||
|
|
||||||
### Linux
|
### Linux
|
||||||
|
@ -210,6 +223,8 @@ We cache the elements of the Cabal store separately, as the entirety of `~/.caba
|
||||||
|
|
||||||
## Haskell - Stack
|
## Haskell - Stack
|
||||||
|
|
||||||
|
### Linux or macOS
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
- uses: actions/cache@v3
|
- uses: actions/cache@v3
|
||||||
name: Cache ~/.stack
|
name: Cache ~/.stack
|
||||||
|
@ -227,6 +242,27 @@ We cache the elements of the Cabal store separately, as the entirety of `~/.caba
|
||||||
${{ runner.os }}-stack-work-
|
${{ runner.os }}-stack-work-
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Windows
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
- uses: actions/cache@v3
|
||||||
|
name: Cache %APPDATA%\stack %LOCALAPPDATA%\Programs\stack
|
||||||
|
with:
|
||||||
|
path: |
|
||||||
|
~\AppData\Roaming\stack
|
||||||
|
~\AppData\Local\Programs\stack
|
||||||
|
key: ${{ runner.os }}-stack-global-${{ hashFiles('stack.yaml') }}-${{ hashFiles('package.yaml') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-stack-global-
|
||||||
|
- uses: actions/cache@v3
|
||||||
|
name: Cache .stack-work
|
||||||
|
with:
|
||||||
|
path: .stack-work
|
||||||
|
key: ${{ runner.os }}-stack-work-${{ hashFiles('stack.yaml') }}-${{ hashFiles('package.yaml') }}-${{ hashFiles('**/*.hs') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-stack-work-
|
||||||
|
```
|
||||||
|
|
||||||
## Java - Gradle
|
## Java - Gradle
|
||||||
|
|
||||||
>Note: Ensure no Gradle daemons are running anymore when your workflow completes. Creating the cache package might fail due to locks being held by Gradle. Refer to the [Gradle Daemon documentation](https://docs.gradle.org/current/userguide/gradle_daemon.html) on how to disable or stop the Gradle Daemons.
|
>Note: Ensure no Gradle daemons are running anymore when your workflow completes. Creating the cache package might fail due to locks being held by Gradle. Refer to the [Gradle Daemon documentation](https://docs.gradle.org/current/userguide/gradle_daemon.html) on how to disable or stop the Gradle Daemons.
|
||||||
|
|
13
package-lock.json
generated
13
package-lock.json
generated
|
@ -1,18 +1,18 @@
|
||||||
{
|
{
|
||||||
"name": "cache",
|
"name": "cache",
|
||||||
"version": "3.0.3",
|
"version": "3.0.4",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "cache",
|
"name": "cache",
|
||||||
"version": "3.0.3",
|
"version": "3.0.4",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/cache": "^2.0.6",
|
|
||||||
"@actions/core": "^1.7.0",
|
"@actions/core": "^1.7.0",
|
||||||
"@actions/exec": "^1.1.1",
|
"@actions/exec": "^1.1.1",
|
||||||
"@actions/io": "^1.1.2"
|
"@actions/io": "^1.1.2"
|
||||||
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/jest": "^27.5.0",
|
"@types/jest": "^27.5.0",
|
||||||
|
@ -36,9 +36,7 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@actions/cache": {
|
"node_modules/@actions/cache": {
|
||||||
"version": "2.0.6",
|
|
||||||
"resolved": "https://registry.npmjs.org/@actions/cache/-/cache-2.0.6.tgz",
|
|
||||||
"integrity": "sha512-Z39ZrWaTRRPaV/AOQdY7hve+Iy/HloH5prpz+k+0lZgGQs/3SeO0UYSIakVuXOk2pdMZnl0Nv0PoK1rmh9YfGQ==",
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "^1.2.6",
|
"@actions/core": "^1.2.6",
|
||||||
"@actions/exec": "^1.0.1",
|
"@actions/exec": "^1.0.1",
|
||||||
|
@ -9533,9 +9531,6 @@
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/cache": {
|
"@actions/cache": {
|
||||||
"version": "2.0.6",
|
|
||||||
"resolved": "https://registry.npmjs.org/@actions/cache/-/cache-2.0.6.tgz",
|
|
||||||
"integrity": "sha512-Z39ZrWaTRRPaV/AOQdY7hve+Iy/HloH5prpz+k+0lZgGQs/3SeO0UYSIakVuXOk2pdMZnl0Nv0PoK1rmh9YfGQ==",
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"@actions/core": "^1.2.6",
|
"@actions/core": "^1.2.6",
|
||||||
"@actions/exec": "^1.0.1",
|
"@actions/exec": "^1.0.1",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "cache",
|
"name": "cache",
|
||||||
"version": "3.0.3",
|
"version": "3.0.4",
|
||||||
"private": true,
|
"private": true,
|
||||||
"description": "Cache dependencies and build outputs",
|
"description": "Cache dependencies and build outputs",
|
||||||
"main": "dist/restore/index.js",
|
"main": "dist/restore/index.js",
|
||||||
|
@ -23,7 +23,6 @@
|
||||||
"author": "GitHub",
|
"author": "GitHub",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/cache": "^2.0.6",
|
|
||||||
"@actions/core": "^1.7.0",
|
"@actions/core": "^1.7.0",
|
||||||
"@actions/exec": "^1.1.1",
|
"@actions/exec": "^1.1.1",
|
||||||
"@actions/io": "^1.1.2"
|
"@actions/io": "^1.1.2"
|
||||||
|
|
|
@ -29,12 +29,12 @@ async function run(): Promise<void> {
|
||||||
required: true
|
required: true
|
||||||
});
|
});
|
||||||
|
|
||||||
try {
|
|
||||||
const cacheKey = await cache.restoreCache(
|
const cacheKey = await cache.restoreCache(
|
||||||
cachePaths,
|
cachePaths,
|
||||||
primaryKey,
|
primaryKey,
|
||||||
restoreKeys
|
restoreKeys
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!cacheKey) {
|
if (!cacheKey) {
|
||||||
core.info(
|
core.info(
|
||||||
`Cache not found for input keys: ${[
|
`Cache not found for input keys: ${[
|
||||||
|
@ -42,6 +42,7 @@ async function run(): Promise<void> {
|
||||||
...restoreKeys
|
...restoreKeys
|
||||||
].join(", ")}`
|
].join(", ")}`
|
||||||
);
|
);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,17 +51,7 @@ async function run(): Promise<void> {
|
||||||
|
|
||||||
const isExactKeyMatch = utils.isExactKeyMatch(primaryKey, cacheKey);
|
const isExactKeyMatch = utils.isExactKeyMatch(primaryKey, cacheKey);
|
||||||
utils.setCacheHitOutput(isExactKeyMatch);
|
utils.setCacheHitOutput(isExactKeyMatch);
|
||||||
|
|
||||||
core.info(`Cache restored from key: ${cacheKey}`);
|
core.info(`Cache restored from key: ${cacheKey}`);
|
||||||
} catch (error: unknown) {
|
|
||||||
const typedError = error as Error;
|
|
||||||
if (typedError.name === cache.ValidationError.name) {
|
|
||||||
throw error;
|
|
||||||
} else {
|
|
||||||
utils.logWarning(typedError.message);
|
|
||||||
utils.setCacheHitOutput(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (error: unknown) {
|
} catch (error: unknown) {
|
||||||
core.setFailed((error as Error).message);
|
core.setFailed((error as Error).message);
|
||||||
}
|
}
|
||||||
|
|
14
src/save.ts
14
src/save.ts
|
@ -44,20 +44,12 @@ async function run(): Promise<void> {
|
||||||
required: true
|
required: true
|
||||||
});
|
});
|
||||||
|
|
||||||
try {
|
const cacheId = await cache.saveCache(cachePaths, primaryKey, {
|
||||||
await cache.saveCache(cachePaths, primaryKey, {
|
|
||||||
uploadChunkSize: utils.getInputAsInt(Inputs.UploadChunkSize)
|
uploadChunkSize: utils.getInputAsInt(Inputs.UploadChunkSize)
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (cacheId != -1) {
|
||||||
core.info(`Cache saved with key: ${primaryKey}`);
|
core.info(`Cache saved with key: ${primaryKey}`);
|
||||||
} catch (error: unknown) {
|
|
||||||
const typedError = error as Error;
|
|
||||||
if (typedError.name === cache.ValidationError.name) {
|
|
||||||
throw error;
|
|
||||||
} else if (typedError.name === cache.ReserveCacheError.name) {
|
|
||||||
core.info(typedError.message);
|
|
||||||
} else {
|
|
||||||
utils.logWarning(typedError.message);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} catch (error: unknown) {
|
} catch (error: unknown) {
|
||||||
utils.logWarning((error as Error).message);
|
utils.logWarning((error as Error).message);
|
||||||
|
|
Loading…
Reference in a new issue