mirror of
https://github.com/actions/cache.git
synced 2025-07-12 09:10:44 +00:00
npm run format
This commit is contained in:
parent
150eacd6fa
commit
1729a4d479
19 changed files with 222 additions and 206 deletions
|
@ -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()) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue