Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0db2ef8ead | ||
|
|
e3764a56e8 |
@@ -1,3 +1,5 @@
|
|||||||
|
# Temporarily disabled while v2.0.0 of @actions/artifact is under development
|
||||||
|
|
||||||
name: artifact-unit-tests
|
name: artifact-unit-tests
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
@@ -10,8 +12,8 @@ on:
|
|||||||
- '**.md'
|
- '**.md'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
upload:
|
build:
|
||||||
name: Upload
|
name: Build
|
||||||
|
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
@@ -40,13 +42,19 @@ jobs:
|
|||||||
npm run tsc
|
npm run tsc
|
||||||
working-directory: packages/artifact
|
working-directory: packages/artifact
|
||||||
|
|
||||||
|
- name: Set artifact file contents
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
echo "file1=hello from file 1" >> $GITHUB_ENV
|
||||||
|
echo "file2=hello from file 2" >> $GITHUB_ENV
|
||||||
|
|
||||||
- name: Create files that will be uploaded
|
- name: Create files that will be uploaded
|
||||||
run: |
|
run: |
|
||||||
mkdir artifact-path
|
mkdir artifact-path
|
||||||
echo -n 'hello from file 1' > artifact-path/first.txt
|
echo '${{ env.file1 }}' > artifact-path/first.txt
|
||||||
echo -n 'hello from file 2' > artifact-path/second.txt
|
echo '${{ env.file2 }}' > artifact-path/second.txt
|
||||||
|
|
||||||
- name: Upload Artifacts
|
- name: Upload Artifacts using actions/github-script@v7
|
||||||
uses: actions/github-script@v7
|
uses: actions/github-script@v7
|
||||||
with:
|
with:
|
||||||
script: |
|
script: |
|
||||||
@@ -65,16 +73,9 @@ jobs:
|
|||||||
|
|
||||||
console.log(`Successfully uploaded artifact ${id}`)
|
console.log(`Successfully uploaded artifact ${id}`)
|
||||||
|
|
||||||
try {
|
|
||||||
await artifact.uploadArtifact(artifactName, fileContents, './')
|
|
||||||
throw new Error('should have failed second upload')
|
|
||||||
} catch (err) {
|
|
||||||
console.log('Successfully blocked second artifact upload')
|
|
||||||
}
|
|
||||||
verify:
|
verify:
|
||||||
name: Verify
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: [upload]
|
needs: [build]
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
@@ -95,72 +96,35 @@ jobs:
|
|||||||
npm run tsc
|
npm run tsc
|
||||||
working-directory: packages/artifact
|
working-directory: packages/artifact
|
||||||
|
|
||||||
- name: List and Download Artifacts
|
- name: List artifacts using actions/github-script@v7
|
||||||
uses: actions/github-script@v7
|
uses: actions/github-script@v7
|
||||||
with:
|
with:
|
||||||
script: |
|
script: |
|
||||||
const {default: artifactClient} = require('./packages/artifact/lib/artifact')
|
const {default: artifact} = require('./packages/artifact/lib/artifact')
|
||||||
|
|
||||||
const {readFile} = require('fs/promises')
|
const workflowRunId = process.env.GITHUB_RUN_ID
|
||||||
const path = require('path')
|
const repository = process.env.GITHUB_REPOSITORY
|
||||||
|
const repositoryOwner = repository.split('/')[0]
|
||||||
|
const repositoryName = repository.split('/')[1]
|
||||||
|
|
||||||
const findBy = {
|
const listResult = await artifact.listArtifacts(workflowRunId, repositoryOwner, repositoryName, '${{ secrets.GITHUB_TOKEN }}')
|
||||||
repositoryOwner: process.env.GITHUB_REPOSITORY.split('/')[0],
|
|
||||||
repositoryName: process.env.GITHUB_REPOSITORY.split('/')[1],
|
|
||||||
token: '${{ secrets.GITHUB_TOKEN }}',
|
|
||||||
workflowRunId: process.env.GITHUB_RUN_ID
|
|
||||||
}
|
|
||||||
|
|
||||||
const listResult = await artifactClient.listArtifacts({latest: true, findBy})
|
|
||||||
console.log(listResult)
|
console.log(listResult)
|
||||||
|
|
||||||
const artifacts = listResult.artifacts
|
const artifacts = listResult.artifacts
|
||||||
const expected = [
|
|
||||||
'my-artifact-ubuntu-latest',
|
|
||||||
'my-artifact-windows-latest',
|
|
||||||
'my-artifact-macos-latest'
|
|
||||||
]
|
|
||||||
|
|
||||||
const foundArtifacts = artifacts.filter(artifact =>
|
if (artifacts.length !== 3) {
|
||||||
expected.includes(artifact.name)
|
throw new Error('Expected 3 artifacts but only found ' + artifacts.length + ' artifacts')
|
||||||
)
|
}
|
||||||
|
|
||||||
if (foundArtifacts.length !== 3) {
|
const artifactNames = artifacts.map(artifact => artifact.name)
|
||||||
console.log('Unexpected length of found artifacts', foundArtifacts)
|
if (!artifactNames.includes('my-artifact-ubuntu-latest')){
|
||||||
throw new Error(
|
throw new Error("Expected artifact list to contain an artifact named my-artifact-ubuntu-latest but it's missing")
|
||||||
`Expected 3 artifacts but found ${foundArtifacts.length} artifacts.`
|
}
|
||||||
)
|
if (!artifactNames.includes('my-artifact-windows-latest')){
|
||||||
|
throw new Error("Expected artifact list to contain an artifact named my-artifact-windows-latest but it's missing")
|
||||||
|
}
|
||||||
|
if (!artifactNames.includes('my-artifact-macos-latest')){
|
||||||
|
throw new Error("Expected artifact list to contain an artifact named my-artifact-macos-latest but it's missing")
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('Successfully listed artifacts that were uploaded')
|
console.log('Successfully listed artifacts that were uploaded')
|
||||||
|
|
||||||
const files = [
|
|
||||||
{name: 'artifact-path/first.txt', content: 'hello from file 1'},
|
|
||||||
{name: 'artifact-path/second.txt', content: 'hello from file 2'}
|
|
||||||
]
|
|
||||||
|
|
||||||
for (const artifact of foundArtifacts) {
|
|
||||||
const {downloadPath} = await artifactClient.downloadArtifact(artifact.id, {
|
|
||||||
path: artifact.name,
|
|
||||||
findBy
|
|
||||||
})
|
|
||||||
|
|
||||||
console.log('Downloaded artifact to:', downloadPath)
|
|
||||||
|
|
||||||
for (const file of files) {
|
|
||||||
const filepath = path.join(
|
|
||||||
process.env.GITHUB_WORKSPACE,
|
|
||||||
downloadPath,
|
|
||||||
file.name
|
|
||||||
)
|
|
||||||
|
|
||||||
console.log('Checking file:', filepath)
|
|
||||||
|
|
||||||
const content = await readFile(filepath, 'utf8')
|
|
||||||
if (content.trim() !== file.content.trim()) {
|
|
||||||
throw new Error(
|
|
||||||
`Expected file '${file.name}' to contain '${file.content}' but found '${content}'`
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -4,16 +4,9 @@ import {HttpClient} from '@actions/http-client'
|
|||||||
import * as config from '../src/internal/shared/config'
|
import * as config from '../src/internal/shared/config'
|
||||||
import {internalArtifactTwirpClient} from '../src/internal/shared/artifact-twirp-client'
|
import {internalArtifactTwirpClient} from '../src/internal/shared/artifact-twirp-client'
|
||||||
import {noopLogs} from './common'
|
import {noopLogs} from './common'
|
||||||
import {NetworkError, UsageError} from '../src/internal/shared/errors'
|
|
||||||
|
|
||||||
jest.mock('@actions/http-client')
|
jest.mock('@actions/http-client')
|
||||||
|
|
||||||
const clientOptions = {
|
|
||||||
maxAttempts: 5,
|
|
||||||
retryIntervalMs: 1,
|
|
||||||
retryMultiplier: 1.5
|
|
||||||
}
|
|
||||||
|
|
||||||
describe('artifact-http-client', () => {
|
describe('artifact-http-client', () => {
|
||||||
beforeAll(() => {
|
beforeAll(() => {
|
||||||
noopLogs()
|
noopLogs()
|
||||||
@@ -101,7 +94,11 @@ describe('artifact-http-client', () => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const client = internalArtifactTwirpClient(clientOptions)
|
const client = internalArtifactTwirpClient({
|
||||||
|
maxAttempts: 5,
|
||||||
|
retryIntervalMs: 1,
|
||||||
|
retryMultiplier: 1.5
|
||||||
|
})
|
||||||
const artifact = await client.CreateArtifact({
|
const artifact = await client.CreateArtifact({
|
||||||
workflowRunBackendId: '1234',
|
workflowRunBackendId: '1234',
|
||||||
workflowJobRunBackendId: '5678',
|
workflowJobRunBackendId: '5678',
|
||||||
@@ -136,7 +133,11 @@ describe('artifact-http-client', () => {
|
|||||||
post: mockPost
|
post: mockPost
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
const client = internalArtifactTwirpClient(clientOptions)
|
const client = internalArtifactTwirpClient({
|
||||||
|
maxAttempts: 5,
|
||||||
|
retryIntervalMs: 1,
|
||||||
|
retryMultiplier: 1.5
|
||||||
|
})
|
||||||
await expect(async () => {
|
await expect(async () => {
|
||||||
await client.CreateArtifact({
|
await client.CreateArtifact({
|
||||||
workflowRunBackendId: '1234',
|
workflowRunBackendId: '1234',
|
||||||
@@ -171,7 +172,11 @@ describe('artifact-http-client', () => {
|
|||||||
post: mockPost
|
post: mockPost
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
const client = internalArtifactTwirpClient(clientOptions)
|
const client = internalArtifactTwirpClient({
|
||||||
|
maxAttempts: 5,
|
||||||
|
retryIntervalMs: 1,
|
||||||
|
retryMultiplier: 1.5
|
||||||
|
})
|
||||||
await expect(async () => {
|
await expect(async () => {
|
||||||
await client.CreateArtifact({
|
await client.CreateArtifact({
|
||||||
workflowRunBackendId: '1234',
|
workflowRunBackendId: '1234',
|
||||||
@@ -185,116 +190,4 @@ describe('artifact-http-client', () => {
|
|||||||
expect(mockHttpClient).toHaveBeenCalledTimes(1)
|
expect(mockHttpClient).toHaveBeenCalledTimes(1)
|
||||||
expect(mockPost).toHaveBeenCalledTimes(1)
|
expect(mockPost).toHaveBeenCalledTimes(1)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should fail with a descriptive error', async () => {
|
|
||||||
// 409 duplicate error
|
|
||||||
const mockPost = jest.fn(() => {
|
|
||||||
const msgFailed = new http.IncomingMessage(new net.Socket())
|
|
||||||
msgFailed.statusCode = 409
|
|
||||||
msgFailed.statusMessage = 'Conflict'
|
|
||||||
return {
|
|
||||||
message: msgFailed,
|
|
||||||
readBody: async () => {
|
|
||||||
return Promise.resolve(
|
|
||||||
`{"msg": "an artifact with this name already exists on the workflow run"}`
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
const mockHttpClient = (
|
|
||||||
HttpClient as unknown as jest.Mock
|
|
||||||
).mockImplementation(() => {
|
|
||||||
return {
|
|
||||||
post: mockPost
|
|
||||||
}
|
|
||||||
})
|
|
||||||
const client = internalArtifactTwirpClient(clientOptions)
|
|
||||||
await expect(async () => {
|
|
||||||
await client.CreateArtifact({
|
|
||||||
workflowRunBackendId: '1234',
|
|
||||||
workflowJobRunBackendId: '5678',
|
|
||||||
name: 'artifact',
|
|
||||||
version: 4
|
|
||||||
})
|
|
||||||
await client.CreateArtifact({
|
|
||||||
workflowRunBackendId: '1234',
|
|
||||||
workflowJobRunBackendId: '5678',
|
|
||||||
name: 'artifact',
|
|
||||||
version: 4
|
|
||||||
})
|
|
||||||
}).rejects.toThrowError(
|
|
||||||
'Failed to CreateArtifact: Received non-retryable error: Failed request: (409) Conflict: an artifact with this name already exists on the workflow run'
|
|
||||||
)
|
|
||||||
expect(mockHttpClient).toHaveBeenCalledTimes(1)
|
|
||||||
expect(mockPost).toHaveBeenCalledTimes(1)
|
|
||||||
})
|
|
||||||
|
|
||||||
it('should properly describe a network failure', async () => {
|
|
||||||
class FakeNodeError extends Error {
|
|
||||||
code: string
|
|
||||||
constructor(code: string) {
|
|
||||||
super()
|
|
||||||
this.code = code
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const mockPost = jest.fn(() => {
|
|
||||||
throw new FakeNodeError('ENOTFOUND')
|
|
||||||
})
|
|
||||||
|
|
||||||
const mockHttpClient = (
|
|
||||||
HttpClient as unknown as jest.Mock
|
|
||||||
).mockImplementation(() => {
|
|
||||||
return {
|
|
||||||
post: mockPost
|
|
||||||
}
|
|
||||||
})
|
|
||||||
const client = internalArtifactTwirpClient()
|
|
||||||
await expect(async () => {
|
|
||||||
await client.CreateArtifact({
|
|
||||||
workflowRunBackendId: '1234',
|
|
||||||
workflowJobRunBackendId: '5678',
|
|
||||||
name: 'artifact',
|
|
||||||
version: 4
|
|
||||||
})
|
|
||||||
}).rejects.toThrowError(new NetworkError('ENOTFOUND').message)
|
|
||||||
expect(mockHttpClient).toHaveBeenCalledTimes(1)
|
|
||||||
expect(mockPost).toHaveBeenCalledTimes(1)
|
|
||||||
})
|
|
||||||
|
|
||||||
it('should properly describe a usage error', async () => {
|
|
||||||
const mockPost = jest.fn(() => {
|
|
||||||
const msgFailed = new http.IncomingMessage(new net.Socket())
|
|
||||||
msgFailed.statusCode = 403
|
|
||||||
msgFailed.statusMessage = 'Forbidden'
|
|
||||||
return {
|
|
||||||
message: msgFailed,
|
|
||||||
readBody: async () => {
|
|
||||||
return Promise.resolve(
|
|
||||||
`{"msg": "insufficient usage to create artifact"}`
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
const mockHttpClient = (
|
|
||||||
HttpClient as unknown as jest.Mock
|
|
||||||
).mockImplementation(() => {
|
|
||||||
return {
|
|
||||||
post: mockPost
|
|
||||||
}
|
|
||||||
})
|
|
||||||
const client = internalArtifactTwirpClient()
|
|
||||||
await expect(async () => {
|
|
||||||
await client.CreateArtifact({
|
|
||||||
workflowRunBackendId: '1234',
|
|
||||||
workflowJobRunBackendId: '5678',
|
|
||||||
name: 'artifact',
|
|
||||||
version: 4
|
|
||||||
})
|
|
||||||
}).rejects.toThrowError(new UsageError().message)
|
|
||||||
expect(mockHttpClient).toHaveBeenCalledTimes(1)
|
|
||||||
expect(mockPost).toHaveBeenCalledTimes(1)
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -104,7 +104,6 @@ const mockGetArtifactSuccess = jest.fn(() => {
|
|||||||
const message = new http.IncomingMessage(new net.Socket())
|
const message = new http.IncomingMessage(new net.Socket())
|
||||||
message.statusCode = 200
|
message.statusCode = 200
|
||||||
message.push(fs.readFileSync(fixtures.exampleArtifact.path))
|
message.push(fs.readFileSync(fixtures.exampleArtifact.path))
|
||||||
message.push(null)
|
|
||||||
return {
|
return {
|
||||||
message
|
message
|
||||||
}
|
}
|
||||||
@@ -114,7 +113,6 @@ const mockGetArtifactFailure = jest.fn(() => {
|
|||||||
const message = new http.IncomingMessage(new net.Socket())
|
const message = new http.IncomingMessage(new net.Socket())
|
||||||
message.statusCode = 500
|
message.statusCode = 500
|
||||||
message.push('Internal Server Error')
|
message.push('Internal Server Error')
|
||||||
message.push(null)
|
|
||||||
return {
|
return {
|
||||||
message
|
message
|
||||||
}
|
}
|
||||||
|
|||||||
Generated
+138
-13
@@ -18,15 +18,15 @@
|
|||||||
"@octokit/plugin-retry": "^3.0.9",
|
"@octokit/plugin-retry": "^3.0.9",
|
||||||
"@octokit/request-error": "^5.0.0",
|
"@octokit/request-error": "^5.0.0",
|
||||||
"@protobuf-ts/plugin": "^2.2.3-alpha.1",
|
"@protobuf-ts/plugin": "^2.2.3-alpha.1",
|
||||||
|
"@types/unzipper": "^0.10.6",
|
||||||
"archiver": "^5.3.1",
|
"archiver": "^5.3.1",
|
||||||
"crypto": "^1.0.1",
|
"crypto": "^1.0.1",
|
||||||
"jwt-decode": "^3.1.2",
|
"jwt-decode": "^3.1.2",
|
||||||
"twirp-ts": "^2.5.0",
|
"twirp-ts": "^2.5.0",
|
||||||
"unzip-stream": "^0.3.1"
|
"unzipper": "^0.10.14"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/archiver": "^5.3.2",
|
"@types/archiver": "^5.3.2",
|
||||||
"@types/unzip-stream": "^0.3.4",
|
|
||||||
"typedoc": "^0.25.4",
|
"typedoc": "^0.25.4",
|
||||||
"typedoc-plugin-markdown": "^3.17.1",
|
"typedoc-plugin-markdown": "^3.17.1",
|
||||||
"typescript": "^5.2.2"
|
"typescript": "^5.2.2"
|
||||||
@@ -471,11 +471,10 @@
|
|||||||
"@types/node": "*"
|
"@types/node": "*"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@types/unzip-stream": {
|
"node_modules/@types/unzipper": {
|
||||||
"version": "0.3.4",
|
"version": "0.10.6",
|
||||||
"resolved": "https://registry.npmjs.org/@types/unzip-stream/-/unzip-stream-0.3.4.tgz",
|
"resolved": "https://registry.npmjs.org/@types/unzipper/-/unzipper-0.10.6.tgz",
|
||||||
"integrity": "sha512-ud0vtsNRF+joUCyvNMyo0j5DKX2Lh/im+xVgRzBEsfHhQYZ+i4fKTveova9XxLzt6Jl6G0e/0mM4aC0gqZYSnA==",
|
"integrity": "sha512-zcBj329AHgKLQyz209N/S9R0GZqXSkUQO4tJSYE3x02qg4JuDFpgKMj50r82Erk1natCWQDIvSccDddt7jPzjA==",
|
||||||
"dev": true,
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/node": "*"
|
"@types/node": "*"
|
||||||
}
|
}
|
||||||
@@ -589,6 +588,14 @@
|
|||||||
"resolved": "https://registry.npmjs.org/before-after-hook/-/before-after-hook-2.2.3.tgz",
|
"resolved": "https://registry.npmjs.org/before-after-hook/-/before-after-hook-2.2.3.tgz",
|
||||||
"integrity": "sha512-NzUnlZexiaH/46WDhANlyR2bXRopNg4F/zuSA3OpZnllCUgRaOF2znDioDWrmbNVsuZk6l9pMquQB38cfBZwkQ=="
|
"integrity": "sha512-NzUnlZexiaH/46WDhANlyR2bXRopNg4F/zuSA3OpZnllCUgRaOF2znDioDWrmbNVsuZk6l9pMquQB38cfBZwkQ=="
|
||||||
},
|
},
|
||||||
|
"node_modules/big-integer": {
|
||||||
|
"version": "1.6.51",
|
||||||
|
"resolved": "https://registry.npmjs.org/big-integer/-/big-integer-1.6.51.tgz",
|
||||||
|
"integrity": "sha512-GPEid2Y9QU1Exl1rpO9B2IPJGHPSupF5GnVIP0blYvNOMer2bTvSWs1jGOUg04hTmu67nmLsQ9TBo1puaotBHg==",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=0.6"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/binary": {
|
"node_modules/binary": {
|
||||||
"version": "0.3.0",
|
"version": "0.3.0",
|
||||||
"resolved": "https://registry.npmjs.org/binary/-/binary-0.3.0.tgz",
|
"resolved": "https://registry.npmjs.org/binary/-/binary-0.3.0.tgz",
|
||||||
@@ -611,6 +618,11 @@
|
|||||||
"readable-stream": "^3.4.0"
|
"readable-stream": "^3.4.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/bluebird": {
|
||||||
|
"version": "3.4.7",
|
||||||
|
"resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.4.7.tgz",
|
||||||
|
"integrity": "sha512-iD3898SR7sWVRHbiQv+sHUtHnMvC1o3nW5rAcqnq3uOn07DSAppZYUkIGslDz6gXC7HfunPe7YVBgoEJASPcHA=="
|
||||||
|
},
|
||||||
"node_modules/bottleneck": {
|
"node_modules/bottleneck": {
|
||||||
"version": "2.19.5",
|
"version": "2.19.5",
|
||||||
"resolved": "https://registry.npmjs.org/bottleneck/-/bottleneck-2.19.5.tgz",
|
"resolved": "https://registry.npmjs.org/bottleneck/-/bottleneck-2.19.5.tgz",
|
||||||
@@ -656,6 +668,14 @@
|
|||||||
"node": "*"
|
"node": "*"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/buffer-indexof-polyfill": {
|
||||||
|
"version": "1.0.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/buffer-indexof-polyfill/-/buffer-indexof-polyfill-1.0.2.tgz",
|
||||||
|
"integrity": "sha512-I7wzHwA3t1/lwXQh+A5PbNvJxgfo5r3xulgpYDB5zckTu/Z9oUK9biouBKQUjEqzaz3HnAT6TYoovmE+GqSf7A==",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=0.10"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/buffers": {
|
"node_modules/buffers": {
|
||||||
"version": "0.1.1",
|
"version": "0.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/buffers/-/buffers-0.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/buffers/-/buffers-0.1.1.tgz",
|
||||||
@@ -781,6 +801,41 @@
|
|||||||
"dot-object": "bin/dot-object"
|
"dot-object": "bin/dot-object"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/duplexer2": {
|
||||||
|
"version": "0.1.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/duplexer2/-/duplexer2-0.1.4.tgz",
|
||||||
|
"integrity": "sha512-asLFVfWWtJ90ZyOUHMqk7/S2w2guQKxUI2itj3d92ADHhxUSbCMGi1f1cBcJ7xM1To+pE/Khbwo1yuNbMEPKeA==",
|
||||||
|
"dependencies": {
|
||||||
|
"readable-stream": "^2.0.2"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/duplexer2/node_modules/readable-stream": {
|
||||||
|
"version": "2.3.8",
|
||||||
|
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.8.tgz",
|
||||||
|
"integrity": "sha512-8p0AUk4XODgIewSi0l8Epjs+EVnWiK7NoDIEGU0HhE7+ZyY8D1IMY7odu5lRrFXGg71L15KG8QrPmum45RTtdA==",
|
||||||
|
"dependencies": {
|
||||||
|
"core-util-is": "~1.0.0",
|
||||||
|
"inherits": "~2.0.3",
|
||||||
|
"isarray": "~1.0.0",
|
||||||
|
"process-nextick-args": "~2.0.0",
|
||||||
|
"safe-buffer": "~5.1.1",
|
||||||
|
"string_decoder": "~1.1.1",
|
||||||
|
"util-deprecate": "~1.0.1"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/duplexer2/node_modules/safe-buffer": {
|
||||||
|
"version": "5.1.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
|
||||||
|
"integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g=="
|
||||||
|
},
|
||||||
|
"node_modules/duplexer2/node_modules/string_decoder": {
|
||||||
|
"version": "1.1.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz",
|
||||||
|
"integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==",
|
||||||
|
"dependencies": {
|
||||||
|
"safe-buffer": "~5.1.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/end-of-stream": {
|
"node_modules/end-of-stream": {
|
||||||
"version": "1.4.4",
|
"version": "1.4.4",
|
||||||
"resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.4.tgz",
|
"resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.4.tgz",
|
||||||
@@ -820,6 +875,20 @@
|
|||||||
"resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
|
||||||
"integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw=="
|
"integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw=="
|
||||||
},
|
},
|
||||||
|
"node_modules/fstream": {
|
||||||
|
"version": "1.0.12",
|
||||||
|
"resolved": "https://registry.npmjs.org/fstream/-/fstream-1.0.12.tgz",
|
||||||
|
"integrity": "sha512-WvJ193OHa0GHPEL+AycEJgxvBEwyfRkN1vhjca23OaPVMCaLCXTd5qAu82AjTcgP1UJmytkOKb63Ypde7raDIg==",
|
||||||
|
"dependencies": {
|
||||||
|
"graceful-fs": "^4.1.2",
|
||||||
|
"inherits": "~2.0.0",
|
||||||
|
"mkdirp": ">=0.5 0",
|
||||||
|
"rimraf": "2"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=0.6"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/glob": {
|
"node_modules/glob": {
|
||||||
"version": "7.2.3",
|
"version": "7.2.3",
|
||||||
"resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz",
|
"resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz",
|
||||||
@@ -960,6 +1029,11 @@
|
|||||||
"safe-buffer": "~5.1.0"
|
"safe-buffer": "~5.1.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/listenercount": {
|
||||||
|
"version": "1.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/listenercount/-/listenercount-1.0.1.tgz",
|
||||||
|
"integrity": "sha512-3mk/Zag0+IJxeDrxSgaDPy4zZ3w05PRZeJNnlWhzFz5OkX49J4krc+A8X2d2M69vGMBEX0uyl8M+W+8gH+kBqQ=="
|
||||||
|
},
|
||||||
"node_modules/lodash": {
|
"node_modules/lodash": {
|
||||||
"version": "4.17.21",
|
"version": "4.17.21",
|
||||||
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
|
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
|
||||||
@@ -1204,6 +1278,17 @@
|
|||||||
"node": ">=10"
|
"node": ">=10"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/rimraf": {
|
||||||
|
"version": "2.7.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.7.1.tgz",
|
||||||
|
"integrity": "sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w==",
|
||||||
|
"dependencies": {
|
||||||
|
"glob": "^7.1.3"
|
||||||
|
},
|
||||||
|
"bin": {
|
||||||
|
"rimraf": "bin.js"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/safe-buffer": {
|
"node_modules/safe-buffer": {
|
||||||
"version": "5.2.1",
|
"version": "5.2.1",
|
||||||
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz",
|
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz",
|
||||||
@@ -1228,6 +1313,11 @@
|
|||||||
"resolved": "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz",
|
"resolved": "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz",
|
||||||
"integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw=="
|
"integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw=="
|
||||||
},
|
},
|
||||||
|
"node_modules/setimmediate": {
|
||||||
|
"version": "1.0.5",
|
||||||
|
"resolved": "https://registry.npmjs.org/setimmediate/-/setimmediate-1.0.5.tgz",
|
||||||
|
"integrity": "sha512-MATJdZp8sLqDl/68LfQmbP8zKPLQNV6BIZoIgrscFDQ+RsvK/BxeDQOgyxKKoh0y/8h3BqVFnCqQ/gd+reiIXA=="
|
||||||
|
},
|
||||||
"node_modules/shiki": {
|
"node_modules/shiki": {
|
||||||
"version": "0.14.5",
|
"version": "0.14.5",
|
||||||
"resolved": "https://registry.npmjs.org/shiki/-/shiki-0.14.5.tgz",
|
"resolved": "https://registry.npmjs.org/shiki/-/shiki-0.14.5.tgz",
|
||||||
@@ -1423,13 +1513,48 @@
|
|||||||
"resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-6.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-6.0.0.tgz",
|
||||||
"integrity": "sha512-isyNax3wXoKaulPDZWHQqbmIx1k2tb9fb3GGDBRxCscfYV2Ch7WxPArBsFEG8s/safwXTT7H4QGhaIkTp9447w=="
|
"integrity": "sha512-isyNax3wXoKaulPDZWHQqbmIx1k2tb9fb3GGDBRxCscfYV2Ch7WxPArBsFEG8s/safwXTT7H4QGhaIkTp9447w=="
|
||||||
},
|
},
|
||||||
"node_modules/unzip-stream": {
|
"node_modules/unzipper": {
|
||||||
"version": "0.3.1",
|
"version": "0.10.14",
|
||||||
"resolved": "https://registry.npmjs.org/unzip-stream/-/unzip-stream-0.3.1.tgz",
|
"resolved": "https://registry.npmjs.org/unzipper/-/unzipper-0.10.14.tgz",
|
||||||
"integrity": "sha512-RzaGXLNt+CW+T41h1zl6pGz3EaeVhYlK+rdAap+7DxW5kqsqePO8kRtWPaCiVqdhZc86EctSPVYNix30YOMzmw==",
|
"integrity": "sha512-ti4wZj+0bQTiX2KmKWuwj7lhV+2n//uXEotUmGuQqrbVZSEGFMbI68+c6JCQ8aAmUWYvtHEz2A8K6wXvueR/6g==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"binary": "^0.3.0",
|
"big-integer": "^1.6.17",
|
||||||
"mkdirp": "^0.5.1"
|
"binary": "~0.3.0",
|
||||||
|
"bluebird": "~3.4.1",
|
||||||
|
"buffer-indexof-polyfill": "~1.0.0",
|
||||||
|
"duplexer2": "~0.1.4",
|
||||||
|
"fstream": "^1.0.12",
|
||||||
|
"graceful-fs": "^4.2.2",
|
||||||
|
"listenercount": "~1.0.1",
|
||||||
|
"readable-stream": "~2.3.6",
|
||||||
|
"setimmediate": "~1.0.4"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/unzipper/node_modules/readable-stream": {
|
||||||
|
"version": "2.3.8",
|
||||||
|
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.8.tgz",
|
||||||
|
"integrity": "sha512-8p0AUk4XODgIewSi0l8Epjs+EVnWiK7NoDIEGU0HhE7+ZyY8D1IMY7odu5lRrFXGg71L15KG8QrPmum45RTtdA==",
|
||||||
|
"dependencies": {
|
||||||
|
"core-util-is": "~1.0.0",
|
||||||
|
"inherits": "~2.0.3",
|
||||||
|
"isarray": "~1.0.0",
|
||||||
|
"process-nextick-args": "~2.0.0",
|
||||||
|
"safe-buffer": "~5.1.1",
|
||||||
|
"string_decoder": "~1.1.1",
|
||||||
|
"util-deprecate": "~1.0.1"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/unzipper/node_modules/safe-buffer": {
|
||||||
|
"version": "5.1.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
|
||||||
|
"integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g=="
|
||||||
|
},
|
||||||
|
"node_modules/unzipper/node_modules/string_decoder": {
|
||||||
|
"version": "1.1.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz",
|
||||||
|
"integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==",
|
||||||
|
"dependencies": {
|
||||||
|
"safe-buffer": "~5.1.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/util-deprecate": {
|
"node_modules/util-deprecate": {
|
||||||
|
|||||||
@@ -49,15 +49,15 @@
|
|||||||
"@octokit/plugin-retry": "^3.0.9",
|
"@octokit/plugin-retry": "^3.0.9",
|
||||||
"@octokit/request-error": "^5.0.0",
|
"@octokit/request-error": "^5.0.0",
|
||||||
"@protobuf-ts/plugin": "^2.2.3-alpha.1",
|
"@protobuf-ts/plugin": "^2.2.3-alpha.1",
|
||||||
|
"@types/unzipper": "^0.10.6",
|
||||||
"archiver": "^5.3.1",
|
"archiver": "^5.3.1",
|
||||||
"crypto": "^1.0.1",
|
"crypto": "^1.0.1",
|
||||||
"jwt-decode": "^3.1.2",
|
"jwt-decode": "^3.1.2",
|
||||||
"twirp-ts": "^2.5.0",
|
"twirp-ts": "^2.5.0",
|
||||||
"unzip-stream": "^0.3.1"
|
"unzipper": "^0.10.14"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/archiver": "^5.3.2",
|
"@types/archiver": "^5.3.2",
|
||||||
"@types/unzip-stream": "^0.3.4",
|
|
||||||
"typedoc": "^0.25.4",
|
"typedoc": "^0.25.4",
|
||||||
"typedoc-plugin-markdown": "^3.17.1",
|
"typedoc-plugin-markdown": "^3.17.1",
|
||||||
"typescript": "^5.2.2"
|
"typescript": "^5.2.2"
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import fs from 'fs/promises'
|
|||||||
import * as github from '@actions/github'
|
import * as github from '@actions/github'
|
||||||
import * as core from '@actions/core'
|
import * as core from '@actions/core'
|
||||||
import * as httpClient from '@actions/http-client'
|
import * as httpClient from '@actions/http-client'
|
||||||
import unzip from 'unzip-stream'
|
import unzipper from 'unzipper'
|
||||||
import {
|
import {
|
||||||
DownloadArtifactOptions,
|
DownloadArtifactOptions,
|
||||||
DownloadArtifactResponse
|
DownloadArtifactResponse
|
||||||
@@ -47,12 +47,7 @@ async function streamExtract(url: string, directory: string): Promise<void> {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return response.message.pipe(unzipper.Extract({path: directory})).promise()
|
||||||
response.message
|
|
||||||
.pipe(unzip.Extract({path: directory}))
|
|
||||||
.on('close', resolve)
|
|
||||||
.on('error', reject)
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function downloadArtifactPublic(
|
export async function downloadArtifactPublic(
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import {info, debug} from '@actions/core'
|
|||||||
import {ArtifactServiceClientJSON} from '../../generated'
|
import {ArtifactServiceClientJSON} from '../../generated'
|
||||||
import {getResultsServiceUrl, getRuntimeToken} from './config'
|
import {getResultsServiceUrl, getRuntimeToken} from './config'
|
||||||
import {getUserAgentString} from './user-agent'
|
import {getUserAgentString} from './user-agent'
|
||||||
import {NetworkError, UsageError} from './errors'
|
|
||||||
|
|
||||||
// The twirp http client must implement this interface
|
// The twirp http client must implement this interface
|
||||||
interface Rpc {
|
interface Rpc {
|
||||||
@@ -60,11 +59,11 @@ class ArtifactHttpClient implements Rpc {
|
|||||||
'Content-Type': contentType
|
'Content-Type': contentType
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const {body} = await this.retryableRequest(async () =>
|
const response = await this.retryableRequest(async () =>
|
||||||
this.httpClient.post(url, JSON.stringify(data), headers)
|
this.httpClient.post(url, JSON.stringify(data), headers)
|
||||||
)
|
)
|
||||||
|
const body = await response.readBody()
|
||||||
return body
|
return JSON.parse(body)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw new Error(`Failed to ${method}: ${error.message}`)
|
throw new Error(`Failed to ${method}: ${error.message}`)
|
||||||
}
|
}
|
||||||
@@ -72,47 +71,25 @@ class ArtifactHttpClient implements Rpc {
|
|||||||
|
|
||||||
async retryableRequest(
|
async retryableRequest(
|
||||||
operation: () => Promise<HttpClientResponse>
|
operation: () => Promise<HttpClientResponse>
|
||||||
): Promise<{response: HttpClientResponse; body: object}> {
|
): Promise<HttpClientResponse> {
|
||||||
let attempt = 0
|
let attempt = 0
|
||||||
let errorMessage = ''
|
let errorMessage = ''
|
||||||
let rawBody = ''
|
|
||||||
while (attempt < this.maxAttempts) {
|
while (attempt < this.maxAttempts) {
|
||||||
let isRetryable = false
|
let isRetryable = false
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await operation()
|
const response = await operation()
|
||||||
const statusCode = response.message.statusCode
|
const statusCode = response.message.statusCode
|
||||||
rawBody = await response.readBody()
|
debug(`[Response] ${response.message.statusCode}`)
|
||||||
debug(`[Response] - ${response.message.statusCode}`)
|
debug(JSON.stringify(response.message.headers, null, 2))
|
||||||
debug(`Headers: ${JSON.stringify(response.message.headers, null, 2)}`)
|
|
||||||
const body = JSON.parse(rawBody)
|
|
||||||
debug(`Body: ${JSON.stringify(body, null, 2)}`)
|
|
||||||
if (this.isSuccessStatusCode(statusCode)) {
|
if (this.isSuccessStatusCode(statusCode)) {
|
||||||
return {response, body}
|
return response
|
||||||
}
|
}
|
||||||
|
|
||||||
isRetryable = this.isRetryableHttpStatusCode(statusCode)
|
isRetryable = this.isRetryableHttpStatusCode(statusCode)
|
||||||
errorMessage = `Failed request: (${statusCode}) ${response.message.statusMessage}`
|
errorMessage = `Failed request: (${statusCode}) ${response.message.statusMessage}`
|
||||||
if (body.msg) {
|
|
||||||
if (UsageError.isUsageErrorMessage(body.msg)) {
|
|
||||||
throw new UsageError()
|
|
||||||
}
|
|
||||||
|
|
||||||
errorMessage = `${errorMessage}: ${body.msg}`
|
|
||||||
}
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error instanceof SyntaxError) {
|
|
||||||
debug(`Raw Body: ${rawBody}`)
|
|
||||||
throw error
|
|
||||||
}
|
|
||||||
|
|
||||||
if (error instanceof UsageError) {
|
|
||||||
throw error
|
|
||||||
}
|
|
||||||
|
|
||||||
if (NetworkError.isNetworkErrorCode(error?.code)) {
|
|
||||||
throw new NetworkError(error?.code)
|
|
||||||
}
|
|
||||||
|
|
||||||
isRetryable = true
|
isRetryable = true
|
||||||
errorMessage = error.message
|
errorMessage = error.message
|
||||||
}
|
}
|
||||||
@@ -154,7 +131,8 @@ class ArtifactHttpClient implements Rpc {
|
|||||||
HttpCodes.GatewayTimeout,
|
HttpCodes.GatewayTimeout,
|
||||||
HttpCodes.InternalServerError,
|
HttpCodes.InternalServerError,
|
||||||
HttpCodes.ServiceUnavailable,
|
HttpCodes.ServiceUnavailable,
|
||||||
HttpCodes.TooManyRequests
|
HttpCodes.TooManyRequests,
|
||||||
|
413 // Payload Too Large
|
||||||
]
|
]
|
||||||
|
|
||||||
return retryableStatusCodes.includes(statusCode)
|
return retryableStatusCodes.includes(statusCode)
|
||||||
|
|||||||
@@ -35,38 +35,3 @@ export class GHESNotSupportedError extends Error {
|
|||||||
this.name = 'GHESNotSupportedError'
|
this.name = 'GHESNotSupportedError'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class NetworkError extends Error {
|
|
||||||
code: string
|
|
||||||
|
|
||||||
constructor(code: string) {
|
|
||||||
const message = `Unable to make request: ${code}\nIf you are using self-hosted runners, please make sure your runner has access to all GitHub endpoints: https://docs.github.com/en/actions/hosting-your-own-runners/managing-self-hosted-runners/about-self-hosted-runners#communication-between-self-hosted-runners-and-github`
|
|
||||||
super(message)
|
|
||||||
this.code = code
|
|
||||||
this.name = 'NetworkError'
|
|
||||||
}
|
|
||||||
|
|
||||||
static isNetworkErrorCode = (code?: string): boolean => {
|
|
||||||
if (!code) return false
|
|
||||||
return [
|
|
||||||
'ECONNRESET',
|
|
||||||
'ENOTFOUND',
|
|
||||||
'ETIMEDOUT',
|
|
||||||
'ECONNREFUSED',
|
|
||||||
'EHOSTUNREACH'
|
|
||||||
].includes(code)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export class UsageError extends Error {
|
|
||||||
constructor() {
|
|
||||||
const message = `Artifact storage quota has been hit. Unable to upload any new artifacts. Usage is recalculated every 6-12 hours.\nMore info on storage limits: https://docs.github.com/en/billing/managing-billing-for-github-actions/about-billing-for-github-actions#calculating-minute-and-storage-spending`
|
|
||||||
super(message)
|
|
||||||
this.name = 'UsageError'
|
|
||||||
}
|
|
||||||
|
|
||||||
static isUsageErrorMessage = (msg?: string): boolean => {
|
|
||||||
if (!msg) return false
|
|
||||||
return msg.includes('insufficient usage')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import {getUploadChunkSize, getConcurrency} from '../shared/config'
|
|||||||
import * as core from '@actions/core'
|
import * as core from '@actions/core'
|
||||||
import * as crypto from 'crypto'
|
import * as crypto from 'crypto'
|
||||||
import * as stream from 'stream'
|
import * as stream from 'stream'
|
||||||
import {NetworkError} from '../shared/errors'
|
|
||||||
|
|
||||||
export interface BlobUploadResponse {
|
export interface BlobUploadResponse {
|
||||||
/**
|
/**
|
||||||
@@ -53,20 +52,12 @@ export async function uploadZipToBlobStorage(
|
|||||||
|
|
||||||
core.info('Beginning upload of artifact content to blob storage')
|
core.info('Beginning upload of artifact content to blob storage')
|
||||||
|
|
||||||
try {
|
await blockBlobClient.uploadStream(
|
||||||
await blockBlobClient.uploadStream(
|
uploadStream,
|
||||||
uploadStream,
|
bufferSize,
|
||||||
bufferSize,
|
maxConcurrency,
|
||||||
maxConcurrency,
|
options
|
||||||
options
|
)
|
||||||
)
|
|
||||||
} catch (error) {
|
|
||||||
if (NetworkError.isNetworkErrorCode(error?.code)) {
|
|
||||||
throw new NetworkError(error?.code)
|
|
||||||
}
|
|
||||||
|
|
||||||
throw error
|
|
||||||
}
|
|
||||||
|
|
||||||
core.info('Finished uploading artifact content to blob storage!')
|
core.info('Finished uploading artifact content to blob storage!')
|
||||||
|
|
||||||
|
|||||||
@@ -40,6 +40,11 @@ export async function uploadArtifact(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const zipUploadStream = await createZipUploadStream(
|
||||||
|
zipSpecification,
|
||||||
|
options?.compressionLevel
|
||||||
|
)
|
||||||
|
|
||||||
// get the IDs needed for the artifact creation
|
// get the IDs needed for the artifact creation
|
||||||
const backendIds = getBackendIdsFromToken()
|
const backendIds = getBackendIdsFromToken()
|
||||||
|
|
||||||
@@ -68,11 +73,6 @@ export async function uploadArtifact(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const zipUploadStream = await createZipUploadStream(
|
|
||||||
zipSpecification,
|
|
||||||
options?.compressionLevel
|
|
||||||
)
|
|
||||||
|
|
||||||
// Upload zip to blob storage
|
// Upload zip to blob storage
|
||||||
const uploadResult = await uploadZipToBlobStorage(
|
const uploadResult = await uploadZipToBlobStorage(
|
||||||
createArtifactResp.signedUploadUrl,
|
createArtifactResp.signedUploadUrl,
|
||||||
|
|||||||
Reference in New Issue
Block a user