mirror of
https://github.com/actions/cache.git
synced 2026-08-06 03:12:16 +08:00
Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 01b0229624 | |||
| c4678ef19f | |||
| fe28a720e4 | |||
| 84dee78cdb | |||
| bd9fe45728 | |||
| e9d6e93306 | |||
| a89dcfa06d | |||
| 114965806a | |||
| 2bdaf00273 |
+1
-1
@@ -1 +1 @@
|
|||||||
* @actions/artifacts-actions
|
* @artifacts-actions
|
||||||
|
|||||||
Generated
BIN
Binary file not shown.
Generated
BIN
Binary file not shown.
BIN
Binary file not shown.
Generated
BIN
Binary file not shown.
BIN
Binary file not shown.
Generated
BIN
Binary file not shown.
Generated
BIN
Binary file not shown.
Generated
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
Generated
BIN
Binary file not shown.
Generated
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
Generated
BIN
Binary file not shown.
Generated
BIN
Binary file not shown.
Generated
BIN
Binary file not shown.
BIN
Binary file not shown.
Generated
BIN
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -19,6 +19,7 @@ See ["Caching dependencies to speed up workflows"](https://help.github.com/githu
|
|||||||
path: |
|
path: |
|
||||||
~/cache
|
~/cache
|
||||||
!~/cache/exclude
|
!~/cache/exclude
|
||||||
|
**/node_modules
|
||||||
key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }}
|
key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }}
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -99,7 +100,6 @@ See [Examples](examples.md) for a list of `actions/cache` implementations for us
|
|||||||
- [OCaml/Reason - esy](./examples.md#ocamlreason---esy)
|
- [OCaml/Reason - esy](./examples.md#ocamlreason---esy)
|
||||||
- [PHP - Composer](./examples.md#php---composer)
|
- [PHP - Composer](./examples.md#php---composer)
|
||||||
- [Python - pip](./examples.md#python---pip)
|
- [Python - pip](./examples.md#python---pip)
|
||||||
- [Python - pipenv](./examples.md#python---pipenv)
|
|
||||||
- [R - renv](./examples.md#r---renv)
|
- [R - renv](./examples.md#r---renv)
|
||||||
- [Ruby - Bundler](./examples.md#ruby---bundler)
|
- [Ruby - Bundler](./examples.md#ruby---bundler)
|
||||||
- [Rust - Cargo](./examples.md#rust---cargo)
|
- [Rust - Cargo](./examples.md#rust---cargo)
|
||||||
|
|||||||
@@ -213,6 +213,39 @@ test("getInputAsArray handles empty lines correctly", () => {
|
|||||||
expect(actionUtils.getInputAsArray("foo")).toEqual(["bar", "baz"]);
|
expect(actionUtils.getInputAsArray("foo")).toEqual(["bar", "baz"]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("getInputAsArray sorts files correctly", () => {
|
||||||
|
testUtils.setInput(
|
||||||
|
"foo",
|
||||||
|
"bar\n!baz\nwaldo\nqux\nquux\ncorge\ngrault\ngarply"
|
||||||
|
);
|
||||||
|
expect(actionUtils.getInputAsArray("foo")).toEqual([
|
||||||
|
"!baz",
|
||||||
|
"bar",
|
||||||
|
"corge",
|
||||||
|
"garply",
|
||||||
|
"grault",
|
||||||
|
"quux",
|
||||||
|
"qux",
|
||||||
|
"waldo"
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("getInputAsArray removes spaces after ! at the beginning", () => {
|
||||||
|
testUtils.setInput(
|
||||||
|
"foo",
|
||||||
|
"! bar\n! baz\n! qux\n!quux\ncorge\ngrault! garply\n!\r\t waldo"
|
||||||
|
);
|
||||||
|
expect(actionUtils.getInputAsArray("foo")).toEqual([
|
||||||
|
"!bar",
|
||||||
|
"!baz",
|
||||||
|
"!quux",
|
||||||
|
"!qux",
|
||||||
|
"!waldo",
|
||||||
|
"corge",
|
||||||
|
"grault! garply"
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
||||||
test("getInputAsInt returns undefined if input not set", () => {
|
test("getInputAsInt returns undefined if input not set", () => {
|
||||||
expect(actionUtils.getInputAsInt("undefined")).toBeUndefined();
|
expect(actionUtils.getInputAsInt("undefined")).toBeUndefined();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ test("restore with no key", async () => {
|
|||||||
test("restore with too many keys should fail", async () => {
|
test("restore with too many keys should fail", async () => {
|
||||||
const path = "node_modules";
|
const path = "node_modules";
|
||||||
const key = "node-test";
|
const key = "node-test";
|
||||||
const restoreKeys = [...Array(20).keys()].map(x => x.toString());
|
const restoreKeys = [...Array(20).keys()].map(x => x.toString()).sort();
|
||||||
testUtils.setInputs({
|
testUtils.setInputs({
|
||||||
path: path,
|
path: path,
|
||||||
key,
|
key,
|
||||||
|
|||||||
Vendored
+20716
-22320
File diff suppressed because one or more lines are too long
Vendored
+20716
-22321
File diff suppressed because one or more lines are too long
+27
-47
@@ -22,7 +22,6 @@
|
|||||||
- [Multiple OSes in a workflow](#multiple-oss-in-a-workflow)
|
- [Multiple OSes in a workflow](#multiple-oss-in-a-workflow)
|
||||||
- [Using pip to get cache location](#using-pip-to-get-cache-location)
|
- [Using pip to get cache location](#using-pip-to-get-cache-location)
|
||||||
- [Using a script to get cache location](#using-a-script-to-get-cache-location)
|
- [Using a script to get cache location](#using-a-script-to-get-cache-location)
|
||||||
- [Python - pipenv](#python---pipenv)
|
|
||||||
- [R - renv](#r---renv)
|
- [R - renv](#r---renv)
|
||||||
- [Simple example](#simple-example-1)
|
- [Simple example](#simple-example-1)
|
||||||
- [Multiple OSes in a workflow](#multiple-oss-in-a-workflow-1)
|
- [Multiple OSes in a workflow](#multiple-oss-in-a-workflow-1)
|
||||||
@@ -100,9 +99,7 @@ steps:
|
|||||||
```yaml
|
```yaml
|
||||||
- uses: actions/cache@v2
|
- uses: actions/cache@v2
|
||||||
with:
|
with:
|
||||||
path: |
|
path: deps
|
||||||
deps
|
|
||||||
_build
|
|
||||||
key: ${{ runner.os }}-mix-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }}
|
key: ${{ runner.os }}-mix-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }}
|
||||||
restore-keys: |
|
restore-keys: |
|
||||||
${{ runner.os }}-mix-
|
${{ runner.os }}-mix-
|
||||||
@@ -142,7 +139,7 @@ We cache the elements of the Cabal store separately, as the entirety of `~/.caba
|
|||||||
path: |
|
path: |
|
||||||
~/.gradle/caches
|
~/.gradle/caches
|
||||||
~/.gradle/wrapper
|
~/.gradle/wrapper
|
||||||
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
|
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
|
||||||
restore-keys: |
|
restore-keys: |
|
||||||
${{ runner.os }}-gradle-
|
${{ runner.os }}-gradle-
|
||||||
```
|
```
|
||||||
@@ -197,13 +194,12 @@ If using `npm config` to retrieve the cache directory, ensure you run [actions/s
|
|||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
- name: Get npm cache directory
|
- name: Get npm cache directory
|
||||||
id: npm-cache-dir
|
id: npm-cache
|
||||||
run: |
|
run: |
|
||||||
echo "::set-output name=dir::$(npm config get cache)"
|
echo "::set-output name=dir::$(npm config get cache)"
|
||||||
- uses: actions/cache@v2
|
- uses: actions/cache@v2
|
||||||
id: npm-cache # use this to check for `cache-hit` ==> if: steps.npm-cache.outputs.cache-hit != 'true'
|
|
||||||
with:
|
with:
|
||||||
path: ${{ steps.npm-cache-dir.outputs.dir }}
|
path: ${{ steps.npm-cache.outputs.dir }}
|
||||||
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
|
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
|
||||||
restore-keys: |
|
restore-keys: |
|
||||||
${{ runner.os }}-node-
|
${{ runner.os }}-node-
|
||||||
@@ -348,31 +344,6 @@ Replace `~/.cache/pip` with the correct `path` if not using Ubuntu.
|
|||||||
${{ runner.os }}-pip-
|
${{ runner.os }}-pip-
|
||||||
```
|
```
|
||||||
|
|
||||||
### Multiple OS's in a workflow with a matrix
|
|
||||||
|
|
||||||
``` yaml
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
runs-on: ${{ matrix.os }}
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
os: [ubuntu-latest, macos-latest, windows-latest]
|
|
||||||
include:
|
|
||||||
- os: ubuntu-latest
|
|
||||||
path: ~/.cache/pip
|
|
||||||
- os: macos-latest
|
|
||||||
path: ~/Library/Caches/pip
|
|
||||||
- os: windows-latest
|
|
||||||
path: ~\AppData\Local\pip\Cache
|
|
||||||
steps:
|
|
||||||
- uses: actions/cache@v2
|
|
||||||
with:
|
|
||||||
path: ${{ matrix.path }}
|
|
||||||
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
|
|
||||||
restore-keys: |
|
|
||||||
${{ runner.os }}-pip-
|
|
||||||
```
|
|
||||||
|
|
||||||
### Using pip to get cache location
|
### Using pip to get cache location
|
||||||
|
|
||||||
> Note: This requires pip 20.1+
|
> Note: This requires pip 20.1+
|
||||||
@@ -391,15 +362,21 @@ jobs:
|
|||||||
${{ runner.os }}-pip-
|
${{ runner.os }}-pip-
|
||||||
```
|
```
|
||||||
|
|
||||||
## Python - pipenv
|
### Using a script to get cache location
|
||||||
|
|
||||||
|
> Note: This uses an internal pip API and may not always work
|
||||||
```yaml
|
```yaml
|
||||||
|
- name: Get pip cache dir
|
||||||
|
id: pip-cache
|
||||||
|
run: |
|
||||||
|
python -c "from pip._internal.locations import USER_CACHE_DIR; print('::set-output name=dir::' + USER_CACHE_DIR)"
|
||||||
|
|
||||||
- uses: actions/cache@v2
|
- uses: actions/cache@v2
|
||||||
with:
|
with:
|
||||||
path: ~/.local/share/virtualenvs
|
path: ${{ steps.pip-cache.outputs.dir }}
|
||||||
key: ${{ runner.os }}-pipenv-${{ hashFiles('Pipfile.lock') }}
|
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
|
||||||
restore-keys: |
|
restore-keys: |
|
||||||
${{ runner.os }}-pipenv-
|
${{ runner.os }}-pip-
|
||||||
```
|
```
|
||||||
|
|
||||||
## R - renv
|
## R - renv
|
||||||
@@ -453,18 +430,21 @@ Replace `~/.local/share/renv` with the correct `path` if not using Ubuntu.
|
|||||||
|
|
||||||
## Ruby - Bundler
|
## Ruby - Bundler
|
||||||
|
|
||||||
Caching gems with Bundler correctly is not trivial and just using `actions/cache`
|
```yaml
|
||||||
is [not enough](https://github.com/ruby/setup-ruby#caching-bundle-install-manually).
|
- uses: actions/cache@v2
|
||||||
|
with:
|
||||||
Instead, it is recommended to use `ruby/setup-ruby`'s
|
path: vendor/bundle
|
||||||
[`bundler-cache: true` option](https://github.com/ruby/setup-ruby#caching-bundle-install-automatically)
|
key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
|
||||||
whenever possible:
|
restore-keys: |
|
||||||
|
${{ runner.os }}-gems-
|
||||||
|
```
|
||||||
|
When dependencies are installed later in the workflow, we must specify the same path for the bundler.
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
- uses: ruby/setup-ruby@v1
|
- name: Bundle install
|
||||||
with:
|
run: |
|
||||||
ruby-version: ...
|
bundle config path vendor/bundle
|
||||||
bundler-cache: true
|
bundle install --jobs 4 --retry 3
|
||||||
```
|
```
|
||||||
|
|
||||||
## Rust - Cargo
|
## Rust - Cargo
|
||||||
|
|||||||
Generated
+181
-728
File diff suppressed because it is too large
Load Diff
+10
-10
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "cache",
|
"name": "cache",
|
||||||
"version": "2.1.5",
|
"version": "2.1.3",
|
||||||
"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,29 +23,29 @@
|
|||||||
"author": "GitHub",
|
"author": "GitHub",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/cache": "^1.0.7",
|
"@actions/cache": "^1.0.4",
|
||||||
"@actions/core": "^1.2.6",
|
"@actions/core": "^1.2.6",
|
||||||
"@actions/exec": "^1.0.1",
|
"@actions/exec": "^1.0.1",
|
||||||
"@actions/io": "^1.1.0"
|
"@actions/io": "^1.0.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/jest": "^24.0.13",
|
"@types/jest": "^24.0.13",
|
||||||
"@types/nock": "^11.1.0",
|
"@types/nock": "^11.1.0",
|
||||||
"@types/node": "^12.20.7",
|
"@types/node": "^12.0.4",
|
||||||
"@typescript-eslint/eslint-plugin": "^2.7.0",
|
"@typescript-eslint/eslint-plugin": "^2.7.0",
|
||||||
"@typescript-eslint/parser": "^2.7.0",
|
"@typescript-eslint/parser": "^2.7.0",
|
||||||
"@zeit/ncc": "^0.20.5",
|
"@zeit/ncc": "^0.20.5",
|
||||||
"eslint": "^6.6.0",
|
"eslint": "^6.6.0",
|
||||||
"eslint-config-prettier": "^6.15.0",
|
"eslint-config-prettier": "^6.5.0",
|
||||||
"eslint-plugin-import": "^2.22.1",
|
"eslint-plugin-import": "^2.18.2",
|
||||||
"eslint-plugin-jest": "^23.20.0",
|
"eslint-plugin-jest": "^23.0.3",
|
||||||
"eslint-plugin-prettier": "^3.3.1",
|
"eslint-plugin-prettier": "^3.1.1",
|
||||||
"eslint-plugin-simple-import-sort": "^5.0.2",
|
"eslint-plugin-simple-import-sort": "^5.0.2",
|
||||||
"jest": "^24.8.0",
|
"jest": "^24.8.0",
|
||||||
"jest-circus": "^24.7.1",
|
"jest-circus": "^24.7.1",
|
||||||
"nock": "^11.7.0",
|
"nock": "^11.7.0",
|
||||||
"prettier": "^1.19.1",
|
"prettier": "^1.19.1",
|
||||||
"ts-jest": "^26.5.4",
|
"ts-jest": "^24.0.2",
|
||||||
"typescript": "^3.9.9"
|
"typescript": "^3.7.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,7 +44,6 @@ async function run(): Promise<void> {
|
|||||||
await cache.saveCache(cachePaths, primaryKey, {
|
await cache.saveCache(cachePaths, primaryKey, {
|
||||||
uploadChunkSize: utils.getInputAsInt(Inputs.UploadChunkSize)
|
uploadChunkSize: utils.getInputAsInt(Inputs.UploadChunkSize)
|
||||||
});
|
});
|
||||||
core.info(`Cache saved with key: ${primaryKey}`);
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error.name === cache.ValidationError.name) {
|
if (error.name === cache.ValidationError.name) {
|
||||||
throw error;
|
throw error;
|
||||||
|
|||||||
@@ -60,8 +60,9 @@ export function getInputAsArray(
|
|||||||
return core
|
return core
|
||||||
.getInput(name, options)
|
.getInput(name, options)
|
||||||
.split("\n")
|
.split("\n")
|
||||||
.map(s => s.trim())
|
.map(s => s.replace(/^!\s+/, "!").trim())
|
||||||
.filter(x => x !== "");
|
.filter(x => x !== "")
|
||||||
|
.sort();
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getInputAsInt(
|
export function getInputAsInt(
|
||||||
|
|||||||
Reference in New Issue
Block a user