mirror of
https://code.forgejo.org/actions/cache.git
synced 2025-04-16 16:01:22 +02:00
npm run format
This commit is contained in:
parent
150eacd6fa
commit
1729a4d479
19 changed files with 222 additions and 206 deletions
6
.github/workflows/workflow.yml
vendored
6
.github/workflows/workflow.yml
vendored
|
@ -5,12 +5,12 @@ on:
|
|||
branches:
|
||||
- master
|
||||
paths-ignore:
|
||||
- '**.md'
|
||||
- "**.md"
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
paths-ignore:
|
||||
- '**.md'
|
||||
- "**.md"
|
||||
|
||||
jobs:
|
||||
# Build and unit test
|
||||
|
@ -26,7 +26,7 @@ jobs:
|
|||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: '12.x'
|
||||
node-version: "12.x"
|
||||
- name: Determine npm cache directory
|
||||
id: npm-cache
|
||||
run: |
|
||||
|
|
2
.vscode/launch.json
vendored
2
.vscode/launch.json
vendored
|
@ -12,6 +12,6 @@
|
|||
"args": ["--runInBand", "--config=${workspaceFolder}/jest.config.js"],
|
||||
"console": "integratedTerminal",
|
||||
"internalConsoleOptions": "neverOpen"
|
||||
},
|
||||
}
|
||||
]
|
||||
}
|
|
@ -14,21 +14,21 @@ appearance, race, religion, or sexual identity and orientation.
|
|||
Examples of behavior that contributes to creating a positive environment
|
||||
include:
|
||||
|
||||
* Using welcoming and inclusive language
|
||||
* Being respectful of differing viewpoints and experiences
|
||||
* Gracefully accepting constructive criticism
|
||||
* Focusing on what is best for the community
|
||||
* Showing empathy towards other community members
|
||||
- Using welcoming and inclusive language
|
||||
- Being respectful of differing viewpoints and experiences
|
||||
- Gracefully accepting constructive criticism
|
||||
- Focusing on what is best for the community
|
||||
- Showing empathy towards other community members
|
||||
|
||||
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
|
||||
* Trolling, insulting/derogatory comments, and personal or political attacks
|
||||
* Public or private harassment
|
||||
* Publishing others' private information, such as a physical or electronic
|
||||
- Trolling, insulting/derogatory comments, and personal or political attacks
|
||||
- Public or private harassment
|
||||
- Publishing others' private information, such as a physical or electronic
|
||||
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
|
||||
|
||||
## Our Responsibilities
|
||||
|
|
12
README.md
12
README.md
|
@ -11,17 +11,18 @@ See ["Caching dependencies to speed up workflows"](https://help.github.com/githu
|
|||
## Usage
|
||||
|
||||
### 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).
|
||||
|
||||
### Inputs
|
||||
|
||||
* `path` - A directory to store and save 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
|
||||
- `path` - A directory to store and save 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
|
||||
|
||||
### 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
|
||||
|
||||
|
@ -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.
|
||||
|
||||
Example:
|
||||
|
||||
```yaml
|
||||
steps:
|
||||
- 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`)
|
||||
|
||||
## 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.
|
||||
|
||||
## License
|
||||
|
||||
The scripts and documentation in this project are released under the [MIT License](LICENSE)
|
||||
|
|
|
@ -51,7 +51,7 @@ test("isExactKeyMatch with empty cache entry returns false", () => {
|
|||
test("isExactKeyMatch with different keys returns false", () => {
|
||||
const key = "linux-rust";
|
||||
const cacheEntry: ArtifactCacheEntry = {
|
||||
cacheKey: "linux-"
|
||||
cacheKey: "linux-",
|
||||
};
|
||||
|
||||
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", () => {
|
||||
const key = "linux-áccent";
|
||||
const cacheEntry: ArtifactCacheEntry = {
|
||||
cacheKey: "linux-accent"
|
||||
cacheKey: "linux-accent",
|
||||
};
|
||||
|
||||
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", () => {
|
||||
const key = "linux-rust";
|
||||
const cacheEntry: ArtifactCacheEntry = {
|
||||
cacheKey: "linux-rust"
|
||||
cacheKey: "linux-rust",
|
||||
};
|
||||
|
||||
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", () => {
|
||||
const key = "linux-rust";
|
||||
const cacheEntry: ArtifactCacheEntry = {
|
||||
cacheKey: "LINUX-RUST"
|
||||
cacheKey: "LINUX-RUST",
|
||||
};
|
||||
|
||||
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", () => {
|
||||
const key = "linux-rust";
|
||||
const cacheEntry: ArtifactCacheEntry = {
|
||||
cacheKey: "linux-rust"
|
||||
cacheKey: "linux-rust",
|
||||
};
|
||||
|
||||
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", () => {
|
||||
const key = "linux-rust";
|
||||
const cacheEntry: ArtifactCacheEntry = {
|
||||
cacheKey: "linux-rust-bb828da54c148048dd17899ba9fda624811cfb43"
|
||||
cacheKey: "linux-rust-bb828da54c148048dd17899ba9fda624811cfb43",
|
||||
};
|
||||
|
||||
const setOutputMock = jest.spyOn(core, "setOutput");
|
||||
|
@ -160,7 +160,7 @@ test("getCacheState with valid state", () => {
|
|||
cacheKey: "Linux-node-bb828da54c148048dd17899ba9fda624811cfb43",
|
||||
scope: "refs/heads/master",
|
||||
creationTime: "2019-11-13T19:18:02+00:00",
|
||||
archiveLocation: "www.actionscache.test/download"
|
||||
archiveLocation: "www.actionscache.test/download",
|
||||
};
|
||||
const getStateMock = jest.spyOn(core, "getState");
|
||||
getStateMock.mockImplementation(() => {
|
||||
|
|
|
@ -73,11 +73,11 @@ test("restore with no key", async () => {
|
|||
|
||||
test("restore with too many keys should fail", async () => {
|
||||
const key = "node-test";
|
||||
const restoreKeys = [...Array(20).keys()].map(x => x.toString());
|
||||
const restoreKeys = [...Array(20).keys()].map((x) => x.toString());
|
||||
testUtils.setInputs({
|
||||
path: "node_modules",
|
||||
key,
|
||||
restoreKeys
|
||||
restoreKeys,
|
||||
});
|
||||
const failedMock = jest.spyOn(core, "setFailed");
|
||||
await run();
|
||||
|
@ -90,7 +90,7 @@ test("restore with large key should fail", async () => {
|
|||
const key = "foo".repeat(512); // Over the 512 character limit
|
||||
testUtils.setInputs({
|
||||
path: "node_modules",
|
||||
key
|
||||
key,
|
||||
});
|
||||
const failedMock = jest.spyOn(core, "setFailed");
|
||||
await run();
|
||||
|
@ -103,7 +103,7 @@ test("restore with invalid key should fail", async () => {
|
|||
const key = "comma,comma";
|
||||
testUtils.setInputs({
|
||||
path: "node_modules",
|
||||
key
|
||||
key,
|
||||
});
|
||||
const failedMock = jest.spyOn(core, "setFailed");
|
||||
await run();
|
||||
|
@ -116,7 +116,7 @@ test("restore with no cache found", async () => {
|
|||
const key = "node-test";
|
||||
testUtils.setInputs({
|
||||
path: "node_modules",
|
||||
key
|
||||
key,
|
||||
});
|
||||
|
||||
const infoMock = jest.spyOn(core, "info");
|
||||
|
@ -142,7 +142,7 @@ test("restore with server error should fail", async () => {
|
|||
const key = "node-test";
|
||||
testUtils.setInputs({
|
||||
path: "node_modules",
|
||||
key
|
||||
key,
|
||||
});
|
||||
|
||||
const logWarningMock = jest.spyOn(actionUtils, "logWarning");
|
||||
|
@ -175,7 +175,7 @@ test("restore with restore keys and no cache found", async () => {
|
|||
testUtils.setInputs({
|
||||
path: "node_modules",
|
||||
key,
|
||||
restoreKeys: [restoreKey]
|
||||
restoreKeys: [restoreKey],
|
||||
});
|
||||
|
||||
const infoMock = jest.spyOn(core, "info");
|
||||
|
@ -201,7 +201,7 @@ test("restore with cache found", async () => {
|
|||
const key = "node-test";
|
||||
testUtils.setInputs({
|
||||
path: "node_modules",
|
||||
key
|
||||
key,
|
||||
});
|
||||
|
||||
const infoMock = jest.spyOn(core, "info");
|
||||
|
@ -211,7 +211,7 @@ test("restore with cache found", async () => {
|
|||
const cacheEntry: ArtifactCacheEntry = {
|
||||
cacheKey: key,
|
||||
scope: "refs/heads/master",
|
||||
archiveLocation: "www.actionscache.test/download"
|
||||
archiveLocation: "www.actionscache.test/download",
|
||||
};
|
||||
const getCacheMock = jest.spyOn(cacheHttpClient, "getCacheEntry");
|
||||
getCacheMock.mockImplementation(() => {
|
||||
|
@ -269,7 +269,7 @@ test("restore with a pull request event and cache found", async () => {
|
|||
const key = "node-test";
|
||||
testUtils.setInputs({
|
||||
path: "node_modules",
|
||||
key
|
||||
key,
|
||||
});
|
||||
|
||||
process.env[Events.Key] = Events.PullRequest;
|
||||
|
@ -281,7 +281,7 @@ test("restore with a pull request event and cache found", async () => {
|
|||
const cacheEntry: ArtifactCacheEntry = {
|
||||
cacheKey: key,
|
||||
scope: "refs/heads/master",
|
||||
archiveLocation: "www.actionscache.test/download"
|
||||
archiveLocation: "www.actionscache.test/download",
|
||||
};
|
||||
const getCacheMock = jest.spyOn(cacheHttpClient, "getCacheEntry");
|
||||
getCacheMock.mockImplementation(() => {
|
||||
|
@ -338,7 +338,7 @@ test("restore with cache found for restore key", async () => {
|
|||
testUtils.setInputs({
|
||||
path: "node_modules",
|
||||
key,
|
||||
restoreKeys: [restoreKey]
|
||||
restoreKeys: [restoreKey],
|
||||
});
|
||||
|
||||
const infoMock = jest.spyOn(core, "info");
|
||||
|
@ -348,7 +348,7 @@ test("restore with cache found for restore key", async () => {
|
|||
const cacheEntry: ArtifactCacheEntry = {
|
||||
cacheKey: restoreKey,
|
||||
scope: "refs/heads/master",
|
||||
archiveLocation: "www.actionscache.test/download"
|
||||
archiveLocation: "www.actionscache.test/download",
|
||||
};
|
||||
const getCacheMock = jest.spyOn(cacheHttpClient, "getCacheEntry");
|
||||
getCacheMock.mockImplementation(() => {
|
||||
|
|
|
@ -42,8 +42,8 @@ beforeAll(() => {
|
|||
});
|
||||
|
||||
jest.spyOn(actionUtils, "resolvePaths").mockImplementation(
|
||||
async filePaths => {
|
||||
return filePaths.map(x => path.resolve(x));
|
||||
async (filePaths) => {
|
||||
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",
|
||||
scope: "refs/heads/master",
|
||||
creationTime: "2019-11-13T19:18:02+00:00",
|
||||
archiveLocation: "www.actionscache.test/download"
|
||||
archiveLocation: "www.actionscache.test/download",
|
||||
};
|
||||
|
||||
jest.spyOn(core, "getState")
|
||||
|
@ -112,7 +112,7 @@ test("save with exact match returns early", async () => {
|
|||
cacheKey: primaryKey,
|
||||
scope: "refs/heads/master",
|
||||
creationTime: "2019-11-13T19:18:02+00:00",
|
||||
archiveLocation: "www.actionscache.test/download"
|
||||
archiveLocation: "www.actionscache.test/download",
|
||||
};
|
||||
|
||||
jest.spyOn(core, "getState")
|
||||
|
@ -147,7 +147,7 @@ test("save with missing input outputs warning", async () => {
|
|||
cacheKey: "Linux-node-",
|
||||
scope: "refs/heads/master",
|
||||
creationTime: "2019-11-13T19:18:02+00:00",
|
||||
archiveLocation: "www.actionscache.test/download"
|
||||
archiveLocation: "www.actionscache.test/download",
|
||||
};
|
||||
|
||||
jest.spyOn(core, "getState")
|
||||
|
@ -178,7 +178,7 @@ test("save with large cache outputs warning", async () => {
|
|||
cacheKey: "Linux-node-",
|
||||
scope: "refs/heads/master",
|
||||
creationTime: "2019-11-13T19:18:02+00:00",
|
||||
archiveLocation: "www.actionscache.test/download"
|
||||
archiveLocation: "www.actionscache.test/download",
|
||||
};
|
||||
|
||||
jest.spyOn(core, "getState")
|
||||
|
@ -227,7 +227,7 @@ test("save with reserve cache failure outputs warning", async () => {
|
|||
cacheKey: "Linux-node-",
|
||||
scope: "refs/heads/master",
|
||||
creationTime: "2019-11-13T19:18:02+00:00",
|
||||
archiveLocation: "www.actionscache.test/download"
|
||||
archiveLocation: "www.actionscache.test/download",
|
||||
};
|
||||
|
||||
jest.spyOn(core, "getState")
|
||||
|
@ -277,7 +277,7 @@ test("save with server error outputs warning", async () => {
|
|||
cacheKey: "Linux-node-",
|
||||
scope: "refs/heads/master",
|
||||
creationTime: "2019-11-13T19:18:02+00:00",
|
||||
archiveLocation: "www.actionscache.test/download"
|
||||
archiveLocation: "www.actionscache.test/download",
|
||||
};
|
||||
|
||||
jest.spyOn(core, "getState")
|
||||
|
@ -337,7 +337,7 @@ test("save with valid inputs uploads a cache", async () => {
|
|||
cacheKey: "Linux-node-",
|
||||
scope: "refs/heads/master",
|
||||
creationTime: "2019-11-13T19:18:02+00:00",
|
||||
archiveLocation: "www.actionscache.test/download"
|
||||
archiveLocation: "www.actionscache.test/download",
|
||||
};
|
||||
|
||||
jest.spyOn(core, "getState")
|
||||
|
|
|
@ -14,7 +14,7 @@ function getTempDir(): string {
|
|||
}
|
||||
|
||||
beforeAll(async () => {
|
||||
jest.spyOn(io, "which").mockImplementation(tool => {
|
||||
jest.spyOn(io, "which").mockImplementation((tool) => {
|
||||
return Promise.resolve(tool);
|
||||
});
|
||||
|
||||
|
@ -76,10 +76,10 @@ test("create tar", async () => {
|
|||
"-C",
|
||||
workspace,
|
||||
"--files-from",
|
||||
"manifest.txt"
|
||||
"manifest.txt",
|
||||
],
|
||||
{
|
||||
cwd: archiveFolder
|
||||
cwd: archiveFolder,
|
||||
}
|
||||
);
|
||||
});
|
||||
|
|
26
action.yml
26
action.yml
|
@ -1,24 +1,24 @@
|
|||
name: 'Cache'
|
||||
description: 'Cache artifacts like dependencies and build outputs to improve workflow execution time'
|
||||
author: 'GitHub'
|
||||
name: "Cache"
|
||||
description: "Cache artifacts like dependencies and build outputs to improve workflow execution time"
|
||||
author: "GitHub"
|
||||
inputs:
|
||||
path:
|
||||
description: 'A directory to store and save the cache'
|
||||
description: "A directory to store and save the cache"
|
||||
required: true
|
||||
key:
|
||||
description: 'An explicit key for restoring and saving the cache'
|
||||
description: "An explicit key for restoring and saving the cache"
|
||||
required: true
|
||||
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
|
||||
outputs:
|
||||
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:
|
||||
using: 'node12'
|
||||
main: 'dist/restore/index.js'
|
||||
post: 'dist/save/index.js'
|
||||
post-if: 'success()'
|
||||
using: "node12"
|
||||
main: "dist/restore/index.js"
|
||||
post: "dist/save/index.js"
|
||||
post-if: "success()"
|
||||
branding:
|
||||
icon: 'archive'
|
||||
color: 'gray-dark'
|
||||
icon: "archive"
|
||||
color: "gray-dark"
|
||||
|
|
14
examples.md
14
examples.md
|
@ -30,6 +30,7 @@
|
|||
- [Swift - Swift Package Manager](#swift---swift-package-manager)
|
||||
|
||||
## C# - NuGet
|
||||
|
||||
Using [NuGet lock files](https://docs.microsoft.com/nuget/consume-packages/package-references-in-project-files#locking-dependencies):
|
||||
|
||||
```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.
|
||||
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
|
||||
|
||||
```yaml
|
||||
env:
|
||||
NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages
|
||||
|
@ -57,6 +60,7 @@ steps:
|
|||
```
|
||||
|
||||
## Elixir - Mix
|
||||
|
||||
```yaml
|
||||
- uses: actions/cache@v1
|
||||
with:
|
||||
|
@ -169,6 +173,7 @@ For npm, cache files are stored in `~/.npm` on Posix, or `%AppData%/npm-cache` o
|
|||
```
|
||||
|
||||
## 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.
|
||||
|
||||
```yaml
|
||||
|
@ -198,7 +203,9 @@ The yarn cache directory will depend on your operating system and version of `ya
|
|||
```
|
||||
|
||||
## OCaml/Reason - esy
|
||||
|
||||
Esy allows you to export built dependencies and import pre-built dependencies.
|
||||
|
||||
```yaml
|
||||
- name: 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'
|
||||
```
|
||||
|
||||
|
||||
## PHP - Composer
|
||||
|
||||
```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
|
||||
|
||||
Locations:
|
||||
|
||||
- Ubuntu: `~/.cache/pip`
|
||||
- Windows: `~\AppData\Local\pip\Cache`
|
||||
- macOS: `~/Library/Caches/pip`
|
||||
|
||||
### Simple example
|
||||
|
||||
```yaml
|
||||
- uses: actions/cache@v1
|
||||
with:
|
||||
|
@ -292,6 +300,7 @@ Replace `~/.cache/pip` with the correct `path` if not using Ubuntu.
|
|||
### Using a script to get cache location
|
||||
|
||||
> Note: This uses an internal pip API and may not always work
|
||||
|
||||
```yaml
|
||||
- name: Get 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
|
||||
|
||||
Locations:
|
||||
|
||||
- Ubuntu: `~/.local/share/renv`
|
||||
- macOS: `~/Library/Application Support/renv`
|
||||
- Windows: `%LOCALAPPDATA%/renv`
|
||||
|
||||
### Simple example
|
||||
|
||||
```yaml
|
||||
- uses: actions/cache@v1
|
||||
with:
|
||||
|
@ -365,6 +376,7 @@ Replace `~/.local/share/renv` with the correct `path` if not using Ubuntu.
|
|||
restore-keys: |
|
||||
${{ runner.os }}-gems-
|
||||
```
|
||||
|
||||
When dependencies are installed later in the workflow, we must specify the same path for the bundler.
|
||||
|
||||
```yaml
|
||||
|
|
|
@ -7,9 +7,9 @@ module.exports = {
|
|||
testMatch: ["**/*.test.ts"],
|
||||
testRunner: "jest-circus/runner",
|
||||
transform: {
|
||||
"^.+\\.ts$": "ts-jest"
|
||||
"^.+\\.ts$": "ts-jest",
|
||||
},
|
||||
verbose: true
|
||||
verbose: true,
|
||||
};
|
||||
|
||||
const processStdoutWrite = process.stdout.write.bind(process.stdout);
|
||||
|
|
|
@ -4,7 +4,7 @@ import { BearerCredentialHandler } from "@actions/http-client/auth";
|
|||
import {
|
||||
IHttpClientResponse,
|
||||
IRequestOptions,
|
||||
ITypedResponse
|
||||
ITypedResponse,
|
||||
} from "@actions/http-client/interfaces";
|
||||
import * as crypto from "crypto";
|
||||
import * as fs from "fs";
|
||||
|
@ -14,7 +14,7 @@ import {
|
|||
ArtifactCacheEntry,
|
||||
CommitCacheRequest,
|
||||
ReserveCacheRequest,
|
||||
ReserveCacheResponse
|
||||
ReserveCacheResponse,
|
||||
} from "./contracts";
|
||||
import * as utils from "./utils/actionUtils";
|
||||
|
||||
|
@ -34,7 +34,7 @@ function isRetryableStatusCode(statusCode?: number): boolean {
|
|||
const retryableStatusCodes = [
|
||||
HttpCodes.BadGateway,
|
||||
HttpCodes.ServiceUnavailable,
|
||||
HttpCodes.GatewayTimeout
|
||||
HttpCodes.GatewayTimeout,
|
||||
];
|
||||
return retryableStatusCodes.includes(statusCode);
|
||||
}
|
||||
|
@ -64,8 +64,8 @@ function createAcceptHeader(type: string, apiVersion: string): string {
|
|||
function getRequestOptions(): IRequestOptions {
|
||||
const requestOptions: IRequestOptions = {
|
||||
headers: {
|
||||
Accept: createAcceptHeader("application/json", "6.0-preview.1")
|
||||
}
|
||||
Accept: createAcceptHeader("application/json", "6.0-preview.1"),
|
||||
},
|
||||
};
|
||||
|
||||
return requestOptions;
|
||||
|
@ -86,7 +86,7 @@ export function getCacheVersion(): string {
|
|||
// Add salt to cache version to support breaking changes in cache entry
|
||||
const components = [
|
||||
core.getInput(Inputs.Path, { required: true }),
|
||||
versionSalt
|
||||
versionSalt,
|
||||
];
|
||||
|
||||
return crypto
|
||||
|
@ -130,7 +130,7 @@ async function pipeResponseToStream(
|
|||
response: IHttpClientResponse,
|
||||
stream: NodeJS.WritableStream
|
||||
): Promise<void> {
|
||||
return new Promise(resolve => {
|
||||
return new Promise((resolve) => {
|
||||
response.message.pipe(stream).on("close", () => {
|
||||
resolve();
|
||||
});
|
||||
|
@ -154,7 +154,7 @@ export async function reserveCache(key: string): Promise<number> {
|
|||
|
||||
const reserveCacheRequest: ReserveCacheRequest = {
|
||||
key,
|
||||
version
|
||||
version,
|
||||
};
|
||||
const response = await httpClient.postJson<ReserveCacheResponse>(
|
||||
getCacheApiUrl("caches"),
|
||||
|
@ -180,16 +180,16 @@ async function uploadChunk(
|
|||
end: number
|
||||
): Promise<void> {
|
||||
core.debug(
|
||||
`Uploading chunk of size ${end -
|
||||
start +
|
||||
1} bytes at offset ${start} with content range: ${getContentRange(
|
||||
`Uploading chunk of size ${
|
||||
end - start + 1
|
||||
} bytes at offset ${start} with content range: ${getContentRange(
|
||||
start,
|
||||
end
|
||||
)}`
|
||||
);
|
||||
const additionalHeaders = {
|
||||
"Content-Type": "application/octet-stream",
|
||||
"Content-Range": getContentRange(start, end)
|
||||
"Content-Range": getContentRange(start, end),
|
||||
};
|
||||
|
||||
const uploadChunkRequest = async (): Promise<IHttpClientResponse> => {
|
||||
|
@ -263,7 +263,7 @@ async function uploadFile(
|
|||
fd,
|
||||
start,
|
||||
end,
|
||||
autoClose: false
|
||||
autoClose: false,
|
||||
});
|
||||
|
||||
await uploadChunk(
|
||||
|
|
|
@ -1,22 +1,22 @@
|
|||
export enum Inputs {
|
||||
Key = "key",
|
||||
Path = "path",
|
||||
RestoreKeys = "restore-keys"
|
||||
RestoreKeys = "restore-keys",
|
||||
}
|
||||
|
||||
export enum Outputs {
|
||||
CacheHit = "cache-hit"
|
||||
CacheHit = "cache-hit",
|
||||
}
|
||||
|
||||
export enum State {
|
||||
CacheKey = "CACHE_KEY",
|
||||
CacheResult = "CACHE_RESULT"
|
||||
CacheResult = "CACHE_RESULT",
|
||||
}
|
||||
|
||||
export enum Events {
|
||||
Key = "GITHUB_EVENT_NAME",
|
||||
Push = "push",
|
||||
PullRequest = "pull_request"
|
||||
PullRequest = "pull_request",
|
||||
}
|
||||
|
||||
export const CacheFilename = "cache.tgz";
|
||||
|
|
|
@ -26,7 +26,7 @@ async function run(): Promise<void> {
|
|||
const restoreKeys = core
|
||||
.getInput(Inputs.RestoreKeys)
|
||||
.split("\n")
|
||||
.filter(x => x !== "");
|
||||
.filter((x) => x !== "");
|
||||
const keys = [primaryKey, ...restoreKeys];
|
||||
|
||||
core.debug("Resolved Keys:");
|
||||
|
|
|
@ -48,7 +48,7 @@ async function run(): Promise<void> {
|
|||
core
|
||||
.getInput(Inputs.Path, { required: true })
|
||||
.split("\n")
|
||||
.filter(x => x !== "")
|
||||
.filter((x) => x !== "")
|
||||
);
|
||||
|
||||
core.debug("Cache Paths:");
|
||||
|
|
|
@ -62,7 +62,7 @@ export async function createTar(
|
|||
"-C",
|
||||
workingDirectory,
|
||||
"--files-from",
|
||||
manifestFilename
|
||||
manifestFilename,
|
||||
];
|
||||
await execTar(args, archiveFolder);
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ export function isExactKeyMatch(
|
|||
cacheResult &&
|
||||
cacheResult.cacheKey &&
|
||||
cacheResult.cacheKey.localeCompare(key, undefined, {
|
||||
sensitivity: "accent"
|
||||
sensitivity: "accent",
|
||||
}) === 0
|
||||
);
|
||||
}
|
||||
|
@ -88,7 +88,7 @@ export async function resolvePaths(patterns: string[]): Promise<string[]> {
|
|||
const paths: string[] = [];
|
||||
const workspace = process.env["GITHUB_WORKSPACE"] ?? process.cwd();
|
||||
const globber = await glob.create(patterns.join("\n"), {
|
||||
implicitDescendants: false
|
||||
implicitDescendants: false,
|
||||
});
|
||||
|
||||
for await (const file of globber.globGenerator()) {
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
"compilerOptions": {
|
||||
/* Basic Options */
|
||||
// "incremental": true, /* Enable incremental compilation */
|
||||
"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'. */
|
||||
"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'. */,
|
||||
// "allowJs": true, /* Allow javascript files to be compiled. */
|
||||
// "checkJs": true, /* Report errors in .js files. */
|
||||
// "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. */
|
||||
// "sourceMap": true, /* Generates corresponding '.map' file. */
|
||||
// "outFile": "./", /* Concatenate and emit output to single file. */
|
||||
"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. */
|
||||
"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. */,
|
||||
// "composite": true, /* Enable project compilation */
|
||||
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
|
||||
// "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'). */
|
||||
|
||||
/* 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. */
|
||||
"strict": true /* Enable all strict type-checking options. */,
|
||||
"noImplicitAny": false /* Raise error on expressions and declarations with an implied 'any' type. */,
|
||||
// "strictNullChecks": true, /* Enable strict null checks. */
|
||||
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
|
||||
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
|
||||
|
|
Loading…
Add table
Reference in a new issue