mirror of https://github.com/actions/toolkit
update 403 error message for ghes
parent
91d3933eb5
commit
1c71f655eb
|
@ -2,6 +2,7 @@ import * as http from 'http'
|
||||||
import * as io from '../../io/src/io'
|
import * as io from '../../io/src/io'
|
||||||
import * as net from 'net'
|
import * as net from 'net'
|
||||||
import * as path from 'path'
|
import * as path from 'path'
|
||||||
|
import * as config from '../src/internal/config-variables'
|
||||||
import {mocked} from 'ts-jest/utils'
|
import {mocked} from 'ts-jest/utils'
|
||||||
import {exec, execSync} from 'child_process'
|
import {exec, execSync} from 'child_process'
|
||||||
import {createGunzip} from 'zlib'
|
import {createGunzip} from 'zlib'
|
||||||
|
@ -134,6 +135,19 @@ describe('Upload Tests', () => {
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('Create Artifact - Storage Quota Error on GHES', async () => {
|
||||||
|
jest.spyOn(config, 'isGhes').mockReturnValueOnce(true)
|
||||||
|
const artifactName = 'storage-quota-hit'
|
||||||
|
const uploadHttpClient = new UploadHttpClient()
|
||||||
|
expect(
|
||||||
|
uploadHttpClient.createArtifactInFileContainer(artifactName)
|
||||||
|
).rejects.toEqual(
|
||||||
|
new Error(
|
||||||
|
'Create Artifact Container failed: Please reference [Enabling GitHub Actions for GitHub Enterprise Server](https://docs.github.com/en/enterprise-server@3.8/admin/github-actions/enabling-github-actions-for-github-enterprise-server) to ensure Actions storage is configured correctly.'
|
||||||
|
)
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Artifact Upload Tests
|
* Artifact Upload Tests
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -20,18 +20,18 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@actions/core": {
|
"node_modules/@actions/core": {
|
||||||
"version": "1.9.1",
|
"version": "1.10.0",
|
||||||
"resolved": "https://registry.npmjs.org/@actions/core/-/core-1.9.1.tgz",
|
"resolved": "https://registry.npmjs.org/@actions/core/-/core-1.10.0.tgz",
|
||||||
"integrity": "sha512-5ad+U2YGrmmiw6du20AQW5XuWo7UKN2052FjSV7MX+Wfjf8sCqcsZe62NfgHys4QI4/Y+vQvLKYL8jWtA1ZBTA==",
|
"integrity": "sha512-2aZDDa3zrrZbP5ZYg159sNoLRb61nQ7awl5pSvIq5Qpj81vwDzdMRKzkWJGJuwVvWpvZKx7vspJALyvaaIQyug==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/http-client": "^2.0.1",
|
"@actions/http-client": "^2.0.1",
|
||||||
"uuid": "^8.3.2"
|
"uuid": "^8.3.2"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@actions/http-client": {
|
"node_modules/@actions/http-client": {
|
||||||
"version": "2.0.1",
|
"version": "2.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-2.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-2.1.1.tgz",
|
||||||
"integrity": "sha512-PIXiMVtz6VvyaRsGY268qvj57hXQEpsYogYOu2nrQhlf+XCGmZstmuZBbAybUl1nQGnvS1k1eEsQ69ZoD7xlSw==",
|
"integrity": "sha512-qhrkRMB40bbbLo7gF+0vu+X+UawOvQQqNAA/5Unx774RS8poaOhThDOG6BGmxvAnxhQnDp2BG/ZUm65xZILTpw==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"tunnel": "^0.0.6"
|
"tunnel": "^0.0.6"
|
||||||
}
|
}
|
||||||
|
@ -196,18 +196,18 @@
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": {
|
"@actions/core": {
|
||||||
"version": "1.9.1",
|
"version": "1.10.0",
|
||||||
"resolved": "https://registry.npmjs.org/@actions/core/-/core-1.9.1.tgz",
|
"resolved": "https://registry.npmjs.org/@actions/core/-/core-1.10.0.tgz",
|
||||||
"integrity": "sha512-5ad+U2YGrmmiw6du20AQW5XuWo7UKN2052FjSV7MX+Wfjf8sCqcsZe62NfgHys4QI4/Y+vQvLKYL8jWtA1ZBTA==",
|
"integrity": "sha512-2aZDDa3zrrZbP5ZYg159sNoLRb61nQ7awl5pSvIq5Qpj81vwDzdMRKzkWJGJuwVvWpvZKx7vspJALyvaaIQyug==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"@actions/http-client": "^2.0.1",
|
"@actions/http-client": "^2.0.1",
|
||||||
"uuid": "^8.3.2"
|
"uuid": "^8.3.2"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@actions/http-client": {
|
"@actions/http-client": {
|
||||||
"version": "2.0.1",
|
"version": "2.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-2.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-2.1.1.tgz",
|
||||||
"integrity": "sha512-PIXiMVtz6VvyaRsGY268qvj57hXQEpsYogYOu2nrQhlf+XCGmZstmuZBbAybUl1nQGnvS1k1eEsQ69ZoD7xlSw==",
|
"integrity": "sha512-qhrkRMB40bbbLo7gF+0vu+X+UawOvQQqNAA/5Unx774RS8poaOhThDOG6BGmxvAnxhQnDp2BG/ZUm65xZILTpw==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"tunnel": "^0.0.6"
|
"tunnel": "^0.0.6"
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,3 +49,7 @@ export function getWorkFlowRunId(): string {
|
||||||
export function getRetentionDays(): string | undefined {
|
export function getRetentionDays(): string | undefined {
|
||||||
return '45'
|
return '45'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function isGhes(): boolean {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
|
@ -65,3 +65,10 @@ export function getWorkSpaceDirectory(): string {
|
||||||
export function getRetentionDays(): string | undefined {
|
export function getRetentionDays(): string | undefined {
|
||||||
return process.env['GITHUB_RETENTION_DAYS']
|
return process.env['GITHUB_RETENTION_DAYS']
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function isGhes(): boolean {
|
||||||
|
const ghUrl = new URL(
|
||||||
|
process.env['GITHUB_SERVER_URL'] || 'https://github.com'
|
||||||
|
)
|
||||||
|
return ghUrl.hostname.toUpperCase() !== 'GITHUB.COM'
|
||||||
|
}
|
||||||
|
|
|
@ -26,7 +26,8 @@ import {
|
||||||
getUploadChunkSize,
|
getUploadChunkSize,
|
||||||
getUploadFileConcurrency,
|
getUploadFileConcurrency,
|
||||||
getRetryLimit,
|
getRetryLimit,
|
||||||
getRetentionDays
|
getRetentionDays,
|
||||||
|
isGhes
|
||||||
} from './config-variables'
|
} from './config-variables'
|
||||||
import {promisify} from 'util'
|
import {promisify} from 'util'
|
||||||
import {URL} from 'url'
|
import {URL} from 'url'
|
||||||
|
@ -88,7 +89,9 @@ export class UploadHttpClient {
|
||||||
const customErrorMessages: Map<number, string> = new Map([
|
const customErrorMessages: Map<number, string> = new Map([
|
||||||
[
|
[
|
||||||
HttpCodes.Forbidden,
|
HttpCodes.Forbidden,
|
||||||
'Artifact storage quota has been hit. Unable to upload any new artifacts'
|
isGhes()
|
||||||
|
? 'Please reference [Enabling GitHub Actions for GitHub Enterprise Server](https://docs.github.com/en/enterprise-server@3.8/admin/github-actions/enabling-github-actions-for-github-enterprise-server) to ensure Actions storage is configured correctly.'
|
||||||
|
: 'Artifact storage quota has been hit. Unable to upload any new artifacts'
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
HttpCodes.BadRequest,
|
HttpCodes.BadRequest,
|
||||||
|
|
Loading…
Reference in New Issue