mirror of https://github.com/actions/toolkit
Linter fixes and remove unnecessary dependency
parent
267841d7bd
commit
e2028d43a2
|
@ -1,4 +1,4 @@
|
||||||
import { promises as fs } from 'fs'
|
import {promises as fs} from 'fs'
|
||||||
import * as path from 'path'
|
import * as path from 'path'
|
||||||
import * as cacheUtils from '../src/internal/cacheUtils'
|
import * as cacheUtils from '../src/internal/cacheUtils'
|
||||||
|
|
||||||
|
|
|
@ -1,26 +1,25 @@
|
||||||
import { promises as fs } from 'fs'
|
|
||||||
import * as config from '../src/internal/config'
|
import * as config from '../src/internal/config'
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
jest.resetModules()
|
jest.resetModules()
|
||||||
})
|
})
|
||||||
|
|
||||||
test('isGhes returns false for github.com', async () => {
|
test('isGhes returns false for github.com', async () => {
|
||||||
process.env.GITHUB_SERVER_URL = 'https://github.com'
|
process.env.GITHUB_SERVER_URL = 'https://github.com'
|
||||||
expect(config.isGhes()).toBe(false)
|
expect(config.isGhes()).toBe(false)
|
||||||
})
|
})
|
||||||
|
|
||||||
test('isGhes returns false for ghe.com', async () => {
|
test('isGhes returns false for ghe.com', async () => {
|
||||||
process.env.GITHUB_SERVER_URL = 'https://somedomain.ghe.com'
|
process.env.GITHUB_SERVER_URL = 'https://somedomain.ghe.com'
|
||||||
expect(config.isGhes()).toBe(false)
|
expect(config.isGhes()).toBe(false)
|
||||||
})
|
})
|
||||||
|
|
||||||
test('isGhes returns true for enterprise URL', async () => {
|
test('isGhes returns true for enterprise URL', async () => {
|
||||||
process.env.GITHUB_SERVER_URL = 'https://my-enterprise.github.com'
|
process.env.GITHUB_SERVER_URL = 'https://my-enterprise.github.com'
|
||||||
expect(config.isGhes()).toBe(true)
|
expect(config.isGhes()).toBe(true)
|
||||||
})
|
})
|
||||||
|
|
||||||
test('isGhes returns false for ghe.localhost', () => {
|
test('isGhes returns false for ghe.localhost', () => {
|
||||||
process.env.GITHUB_SERVER_URL = 'https://my.domain.ghe.localhost'
|
process.env.GITHUB_SERVER_URL = 'https://my.domain.ghe.localhost'
|
||||||
expect(config.isGhes()).toBe(false)
|
expect(config.isGhes()).toBe(false)
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
import * as core from '@actions/core'
|
import * as core from '@actions/core'
|
||||||
import * as path from 'path'
|
import * as path from 'path'
|
||||||
import { saveCache } from '../src/cache'
|
import {saveCache} from '../src/cache'
|
||||||
import * as cacheHttpClient from '../src/internal/cacheHttpClient'
|
import * as cacheHttpClient from '../src/internal/cacheHttpClient'
|
||||||
import * as cacheUtils from '../src/internal/cacheUtils'
|
import * as cacheUtils from '../src/internal/cacheUtils'
|
||||||
import * as config from '../src/internal/config'
|
import * as config from '../src/internal/config'
|
||||||
import { CacheFilename, CompressionMethod } from '../src/internal/constants'
|
import {CacheFilename, CompressionMethod} from '../src/internal/constants'
|
||||||
import * as tar from '../src/internal/tar'
|
import * as tar from '../src/internal/tar'
|
||||||
import { TypedResponse } from '@actions/http-client/lib/interfaces'
|
import {TypedResponse} from '@actions/http-client/lib/interfaces'
|
||||||
import {
|
import {
|
||||||
ReserveCacheResponse,
|
ReserveCacheResponse,
|
||||||
ITypedResponseWithError
|
ITypedResponseWithError
|
||||||
} from '../src/internal/contracts'
|
} from '../src/internal/contracts'
|
||||||
import { HttpClientError } from '@actions/http-client'
|
import {HttpClientError} from '@actions/http-client'
|
||||||
|
|
||||||
jest.mock('../src/internal/cacheHttpClient')
|
jest.mock('../src/internal/cacheHttpClient')
|
||||||
jest.mock('../src/internal/cacheUtils')
|
jest.mock('../src/internal/cacheUtils')
|
||||||
|
@ -19,11 +19,11 @@ jest.mock('../src/internal/config')
|
||||||
jest.mock('../src/internal/tar')
|
jest.mock('../src/internal/tar')
|
||||||
|
|
||||||
beforeAll(() => {
|
beforeAll(() => {
|
||||||
jest.spyOn(console, 'log').mockImplementation(() => { })
|
jest.spyOn(console, 'log').mockImplementation(() => {})
|
||||||
jest.spyOn(core, 'debug').mockImplementation(() => { })
|
jest.spyOn(core, 'debug').mockImplementation(() => {})
|
||||||
jest.spyOn(core, 'info').mockImplementation(() => { })
|
jest.spyOn(core, 'info').mockImplementation(() => {})
|
||||||
jest.spyOn(core, 'warning').mockImplementation(() => { })
|
jest.spyOn(core, 'warning').mockImplementation(() => {})
|
||||||
jest.spyOn(core, 'error').mockImplementation(() => { })
|
jest.spyOn(core, 'error').mockImplementation(() => {})
|
||||||
jest.spyOn(cacheUtils, 'getCacheFileName').mockImplementation(cm => {
|
jest.spyOn(cacheUtils, 'getCacheFileName').mockImplementation(cm => {
|
||||||
const actualUtils = jest.requireActual('../src/internal/cacheUtils')
|
const actualUtils = jest.requireActual('../src/internal/cacheUtils')
|
||||||
return actualUtils.getCacheFileName(cm)
|
return actualUtils.getCacheFileName(cm)
|
||||||
|
@ -231,7 +231,7 @@ test('save with server error should fail', async () => {
|
||||||
.mockImplementation(async () => {
|
.mockImplementation(async () => {
|
||||||
const response: TypedResponse<ReserveCacheResponse> = {
|
const response: TypedResponse<ReserveCacheResponse> = {
|
||||||
statusCode: 500,
|
statusCode: 500,
|
||||||
result: { cacheId },
|
result: {cacheId},
|
||||||
headers: {}
|
headers: {}
|
||||||
}
|
}
|
||||||
return response
|
return response
|
||||||
|
@ -285,7 +285,7 @@ test('save with valid inputs uploads a cache', async () => {
|
||||||
.mockImplementation(async () => {
|
.mockImplementation(async () => {
|
||||||
const response: TypedResponse<ReserveCacheResponse> = {
|
const response: TypedResponse<ReserveCacheResponse> = {
|
||||||
statusCode: 500,
|
statusCode: 500,
|
||||||
result: { cacheId },
|
result: {cacheId},
|
||||||
headers: {}
|
headers: {}
|
||||||
}
|
}
|
||||||
return response
|
return response
|
||||||
|
|
|
@ -3,18 +3,18 @@ import * as path from 'path'
|
||||||
import * as utils from './internal/cacheUtils'
|
import * as utils from './internal/cacheUtils'
|
||||||
import * as cacheHttpClient from './internal/cacheHttpClient'
|
import * as cacheHttpClient from './internal/cacheHttpClient'
|
||||||
import * as cacheTwirpClient from './internal/shared/cacheTwirpClient'
|
import * as cacheTwirpClient from './internal/shared/cacheTwirpClient'
|
||||||
import { getCacheServiceVersion, isGhes } from './internal/config'
|
import {getCacheServiceVersion, isGhes} from './internal/config'
|
||||||
import { DownloadOptions, UploadOptions } from './options'
|
import {DownloadOptions, UploadOptions} from './options'
|
||||||
import { createTar, extractTar, listTar } from './internal/tar'
|
import {createTar, extractTar, listTar} from './internal/tar'
|
||||||
import {
|
import {
|
||||||
CreateCacheEntryRequest,
|
CreateCacheEntryRequest,
|
||||||
FinalizeCacheEntryUploadRequest,
|
FinalizeCacheEntryUploadRequest,
|
||||||
FinalizeCacheEntryUploadResponse,
|
FinalizeCacheEntryUploadResponse,
|
||||||
GetCacheEntryDownloadURLRequest
|
GetCacheEntryDownloadURLRequest
|
||||||
} from './generated/results/api/v1/cache'
|
} from './generated/results/api/v1/cache'
|
||||||
import { CacheFileSizeLimit } from './internal/constants'
|
import {CacheFileSizeLimit} from './internal/constants'
|
||||||
import { uploadCacheFile } from './internal/blob/upload-cache'
|
import {uploadCacheFile} from './internal/blob/upload-cache'
|
||||||
import { downloadCacheFile } from './internal/blob/download-cache'
|
import {downloadCacheFile} from './internal/blob/download-cache'
|
||||||
export class ValidationError extends Error {
|
export class ValidationError extends Error {
|
||||||
constructor(message: string) {
|
constructor(message: string) {
|
||||||
super(message)
|
super(message)
|
||||||
|
@ -397,9 +397,9 @@ async function saveCacheV1(
|
||||||
} else if (reserveCacheResponse?.statusCode === 400) {
|
} else if (reserveCacheResponse?.statusCode === 400) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
reserveCacheResponse?.error?.message ??
|
reserveCacheResponse?.error?.message ??
|
||||||
`Cache size of ~${Math.round(
|
`Cache size of ~${Math.round(
|
||||||
archiveFileSize / (1024 * 1024)
|
archiveFileSize / (1024 * 1024)
|
||||||
)} MB (${archiveFileSize} B) is over the data cap limit, not saving cache.`
|
)} MB (${archiveFileSize} B) is over the data cap limit, not saving cache.`
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
throw new ReserveCacheError(
|
throw new ReserveCacheError(
|
||||||
|
|
Loading…
Reference in New Issue