diff --git a/RELEASES.md b/RELEASES.md index ec77c2b..58217f8 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -56,3 +56,6 @@ ### 2.0.0 - Added support to check if Actions cache service feature is available or not [#1028](https://github.com/actions/toolkit/pull/1028) + +### 2.0.3 +- Update to v2.0.0 of `@actions/http-client` \ No newline at end of file diff --git a/__tests__/saveCache.test.ts b/__tests__/saveCache.test.ts index 6949759..4627f2c 100644 --- a/__tests__/saveCache.test.ts +++ b/__tests__/saveCache.test.ts @@ -5,7 +5,7 @@ import * as cacheHttpClient from '../src/internal/cacheHttpClient' import * as cacheUtils from '../src/internal/cacheUtils' import {CacheFilename, CompressionMethod} from '../src/internal/constants' import * as tar from '../src/internal/tar' -import {ITypedResponse} from '@actions/http-client/interfaces' +import {TypedResponse} from '@actions/http-client/lib/interfaces' import { ReserveCacheResponse, ITypedResponseWithError @@ -172,7 +172,7 @@ test('save with reserve cache failure should fail', async () => { const reserveCacheMock = jest .spyOn(cacheHttpClient, 'reserveCache') .mockImplementation(async () => { - const response: ITypedResponse = { + const response: TypedResponse = { statusCode: 500, result: null, headers: {} @@ -208,7 +208,7 @@ test('save with server error should fail', async () => { const reserveCacheMock = jest .spyOn(cacheHttpClient, 'reserveCache') .mockImplementation(async () => { - const response: ITypedResponse = { + const response: TypedResponse = { statusCode: 500, result: {cacheId}, headers: {} @@ -257,7 +257,7 @@ test('save with valid inputs uploads a cache', async () => { const reserveCacheMock = jest .spyOn(cacheHttpClient, 'reserveCache') .mockImplementation(async () => { - const response: ITypedResponse = { + const response: TypedResponse = { statusCode: 500, result: {cacheId}, headers: {} diff --git a/package-lock.json b/package-lock.json index 2ec7b7d..d577d79 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,18 +1,18 @@ { "name": "@actions/cache", - "version": "2.0.2", + "version": "2.0.3", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@actions/cache", - "version": "2.0.0", + "version": "2.0.3", "license": "MIT", "dependencies": { "@actions/core": "^1.2.6", "@actions/exec": "^1.0.1", "@actions/glob": "^0.1.0", - "@actions/http-client": "^1.0.9", + "@actions/http-client": "^2.0.0", "@actions/io": "^1.0.1", "@azure/ms-rest-js": "^2.6.0", "@azure/storage-blob": "^12.8.0", @@ -31,9 +31,9 @@ "integrity": "sha512-ZQYitnqiyBc3D+k7LsgSBmMDVkOVidaagDG7j3fOym77jNunWRuYx7VSHa9GNfFZh+zh61xsCjRj4JxMZlDqTA==" }, "node_modules/@actions/exec": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/@actions/exec/-/exec-1.0.4.tgz", - "integrity": "sha512-4DPChWow9yc9W3WqEbUj8Nr86xkpyE29ZzWjXucHItclLbEW6jr80Zx4nqv18QL6KK65+cifiQZXvnqgTV6oHw==", + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/@actions/exec/-/exec-1.1.1.tgz", + "integrity": "sha512-+sCcHHbVdk93a0XT19ECtO/gIXoxvdsgQLzb2fE2/5sIZmWQuluYyjPQtrtTHdU1YzTZ7bAPN4sITq2xi1679w==", "dependencies": { "@actions/io": "^1.0.1" } @@ -48,25 +48,14 @@ } }, "node_modules/@actions/http-client": { - "version": "1.0.9", - "resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-1.0.9.tgz", - "integrity": "sha512-0O4SsJ7q+MK0ycvXPl2e6bMXV7dxAXOGjrXS1eTF9s2S401Tp6c/P3c3Joz04QefC1J6Gt942Wl2jbm3f4mLcg==", - "dependencies": { - "tunnel": "0.0.6" - } - }, - "node_modules/@actions/http-client/node_modules/tunnel": { - "version": "0.0.6", - "resolved": "https://registry.npmjs.org/tunnel/-/tunnel-0.0.6.tgz", - "integrity": "sha512-1h/Lnq9yajKY2PEbBadPXj3VxsDDu844OnaAo52UVmIzIvwwtBPIuNvkjuzBlTWpfJyUbG3ez0KSBibQkj4ojg==", - "engines": { - "node": ">=0.6.11 <=0.7.0 || >=0.7.3" - } + "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/@actions/io": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/@actions/io/-/io-1.0.2.tgz", - "integrity": "sha512-J8KuFqVPr3p6U8W93DOXlXW6zFvrQAJANdS+vw0YhusLIq+bszW8zmK2Fh1C2kDPX8FMvwIl1OUcFgvJoXLbAg==" + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@actions/io/-/io-1.1.2.tgz", + "integrity": "sha512-d+RwPlMp+2qmBfeLYPLXuSRykDIFEwdTA0MMxzS9kh4kvP1ftrc/9fzy6pX6qAjthdXruHQ6/6kjT/DNo5ALuw==" }, "node_modules/@azure/abort-controller": { "version": "1.0.4", @@ -618,9 +607,9 @@ "integrity": "sha512-ZQYitnqiyBc3D+k7LsgSBmMDVkOVidaagDG7j3fOym77jNunWRuYx7VSHa9GNfFZh+zh61xsCjRj4JxMZlDqTA==" }, "@actions/exec": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/@actions/exec/-/exec-1.0.4.tgz", - "integrity": "sha512-4DPChWow9yc9W3WqEbUj8Nr86xkpyE29ZzWjXucHItclLbEW6jr80Zx4nqv18QL6KK65+cifiQZXvnqgTV6oHw==", + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/@actions/exec/-/exec-1.1.1.tgz", + "integrity": "sha512-+sCcHHbVdk93a0XT19ECtO/gIXoxvdsgQLzb2fE2/5sIZmWQuluYyjPQtrtTHdU1YzTZ7bAPN4sITq2xi1679w==", "requires": { "@actions/io": "^1.0.1" } @@ -635,24 +624,14 @@ } }, "@actions/http-client": { - "version": "1.0.9", - "resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-1.0.9.tgz", - "integrity": "sha512-0O4SsJ7q+MK0ycvXPl2e6bMXV7dxAXOGjrXS1eTF9s2S401Tp6c/P3c3Joz04QefC1J6Gt942Wl2jbm3f4mLcg==", - "requires": { - "tunnel": "0.0.6" - }, - "dependencies": { - "tunnel": { - "version": "0.0.6", - "resolved": "https://registry.npmjs.org/tunnel/-/tunnel-0.0.6.tgz", - "integrity": "sha512-1h/Lnq9yajKY2PEbBadPXj3VxsDDu844OnaAo52UVmIzIvwwtBPIuNvkjuzBlTWpfJyUbG3ez0KSBibQkj4ojg==" - } - } + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-2.0.0.tgz", + "integrity": "sha512-fm1+OPPey5ypgStT9K8zbBhICj4J4UV/TJIHDhuWlkb8KyJaAtjcZK184dTqul0dV0nPKX97FNtDXX20BTLXSA==" }, "@actions/io": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/@actions/io/-/io-1.0.2.tgz", - "integrity": "sha512-J8KuFqVPr3p6U8W93DOXlXW6zFvrQAJANdS+vw0YhusLIq+bszW8zmK2Fh1C2kDPX8FMvwIl1OUcFgvJoXLbAg==" + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@actions/io/-/io-1.1.2.tgz", + "integrity": "sha512-d+RwPlMp+2qmBfeLYPLXuSRykDIFEwdTA0MMxzS9kh4kvP1ftrc/9fzy6pX6qAjthdXruHQ6/6kjT/DNo5ALuw==" }, "@azure/abort-controller": { "version": "1.0.4", diff --git a/package.json b/package.json index 97f774b..1185abe 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@actions/cache", - "version": "2.0.2", + "version": "2.0.3", "preview": true, "description": "Actions cache lib", "keywords": [ @@ -40,7 +40,7 @@ "@actions/core": "^1.2.6", "@actions/exec": "^1.0.1", "@actions/glob": "^0.1.0", - "@actions/http-client": "^1.0.9", + "@actions/http-client": "^2.0.0", "@actions/io": "^1.0.1", "@azure/ms-rest-js": "^2.6.0", "@azure/storage-blob": "^12.8.0", diff --git a/src/internal/cacheHttpClient.ts b/src/internal/cacheHttpClient.ts index 21f6991..c66d1a7 100644 --- a/src/internal/cacheHttpClient.ts +++ b/src/internal/cacheHttpClient.ts @@ -1,7 +1,10 @@ import * as core from '@actions/core' import {HttpClient} from '@actions/http-client' -import {BearerCredentialHandler} from '@actions/http-client/auth' -import {IRequestOptions, ITypedResponse} from '@actions/http-client/interfaces' +import {BearerCredentialHandler} from '@actions/http-client/lib/auth' +import { + RequestOptions, + TypedResponse +} from '@actions/http-client/lib/interfaces' import * as crypto from 'crypto' import * as fs from 'fs' import {URL} from 'url' @@ -46,8 +49,8 @@ function createAcceptHeader(type: string, apiVersion: string): string { return `${type};api-version=${apiVersion}` } -function getRequestOptions(): IRequestOptions { - const requestOptions: IRequestOptions = { +function getRequestOptions(): RequestOptions { + const requestOptions: RequestOptions = { headers: { Accept: createAcceptHeader('application/json', '6.0-preview.1') } @@ -275,7 +278,7 @@ async function commitCache( httpClient: HttpClient, cacheId: number, filesize: number -): Promise> { +): Promise> { const commitCacheRequest: CommitCacheRequest = {size: filesize} return await retryTypedResponse('commitCache', async () => httpClient.postJson( diff --git a/src/internal/contracts.d.ts b/src/internal/contracts.d.ts index eb79fda..1b2a13a 100644 --- a/src/internal/contracts.d.ts +++ b/src/internal/contracts.d.ts @@ -1,8 +1,8 @@ import {CompressionMethod} from './constants' -import {ITypedResponse} from '@actions/http-client/interfaces' +import {TypedResponse} from '@actions/http-client/lib/interfaces' import {HttpClientError} from '@actions/http-client' -export interface ITypedResponseWithError extends ITypedResponse { +export interface ITypedResponseWithError extends TypedResponse { error?: HttpClientError } diff --git a/src/internal/downloadUtils.ts b/src/internal/downloadUtils.ts index bedaa37..08b2dee 100644 --- a/src/internal/downloadUtils.ts +++ b/src/internal/downloadUtils.ts @@ -1,6 +1,5 @@ import * as core from '@actions/core' -import {HttpClient} from '@actions/http-client' -import {IHttpClientResponse} from '@actions/http-client/interfaces' +import {HttpClient, HttpClientResponse} from '@actions/http-client' import {BlockBlobClient} from '@azure/storage-blob' import {TransferProgressEvent} from '@azure/ms-rest-js' import * as buffer from 'buffer' @@ -20,7 +19,7 @@ import {retryHttpClientResponse} from './requestUtils' * @param output the writable stream */ async function pipeResponseToStream( - response: IHttpClientResponse, + response: HttpClientResponse, output: NodeJS.WritableStream ): Promise { const pipeline = util.promisify(stream.pipeline) diff --git a/src/internal/requestUtils.ts b/src/internal/requestUtils.ts index be254b9..043c8a7 100644 --- a/src/internal/requestUtils.ts +++ b/src/internal/requestUtils.ts @@ -1,6 +1,9 @@ import * as core from '@actions/core' -import {HttpCodes, HttpClientError} from '@actions/http-client' -import {IHttpClientResponse} from '@actions/http-client/interfaces' +import { + HttpCodes, + HttpClientError, + HttpClientResponse +} from '@actions/http-client' import {DefaultRetryDelay, DefaultRetryAttempts} from './constants' import {ITypedResponseWithError} from './contracts' @@ -103,7 +106,7 @@ export async function retryTypedResponse( maxAttempts, delay, // If the error object contains the statusCode property, extract it and return - // an ITypedResponse so it can be processed by the retry logic. + // an TypedResponse so it can be processed by the retry logic. (error: Error) => { if (error instanceof HttpClientError) { return { @@ -121,14 +124,14 @@ export async function retryTypedResponse( export async function retryHttpClientResponse( name: string, - method: () => Promise, + method: () => Promise, maxAttempts = DefaultRetryAttempts, delay = DefaultRetryDelay -): Promise { +): Promise { return await retry( name, method, - (response: IHttpClientResponse) => response.message.statusCode, + (response: HttpClientResponse) => response.message.statusCode, maxAttempts, delay )