npm run format

This commit is contained in:
BSKY 2020-03-23 23:35:15 +09:00
parent 150eacd6fa
commit 1729a4d479
19 changed files with 222 additions and 206 deletions

View file

@ -5,12 +5,12 @@ on:
branches: branches:
- master - master
paths-ignore: paths-ignore:
- '**.md' - "**.md"
push: push:
branches: branches:
- master - master
paths-ignore: paths-ignore:
- '**.md' - "**.md"
jobs: jobs:
# Build and unit test # Build and unit test
@ -26,7 +26,7 @@ jobs:
- name: Setup Node.js - name: Setup Node.js
uses: actions/setup-node@v1 uses: actions/setup-node@v1
with: with:
node-version: '12.x' node-version: "12.x"
- name: Determine npm cache directory - name: Determine npm cache directory
id: npm-cache id: npm-cache
run: | run: |

2
.vscode/launch.json vendored
View file

@ -12,6 +12,6 @@
"args": ["--runInBand", "--config=${workspaceFolder}/jest.config.js"], "args": ["--runInBand", "--config=${workspaceFolder}/jest.config.js"],
"console": "integratedTerminal", "console": "integratedTerminal",
"internalConsoleOptions": "neverOpen" "internalConsoleOptions": "neverOpen"
}, }
] ]
} }

View file

@ -14,21 +14,21 @@ appearance, race, religion, or sexual identity and orientation.
Examples of behavior that contributes to creating a positive environment Examples of behavior that contributes to creating a positive environment
include: include:
* Using welcoming and inclusive language - Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences - Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism - Gracefully accepting constructive criticism
* Focusing on what is best for the community - Focusing on what is best for the community
* Showing empathy towards other community members - Showing empathy towards other community members
Examples of unacceptable behavior by participants include: Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery and unwelcome sexual attention or - The use of sexualized language or imagery and unwelcome sexual attention or
advances advances
* Trolling, insulting/derogatory comments, and personal or political attacks - Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment - Public or private harassment
* Publishing others' private information, such as a physical or electronic - Publishing others' private information, such as a physical or electronic
address, without explicit permission address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a - Other conduct which could reasonably be considered inappropriate in a
professional setting professional setting
## Our Responsibilities ## Our Responsibilities

View file

@ -11,17 +11,18 @@ See ["Caching dependencies to speed up workflows"](https://help.github.com/githu
## Usage ## Usage
### Pre-requisites ### Pre-requisites
Create a workflow `.yml` file in your repositories `.github/workflows` directory. An [example workflow](#example-workflow) is available below. For more information, reference the GitHub Help Documentation for [Creating a workflow file](https://help.github.com/en/articles/configuring-a-workflow#creating-a-workflow-file). Create a workflow `.yml` file in your repositories `.github/workflows` directory. An [example workflow](#example-workflow) is available below. For more information, reference the GitHub Help Documentation for [Creating a workflow file](https://help.github.com/en/articles/configuring-a-workflow#creating-a-workflow-file).
### Inputs ### Inputs
* `path` - A directory to store and save the cache - `path` - A directory to store and save the cache
* `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 the cache if no cache hit occurred for key
### Outputs ### Outputs
* `cache-hit` - A boolean value to indicate an exact match was found for the key - `cache-hit` - A boolean value to indicate an exact match was found for the key
> See [Skipping steps based on cache-hit](#Skipping-steps-based-on-cache-hit) for info on using this output > See [Skipping steps based on cache-hit](#Skipping-steps-based-on-cache-hit) for info on using this output
@ -88,6 +89,7 @@ A repository can have up to 5GB of caches. Once the 5GB limit is reached, older
Using the `cache-hit` output, subsequent steps (such as install or build) can be skipped when a cache hit occurs on the key. Using the `cache-hit` output, subsequent steps (such as install or build) can be skipped when a cache hit occurs on the key.
Example: Example:
```yaml ```yaml
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
@ -106,7 +108,9 @@ steps:
> Note: The `id` defined in `actions/cache` must match the `id` in the `if` statement (i.e. `steps.[ID].outputs.cache-hit`) > Note: The `id` defined in `actions/cache` must match the `id` in the `if` statement (i.e. `steps.[ID].outputs.cache-hit`)
## Contributing ## Contributing
We would love for you to contribute to `@actions/cache`, pull requests are welcome! Please see the [CONTRIBUTING.md](CONTRIBUTING.md) for more information. We would love for you to contribute to `@actions/cache`, pull requests are welcome! Please see the [CONTRIBUTING.md](CONTRIBUTING.md) for more information.
## License ## License
The scripts and documentation in this project are released under the [MIT License](LICENSE) The scripts and documentation in this project are released under the [MIT License](LICENSE)

View file

@ -51,7 +51,7 @@ test("isExactKeyMatch with empty cache entry returns false", () => {
test("isExactKeyMatch with different keys returns false", () => { test("isExactKeyMatch with different keys returns false", () => {
const key = "linux-rust"; const key = "linux-rust";
const cacheEntry: ArtifactCacheEntry = { const cacheEntry: ArtifactCacheEntry = {
cacheKey: "linux-" cacheKey: "linux-",
}; };
expect(actionUtils.isExactKeyMatch(key, cacheEntry)).toBe(false); expect(actionUtils.isExactKeyMatch(key, cacheEntry)).toBe(false);
@ -60,7 +60,7 @@ test("isExactKeyMatch with different keys returns false", () => {
test("isExactKeyMatch with different key accents returns false", () => { test("isExactKeyMatch with different key accents returns false", () => {
const key = "linux-áccent"; const key = "linux-áccent";
const cacheEntry: ArtifactCacheEntry = { const cacheEntry: ArtifactCacheEntry = {
cacheKey: "linux-accent" cacheKey: "linux-accent",
}; };
expect(actionUtils.isExactKeyMatch(key, cacheEntry)).toBe(false); expect(actionUtils.isExactKeyMatch(key, cacheEntry)).toBe(false);
@ -69,7 +69,7 @@ test("isExactKeyMatch with different key accents returns false", () => {
test("isExactKeyMatch with same key returns true", () => { test("isExactKeyMatch with same key returns true", () => {
const key = "linux-rust"; const key = "linux-rust";
const cacheEntry: ArtifactCacheEntry = { const cacheEntry: ArtifactCacheEntry = {
cacheKey: "linux-rust" cacheKey: "linux-rust",
}; };
expect(actionUtils.isExactKeyMatch(key, cacheEntry)).toBe(true); expect(actionUtils.isExactKeyMatch(key, cacheEntry)).toBe(true);
@ -78,7 +78,7 @@ test("isExactKeyMatch with same key returns true", () => {
test("isExactKeyMatch with same key and different casing returns true", () => { test("isExactKeyMatch with same key and different casing returns true", () => {
const key = "linux-rust"; const key = "linux-rust";
const cacheEntry: ArtifactCacheEntry = { const cacheEntry: ArtifactCacheEntry = {
cacheKey: "LINUX-RUST" cacheKey: "LINUX-RUST",
}; };
expect(actionUtils.isExactKeyMatch(key, cacheEntry)).toBe(true); expect(actionUtils.isExactKeyMatch(key, cacheEntry)).toBe(true);
@ -102,7 +102,7 @@ test("setOutputAndState with undefined entry to set cache-hit output", () => {
test("setOutputAndState with exact match to set cache-hit output and state", () => { test("setOutputAndState with exact match to set cache-hit output and state", () => {
const key = "linux-rust"; const key = "linux-rust";
const cacheEntry: ArtifactCacheEntry = { const cacheEntry: ArtifactCacheEntry = {
cacheKey: "linux-rust" cacheKey: "linux-rust",
}; };
const setOutputMock = jest.spyOn(core, "setOutput"); const setOutputMock = jest.spyOn(core, "setOutput");
@ -123,7 +123,7 @@ test("setOutputAndState with exact match to set cache-hit output and state", ()
test("setOutputAndState with no exact match to set cache-hit output and state", () => { test("setOutputAndState with no exact match to set cache-hit output and state", () => {
const key = "linux-rust"; const key = "linux-rust";
const cacheEntry: ArtifactCacheEntry = { const cacheEntry: ArtifactCacheEntry = {
cacheKey: "linux-rust-bb828da54c148048dd17899ba9fda624811cfb43" cacheKey: "linux-rust-bb828da54c148048dd17899ba9fda624811cfb43",
}; };
const setOutputMock = jest.spyOn(core, "setOutput"); const setOutputMock = jest.spyOn(core, "setOutput");
@ -160,7 +160,7 @@ test("getCacheState with valid state", () => {
cacheKey: "Linux-node-bb828da54c148048dd17899ba9fda624811cfb43", cacheKey: "Linux-node-bb828da54c148048dd17899ba9fda624811cfb43",
scope: "refs/heads/master", scope: "refs/heads/master",
creationTime: "2019-11-13T19:18:02+00:00", creationTime: "2019-11-13T19:18:02+00:00",
archiveLocation: "www.actionscache.test/download" archiveLocation: "www.actionscache.test/download",
}; };
const getStateMock = jest.spyOn(core, "getState"); const getStateMock = jest.spyOn(core, "getState");
getStateMock.mockImplementation(() => { getStateMock.mockImplementation(() => {

View file

@ -73,11 +73,11 @@ 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 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());
testUtils.setInputs({ testUtils.setInputs({
path: "node_modules", path: "node_modules",
key, key,
restoreKeys restoreKeys,
}); });
const failedMock = jest.spyOn(core, "setFailed"); const failedMock = jest.spyOn(core, "setFailed");
await run(); await run();
@ -90,7 +90,7 @@ test("restore with large key should fail", async () => {
const key = "foo".repeat(512); // Over the 512 character limit const key = "foo".repeat(512); // Over the 512 character limit
testUtils.setInputs({ testUtils.setInputs({
path: "node_modules", path: "node_modules",
key key,
}); });
const failedMock = jest.spyOn(core, "setFailed"); const failedMock = jest.spyOn(core, "setFailed");
await run(); await run();
@ -103,7 +103,7 @@ test("restore with invalid key should fail", async () => {
const key = "comma,comma"; const key = "comma,comma";
testUtils.setInputs({ testUtils.setInputs({
path: "node_modules", path: "node_modules",
key key,
}); });
const failedMock = jest.spyOn(core, "setFailed"); const failedMock = jest.spyOn(core, "setFailed");
await run(); await run();
@ -116,7 +116,7 @@ test("restore with no cache found", async () => {
const key = "node-test"; const key = "node-test";
testUtils.setInputs({ testUtils.setInputs({
path: "node_modules", path: "node_modules",
key key,
}); });
const infoMock = jest.spyOn(core, "info"); const infoMock = jest.spyOn(core, "info");
@ -142,7 +142,7 @@ test("restore with server error should fail", async () => {
const key = "node-test"; const key = "node-test";
testUtils.setInputs({ testUtils.setInputs({
path: "node_modules", path: "node_modules",
key key,
}); });
const logWarningMock = jest.spyOn(actionUtils, "logWarning"); const logWarningMock = jest.spyOn(actionUtils, "logWarning");
@ -175,7 +175,7 @@ test("restore with restore keys and no cache found", async () => {
testUtils.setInputs({ testUtils.setInputs({
path: "node_modules", path: "node_modules",
key, key,
restoreKeys: [restoreKey] restoreKeys: [restoreKey],
}); });
const infoMock = jest.spyOn(core, "info"); const infoMock = jest.spyOn(core, "info");
@ -201,7 +201,7 @@ test("restore with cache found", async () => {
const key = "node-test"; const key = "node-test";
testUtils.setInputs({ testUtils.setInputs({
path: "node_modules", path: "node_modules",
key key,
}); });
const infoMock = jest.spyOn(core, "info"); const infoMock = jest.spyOn(core, "info");
@ -211,7 +211,7 @@ test("restore with cache found", async () => {
const cacheEntry: ArtifactCacheEntry = { const cacheEntry: ArtifactCacheEntry = {
cacheKey: key, cacheKey: key,
scope: "refs/heads/master", scope: "refs/heads/master",
archiveLocation: "www.actionscache.test/download" archiveLocation: "www.actionscache.test/download",
}; };
const getCacheMock = jest.spyOn(cacheHttpClient, "getCacheEntry"); const getCacheMock = jest.spyOn(cacheHttpClient, "getCacheEntry");
getCacheMock.mockImplementation(() => { getCacheMock.mockImplementation(() => {
@ -269,7 +269,7 @@ test("restore with a pull request event and cache found", async () => {
const key = "node-test"; const key = "node-test";
testUtils.setInputs({ testUtils.setInputs({
path: "node_modules", path: "node_modules",
key key,
}); });
process.env[Events.Key] = Events.PullRequest; process.env[Events.Key] = Events.PullRequest;
@ -281,7 +281,7 @@ test("restore with a pull request event and cache found", async () => {
const cacheEntry: ArtifactCacheEntry = { const cacheEntry: ArtifactCacheEntry = {
cacheKey: key, cacheKey: key,
scope: "refs/heads/master", scope: "refs/heads/master",
archiveLocation: "www.actionscache.test/download" archiveLocation: "www.actionscache.test/download",
}; };
const getCacheMock = jest.spyOn(cacheHttpClient, "getCacheEntry"); const getCacheMock = jest.spyOn(cacheHttpClient, "getCacheEntry");
getCacheMock.mockImplementation(() => { getCacheMock.mockImplementation(() => {
@ -338,7 +338,7 @@ test("restore with cache found for restore key", async () => {
testUtils.setInputs({ testUtils.setInputs({
path: "node_modules", path: "node_modules",
key, key,
restoreKeys: [restoreKey] restoreKeys: [restoreKey],
}); });
const infoMock = jest.spyOn(core, "info"); const infoMock = jest.spyOn(core, "info");
@ -348,7 +348,7 @@ test("restore with cache found for restore key", async () => {
const cacheEntry: ArtifactCacheEntry = { const cacheEntry: ArtifactCacheEntry = {
cacheKey: restoreKey, cacheKey: restoreKey,
scope: "refs/heads/master", scope: "refs/heads/master",
archiveLocation: "www.actionscache.test/download" archiveLocation: "www.actionscache.test/download",
}; };
const getCacheMock = jest.spyOn(cacheHttpClient, "getCacheEntry"); const getCacheMock = jest.spyOn(cacheHttpClient, "getCacheEntry");
getCacheMock.mockImplementation(() => { getCacheMock.mockImplementation(() => {

View file

@ -42,8 +42,8 @@ beforeAll(() => {
}); });
jest.spyOn(actionUtils, "resolvePaths").mockImplementation( jest.spyOn(actionUtils, "resolvePaths").mockImplementation(
async filePaths => { async (filePaths) => {
return filePaths.map(x => path.resolve(x)); return filePaths.map((x) => path.resolve(x));
} }
); );
@ -81,7 +81,7 @@ test("save with no primary key in state outputs warning", async () => {
cacheKey: "Linux-node-bb828da54c148048dd17899ba9fda624811cfb43", cacheKey: "Linux-node-bb828da54c148048dd17899ba9fda624811cfb43",
scope: "refs/heads/master", scope: "refs/heads/master",
creationTime: "2019-11-13T19:18:02+00:00", creationTime: "2019-11-13T19:18:02+00:00",
archiveLocation: "www.actionscache.test/download" archiveLocation: "www.actionscache.test/download",
}; };
jest.spyOn(core, "getState") jest.spyOn(core, "getState")
@ -112,7 +112,7 @@ test("save with exact match returns early", async () => {
cacheKey: primaryKey, cacheKey: primaryKey,
scope: "refs/heads/master", scope: "refs/heads/master",
creationTime: "2019-11-13T19:18:02+00:00", creationTime: "2019-11-13T19:18:02+00:00",
archiveLocation: "www.actionscache.test/download" archiveLocation: "www.actionscache.test/download",
}; };
jest.spyOn(core, "getState") jest.spyOn(core, "getState")
@ -147,7 +147,7 @@ test("save with missing input outputs warning", async () => {
cacheKey: "Linux-node-", cacheKey: "Linux-node-",
scope: "refs/heads/master", scope: "refs/heads/master",
creationTime: "2019-11-13T19:18:02+00:00", creationTime: "2019-11-13T19:18:02+00:00",
archiveLocation: "www.actionscache.test/download" archiveLocation: "www.actionscache.test/download",
}; };
jest.spyOn(core, "getState") jest.spyOn(core, "getState")
@ -178,7 +178,7 @@ test("save with large cache outputs warning", async () => {
cacheKey: "Linux-node-", cacheKey: "Linux-node-",
scope: "refs/heads/master", scope: "refs/heads/master",
creationTime: "2019-11-13T19:18:02+00:00", creationTime: "2019-11-13T19:18:02+00:00",
archiveLocation: "www.actionscache.test/download" archiveLocation: "www.actionscache.test/download",
}; };
jest.spyOn(core, "getState") jest.spyOn(core, "getState")
@ -227,7 +227,7 @@ test("save with reserve cache failure outputs warning", async () => {
cacheKey: "Linux-node-", cacheKey: "Linux-node-",
scope: "refs/heads/master", scope: "refs/heads/master",
creationTime: "2019-11-13T19:18:02+00:00", creationTime: "2019-11-13T19:18:02+00:00",
archiveLocation: "www.actionscache.test/download" archiveLocation: "www.actionscache.test/download",
}; };
jest.spyOn(core, "getState") jest.spyOn(core, "getState")
@ -277,7 +277,7 @@ test("save with server error outputs warning", async () => {
cacheKey: "Linux-node-", cacheKey: "Linux-node-",
scope: "refs/heads/master", scope: "refs/heads/master",
creationTime: "2019-11-13T19:18:02+00:00", creationTime: "2019-11-13T19:18:02+00:00",
archiveLocation: "www.actionscache.test/download" archiveLocation: "www.actionscache.test/download",
}; };
jest.spyOn(core, "getState") jest.spyOn(core, "getState")
@ -337,7 +337,7 @@ test("save with valid inputs uploads a cache", async () => {
cacheKey: "Linux-node-", cacheKey: "Linux-node-",
scope: "refs/heads/master", scope: "refs/heads/master",
creationTime: "2019-11-13T19:18:02+00:00", creationTime: "2019-11-13T19:18:02+00:00",
archiveLocation: "www.actionscache.test/download" archiveLocation: "www.actionscache.test/download",
}; };
jest.spyOn(core, "getState") jest.spyOn(core, "getState")

View file

@ -14,7 +14,7 @@ function getTempDir(): string {
} }
beforeAll(async () => { beforeAll(async () => {
jest.spyOn(io, "which").mockImplementation(tool => { jest.spyOn(io, "which").mockImplementation((tool) => {
return Promise.resolve(tool); return Promise.resolve(tool);
}); });
@ -76,10 +76,10 @@ test("create tar", async () => {
"-C", "-C",
workspace, workspace,
"--files-from", "--files-from",
"manifest.txt" "manifest.txt",
], ],
{ {
cwd: archiveFolder cwd: archiveFolder,
} }
); );
}); });

View file

@ -1,24 +1,24 @@
name: 'Cache' name: "Cache"
description: 'Cache artifacts like dependencies and build outputs to improve workflow execution time' description: "Cache artifacts like dependencies and build outputs to improve workflow execution time"
author: 'GitHub' author: "GitHub"
inputs: inputs:
path: path:
description: 'A directory to store and save the cache' description: "A directory to store and save the cache"
required: true required: true
key: key:
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 the cache if no cache hit occurred for key"
required: false required: false
outputs: outputs:
cache-hit: cache-hit:
description: 'A boolean value to indicate an exact match was found for the primary key' description: "A boolean value to indicate an exact match was found for the primary key"
runs: runs:
using: 'node12' using: "node12"
main: 'dist/restore/index.js' main: "dist/restore/index.js"
post: 'dist/save/index.js' post: "dist/save/index.js"
post-if: 'success()' post-if: "success()"
branding: branding:
icon: 'archive' icon: "archive"
color: 'gray-dark' color: "gray-dark"

View file

@ -30,6 +30,7 @@
- [Swift - Swift Package Manager](#swift---swift-package-manager) - [Swift - Swift Package Manager](#swift---swift-package-manager)
## C# - NuGet ## C# - NuGet
Using [NuGet lock files](https://docs.microsoft.com/nuget/consume-packages/package-references-in-project-files#locking-dependencies): Using [NuGet lock files](https://docs.microsoft.com/nuget/consume-packages/package-references-in-project-files#locking-dependencies):
```yaml ```yaml
@ -43,7 +44,9 @@ Using [NuGet lock files](https://docs.microsoft.com/nuget/consume-packages/packa
Depending on the environment, huge packages might be pre-installed in the global cache folder. Depending on the environment, huge packages might be pre-installed in the global cache folder.
If you do not want to include them, consider to move the cache folder like below. If you do not want to include them, consider to move the cache folder like below.
> Note: This workflow does not work for projects that require files to be placed in user profile package folder > Note: This workflow does not work for projects that require files to be placed in user profile package folder
```yaml ```yaml
env: env:
NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages
@ -57,6 +60,7 @@ steps:
``` ```
## Elixir - Mix ## Elixir - Mix
```yaml ```yaml
- uses: actions/cache@v1 - uses: actions/cache@v1
with: with:
@ -169,6 +173,7 @@ For npm, cache files are stored in `~/.npm` on Posix, or `%AppData%/npm-cache` o
``` ```
## Node - Yarn ## Node - Yarn
The yarn cache directory will depend on your operating system and version of `yarn`. See https://yarnpkg.com/lang/en/docs/cli/cache/ for more info. The yarn cache directory will depend on your operating system and version of `yarn`. See https://yarnpkg.com/lang/en/docs/cli/cache/ for more info.
```yaml ```yaml
@ -198,7 +203,9 @@ The yarn cache directory will depend on your operating system and version of `ya
``` ```
## OCaml/Reason - esy ## OCaml/Reason - esy
Esy allows you to export built dependencies and import pre-built dependencies. Esy allows you to export built dependencies and import pre-built dependencies.
```yaml ```yaml
- name: Restore Cache - name: Restore Cache
id: restore-cache id: restore-cache
@ -224,7 +231,6 @@ Esy allows you to export built dependencies and import pre-built dependencies.
if: steps.restore-cache.outputs.cache-hit != 'true' if: steps.restore-cache.outputs.cache-hit != 'true'
``` ```
## PHP - Composer ## PHP - Composer
```yaml ```yaml
@ -245,11 +251,13 @@ Esy allows you to export built dependencies and import pre-built dependencies.
For pip, the cache directory will vary by OS. See https://pip.pypa.io/en/stable/reference/pip_install/#caching For pip, the cache directory will vary by OS. See https://pip.pypa.io/en/stable/reference/pip_install/#caching
Locations: Locations:
- Ubuntu: `~/.cache/pip` - Ubuntu: `~/.cache/pip`
- Windows: `~\AppData\Local\pip\Cache` - Windows: `~\AppData\Local\pip\Cache`
- macOS: `~/Library/Caches/pip` - macOS: `~/Library/Caches/pip`
### Simple example ### Simple example
```yaml ```yaml
- uses: actions/cache@v1 - uses: actions/cache@v1
with: with:
@ -292,6 +300,7 @@ Replace `~/.cache/pip` with the correct `path` if not using Ubuntu.
### Using a script to get cache location ### Using a script to get cache location
> Note: This uses an internal pip API and may not always work > Note: This uses an internal pip API and may not always work
```yaml ```yaml
- name: Get pip cache - name: Get pip cache
id: pip-cache id: pip-cache
@ -311,11 +320,13 @@ Replace `~/.cache/pip` with the correct `path` if not using Ubuntu.
For renv, the cache directory will vary by OS. Look at https://rstudio.github.io/renv/articles/renv.html#cache For renv, the cache directory will vary by OS. Look at https://rstudio.github.io/renv/articles/renv.html#cache
Locations: Locations:
- Ubuntu: `~/.local/share/renv` - Ubuntu: `~/.local/share/renv`
- macOS: `~/Library/Application Support/renv` - macOS: `~/Library/Application Support/renv`
- Windows: `%LOCALAPPDATA%/renv` - Windows: `%LOCALAPPDATA%/renv`
### Simple example ### Simple example
```yaml ```yaml
- uses: actions/cache@v1 - uses: actions/cache@v1
with: with:
@ -365,6 +376,7 @@ Replace `~/.local/share/renv` with the correct `path` if not using Ubuntu.
restore-keys: | restore-keys: |
${{ runner.os }}-gems- ${{ runner.os }}-gems-
``` ```
When dependencies are installed later in the workflow, we must specify the same path for the bundler. When dependencies are installed later in the workflow, we must specify the same path for the bundler.
```yaml ```yaml

View file

@ -7,9 +7,9 @@ module.exports = {
testMatch: ["**/*.test.ts"], testMatch: ["**/*.test.ts"],
testRunner: "jest-circus/runner", testRunner: "jest-circus/runner",
transform: { transform: {
"^.+\\.ts$": "ts-jest" "^.+\\.ts$": "ts-jest",
}, },
verbose: true verbose: true,
}; };
const processStdoutWrite = process.stdout.write.bind(process.stdout); const processStdoutWrite = process.stdout.write.bind(process.stdout);

View file

@ -4,7 +4,7 @@ import { BearerCredentialHandler } from "@actions/http-client/auth";
import { import {
IHttpClientResponse, IHttpClientResponse,
IRequestOptions, IRequestOptions,
ITypedResponse ITypedResponse,
} from "@actions/http-client/interfaces"; } from "@actions/http-client/interfaces";
import * as crypto from "crypto"; import * as crypto from "crypto";
import * as fs from "fs"; import * as fs from "fs";
@ -14,7 +14,7 @@ import {
ArtifactCacheEntry, ArtifactCacheEntry,
CommitCacheRequest, CommitCacheRequest,
ReserveCacheRequest, ReserveCacheRequest,
ReserveCacheResponse ReserveCacheResponse,
} from "./contracts"; } from "./contracts";
import * as utils from "./utils/actionUtils"; import * as utils from "./utils/actionUtils";
@ -34,7 +34,7 @@ function isRetryableStatusCode(statusCode?: number): boolean {
const retryableStatusCodes = [ const retryableStatusCodes = [
HttpCodes.BadGateway, HttpCodes.BadGateway,
HttpCodes.ServiceUnavailable, HttpCodes.ServiceUnavailable,
HttpCodes.GatewayTimeout HttpCodes.GatewayTimeout,
]; ];
return retryableStatusCodes.includes(statusCode); return retryableStatusCodes.includes(statusCode);
} }
@ -64,8 +64,8 @@ function createAcceptHeader(type: string, apiVersion: string): string {
function getRequestOptions(): IRequestOptions { function getRequestOptions(): IRequestOptions {
const requestOptions: IRequestOptions = { const requestOptions: IRequestOptions = {
headers: { headers: {
Accept: createAcceptHeader("application/json", "6.0-preview.1") Accept: createAcceptHeader("application/json", "6.0-preview.1"),
} },
}; };
return requestOptions; return requestOptions;
@ -86,7 +86,7 @@ export function getCacheVersion(): string {
// Add salt to cache version to support breaking changes in cache entry // Add salt to cache version to support breaking changes in cache entry
const components = [ const components = [
core.getInput(Inputs.Path, { required: true }), core.getInput(Inputs.Path, { required: true }),
versionSalt versionSalt,
]; ];
return crypto return crypto
@ -130,7 +130,7 @@ async function pipeResponseToStream(
response: IHttpClientResponse, response: IHttpClientResponse,
stream: NodeJS.WritableStream stream: NodeJS.WritableStream
): Promise<void> { ): Promise<void> {
return new Promise(resolve => { return new Promise((resolve) => {
response.message.pipe(stream).on("close", () => { response.message.pipe(stream).on("close", () => {
resolve(); resolve();
}); });
@ -154,7 +154,7 @@ export async function reserveCache(key: string): Promise<number> {
const reserveCacheRequest: ReserveCacheRequest = { const reserveCacheRequest: ReserveCacheRequest = {
key, key,
version version,
}; };
const response = await httpClient.postJson<ReserveCacheResponse>( const response = await httpClient.postJson<ReserveCacheResponse>(
getCacheApiUrl("caches"), getCacheApiUrl("caches"),
@ -180,16 +180,16 @@ async function uploadChunk(
end: number end: number
): Promise<void> { ): Promise<void> {
core.debug( core.debug(
`Uploading chunk of size ${end - `Uploading chunk of size ${
start + end - start + 1
1} bytes at offset ${start} with content range: ${getContentRange( } bytes at offset ${start} with content range: ${getContentRange(
start, start,
end end
)}` )}`
); );
const additionalHeaders = { const additionalHeaders = {
"Content-Type": "application/octet-stream", "Content-Type": "application/octet-stream",
"Content-Range": getContentRange(start, end) "Content-Range": getContentRange(start, end),
}; };
const uploadChunkRequest = async (): Promise<IHttpClientResponse> => { const uploadChunkRequest = async (): Promise<IHttpClientResponse> => {
@ -263,7 +263,7 @@ async function uploadFile(
fd, fd,
start, start,
end, end,
autoClose: false autoClose: false,
}); });
await uploadChunk( await uploadChunk(

View file

@ -1,22 +1,22 @@
export enum Inputs { export enum Inputs {
Key = "key", Key = "key",
Path = "path", Path = "path",
RestoreKeys = "restore-keys" RestoreKeys = "restore-keys",
} }
export enum Outputs { export enum Outputs {
CacheHit = "cache-hit" CacheHit = "cache-hit",
} }
export enum State { export enum State {
CacheKey = "CACHE_KEY", CacheKey = "CACHE_KEY",
CacheResult = "CACHE_RESULT" CacheResult = "CACHE_RESULT",
} }
export enum Events { export enum Events {
Key = "GITHUB_EVENT_NAME", Key = "GITHUB_EVENT_NAME",
Push = "push", Push = "push",
PullRequest = "pull_request" PullRequest = "pull_request",
} }
export const CacheFilename = "cache.tgz"; export const CacheFilename = "cache.tgz";

View file

@ -26,7 +26,7 @@ async function run(): Promise<void> {
const restoreKeys = core const restoreKeys = core
.getInput(Inputs.RestoreKeys) .getInput(Inputs.RestoreKeys)
.split("\n") .split("\n")
.filter(x => x !== ""); .filter((x) => x !== "");
const keys = [primaryKey, ...restoreKeys]; const keys = [primaryKey, ...restoreKeys];
core.debug("Resolved Keys:"); core.debug("Resolved Keys:");

View file

@ -48,7 +48,7 @@ async function run(): Promise<void> {
core core
.getInput(Inputs.Path, { required: true }) .getInput(Inputs.Path, { required: true })
.split("\n") .split("\n")
.filter(x => x !== "") .filter((x) => x !== "")
); );
core.debug("Cache Paths:"); core.debug("Cache Paths:");

View file

@ -62,7 +62,7 @@ export async function createTar(
"-C", "-C",
workingDirectory, workingDirectory,
"--files-from", "--files-from",
manifestFilename manifestFilename,
]; ];
await execTar(args, archiveFolder); await execTar(args, archiveFolder);
} }

View file

@ -47,7 +47,7 @@ export function isExactKeyMatch(
cacheResult && cacheResult &&
cacheResult.cacheKey && cacheResult.cacheKey &&
cacheResult.cacheKey.localeCompare(key, undefined, { cacheResult.cacheKey.localeCompare(key, undefined, {
sensitivity: "accent" sensitivity: "accent",
}) === 0 }) === 0
); );
} }
@ -88,7 +88,7 @@ export async function resolvePaths(patterns: string[]): Promise<string[]> {
const paths: string[] = []; const paths: string[] = [];
const workspace = process.env["GITHUB_WORKSPACE"] ?? process.cwd(); const workspace = process.env["GITHUB_WORKSPACE"] ?? process.cwd();
const globber = await glob.create(patterns.join("\n"), { const globber = await glob.create(patterns.join("\n"), {
implicitDescendants: false implicitDescendants: false,
}); });
for await (const file of globber.globGenerator()) { for await (const file of globber.globGenerator()) {

View file

@ -2,8 +2,8 @@
"compilerOptions": { "compilerOptions": {
/* Basic Options */ /* Basic Options */
// "incremental": true, /* Enable incremental compilation */ // "incremental": true, /* Enable incremental compilation */
"target": "es6", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */ "target": "es6" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */,
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */ "module": "commonjs" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */,
// "allowJs": true, /* Allow javascript files to be compiled. */ // "allowJs": true, /* Allow javascript files to be compiled. */
// "checkJs": true, /* Report errors in .js files. */ // "checkJs": true, /* Report errors in .js files. */
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
@ -11,8 +11,8 @@
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */ // "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
// "sourceMap": true, /* Generates corresponding '.map' file. */ // "sourceMap": true, /* Generates corresponding '.map' file. */
// "outFile": "./", /* Concatenate and emit output to single file. */ // "outFile": "./", /* Concatenate and emit output to single file. */
"outDir": "./lib", /* Redirect output structure to the directory. */ "outDir": "./lib" /* Redirect output structure to the directory. */,
"rootDir": "./src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ "rootDir": "./src" /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */,
// "composite": true, /* Enable project compilation */ // "composite": true, /* Enable project compilation */
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */ // "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
// "removeComments": true, /* Do not emit comments to output. */ // "removeComments": true, /* Do not emit comments to output. */
@ -22,8 +22,8 @@
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */ // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
/* Strict Type-Checking Options */ /* Strict Type-Checking Options */
"strict": true, /* Enable all strict type-checking options. */ "strict": true /* Enable all strict type-checking options. */,
"noImplicitAny": false, /* Raise error on expressions and declarations with an implied 'any' type. */ "noImplicitAny": false /* Raise error on expressions and declarations with an implied 'any' type. */,
// "strictNullChecks": true, /* Enable strict null checks. */ // "strictNullChecks": true, /* Enable strict null checks. */
// "strictFunctionTypes": true, /* Enable strict checking of function types. */ // "strictFunctionTypes": true, /* Enable strict checking of function types. */
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */ // "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */