Skip to content

Update folder structure for cache #2000

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
8 changes: 4 additions & 4 deletions packages/cache/__tests__/cacheHttpClient.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import {downloadCache} from '../src/internal/cacheHttpClient'
import {getCacheVersion} from '../src/internal/cacheUtils'
import {CompressionMethod} from '../src/internal/constants'
import * as downloadUtils from '../src/internal/downloadUtils'
import {getCacheVersion} from '../src/internal/shared/cacheUtils'
import {CompressionMethod} from '../src/internal/shared/constants'
import * as downloadUtils from '../src/internal/shared/downloadUtils'
import {DownloadOptions, getDownloadOptions} from '../src/options'

jest.mock('../src/internal/downloadUtils')
jest.mock('../src/internal/shared/downloadUtils')

test('getCacheVersion does not mutate arguments', async () => {
const paths = ['node_modules']
Expand Down
2 changes: 1 addition & 1 deletion packages/cache/__tests__/cacheUtils.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {promises as fs} from 'fs'
import * as path from 'path'
import * as cacheUtils from '../src/internal/cacheUtils'
import * as cacheUtils from '../src/internal/shared/cacheUtils'

beforeEach(() => {
jest.resetModules()
Expand Down
2 changes: 1 addition & 1 deletion packages/cache/__tests__/config.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as config from '../src/internal/config'
import * as config from '../src/internal/shared/config'

beforeEach(() => {
jest.resetModules()
Expand Down
2 changes: 1 addition & 1 deletion packages/cache/__tests__/downloadUtils.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as core from '@actions/core'
import {DownloadProgress} from '../src/internal/downloadUtils'
import {DownloadProgress} from '../src/internal/shared/downloadUtils'

test('download progress tracked correctly', () => {
const progress = new DownloadProgress(1000)
Expand Down
4 changes: 2 additions & 2 deletions packages/cache/__tests__/requestUtils.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {retry, retryTypedResponse} from '../src/internal/requestUtils'
import {retry, retryTypedResponse} from '../src/internal/shared/requestUtils'
import {HttpClientError} from '@actions/http-client'
import * as requestUtils from '../src/internal/requestUtils'
import * as requestUtils from '../src/internal/shared/requestUtils'

interface ITestResponse {
statusCode: number
Expand Down
11 changes: 7 additions & 4 deletions packages/cache/__tests__/restoreCache.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@ import * as core from '@actions/core'
import * as path from 'path'
import {restoreCache} from '../src/cache'
import * as cacheHttpClient from '../src/internal/cacheHttpClient'
import * as cacheUtils from '../src/internal/cacheUtils'
import {CacheFilename, CompressionMethod} from '../src/internal/constants'
import * as cacheUtils from '../src/internal/shared/cacheUtils'
import {
CacheFilename,
CompressionMethod
} from '../src/internal/shared/constants'
import {ArtifactCacheEntry} from '../src/internal/contracts'
import * as tar from '../src/internal/tar'

jest.mock('../src/internal/cacheHttpClient')
jest.mock('../src/internal/cacheUtils')
jest.mock('../src/internal/shared/cacheUtils')
jest.mock('../src/internal/tar')

beforeAll(() => {
Expand All @@ -19,7 +22,7 @@ beforeAll(() => {
jest.spyOn(core, 'error').mockImplementation(() => {})

jest.spyOn(cacheUtils, 'getCacheFileName').mockImplementation(cm => {
const actualUtils = jest.requireActual('../src/internal/cacheUtils')
const actualUtils = jest.requireActual('../src/internal/shared/cacheUtils')
return actualUtils.getCacheFileName(cm)
})
})
Expand Down
15 changes: 9 additions & 6 deletions packages/cache/__tests__/restoreCacheV2.test.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
import * as core from '@actions/core'
import * as path from 'path'
import * as tar from '../src/internal/tar'
import * as config from '../src/internal/config'
import * as cacheUtils from '../src/internal/cacheUtils'
import * as config from '../src/internal/shared/config'
import * as cacheUtils from '../src/internal/shared/cacheUtils'
import * as cacheHttpClient from '../src/internal/cacheHttpClient'
import {restoreCache} from '../src/cache'
import {CacheFilename, CompressionMethod} from '../src/internal/constants'
import {
CacheFilename,
CompressionMethod
} from '../src/internal/shared/constants'
import {CacheServiceClientJSON} from '../src/generated/results/api/v1/cache.twirp-client'
import {DownloadOptions} from '../src/options'

jest.mock('../src/internal/cacheHttpClient')
jest.mock('../src/internal/cacheUtils')
jest.mock('../src/internal/config')
jest.mock('../src/internal/shared/cacheUtils')
jest.mock('../src/internal/shared/config')
jest.mock('../src/internal/tar')

let logDebugMock: jest.SpyInstance
Expand All @@ -25,7 +28,7 @@ beforeAll(() => {
jest.spyOn(core, 'error').mockImplementation(() => {})

jest.spyOn(cacheUtils, 'getCacheFileName').mockImplementation(cm => {
const actualUtils = jest.requireActual('../src/internal/cacheUtils')
const actualUtils = jest.requireActual('../src/internal/shared/cacheUtils')
return actualUtils.getCacheFileName(cm)
})

Expand Down
15 changes: 9 additions & 6 deletions packages/cache/__tests__/saveCache.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@ import * as core from '@actions/core'
import * as path from 'path'
import {saveCache} from '../src/cache'
import * as cacheHttpClient from '../src/internal/cacheHttpClient'
import * as cacheUtils from '../src/internal/cacheUtils'
import * as config from '../src/internal/config'
import {CacheFilename, CompressionMethod} from '../src/internal/constants'
import * as cacheUtils from '../src/internal/shared/cacheUtils'
import * as config from '../src/internal/shared/config'
import {
CacheFilename,
CompressionMethod
} from '../src/internal/shared/constants'
import * as tar from '../src/internal/tar'
import {TypedResponse} from '@actions/http-client/lib/interfaces'
import {
Expand All @@ -14,8 +17,8 @@ import {
import {HttpClientError} from '@actions/http-client'

jest.mock('../src/internal/cacheHttpClient')
jest.mock('../src/internal/cacheUtils')
jest.mock('../src/internal/config')
jest.mock('../src/internal/shared/cacheUtils')
jest.mock('../src/internal/shared/config')
jest.mock('../src/internal/tar')

beforeAll(() => {
Expand All @@ -25,7 +28,7 @@ beforeAll(() => {
jest.spyOn(core, 'warning').mockImplementation(() => {})
jest.spyOn(core, 'error').mockImplementation(() => {})
jest.spyOn(cacheUtils, 'getCacheFileName').mockImplementation(cm => {
const actualUtils = jest.requireActual('../src/internal/cacheUtils')
const actualUtils = jest.requireActual('../src/internal/shared/cacheUtils')
return actualUtils.getCacheFileName(cm)
})
jest.spyOn(cacheUtils, 'resolvePaths').mockImplementation(async filePaths => {
Expand Down
9 changes: 6 additions & 3 deletions packages/cache/__tests__/saveCacheV2.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import * as core from '@actions/core'
import * as path from 'path'
import {saveCache} from '../src/cache'
import * as cacheUtils from '../src/internal/cacheUtils'
import {CacheFilename, CompressionMethod} from '../src/internal/constants'
import * as config from '../src/internal/config'
import * as cacheUtils from '../src/internal/shared/cacheUtils'
import {
CacheFilename,
CompressionMethod
} from '../src/internal/shared/constants'
import * as config from '../src/internal/shared/config'
import * as tar from '../src/internal/tar'
import {CacheServiceClientJSON} from '../src/generated/results/api/v1/cache.twirp-client'
import * as cacheHttpClient from '../src/internal/cacheHttpClient'
Expand Down
4 changes: 2 additions & 2 deletions packages/cache/__tests__/tar.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import {
ManifestFilename,
SystemTarPathOnWindows,
TarFilename
} from '../src/internal/constants'
} from '../src/internal/shared/constants'
import * as tar from '../src/internal/tar'
import * as utils from '../src/internal/cacheUtils'
import * as utils from '../src/internal/shared/cacheUtils'
// eslint-disable-next-line @typescript-eslint/no-require-imports
import fs = require('fs')

Expand Down
2 changes: 1 addition & 1 deletion packages/cache/__tests__/uploadUtils.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as uploadUtils from '../src/internal/uploadUtils'
import * as uploadUtils from '../src/internal/shared/uploadUtils'
import {TransferProgressEvent} from '@azure/ms-rest-js'

test('upload progress tracked correctly', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/cache/__tests__/util.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {maskSigUrl, maskSecretUrls} from '../src/internal/shared/util'
import {maskSigUrl, maskSecretUrls} from '../src/internal/shared/requestUtils'
import {setSecret, debug} from '@actions/core'

jest.mock('@actions/core')
Expand Down
8 changes: 4 additions & 4 deletions packages/cache/src/cache.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import * as core from '@actions/core'
import * as path from 'path'
import * as utils from './internal/cacheUtils'
import * as utils from './internal/shared/cacheUtils'
import * as cacheHttpClient from './internal/cacheHttpClient'
import * as cacheTwirpClient from './internal/shared/cacheTwirpClient'
import {getCacheServiceVersion, isGhes} from './internal/config'
import * as cacheTwirpClient from './internal/cacheTwirpClient'
import {getCacheServiceVersion, isGhes} from './internal/shared/config'
import {DownloadOptions, UploadOptions} from './options'
import {createTar, extractTar, listTar} from './internal/tar'
import {
Expand All @@ -12,7 +12,7 @@ import {
FinalizeCacheEntryUploadResponse,
GetCacheEntryDownloadURLRequest
} from './generated/results/api/v1/cache'
import {CacheFileSizeLimit} from './internal/constants'
import {CacheFileSizeLimit} from './internal/shared/constants'
export class ValidationError extends Error {
constructor(message: string) {
super(message)
Expand Down
10 changes: 5 additions & 5 deletions packages/cache/src/internal/cacheHttpClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import {
} from '@actions/http-client/lib/interfaces'
import * as fs from 'fs'
import {URL} from 'url'
import * as utils from './cacheUtils'
import {uploadCacheArchiveSDK} from './uploadUtils'
import * as utils from './shared/cacheUtils'
import {uploadCacheArchiveSDK} from './shared/uploadUtils'
import {
ArtifactCacheEntry,
InternalCacheOptions,
Expand All @@ -22,7 +22,7 @@ import {
downloadCacheHttpClient,
downloadCacheHttpClientConcurrent,
downloadCacheStorageSDK
} from './downloadUtils'
} from './shared/downloadUtils'
import {
DownloadOptions,
UploadOptions,
Expand All @@ -33,8 +33,8 @@ import {
isSuccessStatusCode,
retryHttpClientResponse,
retryTypedResponse
} from './requestUtils'
import {getCacheServiceURL} from './config'
} from './shared/requestUtils'
import {getCacheServiceURL} from './shared/config'
import {getUserAgentString} from './shared/user-agent'

function getCacheApiUrl(resource: string): string {
Expand Down
Loading
Loading