diff --git a/RELEASES.md b/RELEASES.md index 8f3fd7132c..3d4425d8b3 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -77,4 +77,8 @@ ### 1.0.0 -- Update `lockfileVersion` to `v2` in `package-lock.json [#1009](https://github.com/actions/toolkit/pull/1009) \ No newline at end of file +- Update `lockfileVersion` to `v2` in `package-lock.json` [#1009](https://github.com/actions/toolkit/pull/1009) + +### 1.0.1 + +- Update to v2.0.0 of `@actions/http-client` \ No newline at end of file diff --git a/__tests__/retry.test.ts b/__tests__/retry.test.ts index 12c497842a..d1e9256ed0 100644 --- a/__tests__/retry.test.ts +++ b/__tests__/retry.test.ts @@ -3,7 +3,6 @@ import * as net from 'net' import * as core from '@actions/core' import * as configVariables from '../src/internal/config-variables' import {retry} from '../src/internal/requestUtils' -import {IHttpClientResponse} from '@actions/http-client/interfaces' import {HttpClientResponse} from '@actions/http-client' jest.mock('../src/internal/config-variables') @@ -42,7 +41,7 @@ async function testRetry( async function handleResponse( testResponseCode: number | undefined -): Promise { +): Promise { if (!testResponseCode) { throw new Error( 'Test incorrectly set up. reverse.pop() was called too many times so not enough test response codes were supplied' @@ -72,7 +71,7 @@ async function emptyMockReadBody(): Promise { async function setupSingleMockResponse( statusCode: number -): Promise { +): Promise { const mockMessage = new http.IncomingMessage(new net.Socket()) const mockReadBody = emptyMockReadBody mockMessage.statusCode = statusCode diff --git a/package-lock.json b/package-lock.json index 7f5ec7d259..56e6a712eb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,16 +1,16 @@ { "name": "@actions/artifact", - "version": "0.6.1", + "version": "1.0.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@actions/artifact", - "version": "0.6.1", + "version": "1.0.1", "license": "MIT", "dependencies": { "@actions/core": "^1.2.6", - "@actions/http-client": "^1.0.11", + "@actions/http-client": "^2.0.0", "tmp": "^0.2.1", "tmp-promise": "^3.0.2" }, @@ -20,14 +20,14 @@ } }, "node_modules/@actions/core": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/@actions/core/-/core-1.6.0.tgz", - "integrity": "sha512-NB1UAZomZlCV/LmJqkLhNTqtKfFXJZAUPcfl/zqG7EfsQdeUJtaWO98SGbuQ3pydJ3fHl2CvI/51OKYlCYYcaw==", + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/@actions/core/-/core-1.8.0.tgz", + "integrity": "sha512-XirM+Zo/PFlA+1h+i4bkfvagujta+LIM2AOSzPbt8JqXbbuxb1HTB+FqIyaKmue9yiCx/JIJY6pXsOl3+T8JGw==", "dependencies": { "@actions/http-client": "^1.0.11" } }, - "node_modules/@actions/http-client": { + "node_modules/@actions/core/node_modules/@actions/http-client": { "version": "1.0.11", "resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-1.0.11.tgz", "integrity": "sha512-VRYHGQV1rqnROJqdMvGUbY/Kn8vriQe/F9HR2AlYHzmKuM/p3kjNuXhmdBfcVgsvRWTz5C5XW5xvndZrVBuAYg==", @@ -35,6 +35,11 @@ "tunnel": "0.0.6" } }, + "node_modules/@actions/http-client": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-2.0.0.tgz", + "integrity": "sha512-fm1+OPPey5ypgStT9K8zbBhICj4J4UV/TJIHDhuWlkb8KyJaAtjcZK184dTqul0dV0nPKX97FNtDXX20BTLXSA==" + }, "node_modules/@types/tmp": { "version": "0.2.3", "resolved": "https://registry.npmjs.org/@types/tmp/-/tmp-0.2.3.tgz", @@ -187,20 +192,27 @@ }, "dependencies": { "@actions/core": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/@actions/core/-/core-1.6.0.tgz", - "integrity": "sha512-NB1UAZomZlCV/LmJqkLhNTqtKfFXJZAUPcfl/zqG7EfsQdeUJtaWO98SGbuQ3pydJ3fHl2CvI/51OKYlCYYcaw==", + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/@actions/core/-/core-1.8.0.tgz", + "integrity": "sha512-XirM+Zo/PFlA+1h+i4bkfvagujta+LIM2AOSzPbt8JqXbbuxb1HTB+FqIyaKmue9yiCx/JIJY6pXsOl3+T8JGw==", "requires": { "@actions/http-client": "^1.0.11" + }, + "dependencies": { + "@actions/http-client": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-1.0.11.tgz", + "integrity": "sha512-VRYHGQV1rqnROJqdMvGUbY/Kn8vriQe/F9HR2AlYHzmKuM/p3kjNuXhmdBfcVgsvRWTz5C5XW5xvndZrVBuAYg==", + "requires": { + "tunnel": "0.0.6" + } + } } }, "@actions/http-client": { - "version": "1.0.11", - "resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-1.0.11.tgz", - "integrity": "sha512-VRYHGQV1rqnROJqdMvGUbY/Kn8vriQe/F9HR2AlYHzmKuM/p3kjNuXhmdBfcVgsvRWTz5C5XW5xvndZrVBuAYg==", - "requires": { - "tunnel": "0.0.6" - } + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-2.0.0.tgz", + "integrity": "sha512-fm1+OPPey5ypgStT9K8zbBhICj4J4UV/TJIHDhuWlkb8KyJaAtjcZK184dTqul0dV0nPKX97FNtDXX20BTLXSA==" }, "@types/tmp": { "version": "0.2.3", diff --git a/package.json b/package.json index 6dd84aa236..64c5166867 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@actions/artifact", - "version": "1.0.0", + "version": "1.0.1", "preview": true, "description": "Actions artifact lib", "keywords": [ @@ -38,7 +38,7 @@ }, "dependencies": { "@actions/core": "^1.2.6", - "@actions/http-client": "^1.0.11", + "@actions/http-client": "^2.0.0", "tmp": "^0.2.1", "tmp-promise": "^3.0.2" }, diff --git a/src/internal/download-http-client.ts b/src/internal/download-http-client.ts index c81ac917a6..2df4675fec 100644 --- a/src/internal/download-http-client.ts +++ b/src/internal/download-http-client.ts @@ -18,7 +18,7 @@ import {URL} from 'url' import {StatusReporter} from './status-reporter' import {performance} from 'perf_hooks' import {ListArtifactsResponse, QueryArtifactResponse} from './contracts' -import {IHttpClientResponse} from '@actions/http-client/interfaces' +import {HttpClientResponse} from '@actions/http-client' import {HttpManager} from './http-manager' import {DownloadItem} from './download-specification' import {getDownloadFileConcurrency, getRetryLimit} from './config-variables' @@ -152,7 +152,7 @@ export class DownloadHttpClient { const headers = getDownloadHeaders('application/json', true, true) // a single GET request is used to download a file - const makeDownloadRequest = async (): Promise => { + const makeDownloadRequest = async (): Promise => { const client = this.downloadHttpManager.getClient(httpClientIndex) return await client.get(artifactLocation, headers) } @@ -225,7 +225,7 @@ export class DownloadHttpClient { // keep trying to download a file until a retry limit has been reached while (retryCount <= retryLimit) { - let response: IHttpClientResponse + let response: HttpClientResponse try { response = await makeDownloadRequest() } catch (error) { @@ -295,7 +295,7 @@ export class DownloadHttpClient { * @param isGzip a boolean denoting if the content is compressed using gzip and if we need to decode it */ async pipeResponseToFile( - response: IHttpClientResponse, + response: HttpClientResponse, destinationStream: fs.WriteStream, isGzip: boolean ): Promise { diff --git a/src/internal/http-manager.ts b/src/internal/http-manager.ts index 9c19a620e4..9b44fb8584 100644 --- a/src/internal/http-manager.ts +++ b/src/internal/http-manager.ts @@ -1,4 +1,4 @@ -import {HttpClient} from '@actions/http-client/index' +import {HttpClient} from '@actions/http-client' import {createHttpClient} from './utils' /** diff --git a/src/internal/requestUtils.ts b/src/internal/requestUtils.ts index 65f40e7bfa..4abc5b039d 100644 --- a/src/internal/requestUtils.ts +++ b/src/internal/requestUtils.ts @@ -1,4 +1,4 @@ -import {IHttpClientResponse} from '@actions/http-client/interfaces' +import {HttpClientResponse} from '@actions/http-client' import { isRetryableStatusCode, isSuccessStatusCode, @@ -11,11 +11,11 @@ import {getRetryLimit} from './config-variables' export async function retry( name: string, - operation: () => Promise, + operation: () => Promise, customErrorMessages: Map, maxAttempts: number -): Promise { - let response: IHttpClientResponse | undefined = undefined +): Promise { + let response: HttpClientResponse | undefined = undefined let statusCode: number | undefined = undefined let isRetryable = false let errorMessage = '' @@ -71,9 +71,9 @@ export async function retry( export async function retryHttpClientRequest( name: string, - method: () => Promise, + method: () => Promise, customErrorMessages: Map = new Map(), maxAttempts = getRetryLimit() -): Promise { +): Promise { return await retry(name, method, customErrorMessages, maxAttempts) } diff --git a/src/internal/upload-http-client.ts b/src/internal/upload-http-client.ts index 9892a42d79..180466e78f 100644 --- a/src/internal/upload-http-client.ts +++ b/src/internal/upload-http-client.ts @@ -31,8 +31,7 @@ import {promisify} from 'util' import {URL} from 'url' import {performance} from 'perf_hooks' import {StatusReporter} from './status-reporter' -import {HttpCodes} from '@actions/http-client' -import {IHttpClientResponse} from '@actions/http-client/interfaces' +import {HttpCodes, HttpClientResponse} from '@actions/http-client' import {HttpManager} from './http-manager' import {UploadSpecification} from './upload-specification' import {UploadOptions} from './upload-options' @@ -416,7 +415,7 @@ export class UploadHttpClient { getContentRange(start, end, uploadFileSize) ) - const uploadChunkRequest = async (): Promise => { + const uploadChunkRequest = async (): Promise => { const client = this.uploadHttpManager.getClient(httpClientIndex) return await client.sendStream('PUT', resourceUrl, openStream(), headers) } @@ -427,7 +426,7 @@ export class UploadHttpClient { // Increments the current retry count and then checks if the retry limit has been reached // If there have been too many retries, fail so the download stops const incrementAndCheckRetryLimit = ( - response?: IHttpClientResponse + response?: HttpClientResponse ): boolean => { retryCount++ if (retryCount > retryLimit) { @@ -464,7 +463,7 @@ export class UploadHttpClient { // allow for failed chunks to be retried multiple times while (retryCount <= retryLimit) { - let response: IHttpClientResponse + let response: HttpClientResponse try { response = await uploadChunkRequest() diff --git a/src/internal/utils.ts b/src/internal/utils.ts index f2b99f335c..2f2883e7ac 100644 --- a/src/internal/utils.ts +++ b/src/internal/utils.ts @@ -1,9 +1,8 @@ -import {debug, info, warning} from '@actions/core' import {promises as fs} from 'fs' -import {HttpCodes, HttpClient} from '@actions/http-client' -import {BearerCredentialHandler} from '@actions/http-client/auth' -import {IHeaders, IHttpClientResponse} from '@actions/http-client/interfaces' -import {IncomingHttpHeaders} from 'http' +import {IncomingHttpHeaders, OutgoingHttpHeaders} from 'http' +import {debug, info, warning} from '@actions/core' +import {HttpCodes, HttpClient, HttpClientResponse} from '@actions/http-client' +import {BearerCredentialHandler} from '@actions/http-client/lib/auth' import { getRuntimeToken, getRuntimeUrl, @@ -139,8 +138,8 @@ export function getDownloadHeaders( contentType: string, isKeepAlive?: boolean, acceptGzip?: boolean -): IHeaders { - const requestOptions: IHeaders = {} +): OutgoingHttpHeaders { + const requestOptions: OutgoingHttpHeaders = {} if (contentType) { requestOptions['Content-Type'] = contentType @@ -181,8 +180,8 @@ export function getUploadHeaders( uncompressedLength?: number, contentLength?: number, contentRange?: string -): IHeaders { - const requestOptions: IHeaders = {} +): OutgoingHttpHeaders { + const requestOptions: OutgoingHttpHeaders = {} requestOptions['Accept'] = `application/json;api-version=${getApiVersion()}` if (contentType) { requestOptions['Content-Type'] = contentType @@ -227,7 +226,7 @@ export function getArtifactUrl(): string { * Certain information such as the TLSSocket and the Readable state are not really useful for diagnostic purposes so they can be avoided. * Other information such as the headers, the response code and message might be useful, so this is displayed. */ -export function displayHttpDiagnostics(response: IHttpClientResponse): void { +export function displayHttpDiagnostics(response: HttpClientResponse): void { info( `##### Begin Diagnostic HTTP information ##### Status Code: ${response.message.statusCode}