8000 Merge releases/v3 into releases/v2 by github-actions[bot] · Pull Request #2202 · github/codeql-action · GitHub
[go: up one dir, main page]

Skip to content

Merge releases/v3 into releases/v2 #2202

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 27 commits into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
ef507e1
Update changelog and version after v3.24.7
github-actions[bot] Mar 12, 2024
a7b089b
Update checked-in dependencies
github-actions[bot] Mar 12, 2024
f195496
Merge pull request #2193 from github/mergeback/v3.24.7-to-main-3ab41019
angelapwen Mar 12, 2024
362c407
Bump verbosity on `trace-command` when in debug mode
henrymercer Mar 13, 2024
649f3e8
Bump verbosity when running autobuild script directly in debug mode
henrymercer Mar 13, 2024
070b051
Bump verbosity of `database finalize` in debug mode
henrymercer Mar 13, 2024
8da95d8
Refactoring: Add `getExtractionVerbosityArguments` wrapper
henrymercer Mar 13, 2024
3b6ebfb
Add changelog note
henrymercer Mar 13, 2024
a009e4d
Remove "experimental" designation from `packs` input
henrymercer Mar 13, 2024
e402144
Log job status in `init-post`
henrymercer Mar 13, 2024
3d82264
Merge pull request #2195 from github/henrymercer/extraction-debug-mode
henrymercer Mar 13, 2024
0d680ab
Merge pull request #2196 from github/henrymercer/update-packs-input-d…
henrymercer Mar 13, 2024
f055b5e
Merge pull request #2197 from github/henrymercer/log-job-status
henrymercer Mar 13, 2024
88b28eb
Surface autobuild errors from stderr stream
henrymercer Mar 14, 2024
88a0b7a
Mark Maven build failures as configuration errors
henrymercer Mar 14, 2024
3edd1bf
Truncate autobuild errors to 10 lines
henrymercer Mar 15, 2024
bddfc7c
Add config error for Gradle build failures
henrymercer Mar 15, 2024
e28ae3a
Add config error for Swift build failures
henrymercer Mar 15, 2024
1ecc277
Merge pull request #2198 from github/henrymercer/improve-tracking-aut…
henrymercer Mar 15, 2024
2b9b521
Update changelog for v3.24.8
github-actions[bot] Mar 18, 2024
05963f4
Merge pull request #2200 from github/update-v3.24.8-1ecc2779e
henrymercer Mar 18, 2024
4821ae1
Revert "Update version and changelog for v2.24.7"
github-actions[bot] Mar 18, 2024
76d4863
Revert "Update checked-in dependencies"
github-actions[bot] Mar 18, 2024
bcca54f
Merge remote-tracking branch 'origin/releases/v3' into backport-v2.24…
github-actions[bot] Mar 18, 2024
efed72e
Remove duplicate header
henrymercer Mar 18, 2024
6007966
Update version and changelog for v2.24.8
github-actions[bot] Mar 18, 2024
f018a95
Update checked-in dependencies
github-actions[bot] Mar 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Surface autobuild errors from stderr stream
  • Loading branch information
henrymercer committed Mar 14, 2024
commit 88b28eb70de0ce90819beb741e488921e89177e1
38 changes: 28 additions & 10 deletions lib/cli-errors.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/cli-errors.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions lib/codeql.test.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/codeql.test.js.map

Large diffs are not rendered by default.

43 changes: 31 additions & 12 deletions src/cli-errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,31 @@ export class CommandInvocationError extends Error {
.join(" ");

const fatalErrors = extractFatalErrors(stderr);
const lastLine = stderr.trim().split("\n").pop()?.trim();
let error = fatalErrors
? ` and error was: ${fatalErrors.trim()}`
: lastLine
? ` and last log line was: ${lastLine}`
: "";
if (error[error.length - 1] !== ".") {
error += ".";
const autobuildErrors = extractAutobuildErrors(stderr);
let message: string;

if (fatalErrors) {
message =
`Encountered a fatal error while running "${prettyCommand}". ` +
`Exit code was ${exitCode} and error was: ${fatalErrors.trim()} See the logs for more details.`;
} else if (autobuildErrors) {
const autobuildHelpLink =
"https://docs.github.com/en/code-security/code-scanning/troubleshooting-code-scanning/automatic-build-failed";
message =
"We were unable to automatically build your code. Please provide manual build steps. " +
`For more information, see ${autobuildHelpLink}. ` +
`Encountered the following error: ${autobuildErrors}`;
} else {
let lastLine = stderr.trim().split("\n").pop()?.trim() || "";
if (lastLine[lastLine.length - 1] !== ".") {
lastLine += ".";
}
message =
`Encountered a fatal error while running "${prettyCommand}". ` +
`Exit code was ${exitCode} and last log line was: ${lastLine} See the logs for more details.`;
}

super(
`Encountered a fatal error while running "${prettyCommand}". ` +
`Exit code was ${exitCode}${error} See the logs for more details.`,
);
super(message);
}
}

Expand Down Expand Up @@ -96,6 +107,14 @@ function extractFatalErrors(error: string): string | undefined {
return undefined;
}

function extractAutobuildErrors(error: string): string | undefined {
const pattern = /.*\[autobuild\] \[ERROR\] (.*)/gi;
return (
[...error.matchAll(pattern)].map((match) => match[1]).join("\n") ||
undefined
);
}

function ensureEndsInPeriod(text: string): string {
return text[text.length - 1] === "." ? text : `${text}.`;
}
Expand Down
35 changes: 35 additions & 0 deletions src/codeql.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import * as sinon from "sinon";

import * as actionsUtil from "./actions-util";
import { GitHubApiDetails } from "./api-client";
import { CommandInvocationError } from "./cli-errors";
import * as codeql from "./codeql";
import { AugmentationProperties, Config } from "./config-utils";
import * as defaults from "./defaults.json";
Expand Down Expand Up @@ -967,6 +968,40 @@ test("runTool summarizes several fatal errors", async (t) => {
);
});

test("runTool summarizes autobuilder errors", async (t) => {
const stderr = `
[2019-09-18 12:00:00] [autobuild] A non-error message
[2019-09-18 12:00:00] Untagged message
[2019-09-18 12:00:00] [autobuild] [ERROR] Start of the error message
[2019-09-18 12:00:00] [autobuild] An interspersed non-error message
[2019-09-18 12:00:01] [autobuild] [ERROR] Some more context about the error message
[2019-09-18 12:00:01] [autobuild] [ERROR] continued
[2019-09-18 12:00:01] [autobuild] [ERROR] and finished here.
[2019-09-18 12:00:01] [autobuild] A non-error message
`;
stubToolRunnerConstructor(1, stderr);
const codeqlObject = await codeql.getCodeQLForTesting();
sinon.stub(codeqlObject, "getVersion").resolves(makeVersionInfo("2.12.4"));
sinon.stub(codeqlObject, "resolveExtractor").resolves("/path/to/extractor");
// safeWhich throws because of the test CodeQL object.
sinon.stub(safeWhich, "safeWhich").resolves("");

await t.throwsAsync(
async () => await codeqlObject.runAutobuild(Language.java, false),
{
instanceOf: CommandInvocationError,
message:
"We were unable to automatically build your code. Please provide manual build steps. " +
"For more information, see " +
"https://docs.github.com/en/code-security/code-scanning/troubleshooting-code-scanning/automatic-build-failed. " +
"Encountered the following error: Start of the error message\n" +
" Some more context about the error message\n" +
" continued\n" +
" and finished here.",
},
);
});

test("runTool outputs last line of stderr if fatal error could not be found", async (t) => {
const cliStderr = "line1\nline2\nline3\nline4\nline5";
stubToolRunnerConstructor(32, cliStderr);
Expand Down
0