mirror of
https://github.com/actions/cache.git
synced 2025-11-14 13:00:24 +07:00
Compare commits
4 Commits
bishal-pdM
...
phantsure/
| Author | SHA1 | Date | |
|---|---|---|---|
| 914fcb3068 | |||
| 95a9c77002 | |||
| c17f4bf466 | |||
| ac25611cae |
14
.devcontainer/devcontainer.json
Normal file
14
.devcontainer/devcontainer.json
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"name": "Node.js & TypeScript",
|
||||||
|
"image": "mcr.microsoft.com/devcontainers/typescript-node:16-bullseye",
|
||||||
|
// Features to add to the dev container. More info: https://containers.dev/implementors/features.
|
||||||
|
// "features": {},
|
||||||
|
// Use 'forwardPorts' to make a list of ports inside the container available locally.
|
||||||
|
// "forwardPorts": [],
|
||||||
|
// Use 'postCreateCommand' to run commands after the container is created.
|
||||||
|
"postCreateCommand": "npm install"
|
||||||
|
// Configure tool-specific properties.
|
||||||
|
// "customizations": {},
|
||||||
|
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
|
||||||
|
// "remoteUser": "root"
|
||||||
|
}
|
||||||
2
.licenses/npm/@actions/cache.dep.yml
generated
2
.licenses/npm/@actions/cache.dep.yml
generated
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
name: "@actions/cache"
|
name: "@actions/cache"
|
||||||
version: 3.0.5
|
version: 3.1.0
|
||||||
type: npm
|
type: npm
|
||||||
summary:
|
summary:
|
||||||
homepage:
|
homepage:
|
||||||
|
|||||||
@ -2,12 +2,19 @@
|
|||||||
|
|
||||||
This action allows caching dependencies and build outputs to improve workflow execution time.
|
This action allows caching dependencies and build outputs to improve workflow execution time.
|
||||||
|
|
||||||
|
In addition to this `cache` action, other two actions are also available
|
||||||
|
|
||||||
|
[Restore action](./restore/README.md)
|
||||||
|
|
||||||
|
[Save action](./save/README.md)
|
||||||
|
|
||||||
[](https://github.com/actions/cache/actions/workflows/workflow.yml)
|
[](https://github.com/actions/cache/actions/workflows/workflow.yml)
|
||||||
|
|
||||||
## Documentation
|
## Documentation
|
||||||
|
|
||||||
See ["Caching dependencies to speed up workflows"](https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows).
|
See ["Caching dependencies to speed up workflows"](https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows).
|
||||||
|
|
||||||
|
|
||||||
## What's New
|
## What's New
|
||||||
### v3
|
### v3
|
||||||
* Added support for caching from GHES 3.5.
|
* Added support for caching from GHES 3.5.
|
||||||
@ -20,6 +27,8 @@ See ["Caching dependencies to speed up workflows"](https://docs.github.com/en/ac
|
|||||||
* Fixed the download stuck problem by introducing a timeout of 1 hour for cache downloads.
|
* Fixed the download stuck problem by introducing a timeout of 1 hour for cache downloads.
|
||||||
* Fix zstd not working for windows on gnu tar in issues.
|
* Fix zstd not working for windows on gnu tar in issues.
|
||||||
* Allowing users to provide a custom timeout as input for aborting download of a cache segment using an environment variable `SEGMENT_DOWNLOAD_TIMEOUT_MINS`. Default is 60 minutes.
|
* Allowing users to provide a custom timeout as input for aborting download of a cache segment using an environment variable `SEGMENT_DOWNLOAD_TIMEOUT_MINS`. Default is 60 minutes.
|
||||||
|
* Two new actions available for granular control over caches - [restore](restore/action.yml) and [save](save/action.yml)
|
||||||
|
* Add support for cross os caching. For example, a cache saved on windows can be restored on ubuntu and vice versa.
|
||||||
|
|
||||||
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
|
||||||
|
|
||||||
|
|||||||
20
RELEASES.md
20
RELEASES.md
@ -40,3 +40,23 @@
|
|||||||
### 3.0.11
|
### 3.0.11
|
||||||
- Update toolkit version to 3.0.5 to include `@actions/core@^1.10.0`
|
- Update toolkit version to 3.0.5 to include `@actions/core@^1.10.0`
|
||||||
- Update `@actions/cache` to use updated `saveState` and `setOutput` functions from `@actions/core@^1.10.0`
|
- Update `@actions/cache` to use updated `saveState` and `setOutput` functions from `@actions/core@^1.10.0`
|
||||||
|
|
||||||
|
### 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))
|
||||||
|
|
||||||
|
### 3.1.0-beta.2
|
||||||
|
- Added support for fallback to gzip to restore old caches on windows.
|
||||||
|
|
||||||
|
### 3.1.0-beta.3
|
||||||
|
- Bug fixes for bsdtar fallback if gnutar not available and gzip fallback if cache saved using old cache action on windows.
|
||||||
|
|
||||||
|
### 3.2.0-beta.1
|
||||||
|
- Added two new actions - [restore](restore/action.yml) and [save](save/action.yml) for granular control on cache.
|
||||||
|
|
||||||
|
### 3.2.0
|
||||||
|
- Released the two new actions - [restore](restore/action.yml) and [save](save/action.yml) for granular control on cache
|
||||||
|
|
||||||
|
### 3.2.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))
|
||||||
|
- Added support for fallback to gzip to restore old caches on windows.
|
||||||
|
- Added logs for cache version in case of a cache miss.
|
||||||
@ -1,7 +1,7 @@
|
|||||||
import * as cache from "@actions/cache";
|
import * as cache from "@actions/cache";
|
||||||
import * as core from "@actions/core";
|
import * as core from "@actions/core";
|
||||||
|
|
||||||
import { Events, Outputs, RefKey, State } from "../src/constants";
|
import { Events, RefKey } from "../src/constants";
|
||||||
import * as actionUtils from "../src/utils/actionUtils";
|
import * as actionUtils from "../src/utils/actionUtils";
|
||||||
import * as testUtils from "../src/utils/testUtils";
|
import * as testUtils from "../src/utils/testUtils";
|
||||||
|
|
||||||
@ -79,83 +79,6 @@ test("isExactKeyMatch with same key and different casing returns true", () => {
|
|||||||
expect(actionUtils.isExactKeyMatch(key, cacheKey)).toBe(true);
|
expect(actionUtils.isExactKeyMatch(key, cacheKey)).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("setOutputAndState with undefined entry to set cache-hit output", () => {
|
|
||||||
const key = "linux-rust";
|
|
||||||
const cacheKey = undefined;
|
|
||||||
|
|
||||||
const setOutputMock = jest.spyOn(core, "setOutput");
|
|
||||||
const saveStateMock = jest.spyOn(core, "saveState");
|
|
||||||
|
|
||||||
actionUtils.setOutputAndState(key, cacheKey);
|
|
||||||
|
|
||||||
expect(setOutputMock).toHaveBeenCalledWith(Outputs.CacheHit, "false");
|
|
||||||
expect(setOutputMock).toHaveBeenCalledTimes(1);
|
|
||||||
|
|
||||||
expect(saveStateMock).toHaveBeenCalledTimes(0);
|
|
||||||
});
|
|
||||||
|
|
||||||
test("setOutputAndState with exact match to set cache-hit output and state", () => {
|
|
||||||
const key = "linux-rust";
|
|
||||||
const cacheKey = "linux-rust";
|
|
||||||
|
|
||||||
const setOutputMock = jest.spyOn(core, "setOutput");
|
|
||||||
const saveStateMock = jest.spyOn(core, "saveState");
|
|
||||||
|
|
||||||
actionUtils.setOutputAndState(key, cacheKey);
|
|
||||||
|
|
||||||
expect(setOutputMock).toHaveBeenCalledWith(Outputs.CacheHit, "true");
|
|
||||||
expect(setOutputMock).toHaveBeenCalledTimes(1);
|
|
||||||
|
|
||||||
expect(saveStateMock).toHaveBeenCalledWith(State.CacheMatchedKey, cacheKey);
|
|
||||||
expect(saveStateMock).toHaveBeenCalledTimes(1);
|
|
||||||
});
|
|
||||||
|
|
||||||
test("setOutputAndState with no exact match to set cache-hit output and state", () => {
|
|
||||||
const key = "linux-rust";
|
|
||||||
const cacheKey = "linux-rust-bb828da54c148048dd17899ba9fda624811cfb43";
|
|
||||||
|
|
||||||
const setOutputMock = jest.spyOn(core, "setOutput");
|
|
||||||
const saveStateMock = jest.spyOn(core, "saveState");
|
|
||||||
|
|
||||||
actionUtils.setOutputAndState(key, cacheKey);
|
|
||||||
|
|
||||||
expect(setOutputMock).toHaveBeenCalledWith(Outputs.CacheHit, "false");
|
|
||||||
expect(setOutputMock).toHaveBeenCalledTimes(1);
|
|
||||||
|
|
||||||
expect(saveStateMock).toHaveBeenCalledWith(State.CacheMatchedKey, cacheKey);
|
|
||||||
expect(saveStateMock).toHaveBeenCalledTimes(1);
|
|
||||||
});
|
|
||||||
|
|
||||||
test("getCacheState with no state returns undefined", () => {
|
|
||||||
const getStateMock = jest.spyOn(core, "getState");
|
|
||||||
getStateMock.mockImplementation(() => {
|
|
||||||
return "";
|
|
||||||
});
|
|
||||||
|
|
||||||
const state = actionUtils.getCacheState();
|
|
||||||
|
|
||||||
expect(state).toBe(undefined);
|
|
||||||
|
|
||||||
expect(getStateMock).toHaveBeenCalledWith(State.CacheMatchedKey);
|
|
||||||
expect(getStateMock).toHaveBeenCalledTimes(1);
|
|
||||||
});
|
|
||||||
|
|
||||||
test("getCacheState with valid state", () => {
|
|
||||||
const cacheKey = "Linux-node-bb828da54c148048dd17899ba9fda624811cfb43";
|
|
||||||
|
|
||||||
const getStateMock = jest.spyOn(core, "getState");
|
|
||||||
getStateMock.mockImplementation(() => {
|
|
||||||
return cacheKey;
|
|
||||||
});
|
|
||||||
|
|
||||||
const state = actionUtils.getCacheState();
|
|
||||||
|
|
||||||
expect(state).toEqual(cacheKey);
|
|
||||||
|
|
||||||
expect(getStateMock).toHaveBeenCalledWith(State.CacheMatchedKey);
|
|
||||||
expect(getStateMock).toHaveBeenCalledTimes(1);
|
|
||||||
});
|
|
||||||
|
|
||||||
test("logWarning logs a message with a warning prefix", () => {
|
test("logWarning logs a message with a warning prefix", () => {
|
||||||
const message = "A warning occurred.";
|
const message = "A warning occurred.";
|
||||||
|
|
||||||
|
|||||||