diff --git a/packages/cache/__tests__/saveCacheV2.test.ts b/packages/cache/__tests__/saveCacheV2.test.ts index 2c69c5ee..ab98bc81 100644 --- a/packages/cache/__tests__/saveCacheV2.test.ts +++ b/packages/cache/__tests__/saveCacheV2.test.ts @@ -1,14 +1,14 @@ import * as core from '@actions/core' import * as path from 'path' -import { saveCache } from '../src/cache' +import {saveCache} from '../src/cache' import * as cacheUtils from '../src/internal/cacheUtils' -import { CacheFilename, CompressionMethod } from '../src/internal/constants' +import {CacheFilename, CompressionMethod} from '../src/internal/constants' import * as config from '../src/internal/config' import * as tar from '../src/internal/tar' -import { CacheServiceClientJSON } from '../src/generated/results/api/v1/cache.twirp' +import {CacheServiceClientJSON} from '../src/generated/results/api/v1/cache.twirp' import * as uploadCacheModule from '../src/internal/uploadUtils' -import { BlobUploadCommonResponse } from '@azure/storage-blob' -import { InvalidResponseError } from '../src/internal/shared/errors' +import {BlobUploadCommonResponse} from '@azure/storage-blob' +import {InvalidResponseError} from '../src/internal/shared/errors' let logDebugMock: jest.SpyInstance @@ -28,11 +28,11 @@ jest.mock('@azure/storage-blob', () => ({ beforeAll(() => { process.env['ACTIONS_RUNTIME_TOKEN'] = 'token' - jest.spyOn(console, 'log').mockImplementation(() => { }) - jest.spyOn(core, 'debug').mockImplementation(() => { }) - jest.spyOn(core, 'info').mockImplementation(() => { }) - jest.spyOn(core, 'warning').mockImplementation(() => { }) - jest.spyOn(core, 'error').mockImplementation(() => { }) + jest.spyOn(console, 'log').mockImplementation(() => {}) + jest.spyOn(core, 'debug').mockImplementation(() => {}) + jest.spyOn(core, 'info').mockImplementation(() => {}) + jest.spyOn(core, 'warning').mockImplementation(() => {}) + jest.spyOn(core, 'error').mockImplementation(() => {}) jest.spyOn(cacheUtils, 'resolvePaths').mockImplementation(async filePaths => { return filePaths.map(x => path.resolve(x)) }) @@ -100,7 +100,7 @@ test('create cache entry failure', async () => { const createCacheEntryMock = jest .spyOn(CacheServiceClientJSON.prototype, 'CreateCacheEntry') - .mockReturnValue(Promise.resolve({ ok: false, signedUploadUrl: '' })) + .mockReturnValue(Promise.resolve({ok: false, signedUploadUrl: ''})) const createTarMock = jest.spyOn(tar, 'createTar') const finalizeCacheEntryMock = jest.spyOn( @@ -152,7 +152,7 @@ test('finalize save cache failure', async () => { const createCacheEntryMock = jest .spyOn(CacheServiceClientJSON.prototype, 'CreateCacheEntry') .mockReturnValue( - Promise.resolve({ ok: true, signedUploadUrl: signedUploadURL }) + Promise.resolve({ok: true, signedUploadUrl: signedUploadURL}) ) const createTarMock = jest.spyOn(tar, 'createTar') @@ -179,7 +179,7 @@ test('finalize save cache failure', async () => { const finalizeCacheEntryMock = jest .spyOn(CacheServiceClientJSON.prototype, 'FinalizeCacheEntryUpload') - .mockReturnValue(Promise.resolve({ ok: false, entryId: '' })) + .mockReturnValue(Promise.resolve({ok: false, entryId: ''})) const cacheId = await saveCache([paths], key) @@ -218,7 +218,7 @@ test('save with uploadCache Server error will fail', async () => { jest .spyOn(CacheServiceClientJSON.prototype, 'CreateCacheEntry') .mockReturnValue( - Promise.resolve({ ok: true, signedUploadUrl: signedUploadURL }) + Promise.resolve({ok: true, signedUploadUrl: signedUploadURL}) ) const archiveFileSize = 1024 @@ -241,7 +241,7 @@ test('uploadFile returns 500', async () => { jest .spyOn(CacheServiceClientJSON.prototype, 'CreateCacheEntry') .mockReturnValue( - Promise.resolve({ ok: true, signedUploadUrl: signedUploadURL }) + Promise.resolve({ok: true, signedUploadUrl: signedUploadURL}) ) const archiveFileSize = 1024 @@ -279,7 +279,7 @@ test('save with valid inputs uploads a cache', async () => { jest .spyOn(CacheServiceClientJSON.prototype, 'CreateCacheEntry') .mockReturnValue( - Promise.resolve({ ok: true, signedUploadUrl: signedUploadURL }) + Promise.resolve({ok: true, signedUploadUrl: signedUploadURL}) ) const uploadCacheMock = jest @@ -300,7 +300,7 @@ test('save with valid inputs uploads a cache', async () => { const finalizeCacheEntryMock = jest .spyOn(CacheServiceClientJSON.prototype, 'FinalizeCacheEntryUpload') - .mockReturnValue(Promise.resolve({ ok: true, entryId: cacheId.toString() })) + .mockReturnValue(Promise.resolve({ok: true, entryId: cacheId.toString()})) const expectedCacheId = await saveCache([paths], key) diff --git a/packages/cache/src/cache.ts b/packages/cache/src/cache.ts index adc8b915..1617b793 100644 --- a/packages/cache/src/cache.ts +++ b/packages/cache/src/cache.ts @@ -3,18 +3,18 @@ import * as path from 'path' import * as utils from './internal/cacheUtils' import * as cacheHttpClient from './internal/cacheHttpClient' import * as cacheTwirpClient from './internal/shared/cacheTwirpClient' -import { downloadCacheStorageSDK } from './internal/downloadUtils' -import { getCacheServiceVersion, isGhes } from './internal/config' -import { DownloadOptions, UploadOptions } from './options' -import { createTar, extractTar, listTar } from './internal/tar' +import {downloadCacheStorageSDK} from './internal/downloadUtils' +import {getCacheServiceVersion, isGhes} from './internal/config' +import {DownloadOptions, UploadOptions} from './options' +import {createTar, extractTar, listTar} from './internal/tar' import { CreateCacheEntryRequest, FinalizeCacheEntryUploadRequest, FinalizeCacheEntryUploadResponse, GetCacheEntryDownloadURLRequest } from './generated/results/api/v1/cache' -import { CacheFileSizeLimit } from './internal/constants' -import { uploadCacheArchiveSDK } from './internal/uploadUtils' +import {CacheFileSizeLimit} from './internal/constants' +import {uploadCacheArchiveSDK} from './internal/uploadUtils' export class ValidationError extends Error { constructor(message: string) { super(message) @@ -275,9 +275,9 @@ async function restoreCacheV2( response.signedDownloadUrl, archivePath, options || - ({ - timeoutInMs: 30000 - } as DownloadOptions) + ({ + timeoutInMs: 30000 + } as DownloadOptions) ) const archiveFileSize = utils.getArchiveFileSizeInBytes(archivePath) @@ -414,9 +414,9 @@ async function saveCacheV1( } else if (reserveCacheResponse?.statusCode === 400) { throw new Error( reserveCacheResponse?.error?.message ?? - `Cache size of ~${Math.round( - archiveFileSize / (1024 * 1024) - )} MB (${archiveFileSize} B) is over the data cap limit, not saving cache.` + `Cache size of ~${Math.round( + archiveFileSize / (1024 * 1024) + )} MB (${archiveFileSize} B) is over the data cap limit, not saving cache.` ) } else { throw new ReserveCacheError( diff --git a/packages/cache/src/internal/uploadUtils.ts b/packages/cache/src/internal/uploadUtils.ts index ffcb37f8..60b4a315 100644 --- a/packages/cache/src/internal/uploadUtils.ts +++ b/packages/cache/src/internal/uploadUtils.ts @@ -5,13 +5,12 @@ import { BlockBlobClient, BlockBlobParallelUploadOptions } from '@azure/storage-blob' -import { InvalidResponseError } from './shared/errors' +import {InvalidResponseError} from './shared/errors' -export async function uploadCacheArchiveSDK - ( - signedUploadURL: string, - archivePath: string - ): Promise { +export async function uploadCacheArchiveSDK( + signedUploadURL: string, + archivePath: string +): Promise { // Specify data transfer options const uploadOptions: BlockBlobParallelUploadOptions = { blockSize: 4 * 1024 * 1024, // 4 MiB max block size