Skip to content

Commit f33ae7c

Browse files
committed
Debug zstd bundle extraction errors
1 parent 1c15a48 commit f33ae7c

File tree

3 files changed

+123
-1
lines changed

3 files changed

+123
-1
lines changed

lib/tools-download.js

Lines changed: 57 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/tools-download.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/tools-download.ts

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import * as path from "path";
55
import { performance } from "perf_hooks";
66

77
import * as core from "@actions/core";
8+
import * as toolrunner from "@actions/exec/lib/toolrunner";
89
import { HttpClient } from "@actions/http-client";
910
import * as toolcache from "@actions/tool-cache";
1011
import { https } from "follow-redirects";
@@ -148,6 +149,13 @@ export async function downloadAndExtract(
148149
)}).`,
149150
);
150151

152+
// Add the following log to display the size of the downloaded bundle
153+
const bundleSize = fs.statSync(archivedBundlePath).size;
154+
logger.info(`Size of the downloaded CodeQL bundle: ${bundleSize} bytes`);
155+
156+
await logDiskUsage(logger);
157+
await verifyZstdIntegrity(archivedBundlePath, logger);
158+
151159
let extractionDurationMs: number;
152160

153161
try {
@@ -167,6 +175,8 @@ export async function downloadAndExtract(
167175
)}).`,
168176
);
169177
} finally {
178+
await logDiskUsage(logger);
179+
await verifyZstdIntegrity(archivedBundlePath, logger);
170180
await cleanUpGlob(archivedBundlePath, "CodeQL bundle archive", logger);
171181
}
172182

@@ -180,6 +190,61 @@ export async function downloadAndExtract(
180190
};
181191
}
182192

193+
async function logDiskUsage(logger: Logger) {
194+
let stdout = "";
195+
let stderr = "";
196+
try {
197+
const dfRunner = new toolrunner.ToolRunner("df", ["-h"], {
198+
silent: true,
199+
listeners: {
200+
stdout: (data: Buffer) => {
201+
stdout += data.toString();
202+
},
203+
stderr: (data: Buffer) => {
204+
stderr += data.toString();
205+
},
206+
},
207+
});
208+
const exitCode = await dfRunner.exec();
209+
logger.info(`df -h exited with code ${exitCode}.`);
210+
} catch (error) {
211+
logger.warning(`Failed to run df: ${error}`);
212+
}
213+
logger.info(`df -h stdout: ${stdout}`);
214+
logger.info(`df -h stderr: ${stderr}`);
215+
}
216+
217+
async function verifyZstdIntegrity(archivedBundlePath: string, logger: Logger) {
218+
// Run `zstd -t` on the CodeQL bundle and log the results
219+
let stdout = "";
220+
let stderr = "";
221+
try {
222+
const zstdTestRunner = new toolrunner.ToolRunner(
223+
"zstd",
224+
["-t", archivedBundlePath],
225+
{
226+
silent: true,
227+
listeners: {
228+
stdout: (data: Buffer) => {
229+
stdout += data.toString();
230+
},
231+
stderr: (data: Buffer) => {
232+
stderr += data.toString();
233+
},
234+
},
235+
},
236+
);
237+
const exitCode = await zstdTestRunner.exec();
238+
logger.info(`zstd -t exited with code ${exitCode}.`);
239+
} catch (error) {
240+
logger.warning(
241+
`Failed to verify the integrity of the CodeQL bundle using zstd: ${error}`,
242+
);
243+
}
244+
logger.info(`zstd -t stdout: ${stdout}`);
245+
logger.info(`zstd -t stderr: ${stderr}`);
246+
}
247+
183248
async function downloadAndExtractZstdWithStreaming(
184249
codeqlURL: string,
185250
dest: string,

0 commit comments

Comments
 (0)