Add ACTIONS_ORCHESTRATION_ID support to http-client user-agent
Co-authored-by: TingluoHuang <[email protected]>
This commit is contained in:
co-authored by
TingluoHuang
parent
09cb71a033
commit
4e1c194b34
Vendored
+1180
File diff suppressed because it is too large
Load Diff
Vendored
+1
@@ -0,0 +1 @@
|
|||||||
|
12463729879319616318
|
||||||
Vendored
+21435
File diff suppressed because it is too large
Load Diff
Vendored
+22019
File diff suppressed because it is too large
Load Diff
+18
@@ -0,0 +1,18 @@
|
|||||||
|
|
||||||
|
> @actions/[email protected] tsc
|
||||||
|
> tsc
|
||||||
|
|
||||||
|
src/io-util.ts(1,21): error TS2307: Cannot find module 'fs' or its corresponding type declarations.
|
||||||
|
src/io-util.ts(2,23): error TS2307: Cannot find module 'path' or its corresponding type declarations.
|
||||||
|
src/io-util.ts(19,27): error TS2580: Cannot find name 'process'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.
|
||||||
|
src/io-util.ts(194,7): error TS2580: Cannot find name 'process'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.
|
||||||
|
src/io-util.ts(195,21): error TS2580: Cannot find name 'process'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.
|
||||||
|
src/io-util.ts(197,7): error TS2580: Cannot find name 'process'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.
|
||||||
|
src/io-util.ts(198,21): error TS2580: Cannot find name 'process'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.
|
||||||
|
src/io-util.ts(204,10): error TS2580: Cannot find name 'process'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.
|
||||||
|
src/io.ts(1,18): error TS2307: Cannot find module 'assert' or its corresponding type declarations.
|
||||||
|
src/io.ts(2,23): error TS2307: Cannot find module 'path' or its corresponding type declarations.
|
||||||
|
src/io.ts(200,28): error TS2580: Cannot find name 'process'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.
|
||||||
|
src/io.ts(201,29): error TS2580: Cannot find name 'process'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.
|
||||||
|
src/io.ts(232,7): error TS2580: Cannot find name 'process'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.
|
||||||
|
src/io.ts(233,21): error TS2580: Cannot find name 'process'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.
|
||||||
+43
@@ -0,0 +1,43 @@
|
|||||||
|
|
||||||
|
> @actions/[email protected] tsc
|
||||||
|
> tsc
|
||||||
|
|
||||||
|
src/auth.ts(1,23): error TS2307: Cannot find module 'http' or its corresponding type declarations.
|
||||||
|
src/auth.ts(18,49): error TS2580: Cannot find name 'Buffer'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.
|
||||||
|
src/auth.ts(74,49): error TS2580: Cannot find name 'Buffer'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.
|
||||||
|
src/index.ts(3,23): error TS2307: Cannot find module 'http' or its corresponding type declarations.
|
||||||
|
src/index.ts(4,24): error TS2307: Cannot find module 'https' or its corresponding type declarations.
|
||||||
|
src/index.ts(6,22): error TS2307: Cannot find module 'net' or its corresponding type declarations.
|
||||||
|
src/index.ts(8,25): error TS2307: Cannot find module 'tunnel' or its corresponding type declarations.
|
||||||
|
src/index.ts(9,26): error TS2307: Cannot find module 'undici' or its corresponding type declarations.
|
||||||
|
src/index.ts(95,20): error TS2580: Cannot find name 'Buffer'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.
|
||||||
|
src/index.ts(97,39): error TS2580: Cannot find name 'Buffer'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.
|
||||||
|
src/index.ts(98,18): error TS2580: Cannot find name 'Buffer'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.
|
||||||
|
src/index.ts(107,36): error TS2580: Cannot find name 'Buffer'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.
|
||||||
|
src/index.ts(108,24): error TS2580: Cannot find name 'Buffer'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.
|
||||||
|
src/index.ts(109,21): error TS2580: Cannot find name 'Buffer'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.
|
||||||
|
src/index.ts(111,39): error TS2580: Cannot find name 'Buffer'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.
|
||||||
|
src/index.ts(116,17): error TS2580: Cannot find name 'Buffer'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.
|
||||||
|
src/index.ts(241,13): error TS2503: Cannot find namespace 'NodeJS'.
|
||||||
|
src/index.ts(347,20): error TS2503: Cannot find namespace 'NodeJS'.
|
||||||
|
src/index.ts(359,48): error TS2550: Property 'includes' does not exist on type 'string[]'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2016' or later.
|
||||||
|
src/index.ts(395,27): error TS2550: Property 'includes' does not exist on type 'number[]'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2016' or later.
|
||||||
|
src/index.ts(438,33): error TS2550: Property 'includes' does not exist on type 'number[]'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2016' or later.
|
||||||
|
src/index.ts(473,20): error TS2503: Cannot find namespace 'NodeJS'.
|
||||||
|
src/index.ts(499,20): error TS2503: Cannot find namespace 'NodeJS'.
|
||||||
|
src/index.ts(506,48): error TS2580: Cannot find name 'Buffer'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.
|
||||||
|
src/index.ts(800,25): error TS2580: Cannot find name 'Buffer'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.
|
||||||
|
src/index.ts(820,20): error TS2580: Cannot find name 'process'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.
|
||||||
|
src/interfaces.ts(1,23): error TS2307: Cannot find module 'http' or its corresponding type declarations.
|
||||||
|
src/interfaces.ts(2,24): error TS2307: Cannot find module 'https' or its corresponding type declarations.
|
||||||
|
src/interfaces.ts(36,13): error TS2503: Cannot find namespace 'NodeJS'.
|
||||||
|
src/interfaces.ts(42,20): error TS2503: Cannot find namespace 'NodeJS'.
|
||||||
|
src/interfaces.ts(47,20): error TS2503: Cannot find namespace 'NodeJS'.
|
||||||
|
src/interfaces.ts(51,20): error TS2503: Cannot find namespace 'NodeJS'.
|
||||||
|
src/interfaces.ts(62,20): error TS2503: Cannot find namespace 'NodeJS'.
|
||||||
|
src/proxy.ts(10,14): error TS2580: Cannot find name 'process'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.
|
||||||
|
src/proxy.ts(10,44): error TS2580: Cannot find name 'process'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.
|
||||||
|
src/proxy.ts(12,14): error TS2580: Cannot find name 'process'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.
|
||||||
|
src/proxy.ts(12,43): error TS2580: Cannot find name 'process'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.
|
||||||
|
src/proxy.ts(38,19): error TS2580: Cannot find name 'process'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.
|
||||||
|
src/proxy.ts(38,46): error TS2580: Cannot find name 'process'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.
|
||||||
+36
@@ -0,0 +1,36 @@
|
|||||||
|
|
||||||
|
> @actions/[email protected] tsc
|
||||||
|
> tsc
|
||||||
|
|
||||||
|
src/context.ts(3,40): error TS2307: Cannot find module 'fs' or its corresponding type declarations.
|
||||||
|
src/context.ts(4,19): error TS2307: Cannot find module 'os' or its corresponding type declarations.
|
||||||
|
src/context.ts(31,9): error TS2580: Cannot find name 'process'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.
|
||||||
|
src/context.ts(32,22): error TS2580: Cannot find name 'process'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.
|
||||||
|
src/context.ts(34,24): error TS2580: Cannot find name 'process'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.
|
||||||
|
src/context.ts(37,22): error TS2580: Cannot find name 'process'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.
|
||||||
|
src/context.ts(38,9): error TS2580: Cannot find name 'process'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.
|
||||||
|
src/context.ts(41,22): error TS2580: Cannot find name 'process'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.
|
||||||
|
src/context.ts(42,16): error TS2580: Cannot find name 'process'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.
|
||||||
|
src/context.ts(43,16): error TS2580: Cannot find name 'process'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.
|
||||||
|
src/context.ts(44,21): error TS2580: Cannot find name 'process'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.
|
||||||
|
src/context.ts(45,19): error TS2580: Cannot find name 'process'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.
|
||||||
|
src/context.ts(46,18): error TS2580: Cannot find name 'process'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.
|
||||||
|
src/context.ts(47,16): error TS2580: Cannot find name 'process'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.
|
||||||
|
src/context.ts(48,32): error TS2580: Cannot find name 'process'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.
|
||||||
|
src/context.ts(49,31): error TS2580: Cannot find name 'process'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.
|
||||||
|
src/context.ts(50,27): error TS2580: Cannot find name 'process'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.
|
||||||
|
src/context.ts(51,19): error TS2580: Cannot find name 'process'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.
|
||||||
|
src/context.ts(52,22): error TS2580: Cannot find name 'process'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.
|
||||||
|
src/context.ts(54,7): error TS2580: Cannot find name 'process'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.
|
||||||
|
src/context.ts(67,9): error TS2580: Cannot find name 'process'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.
|
||||||
|
src/context.ts(68,29): error TS2580: Cannot find name 'process'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.
|
||||||
|
src/github.ts(5,45): error TS2307: Cannot find module '@octokit/core/dist-types/types' or its corresponding type declarations.
|
||||||
|
src/internal/utils.ts(1,23): error TS2307: Cannot find module 'http' or its corresponding type declarations.
|
||||||
|
src/internal/utils.ts(2,29): error TS2307: Cannot find module '@actions/http-client' or its corresponding type declarations.
|
||||||
|
src/internal/utils.ts(3,30): error TS2307: Cannot find module '@octokit/core/dist-types/types' or its corresponding type declarations.
|
||||||
|
src/internal/utils.ts(4,33): error TS2307: Cannot find module 'undici' or its corresponding type declarations.
|
||||||
|
src/internal/utils.ts(43,10): error TS2580: Cannot find name 'process'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.
|
||||||
|
src/utils.ts(5,23): error TS2307: Cannot find module '@octokit/core' or its corresponding type declarations.
|
||||||
|
src/utils.ts(6,30): error TS2307: Cannot find module '@octokit/core/dist-types/types' or its corresponding type declarations.
|
||||||
|
src/utils.ts(7,35): error TS2307: Cannot find module '@octokit/plugin-rest-endpoint-methods' or its corresponding type declarations.
|
||||||
|
src/utils.ts(8,28): error TS2307: Cannot find module '@octokit/plugin-paginate-rest' or its corresponding type declarations.
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1 @@
|
|||||||
|
4457673479152766597
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
4457673479152766597
|
||||||
Binary file not shown.
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Generated
+2
-3
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "@actions/artifact",
|
"name": "@actions/artifact",
|
||||||
"version": "5.0.0",
|
"version": "5.0.1",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "@actions/artifact",
|
"name": "@actions/artifact",
|
||||||
"version": "5.0.0",
|
"version": "5.0.1",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "^2.0.0",
|
"@actions/core": "^2.0.0",
|
||||||
@@ -1986,7 +1986,6 @@
|
|||||||
"version": "5.9.2",
|
"version": "5.9.2",
|
||||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.2.tgz",
|
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.2.tgz",
|
||||||
"integrity": "sha512-CWBzXQrc/qOkhidw1OzBTQuYRbfyxDXJMVJ1XNwUHGROVmuaeiEm3OslpZ1RV96d7SKKjZKrSJu3+t/xlw3R9A==",
|
"integrity": "sha512-CWBzXQrc/qOkhidw1OzBTQuYRbfyxDXJMVJ1XNwUHGROVmuaeiEm3OslpZ1RV96d7SKKjZKrSJu3+t/xlw3R9A==",
|
||||||
"dev": true,
|
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"bin": {
|
"bin": {
|
||||||
"tsc": "bin/tsc",
|
"tsc": "bin/tsc",
|
||||||
|
|||||||
+2
-2
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "@actions/cache",
|
"name": "@actions/cache",
|
||||||
"version": "5.0.0",
|
"version": "5.0.1",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "@actions/cache",
|
"name": "@actions/cache",
|
||||||
"version": "5.0.0",
|
"version": "5.0.1",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "^2.0.0",
|
"@actions/core": "^2.0.0",
|
||||||
|
|||||||
@@ -374,4 +374,35 @@ describe('basics', () => {
|
|||||||
httpm.MediaTypes.ApplicationJson
|
httpm.MediaTypes.ApplicationJson
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('appends orchestration ID to user-agent when ACTIONS_ORCHESTRATION_ID is set', async () => {
|
||||||
|
const orchId = 'test-orch-id-12345'
|
||||||
|
process.env['ACTIONS_ORCHESTRATION_ID'] = orchId
|
||||||
|
|
||||||
|
const http: httpm.HttpClient = new httpm.HttpClient('http-client-tests')
|
||||||
|
const res: httpm.HttpClientResponse = await http.get(
|
||||||
|
'https://postman-echo.com/get'
|
||||||
|
)
|
||||||
|
expect(res.message.statusCode).toBe(200)
|
||||||
|
const body: string = await res.readBody()
|
||||||
|
const obj = JSON.parse(body)
|
||||||
|
expect(obj.headers['user-agent']).toBe(
|
||||||
|
`http-client-tests (gh_orch_id:${orchId})`
|
||||||
|
)
|
||||||
|
|
||||||
|
delete process.env['ACTIONS_ORCHESTRATION_ID']
|
||||||
|
})
|
||||||
|
|
||||||
|
it('does not modify user-agent when ACTIONS_ORCHESTRATION_ID is not set', async () => {
|
||||||
|
delete process.env['ACTIONS_ORCHESTRATION_ID']
|
||||||
|
|
||||||
|
const http: httpm.HttpClient = new httpm.HttpClient('http-client-tests')
|
||||||
|
const res: httpm.HttpClientResponse = await http.get(
|
||||||
|
'https://postman-echo.com/get'
|
||||||
|
)
|
||||||
|
expect(res.message.statusCode).toBe(200)
|
||||||
|
const body: string = await res.readBody()
|
||||||
|
const obj = JSON.parse(body)
|
||||||
|
expect(obj.headers['user-agent']).toBe('http-client-tests')
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -599,7 +599,7 @@ export class HttpClient {
|
|||||||
info.options.method = method
|
info.options.method = method
|
||||||
info.options.headers = this._mergeHeaders(headers)
|
info.options.headers = this._mergeHeaders(headers)
|
||||||
if (this.userAgent != null) {
|
if (this.userAgent != null) {
|
||||||
info.options.headers['user-agent'] = this.userAgent
|
info.options.headers['user-agent'] = this._getUserAgentWithOrchestrationId(this.userAgent)
|
||||||
}
|
}
|
||||||
|
|
||||||
info.options.agent = this._getAgent(info.parsedUrl)
|
info.options.agent = this._getAgent(info.parsedUrl)
|
||||||
@@ -816,6 +816,14 @@ export class HttpClient {
|
|||||||
return proxyAgent
|
return proxyAgent
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private _getUserAgentWithOrchestrationId(userAgent: string): string {
|
||||||
|
const orchId = process.env['ACTIONS_ORCHESTRATION_ID']
|
||||||
|
if (orchId) {
|
||||||
|
return `${userAgent} (gh_orch_id:${orchId})`
|
||||||
|
}
|
||||||
|
return userAgent
|
||||||
|
}
|
||||||
|
|
||||||
private async _performExponentialBackoff(retryNumber: number): Promise<void> {
|
private async _performExponentialBackoff(retryNumber: number): Promise<void> {
|
||||||
retryNumber = Math.min(ExponentialBackoffCeiling, retryNumber)
|
retryNumber = Math.min(ExponentialBackoffCeiling, retryNumber)
|
||||||
const ms: number = ExponentialBackoffTimeSlice * Math.pow(2, retryNumber)
|
const ms: number = ExponentialBackoffTimeSlice * Math.pow(2, retryNumber)
|
||||||
|
|||||||
Reference in New Issue
Block a user