@@ -2,14 +2,15 @@ import { IncomingMessage, OutgoingHttpHeaders, RequestOptions } from "http";
22import * as path from "path" ;
33import { performance } from "perf_hooks" ;
44
5+ import * as core from "@actions/core" ;
56import { getProxyUrl } from "@actions/http-client/lib/proxy" ;
67import * as toolcache from "@actions/tool-cache" ;
78import { https } from "follow-redirects" ;
89import { v4 as uuidV4 } from "uuid" ;
910
1011import { formatDuration , Logger } from "./logging" ;
1112import * as tar from "./tar" ;
12- import { cleanUpGlob } from "./util" ;
13+ import { cleanUpGlob , getErrorMessage } from "./util" ;
1314
1415/**
1516 * High watermark to use when streaming the download and extraction of the CodeQL tools.
@@ -88,37 +89,42 @@ export async function downloadAndExtract(
8889
8990 const compressionMethod = tar . inferCompressionMethod ( codeqlURL ) ;
9091
91- // TODO: Re-enable streaming when we have a more reliable way to respect proxy settings.
92-
93- if ( compressionMethod === "zstd" && process . platform === "linux" ) {
94- logger . info ( `Streaming the extraction of the CodeQL bundle.` ) ;
95-
96- const toolsInstallStart = performance . now ( ) ;
97- const extractedBundlePath = await downloadAndExtractZstdWithStreaming (
98- codeqlURL ,
99- authorization ,
100- headers ,
101- tarVersion ! ,
102- logger ,
103- ) ;
92+ try {
93+ if ( compressionMethod === "zstd" && process . platform === "linux" ) {
94+ logger . info ( `Streaming the extraction of the CodeQL bundle.` ) ;
10495
105- const combinedDurationMs = Math . round (
106- performance . now ( ) - toolsInstallStart ,
107- ) ;
108- logger . info (
109- `Finished downloading and extracting CodeQL bundle to ${ extractedBundlePath } (${ formatDuration (
110- combinedDurationMs ,
111- ) } ).`,
96+ const toolsInstallStart = performance . now ( ) ;
97+ const extractedBundlePath = await downloadAndExtractZstdWithStreaming (
98+ codeqlURL ,
99+ authorization ,
100+ headers ,
101+ tarVersion ! ,
102+ logger ,
103+ ) ;
104+
105+ const combinedDurationMs = Math . round (
106+ performance . now ( ) - toolsInstallStart ,
107+ ) ;
108+ logger . info (
109+ `Finished downloading and extracting CodeQL bundle to ${ extractedBundlePath } (${ formatDuration (
110+ combinedDurationMs ,
111+ ) } ).`,
112+ ) ;
113+
114+ return {
115+ extractedBundlePath,
116+ statusReport : {
117+ compressionMethod,
118+ toolsUrl : sanitizeUrlForStatusReport ( codeqlURL ) ,
119+ ...makeStreamedToolsDownloadDurations ( combinedDurationMs ) ,
120+ } ,
121+ } ;
122+ }
123+ } catch ( e ) {
124+ core . warning (
125+ `Failed to download and extract CodeQL bundle using streaming. Falling back to downloading the bundle before extracting.` ,
112126 ) ;
113-
114- return {
115- extractedBundlePath,
116- statusReport : {
117- compressionMethod,
118- toolsUrl : sanitizeUrlForStatusReport ( codeqlURL ) ,
119- ...makeStreamedToolsDownloadDurations ( combinedDurationMs ) ,
120- } ,
121- } ;
127+ core . warning ( getErrorMessage ( e ) ) ;
122128 }
123129
124130 const dest = path . join ( tempDir , uuidV4 ( ) ) ;
0 commit comments