1
0
Fork 0

modifies for warpcache

pull/1716/head
Prajjwal 2024-04-15 10:13:42 +05:30
parent 917853e23b
commit 9a8c6b26ce
33 changed files with 701 additions and 146 deletions

View File

@ -1,6 +1,6 @@
{
"name": "github-actions.warp-cache",
"version": "0.3.0",
"version": "1.0.0",
"preview": true,
"description": "Github action to use WarpBuild's in-house cache offering",
"keywords": [

View File

@ -66,6 +66,7 @@ export function isFeatureAvailable(): boolean {
* @param restoreKeys an optional ordered list of keys to use for restoring the cache if no cache hit occurred for key
* @param downloadOptions cache download options
* @param enableCrossOsArchive an optional boolean enabled to restore on windows any cache created on any platform
* @param enableCrossArchArchive an optional boolean enabled to restore cache created on any arch
* @returns string returns the key for the cache hit, otherwise returns undefined
*/
export async function restoreCache(
@ -73,22 +74,23 @@ export async function restoreCache(
primaryKey: string,
restoreKeys?: string[],
options?: DownloadOptions,
enableCrossOsArchive = false
enableCrossOsArchive = false,
enableCrossArchArchive = false
): Promise<string | undefined> {
checkPaths(paths)
checkKey(primaryKey)
restoreKeys = restoreKeys ?? []
const keys = [primaryKey, ...restoreKeys]
core.debug('Resolved Keys:')
core.debug(JSON.stringify(keys))
core.debug('Resolved Restore Keys:')
core.debug(JSON.stringify(restoreKeys))
if (keys.length > 10) {
if (restoreKeys.length > 9) {
throw new ValidationError(
`Key Validation Error: Keys are limited to a maximum of 10.`
)
}
for (const key of keys) {
for (const key of restoreKeys) {
checkKey(key)
}
@ -96,10 +98,16 @@ export async function restoreCache(
let archivePath = ''
try {
// path are needed to compute version
const cacheEntry = await cacheHttpClient.getCacheEntry(keys, paths, {
compressionMethod,
enableCrossOsArchive
})
const cacheEntry = await cacheHttpClient.getCacheEntry(
primaryKey,
restoreKeys,
paths,
{
compressionMethod,
enableCrossOsArchive,
enableCrossArchArchive
}
)
if (!cacheEntry) {
// Internal Error
@ -205,13 +213,14 @@ export async function restoreCache(
* @param paths a list of file paths to be cached
* @param key an explicit key for restoring the cache
* @param enableCrossOsArchive an optional boolean enabled to save cache on windows which could be restored on any platform
* @param options cache upload options
* @returns number returns cacheId if the cache was saved successfully and throws an error if save fails
* @param enableCrossArchArchive an optional boolean enabled to save cache on any arch which could be restored on any arch
* @returns string returns cacheId if the cache was saved successfully and throws an error if save fails
*/
export async function saveCache(
paths: string[],
key: string,
enableCrossOsArchive = false
enableCrossOsArchive = false,
enableCrossArchArchive = false
): Promise<string> {
checkPaths(paths)
checkKey(key)
@ -254,6 +263,13 @@ export async function saveCache(
)
}
const cacheVersion = cacheHttpClient.getCacheVersion(
paths,
compressionMethod,
enableCrossOsArchive,
enableCrossArchArchive
)
core.debug('Reserving Cache')
// Calculate number of chunks required. This is only required if backend is S3 as Google Cloud SDK will do it for us
const uploadOptions = getUploadOptions()
@ -262,11 +278,7 @@ export async function saveCache(
const reserveCacheResponse = await cacheHttpClient.reserveCache(
key,
numberOfChunks,
{
compressionMethod,
enableCrossOsArchive,
cacheSize: archiveFileSize
}
cacheVersion
)
if (reserveCacheResponse?.statusCode === 400) {
@ -278,12 +290,6 @@ export async function saveCache(
)
}
const cacheVersion = cacheHttpClient.getCacheVersion(
paths,
compressionMethod,
enableCrossOsArchive
)
switch (reserveCacheResponse.result?.provider) {
case 's3':
core.debug(`Saving Cache to S3`)
@ -341,18 +347,30 @@ export async function saveCache(
/**
* Deletes an entire cache by cache key.
* @param keys The cache keys
* @param key The cache keys
*/
export async function deleteCache(keys: string[]): Promise<void> {
for (const key of keys) {
checkKey(key)
}
export async function deleteCache(
paths: string[],
key: string,
enableCrossOsArchive = false,
enableCrossArchArchive = false
): Promise<void> {
checkKey(key)
core.debug('Deleting Cache')
core.debug(`Cache Keys: ${keys}`)
core.debug(`Cache Key: ${key}`)
const compressionMethod = await utils.getCompressionMethod()
const cacheVersion = cacheHttpClient.getCacheVersion(
paths,
compressionMethod,
enableCrossOsArchive,
enableCrossArchArchive
)
try {
await cacheHttpClient.deleteCache(keys)
await cacheHttpClient.deleteCache(key, cacheVersion)
} catch (error) {
core.warning(`Failed to delete cache: ${error}`)
}

View File

@ -23,11 +23,14 @@ import {Storage} from '@google-cloud/storage'
import {
CommonsCommitCacheRequest,
CommonsCommitCacheResponse,
CommonsDeleteCacheResponse,
CommonsGetCacheResponse,
CommonsReserveCacheRequest,
CommonsReserveCacheResponse
} from './warpcache-ts-sdk'
import {multiPartUploadToGCS, uploadFileToS3} from './uploadUtils'
import {CommonsGetCacheRequest} from './warpcache-ts-sdk/models/commons-get-cache-request'
import {CommonsDeleteCacheRequest} from './warpcache-ts-sdk/models/commons-delete-cache-request'
const versionSalt = '1.0'
@ -47,6 +50,16 @@ function createAcceptHeader(type: string, apiVersion: string): string {
return `${type};api-version=${apiVersion}`
}
function getVCSRepository(): string {
const vcsRepository = process.env['GITHUB_REPOSITORY'] ?? ''
return vcsRepository
}
function getVCSRef(): string {
const vcsBranch = process.env['GITHUB_REF'] ?? ''
return vcsBranch
}
function getRequestOptions(): RequestOptions {
const requestOptions: RequestOptions = {
headers: {
@ -71,7 +84,8 @@ function createHttpClient(): HttpClient {
export function getCacheVersion(
paths: string[],
compressionMethod?: CompressionMethod,
enableCrossOsArchive = false
enableCrossOsArchive = false,
enableCrossArchArchive = false
): string {
const components = paths
@ -86,6 +100,11 @@ export function getCacheVersion(
components.push('windows-only')
}
// Add architecture to cache version
if (!enableCrossArchArchive) {
components.push(process.arch)
}
// Add salt to cache version to support breaking changes in cache entry
components.push(versionSalt)
@ -93,7 +112,8 @@ export function getCacheVersion(
}
export async function getCacheEntry(
keys: string[],
key: string,
restoreKeys: string[],
paths: string[],
options?: InternalCacheOptions
): Promise<CommonsGetCacheResponse | null> {
@ -101,14 +121,23 @@ export async function getCacheEntry(
const version = getCacheVersion(
paths,
options?.compressionMethod,
options?.enableCrossOsArchive
options?.enableCrossOsArchive,
options?.enableCrossArchArchive
)
const resource = `cache?keys=${encodeURIComponent(
keys.join(',')
)}&version=${version}`
const getCacheRequest: CommonsGetCacheRequest = {
cache_key: key,
restore_keys: restoreKeys,
cache_version: version,
vcs_repository: getVCSRepository(),
vcs_ref: getVCSRef()
}
const response = await retryTypedResponse('getCacheEntry', async () =>
httpClient.getJson<CommonsGetCacheResponse>(getCacheApiUrl(resource))
httpClient.postJson<CommonsGetCacheResponse>(
getCacheApiUrl('cache/get'),
getCacheRequest
)
)
if (response.statusCode === 204) {
@ -190,14 +219,17 @@ export function downloadCacheStreaming(
export async function reserveCache(
cacheKey: string,
numberOfChunks: number,
options?: InternalCacheOptions
cacheVersion: string
): Promise<ITypedResponseWithError<CommonsReserveCacheResponse>> {
const httpClient = createHttpClient()
const reserveCacheRequest: CommonsReserveCacheRequest = {
cache_key: cacheKey,
cache_version: cacheVersion,
number_of_chunks: numberOfChunks,
content_type: 'application/zstd'
content_type: 'application/zstd',
vcs_repository: getVCSRepository(),
vcs_ref: getVCSRef()
}
const response = await retryTypedResponse('reserveCache', async () =>
httpClient.postJson<CommonsReserveCacheResponse>(
@ -227,8 +259,9 @@ async function commitCache(
upload_key: uploadKey,
upload_id: uploadID,
parts: parts,
os: process.env['RUNNER_OS'] ?? 'Linux',
vcs_type: 'github'
vcs_type: 'github',
vcs_repository: getVCSRepository(),
vcs_ref: getVCSRef()
}
return await retryTypedResponse('commitCache', async () =>
httpClient.postJson<CommonsCommitCacheResponse>(
@ -340,13 +373,24 @@ export async function saveCache(
return cacheKeyResponse
}
export async function deleteCache(keys: string[]) {
export async function deleteCache(cacheKey: string, cacheVersion: string) {
const httpClient = createHttpClient()
const resource = `cache?keys=${encodeURIComponent(keys.join(','))}`
const response = await httpClient.del(getCacheApiUrl(resource))
if (!isSuccessStatusCode(response.message.statusCode)) {
throw new Error(
`Cache service responded with ${response.message.statusCode}`
const deleteCacheRequest: CommonsDeleteCacheRequest = {
cache_key: cacheKey,
cache_version: cacheVersion,
vcs_repository: getVCSRepository(),
vcs_ref: getVCSRef()
}
const response = await retryTypedResponse('deleteCacheEntry', async () =>
httpClient.postJson<CommonsDeleteCacheResponse>(
getCacheApiUrl('cache/delete'),
deleteCacheRequest
)
)
if (!isSuccessStatusCode(response.statusCode)) {
throw new Error(`Cache service responded with ${response.statusCode}`)
}
}

View File

@ -9,6 +9,7 @@ export interface ITypedResponseWithError<T> extends TypedResponse<T> {
export interface InternalCacheOptions {
compressionMethod?: CompressionMethod
enableCrossOsArchive?: boolean
enableCrossArchArchive?: boolean
cacheSize?: number
}

View File

@ -111,7 +111,7 @@ export async function retryTypedResponse<T>(
if (error instanceof HttpClientError) {
return {
statusCode: error.statusCode,
result: null,
result: error.result ?? null,
headers: {},
error
}

View File

@ -9,12 +9,16 @@ common.ts
configuration.ts
git_push.sh
index.ts
models/commons-cache-entry.ts
models/commons-commit-cache-request.ts
models/commons-commit-cache-response.ts
models/commons-delete-cache-request.ts
models/commons-delete-cache-response.ts
models/commons-gcscommit-cache-response.ts
models/commons-gcsdelete-cache-response.ts
models/commons-gcsget-cache-reponse.ts
models/commons-gcsreserve-cache-response.ts
models/commons-get-cache-request.ts
models/commons-get-cache-response.ts
models/commons-reserve-cache-request.ts
models/commons-reserve-cache-response.ts

View File

@ -26,8 +26,12 @@ import { CommonsCommitCacheRequest } from '../models';
// @ts-ignore
import { CommonsCommitCacheResponse } from '../models';
// @ts-ignore
import { CommonsDeleteCacheRequest } from '../models';
// @ts-ignore
import { CommonsDeleteCacheResponse } from '../models';
// @ts-ignore
import { CommonsGetCacheRequest } from '../models';
// @ts-ignore
import { CommonsGetCacheResponse } from '../models';
// @ts-ignore
import { CommonsReserveCacheRequest } from '../models';
@ -110,13 +114,13 @@ export const DefaultApiAxiosParamCreator = function (configuration?: Configurati
/**
* delete cache
* @summary delete cache
* @param {string} keys cache keys
* @param {CommonsDeleteCacheRequest} body Delete Cache Request Body
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
v1CacheDeleteDelete: async (keys: string, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
// verify required parameter 'keys' is not null or undefined
assertParamExists('v1CacheDeleteDelete', 'keys', keys)
v1CacheDeletePost: async (body: CommonsDeleteCacheRequest, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
// verify required parameter 'body' is not null or undefined
assertParamExists('v1CacheDeletePost', 'body', body)
const localVarPath = `/v1/cache/delete`;
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
@ -125,19 +129,18 @@ export const DefaultApiAxiosParamCreator = function (configuration?: Configurati
baseOptions = configuration.baseOptions;
}
const localVarRequestOptions = { method: 'DELETE', ...baseOptions, ...options};
const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options};
const localVarHeaderParameter = {} as any;
const localVarQueryParameter = {} as any;
if (keys !== undefined) {
localVarQueryParameter['keys'] = keys;
}
localVarHeaderParameter['Content-Type'] = 'application/json';
setSearchParams(localVarUrlObj, localVarQueryParameter);
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
localVarRequestOptions.data = serializeDataIfNeeded(body, localVarRequestOptions, configuration)
return {
url: toPathString(localVarUrlObj),
@ -147,17 +150,14 @@ export const DefaultApiAxiosParamCreator = function (configuration?: Configurati
/**
* get cache
* @summary get cache
* @param {string} keys cache keys
* @param {string} version cache version
* @param {CommonsGetCacheRequest} body Get Cache Request Body
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
v1CacheGet: async (keys: string, version: string, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
// verify required parameter 'keys' is not null or undefined
assertParamExists('v1CacheGet', 'keys', keys)
// verify required parameter 'version' is not null or undefined
assertParamExists('v1CacheGet', 'version', version)
const localVarPath = `/v1/cache`;
v1CacheGetPost: async (body: CommonsGetCacheRequest, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
// verify required parameter 'body' is not null or undefined
assertParamExists('v1CacheGetPost', 'body', body)
const localVarPath = `/v1/cache/get`;
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
let baseOptions;
@ -165,23 +165,18 @@ export const DefaultApiAxiosParamCreator = function (configuration?: Configurati
baseOptions = configuration.baseOptions;
}
const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options};
const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options};
const localVarHeaderParameter = {} as any;
const localVarQueryParameter = {} as any;
if (keys !== undefined) {
localVarQueryParameter['keys'] = keys;
}
if (version !== undefined) {
localVarQueryParameter['version'] = version;
}
localVarHeaderParameter['Content-Type'] = 'application/json';
setSearchParams(localVarUrlObj, localVarQueryParameter);
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
localVarRequestOptions.data = serializeDataIfNeeded(body, localVarRequestOptions, configuration)
return {
url: toPathString(localVarUrlObj),
@ -262,28 +257,27 @@ export const DefaultApiFp = function(configuration?: Configuration) {
/**
* delete cache
* @summary delete cache
* @param {string} keys cache keys
* @param {CommonsDeleteCacheRequest} body Delete Cache Request Body
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async v1CacheDeleteDelete(keys: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<CommonsDeleteCacheResponse>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.v1CacheDeleteDelete(keys, options);
async v1CacheDeletePost(body: CommonsDeleteCacheRequest, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<CommonsDeleteCacheResponse>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.v1CacheDeletePost(body, options);
const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
const localVarOperationServerBasePath = operationServerMap['DefaultApi.v1CacheDeleteDelete']?.[localVarOperationServerIndex]?.url;
const localVarOperationServerBasePath = operationServerMap['DefaultApi.v1CacheDeletePost']?.[localVarOperationServerIndex]?.url;
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
},
/**
* get cache
* @summary get cache
* @param {string} keys cache keys
* @param {string} version cache version
* @param {CommonsGetCacheRequest} body Get Cache Request Body
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async v1CacheGet(keys: string, version: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<CommonsGetCacheResponse>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.v1CacheGet(keys, version, options);
async v1CacheGetPost(body: CommonsGetCacheRequest, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<CommonsGetCacheResponse>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.v1CacheGetPost(body, options);
const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
const localVarOperationServerBasePath = operationServerMap['DefaultApi.v1CacheGet']?.[localVarOperationServerIndex]?.url;
const localVarOperationServerBasePath = operationServerMap['DefaultApi.v1CacheGetPost']?.[localVarOperationServerIndex]?.url;
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
},
/**
@ -331,22 +325,22 @@ export const DefaultApiFactory = function (configuration?: Configuration, basePa
/**
* delete cache
* @summary delete cache
* @param {DefaultApiV1CacheDeleteDeleteRequest} requestParameters Request parameters.
* @param {DefaultApiV1CacheDeletePostRequest} requestParameters Request parameters.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
v1CacheDeleteDelete(requestParameters: DefaultApiV1CacheDeleteDeleteRequest, options?: RawAxiosRequestConfig): AxiosPromise<CommonsDeleteCacheResponse> {
return localVarFp.v1CacheDeleteDelete(requestParameters.keys, options).then((request) => request(axios, basePath));
v1CacheDeletePost(requestParameters: DefaultApiV1CacheDeletePostRequest, options?: RawAxiosRequestConfig): AxiosPromise<CommonsDeleteCacheResponse> {
return localVarFp.v1CacheDeletePost(requestParameters.body, options).then((request) => request(axios, basePath));
},
/**
* get cache
* @summary get cache
* @param {DefaultApiV1CacheGetRequest} requestParameters Request parameters.
* @param {DefaultApiV1CacheGetPostRequest} requestParameters Request parameters.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
v1CacheGet(requestParameters: DefaultApiV1CacheGetRequest, options?: RawAxiosRequestConfig): AxiosPromise<CommonsGetCacheResponse> {
return localVarFp.v1CacheGet(requestParameters.keys, requestParameters.version, options).then((request) => request(axios, basePath));
v1CacheGetPost(requestParameters: DefaultApiV1CacheGetPostRequest, options?: RawAxiosRequestConfig): AxiosPromise<CommonsGetCacheResponse> {
return localVarFp.v1CacheGetPost(requestParameters.body, options).then((request) => request(axios, basePath));
},
/**
* reserve cache
@ -376,38 +370,31 @@ export interface DefaultApiV1CacheCommitPostRequest {
}
/**
* Request parameters for v1CacheDeleteDelete operation in DefaultApi.
* Request parameters for v1CacheDeletePost operation in DefaultApi.
* @export
* @interface DefaultApiV1CacheDeleteDeleteRequest
* @interface DefaultApiV1CacheDeletePostRequest
*/
export interface DefaultApiV1CacheDeleteDeleteRequest {
export interface DefaultApiV1CacheDeletePostRequest {
/**
* cache keys
* @type {string}
* @memberof DefaultApiV1CacheDeleteDelete
* Delete Cache Request Body
* @type {CommonsDeleteCacheRequest}
* @memberof DefaultApiV1CacheDeletePost
*/
readonly keys: string
readonly body: CommonsDeleteCacheRequest
}
/**
* Request parameters for v1CacheGet operation in DefaultApi.
* Request parameters for v1CacheGetPost operation in DefaultApi.
* @export
* @interface DefaultApiV1CacheGetRequest
* @interface DefaultApiV1CacheGetPostRequest
*/
export interface DefaultApiV1CacheGetRequest {
export interface DefaultApiV1CacheGetPostRequest {
/**
* cache keys
* @type {string}
* @memberof DefaultApiV1CacheGet
* Get Cache Request Body
* @type {CommonsGetCacheRequest}
* @memberof DefaultApiV1CacheGetPost
*/
readonly keys: string
/**
* cache version
* @type {string}
* @memberof DefaultApiV1CacheGet
*/
readonly version: string
readonly body: CommonsGetCacheRequest
}
/**
@ -457,25 +444,25 @@ export class DefaultApi extends BaseAPI {
/**
* delete cache
* @summary delete cache
* @param {DefaultApiV1CacheDeleteDeleteRequest} requestParameters Request parameters.
* @param {DefaultApiV1CacheDeletePostRequest} requestParameters Request parameters.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof DefaultApi
*/
public v1CacheDeleteDelete(requestParameters: DefaultApiV1CacheDeleteDeleteRequest, options?: RawAxiosRequestConfig) {
return DefaultApiFp(this.configuration).v1CacheDeleteDelete(requestParameters.keys, options).then((request) => request(this.axios, this.basePath));
public v1CacheDeletePost(requestParameters: DefaultApiV1CacheDeletePostRequest, options?: RawAxiosRequestConfig) {
return DefaultApiFp(this.configuration).v1CacheDeletePost(requestParameters.body, options).then((request) => request(this.axios, this.basePath));
}
/**
* get cache
* @summary get cache
* @param {DefaultApiV1CacheGetRequest} requestParameters Request parameters.
* @param {DefaultApiV1CacheGetPostRequest} requestParameters Request parameters.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof DefaultApi
*/
public v1CacheGet(requestParameters: DefaultApiV1CacheGetRequest, options?: RawAxiosRequestConfig) {
return DefaultApiFp(this.configuration).v1CacheGet(requestParameters.keys, requestParameters.version, options).then((request) => request(this.axios, this.basePath));
public v1CacheGetPost(requestParameters: DefaultApiV1CacheGetPostRequest, options?: RawAxiosRequestConfig) {
return DefaultApiFp(this.configuration).v1CacheGetPost(requestParameters.body, options).then((request) => request(this.axios, this.basePath));
}
/**

View File

@ -0,0 +1,72 @@
/* tslint:disable */
/* eslint-disable */
/**
*
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
/**
*
* @export
* @interface CommonsCacheEntry
*/
export interface CommonsCacheEntry {
/**
*
* @type {string}
* @memberof CommonsCacheEntry
*/
'cache_key'?: string;
/**
*
* @type {string}
* @memberof CommonsCacheEntry
*/
'cache_version'?: string;
/**
*
* @type {string}
* @memberof CommonsCacheEntry
*/
'created_at'?: string;
/**
*
* @type {string}
* @memberof CommonsCacheEntry
*/
'id'?: string;
/**
*
* @type {string}
* @memberof CommonsCacheEntry
*/
'organization_id'?: string;
/**
*
* @type {string}
* @memberof CommonsCacheEntry
*/
'updated_at'?: string;
/**
*
* @type {string}
* @memberof CommonsCacheEntry
*/
'vcs_organization_name'?: string;
/**
*
* @type {string}
* @memberof CommonsCacheEntry
*/
'vcs_repository_name'?: string;
}

View File

@ -23,6 +23,12 @@ import { TypesCompletedPart } from './types-completed-part';
* @interface CommonsCommitCacheRequest
*/
export interface CommonsCommitCacheRequest {
/**
*
* @type {{ [key: string]: string; }}
* @memberof CommonsCommitCacheRequest
*/
'annotations'?: { [key: string]: string; };
/**
*
* @type {string}
@ -35,12 +41,6 @@ export interface CommonsCommitCacheRequest {
* @memberof CommonsCommitCacheRequest
*/
'cache_version': string;
/**
*
* @type {string}
* @memberof CommonsCommitCacheRequest
*/
'os': string;
/**
*
* @type {Array<TypesCompletedPart>}
@ -59,6 +59,18 @@ export interface CommonsCommitCacheRequest {
* @memberof CommonsCommitCacheRequest
*/
'upload_key'?: string;
/**
* VCSRef is the ref of the repository in vcs for which cache is being used. This can be a branch, git tag, or pull request ref.
* @type {string}
* @memberof CommonsCommitCacheRequest
*/
'vcs_ref'?: string;
/**
* VCSRepository is the repository name in vcs. It can be of the format <organization>/<repository> or <repository>. While saving the entry, <organization>/ will be trimmed if passed.
* @type {string}
* @memberof CommonsCommitCacheRequest
*/
'vcs_repository'?: string;
/**
*
* @type {string}

View File

@ -13,6 +13,9 @@
*/
// May contain unused imports in some cases
// @ts-ignore
import { CommonsCacheEntry } from './commons-cache-entry';
// May contain unused imports in some cases
// @ts-ignore
import { CommonsGCSCommitCacheResponse } from './commons-gcscommit-cache-response';
@ -26,6 +29,18 @@ import { CommonsS3CommitCacheResponse } from './commons-s3-commit-cache-response
* @interface CommonsCommitCacheResponse
*/
export interface CommonsCommitCacheResponse {
/**
*
* @type {{ [key: string]: string; }}
* @memberof CommonsCommitCacheResponse
*/
'annotations'?: { [key: string]: string; };
/**
*
* @type {CommonsCacheEntry}
* @memberof CommonsCommitCacheResponse
*/
'cache_entry'?: CommonsCacheEntry;
/**
*
* @type {CommonsGCSCommitCacheResponse}
@ -44,5 +59,11 @@ export interface CommonsCommitCacheResponse {
* @memberof CommonsCommitCacheResponse
*/
's3'?: CommonsS3CommitCacheResponse;
/**
* VCSRepository is the repository name in vcs. It can be of the format <organization>/<repository> or <repository>. While saving the entry, <organization>/ will be trimmed if passed.
* @type {string}
* @memberof CommonsCommitCacheResponse
*/
'vcs_repository'?: string;
}

View File

@ -0,0 +1,54 @@
/* tslint:disable */
/* eslint-disable */
/**
*
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
/**
*
* @export
* @interface CommonsDeleteCacheRequest
*/
export interface CommonsDeleteCacheRequest {
/**
*
* @type {{ [key: string]: string; }}
* @memberof CommonsDeleteCacheRequest
*/
'annotations'?: { [key: string]: string; };
/**
*
* @type {string}
* @memberof CommonsDeleteCacheRequest
*/
'cache_key': string;
/**
*
* @type {string}
* @memberof CommonsDeleteCacheRequest
*/
'cache_version': string;
/**
* VCSRef is the ref of the repository in vcs for which cache is being used. This can be a branch, git tag, or pull request ref.
* @type {string}
* @memberof CommonsDeleteCacheRequest
*/
'vcs_ref'?: string;
/**
* VCSRepository is the repository name in vcs. It can be of the format <organization>/<repository> or <repository>. While saving the entry, <organization>/ will be trimmed if passed.
* @type {string}
* @memberof CommonsDeleteCacheRequest
*/
'vcs_repository'?: string;
}

View File

@ -13,6 +13,12 @@
*/
// May contain unused imports in some cases
// @ts-ignore
import { CommonsCacheEntry } from './commons-cache-entry';
// May contain unused imports in some cases
// @ts-ignore
import { CommonsGCSDeleteCacheResponse } from './commons-gcsdelete-cache-response';
// May contain unused imports in some cases
// @ts-ignore
import { CommonsS3DeleteCacheResponse } from './commons-s3-delete-cache-response';
@ -25,10 +31,22 @@ import { CommonsS3DeleteCacheResponse } from './commons-s3-delete-cache-response
export interface CommonsDeleteCacheResponse {
/**
*
* @type {object}
* @type {{ [key: string]: string; }}
* @memberof CommonsDeleteCacheResponse
*/
'gcs'?: object;
'annotations'?: { [key: string]: string; };
/**
*
* @type {CommonsCacheEntry}
* @memberof CommonsDeleteCacheResponse
*/
'cache_entry'?: CommonsCacheEntry;
/**
*
* @type {CommonsGCSDeleteCacheResponse}
* @memberof CommonsDeleteCacheResponse
*/
'gcs'?: CommonsGCSDeleteCacheResponse;
/**
*
* @type {string}

View File

@ -0,0 +1,36 @@
/* tslint:disable */
/* eslint-disable */
/**
*
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
/**
*
* @export
* @interface CommonsGCSDeleteCacheResponse
*/
export interface CommonsGCSDeleteCacheResponse {
/**
*
* @type {string}
* @memberof CommonsGCSDeleteCacheResponse
*/
'cache_key': string;
/**
*
* @type {string}
* @memberof CommonsGCSDeleteCacheResponse
*/
'cache_version': string;
}

View File

@ -0,0 +1,60 @@
/* tslint:disable */
/* eslint-disable */
/**
*
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
/**
*
* @export
* @interface CommonsGetCacheRequest
*/
export interface CommonsGetCacheRequest {
/**
*
* @type {{ [key: string]: string; }}
* @memberof CommonsGetCacheRequest
*/
'annotations'?: { [key: string]: string; };
/**
*
* @type {string}
* @memberof CommonsGetCacheRequest
*/
'cache_key': string;
/**
*
* @type {string}
* @memberof CommonsGetCacheRequest
*/
'cache_version': string;
/**
*
* @type {Array<string>}
* @memberof CommonsGetCacheRequest
*/
'restore_keys'?: Array<string>;
/**
* VCSRef is the ref of the repository in vcs for which cache is being used. This can be a branch, git tag, or pull request ref.
* @type {string}
* @memberof CommonsGetCacheRequest
*/
'vcs_ref'?: string;
/**
* VCSRepository is the repository name in vcs. It can be of the format <organization>/<repository> or <repository>. While saving the entry, <organization>/ will be trimmed if passed.
* @type {string}
* @memberof CommonsGetCacheRequest
*/
'vcs_repository'?: string;
}

View File

@ -13,6 +13,9 @@
*/
// May contain unused imports in some cases
// @ts-ignore
import { CommonsCacheEntry } from './commons-cache-entry';
// May contain unused imports in some cases
// @ts-ignore
import { CommonsGCSGetCacheReponse } from './commons-gcsget-cache-reponse';
@ -26,6 +29,18 @@ import { CommonsS3GetCacheResponse } from './commons-s3-get-cache-response';
* @interface CommonsGetCacheResponse
*/
export interface CommonsGetCacheResponse {
/**
*
* @type {{ [key: string]: string; }}
* @memberof CommonsGetCacheResponse
*/
'annotations'?: { [key: string]: string; };
/**
*
* @type {CommonsCacheEntry}
* @memberof CommonsGetCacheResponse
*/
'cache_entry'?: CommonsCacheEntry;
/**
*
* @type {CommonsGCSGetCacheReponse}

View File

@ -20,12 +20,24 @@
* @interface CommonsReserveCacheRequest
*/
export interface CommonsReserveCacheRequest {
/**
*
* @type {{ [key: string]: string; }}
* @memberof CommonsReserveCacheRequest
*/
'annotations'?: { [key: string]: string; };
/**
*
* @type {string}
* @memberof CommonsReserveCacheRequest
*/
'cache_key': string;
/**
*
* @type {string}
* @memberof CommonsReserveCacheRequest
*/
'cache_version': string;
/**
* ContentType contains the content type of the cache. * This is not supported for GCS cache. When passed this will be ignored. *
* @type {string}
@ -38,5 +50,17 @@ export interface CommonsReserveCacheRequest {
* @memberof CommonsReserveCacheRequest
*/
'number_of_chunks'?: number;
/**
* VCSRef is the ref of the repository in vcs for which cache is being used. This can be a branch, git tag, or pull request ref.
* @type {string}
* @memberof CommonsReserveCacheRequest
*/
'vcs_ref'?: string;
/**
* VCSRepository is the repository name in vcs. It can be of the format <organization>/<repository> or <repository>. While saving the entry, <organization>/ will be trimmed if passed.
* @type {string}
* @memberof CommonsReserveCacheRequest
*/
'vcs_repository'?: string;
}

View File

@ -26,6 +26,12 @@ import { CommonsS3ReserveCacheResponse } from './commons-s3-reserve-cache-respon
* @interface CommonsReserveCacheResponse
*/
export interface CommonsReserveCacheResponse {
/**
*
* @type {{ [key: string]: string; }}
* @memberof CommonsReserveCacheResponse
*/
'annotations'?: { [key: string]: string; };
/**
*
* @type {CommonsGCSReserveCacheResponse}

View File

@ -20,6 +20,12 @@
* @interface CommonsS3GetCacheResponse
*/
export interface CommonsS3GetCacheResponse {
/**
*
* @type {{ [key: string]: string; }}
* @memberof CommonsS3GetCacheResponse
*/
'annotations'?: { [key: string]: string; };
/**
*
* @type {string}

View File

@ -1,9 +1,13 @@
export * from './commons-cache-entry';
export * from './commons-commit-cache-request';
export * from './commons-commit-cache-response';
export * from './commons-delete-cache-request';
export * from './commons-delete-cache-response';
export * from './commons-gcscommit-cache-response';
export * from './commons-gcsdelete-cache-response';
export * from './commons-gcsget-cache-reponse';
export * from './commons-gcsreserve-cache-response';
export * from './commons-get-cache-request';
export * from './commons-get-cache-response';
export * from './commons-reserve-cache-request';
export * from './commons-reserve-cache-response';

View File

@ -1,13 +1,17 @@
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
export { $commons_CacheAnnotationsMap } from './schemas/$commons_CacheAnnotationsMap';
export { $commons_CacheEntry } from './schemas/$commons_CacheEntry';
export { $commons_CommitCacheRequest } from './schemas/$commons_CommitCacheRequest';
export { $commons_CommitCacheResponse } from './schemas/$commons_CommitCacheResponse';
export { $commons_DeleteCacheRequest } from './schemas/$commons_DeleteCacheRequest';
export { $commons_DeleteCacheResponse } from './schemas/$commons_DeleteCacheResponse';
export { $commons_GCSCommitCacheResponse } from './schemas/$commons_GCSCommitCacheResponse';
export { $commons_GCSDeleteCacheResponse } from './schemas/$commons_GCSDeleteCacheResponse';
export { $commons_GCSGetCacheReponse } from './schemas/$commons_GCSGetCacheReponse';
export { $commons_GCSReserveCacheResponse } from './schemas/$commons_GCSReserveCacheResponse';
export { $commons_GetCacheRequest } from './schemas/$commons_GetCacheRequest';
export { $commons_GetCacheResponse } from './schemas/$commons_GetCacheResponse';
export { $commons_ReserveCacheRequest } from './schemas/$commons_ReserveCacheRequest';
export { $commons_ReserveCacheResponse } from './schemas/$commons_ReserveCacheResponse';

View File

@ -0,0 +1,9 @@
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
export const $commons_CacheAnnotationsMap = {
type: 'dictionary',
contains: {
type: 'string',
},
} as const;

View File

@ -0,0 +1,31 @@
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
export const $commons_CacheEntry = {
properties: {
cache_key: {
type: 'string',
},
cache_version: {
type: 'string',
},
created_at: {
type: 'string',
},
id: {
type: 'string',
},
organization_id: {
type: 'string',
},
updated_at: {
type: 'string',
},
vcs_organization_name: {
type: 'string',
},
vcs_repository_name: {
type: 'string',
},
},
} as const;

View File

@ -3,6 +3,9 @@
/* eslint-disable */
export const $commons_CommitCacheRequest = {
properties: {
annotations: {
type: 'commons_CacheAnnotationsMap',
},
cache_key: {
type: 'string',
isRequired: true,
@ -11,10 +14,6 @@ export const $commons_CommitCacheRequest = {
type: 'string',
isRequired: true,
},
os: {
type: 'string',
isRequired: true,
},
parts: {
type: 'array',
contains: {
@ -28,6 +27,12 @@ export const $commons_CommitCacheRequest = {
upload_key: {
type: 'string',
},
vcs_ref: {
type: 'string',
},
vcs_repository: {
type: 'string',
},
vcs_type: {
type: 'string',
isRequired: true,

View File

@ -3,6 +3,12 @@
/* eslint-disable */
export const $commons_CommitCacheResponse = {
properties: {
annotations: {
type: 'commons_CacheAnnotationsMap',
},
cache_entry: {
type: 'commons_CacheEntry',
},
gcs: {
type: 'commons_GCSCommitCacheResponse',
},
@ -12,5 +18,8 @@ export const $commons_CommitCacheResponse = {
s3: {
type: 'commons_S3CommitCacheResponse',
},
vcs_repository: {
type: 'string',
},
},
} as const;

View File

@ -0,0 +1,24 @@
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
export const $commons_DeleteCacheRequest = {
properties: {
annotations: {
type: 'commons_CacheAnnotationsMap',
},
cache_key: {
type: 'string',
isRequired: true,
},
cache_version: {
type: 'string',
isRequired: true,
},
vcs_ref: {
type: 'string',
},
vcs_repository: {
type: 'string',
},
},
} as const;

View File

@ -3,6 +3,12 @@
/* eslint-disable */
export const $commons_DeleteCacheResponse = {
properties: {
annotations: {
type: 'commons_CacheAnnotationsMap',
},
cache_entry: {
type: 'commons_CacheEntry',
},
gcs: {
type: 'commons_GCSDeleteCacheResponse',
},

View File

@ -3,5 +3,13 @@
/* eslint-disable */
export const $commons_GCSDeleteCacheResponse = {
properties: {
cache_key: {
type: 'string',
isRequired: true,
},
cache_version: {
type: 'string',
isRequired: true,
},
},
} as const;

View File

@ -0,0 +1,30 @@
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
export const $commons_GetCacheRequest = {
properties: {
annotations: {
type: 'commons_CacheAnnotationsMap',
},
cache_key: {
type: 'string',
isRequired: true,
},
cache_version: {
type: 'string',
isRequired: true,
},
restore_keys: {
type: 'array',
contains: {
type: 'string',
},
},
vcs_ref: {
type: 'string',
},
vcs_repository: {
type: 'string',
},
},
} as const;

View File

@ -3,6 +3,12 @@
/* eslint-disable */
export const $commons_GetCacheResponse = {
properties: {
annotations: {
type: 'commons_CacheAnnotationsMap',
},
cache_entry: {
type: 'commons_CacheEntry',
},
gcs: {
type: 'commons_GCSGetCacheReponse',
},

View File

@ -3,15 +3,28 @@
/* eslint-disable */
export const $commons_ReserveCacheRequest = {
properties: {
annotations: {
type: 'commons_CacheAnnotationsMap',
},
cache_key: {
type: 'string',
isRequired: true,
},
cache_version: {
type: 'string',
isRequired: true,
},
content_type: {
type: 'string',
},
number_of_chunks: {
type: 'number',
},
vcs_ref: {
type: 'string',
},
vcs_repository: {
type: 'string',
},
},
} as const;

View File

@ -3,6 +3,9 @@
/* eslint-disable */
export const $commons_ReserveCacheResponse = {
properties: {
annotations: {
type: 'commons_CacheAnnotationsMap',
},
gcs: {
type: 'commons_GCSReserveCacheResponse',
},

View File

@ -3,6 +3,9 @@
/* eslint-disable */
export const $commons_S3GetCacheResponse = {
properties: {
annotations: {
type: 'commons_CacheAnnotationsMap',
},
cache_key: {
type: 'string',
},

View File

@ -1,23 +1,45 @@
import {deleteCache, restoreCache, saveCache} from './cache'
import {getCacheVersion} from './internal/cacheHttpClient'
import {getCompressionMethod} from './internal/cacheUtils'
process.env['WARPBUILD_CACHE_URL'] = 'http://localhost:8002'
process.env['WARPBUILD_CACHE_URL'] = 'https://cache.dev.warpbuild.dev'
// process.env['WARPBUILD_CACHE_URL'] = 'http://localhost:8000'
process.env['RUNNER_TEMP'] = '/Users/prajjwal/Repos/warpbuild/playground/tmp_fs'
process.env['NODE_DEBUG'] = 'http'
process.env['WARPBUILD_RUNNER_VERIFICATION_TOKEN'] =
'eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3MTMwNzE5ODgsInJlcG8iOiJiZW5jaG1hcmtzIiwicmVwb093bmVyIjoiV2FycEJ1aWxkcyIsIngtd2FycGJ1aWxkLW9yZ2FuaXphdGlvbi1pZCI6IndmbW4wODBlaWY4cm5pd3EifQ.Wat-RATKl_KB39SF6egch3nF3_dD8hDE3lbl9wm7AyBUs9pUNEDejJtgHO0xQfGvSN-qRTPbJ_glHKPUIRHE3w'
process.env['RUNNER_DEBUG'] = '1'
process.env['WARPBUILD_RUNNER_VERIFICATION_TOKEN'] = '<Set_token_here>'
process.env['GITHUB_REPOSITORY'] = 'Warpbuilds/backend-cache'
process.env['GITHUB_REF'] = 'refs/heads/main'
saveCache(
['/Users/prajjwal/Repos/warpbuild/playground/test_fs'],
'test-fs-local-key',
true
)
// saveCache(
// ['/Users/prajjwal/Repos/warpbuild/playground/test_fs'],
// 'test-fs-local-key',
// true
// )
restoreCache(
['/Users/prajjwal/Repos/warpbuild/playground/test_fs'],
'test-fs-local-key',
[],
{},
true
)
// saveCache(
// ['/Users/prajjwal/Repos/warpbuild/playground/test_fs'],
// 'test-fs-local-key-2',
// true
// )
deleteCache(['test-fs-local-key'])
// saveCache(
// ['/Users/prajjwal/Repos/warpbuild/playground/test_fs'],
// 'test-fs-local-key',
// true,
// true
// )
// restoreCache(
// ['/Users/prajjwal/Repos/warpbuild/playground/test_fs'],
// 'test-fs-local-key-3',
// ['test-fs'],
// {},
// true,
// false
// )
// deleteCache(
// ['/Users/prajjwal/Repos/warpbuild/playground/test_fs'],
// 'test-fs-local-key'
// )