mirror of
https://github.com/actions/cache.git
synced 2025-07-04 00:00:51 +02:00
Compare commits
3 Commits
v3.1.0-bet
...
v3.1.0-bet
Author | SHA1 | Date | |
---|---|---|---|
4d2f35c1eb | |||
ca82ccb28d | |||
cec18c5924 |
@ -43,6 +43,3 @@
|
|||||||
|
|
||||||
### 3.1.0-beta.1
|
### 3.1.0-beta.1
|
||||||
- Update `@actions/cache` on windows to use gnu tar and zstd by default and fallback to bsdtar and zstd if gnu tar is not available. ([issue](https://github.com/actions/cache/issues/984))
|
- Update `@actions/cache` on windows to use gnu tar and zstd by default and fallback to bsdtar and zstd if gnu tar is not available. ([issue](https://github.com/actions/cache/issues/984))
|
||||||
|
|
||||||
### 3.1.0-beta.2
|
|
||||||
- Added support for fallback to gzip to restore old caches on windows.
|
|
||||||
|
31
dist/restore/index.js
vendored
31
dist/restore/index.js
vendored
@ -47081,7 +47081,6 @@ const path = __importStar(__webpack_require__(622));
|
|||||||
const utils = __importStar(__webpack_require__(15));
|
const utils = __importStar(__webpack_require__(15));
|
||||||
const cacheHttpClient = __importStar(__webpack_require__(114));
|
const cacheHttpClient = __importStar(__webpack_require__(114));
|
||||||
const tar_1 = __webpack_require__(434);
|
const tar_1 = __webpack_require__(434);
|
||||||
const constants_1 = __webpack_require__(931);
|
|
||||||
class ValidationError extends Error {
|
class ValidationError extends Error {
|
||||||
constructor(message) {
|
constructor(message) {
|
||||||
super(message);
|
super(message);
|
||||||
@ -47143,33 +47142,13 @@ function restoreCache(paths, primaryKey, restoreKeys, options) {
|
|||||||
for (const key of keys) {
|
for (const key of keys) {
|
||||||
checkKey(key);
|
checkKey(key);
|
||||||
}
|
}
|
||||||
let cacheEntry;
|
const compressionMethod = yield utils.getCompressionMethod();
|
||||||
let compressionMethod = yield utils.getCompressionMethod();
|
|
||||||
let archivePath = '';
|
let archivePath = '';
|
||||||
try {
|
try {
|
||||||
try {
|
// path are needed to compute version
|
||||||
// path are needed to compute version
|
const cacheEntry = yield cacheHttpClient.getCacheEntry(keys, paths, {
|
||||||
cacheEntry = yield cacheHttpClient.getCacheEntry(keys, paths, {
|
compressionMethod
|
||||||
compressionMethod
|
});
|
||||||
});
|
|
||||||
}
|
|
||||||
catch (error) {
|
|
||||||
// This is to support the old cache entry created
|
|
||||||
// by the old version of the cache action on windows.
|
|
||||||
if (process.platform === 'win32' &&
|
|
||||||
compressionMethod !== constants_1.CompressionMethod.Gzip) {
|
|
||||||
compressionMethod = constants_1.CompressionMethod.Gzip;
|
|
||||||
cacheEntry = yield cacheHttpClient.getCacheEntry(keys, paths, {
|
|
||||||
compressionMethod
|
|
||||||
});
|
|
||||||
if (!(cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.archiveLocation)) {
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!(cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.archiveLocation)) {
|
if (!(cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.archiveLocation)) {
|
||||||
// Cache not found
|
// Cache not found
|
||||||
return undefined;
|
return undefined;
|
||||||
|
31
dist/save/index.js
vendored
31
dist/save/index.js
vendored
@ -47167,7 +47167,6 @@ const path = __importStar(__webpack_require__(622));
|
|||||||
const utils = __importStar(__webpack_require__(15));
|
const utils = __importStar(__webpack_require__(15));
|
||||||
const cacheHttpClient = __importStar(__webpack_require__(114));
|
const cacheHttpClient = __importStar(__webpack_require__(114));
|
||||||
const tar_1 = __webpack_require__(434);
|
const tar_1 = __webpack_require__(434);
|
||||||
const constants_1 = __webpack_require__(931);
|
|
||||||
class ValidationError extends Error {
|
class ValidationError extends Error {
|
||||||
constructor(message) {
|
constructor(message) {
|
||||||
super(message);
|
super(message);
|
||||||
@ -47229,33 +47228,13 @@ function restoreCache(paths, primaryKey, restoreKeys, options) {
|
|||||||
for (const key of keys) {
|
for (const key of keys) {
|
||||||
checkKey(key);
|
checkKey(key);
|
||||||
}
|
}
|
||||||
let cacheEntry;
|
const compressionMethod = yield utils.getCompressionMethod();
|
||||||
let compressionMethod = yield utils.getCompressionMethod();
|
|
||||||
let archivePath = '';
|
let archivePath = '';
|
||||||
try {
|
try {
|
||||||
try {
|
// path are needed to compute version
|
||||||
// path are needed to compute version
|
const cacheEntry = yield cacheHttpClient.getCacheEntry(keys, paths, {
|
||||||
cacheEntry = yield cacheHttpClient.getCacheEntry(keys, paths, {
|
compressionMethod
|
||||||
compressionMethod
|
});
|
||||||
});
|
|
||||||
}
|
|
||||||
catch (error) {
|
|
||||||
// This is to support the old cache entry created
|
|
||||||
// by the old version of the cache action on windows.
|
|
||||||
if (process.platform === 'win32' &&
|
|
||||||
compressionMethod !== constants_1.CompressionMethod.Gzip) {
|
|
||||||
compressionMethod = constants_1.CompressionMethod.Gzip;
|
|
||||||
cacheEntry = yield cacheHttpClient.getCacheEntry(keys, paths, {
|
|
||||||
compressionMethod
|
|
||||||
});
|
|
||||||
if (!(cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.archiveLocation)) {
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!(cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.archiveLocation)) {
|
if (!(cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.archiveLocation)) {
|
||||||
// Cache not found
|
// Cache not found
|
||||||
return undefined;
|
return undefined;
|
||||||
|
21
examples.md
21
examples.md
@ -309,29 +309,14 @@ We cache the elements of the Cabal store separately, as the entirety of `~/.caba
|
|||||||
For npm, cache files are stored in `~/.npm` on Posix, or `~\AppData\npm-cache` on Windows, but it's possible to use `npm config get cache` to find the path on any platform. See [the npm docs](https://docs.npmjs.com/cli/cache#cache) for more details.
|
For npm, cache files are stored in `~/.npm` on Posix, or `~\AppData\npm-cache` on Windows, but it's possible to use `npm config get cache` to find the path on any platform. See [the npm docs](https://docs.npmjs.com/cli/cache#cache) for more details.
|
||||||
|
|
||||||
If using `npm config` to retrieve the cache directory, ensure you run [actions/setup-node](https://github.com/actions/setup-node) first to ensure your `npm` version is correct.
|
If using `npm config` to retrieve the cache directory, ensure you run [actions/setup-node](https://github.com/actions/setup-node) first to ensure your `npm` version is correct.
|
||||||
After [deprecation](https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/) of save-state and set-output commands, the correct way to set output is using `${GITHUB_OUTPUT}`. For linux, we can use `${GITHUB_OUTPUT}` whereas for windows we need to use `${env:GITHUB_OUTPUT}` due to two different default shells in these two different OS ie `bash` and `pwsh` respectively.
|
|
||||||
|
|
||||||
>Note: It is not recommended to cache `node_modules`, as it can break across Node versions and won't work with `npm ci`
|
>Note: It is not recommended to cache `node_modules`, as it can break across Node versions and won't work with `npm ci`
|
||||||
|
|
||||||
### **Get npm cache directory using same shell**
|
|
||||||
### Bash shell
|
|
||||||
```yaml
|
```yaml
|
||||||
- name: Get npm cache directory
|
- name: Get npm cache directory
|
||||||
id: npm-cache
|
id: npm-cache-dir
|
||||||
shell: bash
|
run: |
|
||||||
run: echo "dir=$(npm config get cache)" >> ${GITHUB_OUTPUT}
|
echo "::set-output name=dir::$(npm config get cache)"
|
||||||
```
|
|
||||||
|
|
||||||
### PWSH shell
|
|
||||||
```yaml
|
|
||||||
- name: Get npm cache directory
|
|
||||||
id: npm-cache
|
|
||||||
shell: pwsh
|
|
||||||
run: echo "dir=$(npm config get cache)" >> ${env:GITHUB_OUTPUT}
|
|
||||||
```
|
|
||||||
`Get npm cache directory` step can then be used with `actions/cache` as shown below
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
- uses: actions/cache@v3
|
- uses: actions/cache@v3
|
||||||
id: npm-cache # use this to check for `cache-hit` ==> if: steps.npm-cache.outputs.cache-hit != 'true'
|
id: npm-cache # use this to check for `cache-hit` ==> if: steps.npm-cache.outputs.cache-hit != 'true'
|
||||||
with:
|
with:
|
||||||
|
18
package-lock.json
generated
18
package-lock.json
generated
@ -1,15 +1,15 @@
|
|||||||
{
|
{
|
||||||
"name": "cache",
|
"name": "cache",
|
||||||
"version": "3.1.0-beta.2",
|
"version": "3.1.0-beta.1",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "cache",
|
"name": "cache",
|
||||||
"version": "3.1.0-beta.2",
|
"version": "3.1.0-beta.1",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/cache": "3.1.0-beta.2",
|
"@actions/cache": "3.1.0-beta.1",
|
||||||
"@actions/core": "^1.10.0",
|
"@actions/core": "^1.10.0",
|
||||||
"@actions/exec": "^1.1.1",
|
"@actions/exec": "^1.1.1",
|
||||||
"@actions/io": "^1.1.2"
|
"@actions/io": "^1.1.2"
|
||||||
@ -36,9 +36,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@actions/cache": {
|
"node_modules/@actions/cache": {
|
||||||
"version": "3.1.0-beta.2",
|
"version": "3.1.0-beta.1",
|
||||||
"resolved": "https://registry.npmjs.org/@actions/cache/-/cache-3.1.0-beta.2.tgz",
|
"resolved": "https://registry.npmjs.org/@actions/cache/-/cache-3.1.0-beta.1.tgz",
|
||||||
"integrity": "sha512-xt9NLWPCh5WU9Z5ITeGpT5Nza/57wMXeLsGuNVcRCIVpPuNTf3Puj82vjZZQw4rGqiCCs+n4+hnkTcE9BKw2sw==",
|
"integrity": "sha512-E+lNTJ4x1baOVHbhkkGK7JebxChMM/ogDSWIuDJsiPlpi7bzzL8RnKTk4zlZ3OYmWK8tF2/5QZMerg3rY4c/9A==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "^1.10.0",
|
"@actions/core": "^1.10.0",
|
||||||
"@actions/exec": "^1.0.1",
|
"@actions/exec": "^1.0.1",
|
||||||
@ -9722,9 +9722,9 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/cache": {
|
"@actions/cache": {
|
||||||
"version": "3.1.0-beta.2",
|
"version": "3.1.0-beta.1",
|
||||||
"resolved": "https://registry.npmjs.org/@actions/cache/-/cache-3.1.0-beta.2.tgz",
|
"resolved": "https://registry.npmjs.org/@actions/cache/-/cache-3.1.0-beta.1.tgz",
|
||||||
"integrity": "sha512-xt9NLWPCh5WU9Z5ITeGpT5Nza/57wMXeLsGuNVcRCIVpPuNTf3Puj82vjZZQw4rGqiCCs+n4+hnkTcE9BKw2sw==",
|
"integrity": "sha512-E+lNTJ4x1baOVHbhkkGK7JebxChMM/ogDSWIuDJsiPlpi7bzzL8RnKTk4zlZ3OYmWK8tF2/5QZMerg3rY4c/9A==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"@actions/core": "^1.10.0",
|
"@actions/core": "^1.10.0",
|
||||||
"@actions/exec": "^1.0.1",
|
"@actions/exec": "^1.0.1",
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "cache",
|
"name": "cache",
|
||||||
"version": "3.1.0-beta.2",
|
"version": "3.1.0-beta.1",
|
||||||
"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,7 @@
|
|||||||
"author": "GitHub",
|
"author": "GitHub",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/cache": "3.1.0-beta.2",
|
"@actions/cache": "3.1.0-beta.1",
|
||||||
"@actions/core": "^1.10.0",
|
"@actions/core": "^1.10.0",
|
||||||
"@actions/exec": "^1.1.1",
|
"@actions/exec": "^1.1.1",
|
||||||
"@actions/io": "^1.1.2"
|
"@actions/io": "^1.1.2"
|
||||||
|
Reference in New Issue
Block a user