mirror of https://github.com/actions/toolkit
Troubleshoot
parent
4a272e9053
commit
db1d01308c
|
@ -1,8 +1,8 @@
|
|||
import {UploadProgress} from '../src/internal/uploadUtils'
|
||||
import * as uploadUtils from '../src/internal/uploadUtils'
|
||||
import {TransferProgressEvent} from '@azure/ms-rest-js'
|
||||
|
||||
test('upload progress tracked correctly', () => {
|
||||
const progress = new UploadProgress(1000)
|
||||
const progress = new uploadUtils.UploadProgress(1000)
|
||||
|
||||
expect(progress.contentLength).toBe(1000)
|
||||
expect(progress.sentBytes).toBe(0)
|
||||
|
@ -56,3 +56,25 @@ test('upload progress tracked correctly', () => {
|
|||
expect(progress.getTransferredBytes()).toBe(1000)
|
||||
expect(progress.isDone()).toBe(true)
|
||||
})
|
||||
|
||||
// test('upload to azure blob storage is successful', () => {
|
||||
// const archivePath = 'path/to/archive.tzst'
|
||||
// const signedUploadURL = 'https://storage10.blob.core.windows.net/cache-container/3fe-60?se=2024-12-002T11%3A08%3A58Z&sv=2024-11-04'
|
||||
// const options: UploadOptions = {
|
||||
// useAzureSdk: true,
|
||||
// uploadChunkSize: 64 * 1024 * 1024,
|
||||
// uploadConcurrency: 8
|
||||
// }
|
||||
|
||||
// jest.spyOn(uploadUtils.UploadProgress.prototype, 'onProgress').mockImplementation(() => (progress: TransferProgressEvent) => {
|
||||
// return progress.loadedBytes
|
||||
// })
|
||||
|
||||
// jest.spyOn(uploadUtils.UploadProgress.prototype, 'onProgress').mockImplementation(() => (progress: TransferProgressEvent) => {
|
||||
// return progress.loadedBytes
|
||||
// })
|
||||
|
||||
// const response = uploadUtils.uploadCacheArchiveSDK(signedUploadURL, archivePath, options)
|
||||
|
||||
// expect(response).toBeInstanceOf(Promise)
|
||||
// })
|
||||
|
|
|
@ -561,6 +561,7 @@ async function saveCacheV2(
|
|||
} else {
|
||||
core.warning(`Failed to save: ${typedError.message}`)
|
||||
}
|
||||
throw error
|
||||
} finally {
|
||||
// Try to delete the archive to save space
|
||||
try {
|
||||
|
|
|
@ -140,27 +140,30 @@ export async function uploadCacheArchiveSDK(
|
|||
onProgress: uploadProgress.onProgress()
|
||||
}
|
||||
|
||||
// try {
|
||||
uploadProgress.startDisplayTimer()
|
||||
try {
|
||||
uploadProgress.startDisplayTimer()
|
||||
|
||||
core.debug(
|
||||
`BlobClient: ${blobClient.name}:${blobClient.accountName}:${blobClient.containerName}`
|
||||
)
|
||||
|
||||
const response = await blockBlobClient.uploadFile(archivePath, uploadOptions)
|
||||
|
||||
// TODO: better management of non-retryable errors
|
||||
if (response._response.status >= 400) {
|
||||
throw new InvalidResponseError(
|
||||
`Upload failed with status code ${response._response.status}`
|
||||
core.debug(
|
||||
`BlobClient: ${blobClient.name}:${blobClient.accountName}:${blobClient.containerName}`
|
||||
)
|
||||
}
|
||||
|
||||
return response
|
||||
// } catch (error) {
|
||||
// core.debug(`Error uploading cache archive: ${error}`)
|
||||
// throw error
|
||||
// } finally {
|
||||
// uploadProgress.stopDisplayTimer()
|
||||
// }
|
||||
const response = await blockBlobClient.uploadFile(
|
||||
archivePath,
|
||||
uploadOptions
|
||||
)
|
||||
|
||||
// TODO: better management of non-retryable errors
|
||||
if (response._response.status >= 400) {
|
||||
throw new InvalidResponseError(
|
||||
`Upload failed with status code ${response._response.status}`
|
||||
)
|
||||
}
|
||||
|
||||
return response
|
||||
} catch (error) {
|
||||
core.debug(`Error uploading cache archive: ${error}`)
|
||||
throw error
|
||||
} finally {
|
||||
uploadProgress.stopDisplayTimer()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue