Compare commits

...

75 Commits

Author SHA1 Message Date
Jonathan Tamsut 42b0077729 resolve merge conflicts 2024-04-23 11:15:38 -07:00
Vallie Joseph bcaba45bb9 reverting http update 2024-04-08 18:24:09 +00:00
Vallie Joseph da5e926162 removing promise wrap 2024-04-08 17:39:15 +00:00
Vallie Joseph 6e1d7543c4 updating tests 2024-04-08 17:21:24 +00:00
Vallie Joseph 67c383759c updating errors 2024-04-08 15:43:51 +00:00
Vallie Joseph 4f54b861cf updating errors 2024-04-08 15:40:32 +00:00
Vallie Joseph e7f45861f6 Merge branch 'main' into vmjoseph/node-js-monitor 2024-04-08 15:31:14 +00:00
Vallie Joseph ce603525f8 adding asysnc zip entry logic handling 2024-04-08 15:27:00 +00:00
Vallie Joseph 38f54e9d73 Adding debug statement for upload 2024-04-02 05:39:02 +00:00
Vallie Joseph c5f3463c0b adding more descriptive error 2024-04-02 05:25:10 +00:00
Vallie Joseph 96ef8d5d33 adding more error handling 2024-04-01 20:21:01 +00:00
Vallie Joseph 84d3cef541 Removing extra logs 2024-04-01 20:14:07 +00:00
Vallie Joseph a926fff385 adding queue back 2024-04-01 20:04:49 +00:00
Vallie Joseph a2a8a724c2 test queue 2024-04-01 20:01:19 +00:00
Vallie Joseph a8fa53b609 test async eachof 2024-04-01 19:57:11 +00:00
Vallie Joseph 23039a4345 adding asnyc handler back 2024-04-01 16:57:50 +00:00
Vallie Joseph 4778aebf5b adding asnyc handler back 2024-04-01 16:54:55 +00:00
Vallie Joseph 6eff4e928d adding more debug statements 2024-04-01 15:15:28 +00:00
Vallie Joseph 2c4f0f555e adding error checks 2024-04-01 15:07:28 +00:00
Vallie Joseph dea3595881 re-adding archiver for download 2024-04-01 14:33:36 +00:00
Vallie Joseph 4c878a66e7 adding back archiver 2024-04-01 14:30:14 +00:00
Vallie Joseph 2f2738e4ae removing old packages 2024-04-01 14:01:29 +00:00
Vallie Joseph 2d065559f7 Merge branch 'main' into vmjoseph/node-js-monitor 2024-04-01 13:59:46 +00:00
Vallie Joseph 2da528819c cleanup 2024-04-01 13:58:57 +00:00
Vallie Joseph 90ee020ccd cleaning up debug statements 2024-04-01 13:52:01 +00:00
Vallie Joseph c14e304555 adding more debugging statements 2024-03-28 21:17:54 +00:00
Vallie Joseph a2852cee6f adding catch to upload zip 2024-03-28 21:12:51 +00:00
Vallie Joseph 6d94ad125b Removing uneeded libs 2024-03-28 20:38:01 +00:00
Vallie Joseph d02a834fe3 Remove other debug statements 2024-03-28 20:12:52 +00:00
Vallie Joseph 0f23ae1184 re-adding old async/await pattern 2024-03-28 20:05:16 +00:00
Vallie Joseph 5288db3953 removing debugging statements 2024-03-28 19:57:01 +00:00
Vallie Joseph bc893bf1b4 adding compression level back 2024-03-28 19:48:15 +00:00
Vallie Joseph 9322468ef0 Adding pipe back 2024-03-28 19:32:40 +00:00
Vallie Joseph b6c87ceea7 Adding more error handlrs 2024-03-28 19:22:29 +00:00
Vallie Joseph 17c4cab8b2 adding constant zlib compression level 2024-03-28 19:16:10 +00:00
Vallie Joseph 59593338a6 defaulting compression level 2024-03-28 19:15:10 +00:00
Vallie Joseph 0a0e70d1cd Add another catch to see if upload stream is failing 2024-03-28 19:09:53 +00:00
Vallie Joseph c9e825e841 add blob client property check 2024-03-28 19:06:47 +00:00
Vallie Joseph 31a6086649 Adding concurrency and upload response logs 2024-03-28 18:59:41 +00:00
Vallie Joseph d2d69999e3 adding write check 2024-03-28 18:53:15 +00:00
Vallie Joseph 6ac9cbfda9 check if upload and zipload streams are writable 2024-03-28 18:51:00 +00:00
Vallie Joseph d597cf234f adding upload stream check 2024-03-28 18:46:31 +00:00
Vallie Joseph a768aa30c7 adding more logging 2024-03-28 18:43:58 +00:00
Vallie Joseph e4c0440c3a adding more logging 2024-03-28 18:40:37 +00:00
Vallie Joseph 26b62e0fd5 adding more logging 2024-03-28 18:38:52 +00:00
Vallie Joseph 73f526b642 adding closed check 2024-03-28 18:36:40 +00:00
Vallie Joseph 077846ed34 adding readable check 2024-03-28 18:34:07 +00:00
Vallie Joseph 180b75bf01 wrap promises in chain 2024-03-28 18:29:20 +00:00
Vallie Joseph f33a3f4748 Remove finalize 2024-03-28 18:14:40 +00:00
Vallie Joseph 97e4fcfcd5 wait on write stream 2024-03-28 18:07:20 +00:00
Vallie Joseph fe0c0de7db adding lock 2024-03-28 17:53:08 +00:00
Vallie Joseph c7de68f215 updating resolves 2024-03-28 17:48:56 +00:00
Vallie Joseph 66343faec4 add resolve all promises again 2024-03-28 17:43:17 +00:00
Vallie Joseph fd88cbe6df adding check for running 2024-03-28 17:32:01 +00:00
Vallie Joseph bef1fc5f67 adding check for running 2024-03-28 17:30:06 +00:00
Vallie Joseph 18751738a8 update loop for upload 2024-03-28 17:25:01 +00:00
Vallie Joseph b1f55c6942 adding finalize 2024-03-28 17:15:08 +00:00
Vallie Joseph 9299663297 adding promise all 2024-03-28 17:13:32 +00:00
Vallie Joseph 088b9761b4 cleaning up callback methods 2024-03-28 16:15:29 +00:00
Vallie Joseph d97edf7f61 cleaning up warning callack 2024-03-28 16:11:50 +00:00
Vallie Joseph 06482c6da1 adding promise to upload 2024-03-28 16:06:54 +00:00
Vallie Joseph 7441cc7b8b Removing pipe 2024-03-28 15:55:09 +00:00
Vallie Joseph ca87c5e124 testing debug statements 2024-03-28 15:53:03 +00:00
Vallie Joseph 97629b8767 adding archiver back for download 2024-03-28 15:47:34 +00:00
Vallie Joseph 8e29fb2e30 adding default back to zipstream call 2024-03-28 15:44:27 +00:00
Vallie Joseph 560ae4debd updating archive import 2024-03-28 15:41:52 +00:00
Vallie Joseph fda9d58d06 replacing constructor for zipstream with default 2024-03-28 15:28:14 +00:00
Vallie Joseph 6defe19df1 replacing constructor for zipstream 2024-03-28 15:25:37 +00:00
Vallie Joseph 6e4aebbd4e cleaning up unused imports 2024-03-28 15:17:40 +00:00
Vallie Joseph 14eee6f54a updating event handlers 2024-03-28 15:10:34 +00:00
Vallie Joseph e71ddb9e5a updating append and directory zips 2024-03-28 14:44:20 +00:00
Vallie Joseph 13d981a863 Adding buffer and zlib options 2024-03-28 14:32:03 +00:00
Vallie Joseph 4090623397 update debug statement 2024-03-28 04:20:40 +00:00
Vallie Joseph 4617da254f audit fix 2024-03-15 15:01:45 +00:00
Vallie Joseph 1f22f9faf9 adding debug for mac upload testing 2024-03-15 14:53:33 +00:00
7 changed files with 513 additions and 145 deletions
+18
View File
@@ -9015,6 +9015,24 @@
"node": ">=8"
}
},
"node_modules/jackspeak": {
"version": "2.3.6",
"resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-2.3.6.tgz",
"integrity": "sha512-N3yCS/NegsOBokc8GAdM8UcmfsKiSS8cipheD/nivzr700H+nsMOxJjQnvwOcRYVuFkdH0wGUvW2WbXGmrZGbQ==",
"dev": true,
"dependencies": {
"@isaacs/cliui": "^8.0.2"
},
"engines": {
"node": ">=14"
},
"funding": {
"url": "https://github.com/sponsors/isaacs"
},
"optionalDependencies": {
"@pkgjs/parseargs": "^0.11.0"
}
},
"node_modules/jake": {
"version": "10.8.7",
"resolved": "https://registry.npmjs.org/jake/-/jake-10.8.7.tgz",
+1 -1
View File
@@ -33,4 +33,4 @@
"ts-jest": "^29.1.1",
"typescript": "^5.2.2"
}
}
}
@@ -7,14 +7,21 @@ import {Timestamp, ArtifactServiceClientJSON} from '../src/generated'
import * as blobUpload from '../src/internal/upload/blob-upload'
import {uploadArtifact} from '../src/internal/upload/upload-artifact'
import {noopLogs} from './common'
import {FilesNotFoundError} from '../src/internal/shared/errors'
import {BlockBlobClient} from '@azure/storage-blob'
import * as fs from 'fs'
import * as path from 'path'
import {
FilesNotFoundError,
InvalidResponseError
} from '../src/internal/shared/errors'
class NodeJSError extends Error {
code: string
constructor(message?: string, code?: string) {
super(message) // Pass the message to the Error constructor
this.code = code || ''
}
}
describe('upload-artifact', () => {
beforeEach(() => {
noopLogs()
// noopLogs()
})
afterEach(() => {
@@ -355,93 +362,101 @@ describe('upload-artifact', () => {
expect(uploadResp).rejects.toThrow()
})
it('should throw an error uploading blob chunks get delayed', async () => {
const mockDate = new Date('2020-01-01')
const dirPath = path.join(__dirname, `plz-upload`)
if (!fs.existsSync(dirPath)) {
fs.mkdirSync(dirPath, {recursive: true})
}
fs.writeFileSync(path.join(dirPath, 'file1.txt'), 'test file content')
fs.writeFileSync(path.join(dirPath, 'file2.txt'), 'test file content')
fs.writeFileSync(path.join(dirPath, 'file3.txt'), 'test file content')
jest
.spyOn(uploadZipSpecification, 'validateRootDirectory')
.mockReturnValue()
jest
.spyOn(uploadZipSpecification, 'getUploadZipSpecification')
.mockReturnValue([
{
sourcePath: path.join(dirPath, 'file1.txt'),
destinationPath: 'file1.txt'
},
{
sourcePath: path.join(dirPath, 'file2.txt'),
destinationPath: 'file2.txt'
},
{
sourcePath: path.join(dirPath, 'file3.txt'),
destinationPath: 'dir/file3.txt'
}
])
jest.spyOn(util, 'getBackendIdsFromToken').mockReturnValue({
workflowRunBackendId: '1234',
workflowJobRunBackendId: '5678'
describe('should respond with non-successful callback on different zipstream lifecycle methods', () => {
beforeEach(() => {
noopLogs()
})
jest
.spyOn(retention, 'getExpiration')
.mockReturnValue(Timestamp.fromDate(mockDate))
jest
.spyOn(ArtifactServiceClientJSON.prototype, 'CreateArtifact')
.mockReturnValue(
afterEach(() => {
jest.restoreAllMocks()
})
it('should handle ENOENT error', async () => {
const mockDate = new Date('2020-01-01')
jest
.spyOn(uploadZipSpecification, 'validateRootDirectory')
.mockReturnValue()
jest
.spyOn(uploadZipSpecification, 'getUploadZipSpecification')
.mockReturnValue([
{
sourcePath: '/home/user/files/plz-upload/file1.txt',
destinationPath: 'file1.txt'
},
{
sourcePath: '/home/user/files/plz-upload/file2.txt',
destinationPath: 'file2.txt'
}
])
const mockZipStream = {
entry: jest.fn((source, data, callback) => {
const err = (new NodeJSError(
"ENOENT: no such file or directory, open '/home/user/files/plz-upload/file1.txt'"
).code = 'ENOENT')
callback(null, err)
}),
pipe: jest.fn(),
on: jest.fn(),
finalize: jest.fn()
}
jest.mock('zip-stream', () => {
return {
default: jest.fn().mockImplementation(() => mockZipStream)
}
})
jest
.spyOn(zip, 'createZipUploadStream')
.mockReturnValue(
Promise.reject(
new NodeJSError(
"ENOENT: no such file or directory, open '/home/user/files/plz-upload/file1.txt'"
)
)
)
jest.spyOn(util, 'getBackendIdsFromToken').mockReturnValue({
workflowRunBackendId: '1234',
workflowJobRunBackendId: '5678'
})
jest
.spyOn(retention, 'getExpiration')
.mockReturnValue(Timestamp.fromDate(mockDate))
jest
.spyOn(ArtifactServiceClientJSON.prototype, 'CreateArtifact')
.mockReturnValue(
Promise.resolve({
ok: true,
signedUploadUrl: 'https://signed-upload-url.com'
})
)
jest.spyOn(blobUpload, 'uploadZipToBlobStorage').mockReturnValue(
Promise.resolve({
ok: true,
signedUploadUrl: 'https://signed-upload-url.com'
uploadSize: 1234,
sha256Hash: 'test-sha256-hash'
})
)
jest
.spyOn(blobUpload, 'uploadZipToBlobStorage')
.mockReturnValue(Promise.reject(new Error('Upload progress stalled.')))
jest
.spyOn(ArtifactServiceClientJSON.prototype, 'FinalizeArtifact')
.mockReturnValue(Promise.resolve({ok: true, artifactId: '1'}))
// ArtifactHttpClient mocks
jest.spyOn(config, 'getRuntimeToken').mockReturnValue('test-token')
jest
.spyOn(config, 'getResultsServiceUrl')
.mockReturnValue('https://test-url.com')
// ArtifactHttpClient mocks
jest.spyOn(config, 'getRuntimeToken').mockReturnValue('test-token')
jest
.spyOn(config, 'getResultsServiceUrl')
.mockReturnValue('https://test-url.com')
BlockBlobClient.prototype.uploadStream = jest
.fn()
.mockImplementation(
async (stream, bufferSize, maxConcurrency, options) => {
return new Promise<void>(resolve => {
// Call the onProgress callback with a progress event
options.onProgress({loadedBytes: 0})
// Wait for 31 seconds before resolving the promise
setTimeout(() => {
// Call the onProgress callback again to simulate progress
options.onProgress({loadedBytes: 100})
resolve()
}, 31000) // Delay longer than your timeout
})
}
const uploadResp = uploadArtifact(
'test-artifact',
[
'/home/user/files/plz-upload/file1.txt',
'/home/user/files/plz-upload/file2.txt',
'/home/user/files/plz-upload/dir/file3.txt'
],
'/home/user/files/plz-upload'
)
jest.mock('fs')
const uploadResp = uploadArtifact(
'test-artifact',
[
'/home/user/files/plz-upload/file1.txt',
'/home/user/files/plz-upload/file2.txt',
'/home/user/files/plz-upload/dir/file3.txt'
],
'/home/user/files/plz-upload'
)
expect(uploadResp).rejects.toThrow('Upload progress stalled.')
expect(uploadResp).rejects.toThrowError(InvalidResponseError)
})
})
})
+336 -29
View File
@@ -18,14 +18,15 @@
"@octokit/plugin-retry": "^3.0.9",
"@octokit/request-error": "^5.0.0",
"@protobuf-ts/plugin": "^2.2.3-alpha.1",
"archiver": "^7.0.1",
"archiver": "^5.3.1",
"async": "^3.2.5",
"crypto": "^1.0.1",
"jwt-decode": "^3.1.2",
"twirp-ts": "^2.5.0",
"unzip-stream": "^0.3.1"
"unzip-stream": "^0.3.1",
"zip-stream": "^6.0.1"
},
"devDependencies": {
"@types/archiver": "^5.3.2",
"@types/unzip-stream": "^0.3.4",
"typedoc": "^0.25.4",
"typedoc-plugin-markdown": "^3.17.1",
@@ -443,15 +444,6 @@
"@protobuf-ts/runtime": "^2.9.1"
}
},
"node_modules/@types/archiver": {
"version": "5.3.2",
"resolved": "https://registry.npmjs.org/@types/archiver/-/archiver-5.3.2.tgz",
"integrity": "sha512-IctHreBuWE5dvBDz/0WeKtyVKVRs4h75IblxOACL92wU66v+HGAfEYAOyXkOFphvRJMhuXdI9huDXpX0FC6lCw==",
"dev": true,
"dependencies": {
"@types/readdir-glob": "*"
}
},
"node_modules/@types/node": {
"version": "20.4.9",
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.4.9.tgz",
@@ -479,15 +471,6 @@
"node": ">= 6"
}
},
"node_modules/@types/readdir-glob": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/@types/readdir-glob/-/readdir-glob-1.1.1.tgz",
"integrity": "sha512-ImM6TmoF8bgOwvehGviEj3tRdRBbQujr1N+0ypaln/GWjaerOB26jb93vsRHmdMtvVQZQebOlqt2HROark87mQ==",
"dev": true,
"dependencies": {
"@types/node": "*"
}
},
"node_modules/@types/tunnel": {
"version": "0.0.3",
"resolved": "https://registry.npmjs.org/@types/tunnel/-/tunnel-0.0.3.tgz",
@@ -621,10 +604,69 @@
"url": "https://github.com/sponsors/isaacs"
}
},
"node_modules/archiver/node_modules/compress-commons": {
"version": "4.1.2",
"resolved": "https://registry.npmjs.org/compress-commons/-/compress-commons-4.1.2.tgz",
"integrity": "sha512-D3uMHtGc/fcO1Gt1/L7i1e33VOvD4A9hfQLP+6ewd+BvG/gQ84Yh4oftEhAdjSMgBgwGL+jsppT7JYNpo6MHHg==",
"dependencies": {
"buffer-crc32": "^0.2.13",
"crc32-stream": "^4.0.2",
"normalize-path": "^3.0.0",
"readable-stream": "^3.6.0"
},
"engines": {
"node": ">= 10"
}
},
"node_modules/archiver/node_modules/crc32-stream": {
"version": "4.0.3",
"resolved": "https://registry.npmjs.org/crc32-stream/-/crc32-stream-4.0.3.tgz",
"integrity": "sha512-NT7w2JVU7DFroFdYkeq8cywxrgjPHWkdX1wjpRQXPX5Asews3tA+Ght6lddQO5Mkumffp3X7GEqku3epj2toIw==",
"dependencies": {
"crc-32": "^1.2.0",
"readable-stream": "^3.4.0"
},
"engines": {
"node": ">= 10"
}
},
"node_modules/archiver/node_modules/zip-stream": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/zip-stream/-/zip-stream-4.1.1.tgz",
"integrity": "sha512-9qv4rlDiopXg4E69k+vMHjNN63YFMe9sZMrdlvKnCjlCRWeCBswPPMPUfx+ipsAWq1LXHe70RcbaHdJJpS6hyQ==",
"dependencies": {
"archiver-utils": "^3.0.4",
"compress-commons": "^4.1.2",
"readable-stream": "^3.6.0"
},
"engines": {
"node": ">= 10"
}
},
"node_modules/archiver/node_modules/zip-stream/node_modules/archiver-utils": {
"version": "3.0.4",
"resolved": "https://registry.npmjs.org/archiver-utils/-/archiver-utils-3.0.4.tgz",
"integrity": "sha512-KVgf4XQVrTjhyWmx6cte4RxonPLR9onExufI1jhvw/MQ4BB6IsZD5gT8Lq+u/+pRkWna/6JoHpiQioaqFP5Rzw==",
"dependencies": {
"glob": "^7.2.3",
"graceful-fs": "^4.2.0",
"lazystream": "^1.0.0",
"lodash.defaults": "^4.2.0",
"lodash.difference": "^4.5.0",
"lodash.flatten": "^4.4.0",
"lodash.isplainobject": "^4.0.6",
"lodash.union": "^4.6.0",
"normalize-path": "^3.0.0",
"readable-stream": "^3.6.0"
},
"engines": {
"node": ">= 10"
}
},
"node_modules/async": {
"version": "3.2.4",
"resolved": "https://registry.npmjs.org/async/-/async-3.2.4.tgz",
"integrity": "sha512-iAB+JbDEGXhyIUavoDl9WP/Jj106Kz9DEn1DPgYw5ruDn0e3Wgi3sKFm55sASdGBNOQB8F59d9qQ7deqrHA8wQ=="
"version": "3.2.5",
"resolved": "https://registry.npmjs.org/async/-/async-3.2.5.tgz",
"integrity": "sha512-baNZyqaaLhyLVKm/DlvdW051MSgO6b8eVfIezl9E5PqWxFgzLm/wQntEW4zOytVburDEr0JlALEpdOFwvErLsg=="
},
"node_modules/asynckit": {
"version": "0.4.0",
@@ -806,6 +848,44 @@
"node": ">= 14"
}
},
"node_modules/compress-commons/node_modules/buffer": {
"version": "6.0.3",
"resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz",
"integrity": "sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/feross"
},
{
"type": "patreon",
"url": "https://www.patreon.com/feross"
},
{
"type": "consulting",
"url": "https://feross.org/support"
}
],
"dependencies": {
"base64-js": "^1.3.1",
"ieee754": "^1.2.1"
}
},
"node_modules/compress-commons/node_modules/readable-stream": {
"version": "4.5.2",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-4.5.2.tgz",
"integrity": "sha512-yjavECdqeZ3GLXNgRXgeQEdz9fvDDkNKyHnbHRFtOr7/LcfgBcmct7t/ET+HaCTqfh06OzoAxrkN/IfjJBVe+g==",
"dependencies": {
"abort-controller": "^3.0.0",
"buffer": "^6.0.3",
"events": "^3.3.0",
"process": "^0.11.10",
"string_decoder": "^1.3.0"
},
"engines": {
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
}
},
"node_modules/concat-map": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
@@ -839,6 +919,44 @@
"node": ">= 14"
}
},
"node_modules/crc32-stream/node_modules/buffer": {
"version": "6.0.3",
"resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz",
"integrity": "sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/feross"
},
{
"type": "patreon",
"url": "https://www.patreon.com/feross"
},
{
"type": "consulting",
"url": "https://feross.org/support"
}
],
"dependencies": {
"base64-js": "^1.3.1",
"ieee754": "^1.2.1"
}
},
"node_modules/crc32-stream/node_modules/readable-stream": {
"version": "4.5.2",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-4.5.2.tgz",
"integrity": "sha512-yjavECdqeZ3GLXNgRXgeQEdz9fvDDkNKyHnbHRFtOr7/LcfgBcmct7t/ET+HaCTqfh06OzoAxrkN/IfjJBVe+g==",
"dependencies": {
"abort-controller": "^3.0.0",
"buffer": "^6.0.3",
"events": "^3.3.0",
"process": "^0.11.10",
"string_decoder": "^1.3.0"
},
"engines": {
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
}
},
"node_modules/cross-spawn": {
"version": "7.0.3",
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz",
@@ -893,6 +1011,14 @@
"resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-9.2.2.tgz",
"integrity": "sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg=="
},
"node_modules/end-of-stream": {
"version": "1.4.4",
"resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.4.tgz",
"integrity": "sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==",
"dependencies": {
"once": "^1.4.0"
}
},
"node_modules/event-target-shim": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz",
@@ -909,11 +1035,6 @@
"node": ">=0.8.x"
}
},
"node_modules/fast-fifo": {
"version": "1.3.2",
"resolved": "https://registry.npmjs.org/fast-fifo/-/fast-fifo-1.3.2.tgz",
"integrity": "sha512-/d9sfos4yxzpwkDkuN7k2SqFKtYNmCTzgfEpz82x34IM9/zc8KGxQoXg1liNC/izpRM/MBdt44Nmx41ZWqk+FQ=="
},
"node_modules/foreground-child": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-3.1.1.tgz",
@@ -1576,6 +1697,94 @@
"node": ">=8"
}
},
"node_modules/tar-stream": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-2.2.0.tgz",
"integrity": "sha512-ujeqbceABgwMZxEJnk2HDY2DlnUZ+9oEcb1KzTVfYHio0UE6dG71n60d8D2I4qNvleWrrXpmjpt7vZeF1LnMZQ==",
"dependencies": {
"eastasianwidth": "^0.2.0",
"emoji-regex": "^9.2.2",
"strip-ansi": "^7.0.1"
},
"engines": {
"node": ">=12"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/string-width-cjs": {
"name": "string-width",
"version": "4.2.3",
"resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz",
"integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==",
"dependencies": {
"emoji-regex": "^8.0.0",
"is-fullwidth-code-point": "^3.0.0",
"strip-ansi": "^6.0.1"
},
"engines": {
"node": ">=8"
}
},
"node_modules/string-width-cjs/node_modules/ansi-regex": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz",
"integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==",
"engines": {
"node": ">=8"
}
},
"node_modules/string-width-cjs/node_modules/emoji-regex": {
"version": "8.0.0",
"resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz",
"integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A=="
},
"node_modules/string-width-cjs/node_modules/strip-ansi": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz",
"integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==",
"dependencies": {
"ansi-regex": "^5.0.1"
},
"engines": {
"node": ">=8"
}
},
"node_modules/strip-ansi": {
"version": "7.1.0",
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.0.tgz",
"integrity": "sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ==",
"dependencies": {
"ansi-regex": "^6.0.1"
},
"engines": {
"node": ">=12"
},
"funding": {
"url": "https://github.com/chalk/strip-ansi?sponsor=1"
}
},
"node_modules/strip-ansi-cjs": {
"name": "strip-ansi",
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz",
"integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==",
"dependencies": {
"ansi-regex": "^5.0.1"
},
"engines": {
"node": ">=8"
}
},
"node_modules/strip-ansi-cjs/node_modules/ansi-regex": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz",
"integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==",
"engines": {
"node": ">=8"
}
},
"node_modules/tar-stream": {
"version": "3.1.7",
"resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-3.1.7.tgz",
@@ -1934,6 +2143,104 @@
"engines": {
"node": ">= 14"
}
},
"node_modules/zip-stream/node_modules/archiver-utils": {
"version": "5.0.2",
"resolved": "https://registry.npmjs.org/archiver-utils/-/archiver-utils-5.0.2.tgz",
"integrity": "sha512-wuLJMmIBQYCsGZgYLTy5FIB2pF6Lfb6cXMSF8Qywwk3t20zWnAi7zLcQFdKQmIB8wyZpY5ER38x08GbwtR2cLA==",
"dependencies": {
"glob": "^10.0.0",
"graceful-fs": "^4.2.0",
"is-stream": "^2.0.1",
"lazystream": "^1.0.0",
"lodash": "^4.17.15",
"normalize-path": "^3.0.0",
"readable-stream": "^4.0.0"
},
"engines": {
"node": ">= 14"
}
},
"node_modules/zip-stream/node_modules/brace-expansion": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz",
"integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==",
"dependencies": {
"balanced-match": "^1.0.0"
}
},
"node_modules/zip-stream/node_modules/buffer": {
"version": "6.0.3",
"resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz",
"integrity": "sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/feross"
},
{
"type": "patreon",
"url": "https://www.patreon.com/feross"
},
{
"type": "consulting",
"url": "https://feross.org/support"
}
],
"dependencies": {
"base64-js": "^1.3.1",
"ieee754": "^1.2.1"
}
},
"node_modules/zip-stream/node_modules/glob": {
"version": "10.3.10",
"resolved": "https://registry.npmjs.org/glob/-/glob-10.3.10.tgz",
"integrity": "sha512-fa46+tv1Ak0UPK1TOy/pZrIybNNt4HCv7SDzwyfiOZkvZLEbjsZkJBPtDHVshZjbecAoAGSC20MjLDG/qr679g==",
"dependencies": {
"foreground-child": "^3.1.0",
"jackspeak": "^2.3.5",
"minimatch": "^9.0.1",
"minipass": "^5.0.0 || ^6.0.2 || ^7.0.0",
"path-scurry": "^1.10.1"
},
"bin": {
"glob": "dist/esm/bin.mjs"
},
"engines": {
"node": ">=16 || 14 >=14.17"
},
"funding": {
"url": "https://github.com/sponsors/isaacs"
}
},
"node_modules/zip-stream/node_modules/minimatch": {
"version": "9.0.3",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.3.tgz",
"integrity": "sha512-RHiac9mvaRw0x3AYRgDC1CxAP7HTcNrrECeA8YYJeWnpo+2Q5CegtZjaotWTWxDG3UeGA1coE05iH1mPjT/2mg==",
"dependencies": {
"brace-expansion": "^2.0.1"
},
"engines": {
"node": ">=16 || 14 >=14.17"
},
"funding": {
"url": "https://github.com/sponsors/isaacs"
}
},
"node_modules/zip-stream/node_modules/readable-stream": {
"version": "4.5.2",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-4.5.2.tgz",
"integrity": "sha512-yjavECdqeZ3GLXNgRXgeQEdz9fvDDkNKyHnbHRFtOr7/LcfgBcmct7t/ET+HaCTqfh06OzoAxrkN/IfjJBVe+g==",
"dependencies": {
"abort-controller": "^3.0.0",
"buffer": "^6.0.3",
"events": "^3.3.0",
"process": "^0.11.10",
"string_decoder": "^1.3.0"
},
"engines": {
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
}
}
}
}
+4 -3
View File
@@ -49,14 +49,15 @@
"@octokit/plugin-retry": "^3.0.9",
"@octokit/request-error": "^5.0.0",
"@protobuf-ts/plugin": "^2.2.3-alpha.1",
"archiver": "^7.0.1",
"archiver": "^5.3.1",
"async": "^3.2.5",
"crypto": "^1.0.1",
"jwt-decode": "^3.1.2",
"twirp-ts": "^2.5.0",
"unzip-stream": "^0.3.1"
"unzip-stream": "^0.3.1",
"zip-stream": "^6.0.1"
},
"devDependencies": {
"@types/archiver": "^5.3.2",
"@types/unzip-stream": "^0.3.4",
"typedoc": "^0.25.4",
"typedoc-plugin-markdown": "^3.17.1",
@@ -67,18 +67,25 @@ export async function uploadArtifact(
'CreateArtifact: response from backend was not ok'
)
}
// Create the zipupload stream for use in blob upload
const zipUploadStream = await createZipUploadStream(
zipSpecification,
options?.compressionLevel
)
).catch(err => {
throw new InvalidResponseError(
`createZipUploadStream: response from backend was not ok: ${err}`
)
})
// Upload zip to blob storage
const uploadResult = await uploadZipToBlobStorage(
createArtifactResp.signedUploadUrl,
zipUploadStream
)
).catch(err => {
throw new InvalidResponseError(
`uploadZipToBlobStorage: response blob was not ok: ${err}`
)
})
// finalize the artifact
const finalizeArtifactReq: FinalizeArtifactRequest = {
workflowRunBackendId: backendIds.workflowRunBackendId,
@@ -86,15 +93,12 @@ export async function uploadArtifact(
name,
size: uploadResult.uploadSize ? uploadResult.uploadSize.toString() : '0'
}
if (uploadResult.sha256Hash) {
finalizeArtifactReq.hash = StringValue.create({
value: `sha256:${uploadResult.sha256Hash}`
})
}
core.info(`Finalizing artifact upload`)
const finalizeArtifactResp =
await artifactClient.FinalizeArtifact(finalizeArtifactReq)
if (!finalizeArtifactResp.ok) {
+42 -19
View File
@@ -1,6 +1,7 @@
import * as stream from 'stream'
import * as archiver from 'archiver'
import * as ZipStream from 'zip-stream'
import * as core from '@actions/core'
import async from 'async'
import {createReadStream} from 'fs'
import {UploadZipSpecification} from './upload-zip-specification'
import {getUploadChunkSize} from '../shared/config'
@@ -30,31 +31,57 @@ export async function createZipUploadStream(
`Creating Artifact archive with compressionLevel: ${compressionLevel}`
)
const zip = archiver.create('zip', {
highWaterMark: getUploadChunkSize(),
zlib: {level: compressionLevel}
})
const zlibOptions = {
zlib: {
level: compressionLevel,
bufferSize: getUploadChunkSize()
}
}
const zip = new ZipStream.default(zlibOptions)
const bufferSize = getUploadChunkSize()
const zipUploadStream = new ZipUploadStream(bufferSize)
zip.pipe(zipUploadStream)
// register callbacks for various events during the zip lifecycle
zip.on('error', zipErrorCallback)
zip.on('warning', zipWarningCallback)
zip.on('finish', zipFinishCallback)
zip.on('end', zipEndCallback)
for (const file of uploadSpecification) {
const addFileToZip = (
file: UploadZipSpecification,
callback: (error?: Error) => void
): void => {
if (file.sourcePath !== null) {
// Add a normal file to the zip
zip.append(createReadStream(file.sourcePath), {
name: file.destinationPath
})
zip.entry(
createReadStream(file.sourcePath),
{name: file.destinationPath},
(error: unknown) => {
if (error) {
callback(error as Error) // Cast the error object to the Error type
return
}
callback()
}
)
} else {
// Add a directory to the zip
zip.append('', {name: file.destinationPath})
zip.entry('', {name: file.destinationPath}, (error: unknown) => {
if (error) {
callback(error as Error)
return
}
callback()
})
}
}
const bufferSize = getUploadChunkSize()
const zipUploadStream = new ZipUploadStream(bufferSize)
async.eachSeries(uploadSpecification, addFileToZip, (error: unknown) => {
if (error) {
core.error('Failed to add a file to the zip:')
core.info(error.toString()) // Convert error to string
return
}
zip.finalize() // Finalize the archive once all files have been added
})
core.debug(
`Zip write high watermark value ${zipUploadStream.writableHighWaterMark}`
@@ -63,9 +90,6 @@ export async function createZipUploadStream(
`Zip read high watermark value ${zipUploadStream.readableHighWaterMark}`
)
zip.pipe(zipUploadStream)
zip.finalize()
return zipUploadStream
}
@@ -76,7 +100,6 @@ const zipErrorCallback = (error: any): void => {
throw new Error('An error has occurred during zip creation for the artifact')
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const zipWarningCallback = (error: any): void => {
if (error.code === 'ENOENT') {