Merge pull request #2382 from github/angelapwen/make-autobuild-config-error

Classify autobuild errors as configuration errors
This commit is contained in:
Angela P Wen 2024-07-22 15:25:48 +02:00 committed by GitHub
commit ea8137f35f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 18 additions and 6 deletions

6
lib/cli-errors.js generated
View file

@ -115,6 +115,7 @@ function ensureEndsInPeriod(text) {
/** Error messages from the CLI that we consider configuration errors and handle specially. */ /** Error messages from the CLI that we consider configuration errors and handle specially. */
var CliConfigErrorCategory; var CliConfigErrorCategory;
(function (CliConfigErrorCategory) { (function (CliConfigErrorCategory) {
CliConfigErrorCategory["AutobuildError"] = "AutobuildError";
CliConfigErrorCategory["ExternalRepositoryCloneFailed"] = "ExternalRepositoryCloneFailed"; CliConfigErrorCategory["ExternalRepositoryCloneFailed"] = "ExternalRepositoryCloneFailed";
CliConfigErrorCategory["GradleBuildFailed"] = "GradleBuildFailed"; CliConfigErrorCategory["GradleBuildFailed"] = "GradleBuildFailed";
CliConfigErrorCategory["IncompatibleWithActionVersion"] = "IncompatibleWithActionVersion"; CliConfigErrorCategory["IncompatibleWithActionVersion"] = "IncompatibleWithActionVersion";
@ -138,6 +139,11 @@ var CliConfigErrorCategory;
* would like to categorize an error as a configuration error or not. * would like to categorize an error as a configuration error or not.
*/ */
exports.cliErrorsConfig = { exports.cliErrorsConfig = {
[CliConfigErrorCategory.AutobuildError]: {
cliErrorMessageCandidates: [
new RegExp("We were unable to automatically build your code"),
],
},
[CliConfigErrorCategory.ExternalRepositoryCloneFailed]: { [CliConfigErrorCategory.ExternalRepositoryCloneFailed]: {
cliErrorMessageCandidates: [ cliErrorMessageCandidates: [
new RegExp("Failed to clone external Git repository"), new RegExp("Failed to clone external Git repository"),

File diff suppressed because one or more lines are too long

4
lib/codeql.test.js generated
View file

@ -574,7 +574,7 @@ for (const { codeqlVersion, flagPassed, githubVersion, negativeFlagPassed, } of
// safeWhich throws because of the test CodeQL object. // safeWhich throws because of the test CodeQL object.
sinon.stub(safeWhich, "safeWhich").resolves(""); sinon.stub(safeWhich, "safeWhich").resolves("");
await t.throwsAsync(async () => await codeqlObject.runAutobuild(stubConfig, languages_1.Language.java), { await t.throwsAsync(async () => await codeqlObject.runAutobuild(stubConfig, languages_1.Language.java), {
instanceOf: cli_errors_1.CommandInvocationError, instanceOf: util.ConfigurationError,
message: "We were unable to automatically build your code. Please provide manual build steps. " + message: "We were unable to automatically build your code. Please provide manual build steps. " +
"For more information, see " + "For more information, see " +
"https://docs.github.com/en/code-security/code-scanning/troubleshooting-code-scanning/automatic-build-failed. " + "https://docs.github.com/en/code-security/code-scanning/troubleshooting-code-scanning/automatic-build-failed. " +
@ -593,7 +593,7 @@ for (const { codeqlVersion, flagPassed, githubVersion, negativeFlagPassed, } of
// safeWhich throws because of the test CodeQL object. // safeWhich throws because of the test CodeQL object.
sinon.stub(safeWhich, "safeWhich").resolves(""); sinon.stub(safeWhich, "safeWhich").resolves("");
await t.throwsAsync(async () => await codeqlObject.runAutobuild(stubConfig, languages_1.Language.java), { await t.throwsAsync(async () => await codeqlObject.runAutobuild(stubConfig, languages_1.Language.java), {
instanceOf: cli_errors_1.CommandInvocationError, instanceOf: util.ConfigurationError,
message: "We were unable to automatically build your code. Please provide manual build steps. " + message: "We were unable to automatically build your code. Please provide manual build steps. " +
"For more information, see " + "For more information, see " +
"https://docs.github.com/en/code-security/code-scanning/troubleshooting-code-scanning/automatic-build-failed. " + "https://docs.github.com/en/code-security/code-scanning/troubleshooting-code-scanning/automatic-build-failed. " +

File diff suppressed because one or more lines are too long

View file

@ -122,6 +122,7 @@ function ensureEndsInPeriod(text: string): string {
/** Error messages from the CLI that we consider configuration errors and handle specially. */ /** Error messages from the CLI that we consider configuration errors and handle specially. */
export enum CliConfigErrorCategory { export enum CliConfigErrorCategory {
AutobuildError = "AutobuildError",
ExternalRepositoryCloneFailed = "ExternalRepositoryCloneFailed", ExternalRepositoryCloneFailed = "ExternalRepositoryCloneFailed",
GradleBuildFailed = "GradleBuildFailed", GradleBuildFailed = "GradleBuildFailed",
IncompatibleWithActionVersion = "IncompatibleWithActionVersion", IncompatibleWithActionVersion = "IncompatibleWithActionVersion",
@ -156,6 +157,11 @@ export const cliErrorsConfig: Record<
CliConfigErrorCategory, CliConfigErrorCategory,
CliErrorConfiguration CliErrorConfiguration
> = { > = {
[CliConfigErrorCategory.AutobuildError]: {
cliErrorMessageCandidates: [
new RegExp("We were unable to automatically build your code"),
],
},
[CliConfigErrorCategory.ExternalRepositoryCloneFailed]: { [CliConfigErrorCategory.ExternalRepositoryCloneFailed]: {
cliErrorMessageCandidates: [ cliErrorMessageCandidates: [
new RegExp("Failed to clone external Git repository"), new RegExp("Failed to clone external Git repository"),

View file

@ -906,7 +906,7 @@ test("runTool summarizes autobuilder errors", async (t) => {
await t.throwsAsync( await t.throwsAsync(
async () => await codeqlObject.runAutobuild(stubConfig, Language.java), async () => await codeqlObject.runAutobuild(stubConfig, Language.java),
{ {
instanceOf: CommandInvocationError, instanceOf: util.ConfigurationError,
message: message:
"We were unable to automatically build your code. Please provide manual build steps. " + "We were unable to automatically build your code. Please provide manual build steps. " +
"For more information, see " + "For more information, see " +
@ -934,7 +934,7 @@ test("runTool truncates long autobuilder errors", async (t) => {
await t.throwsAsync( await t.throwsAsync(
async () => await codeqlObject.runAutobuild(stubConfig, Language.java), async () => await codeqlObject.runAutobuild(stubConfig, Language.java),
{ {
instanceOf: CommandInvocationError, instanceOf: util.ConfigurationError,
message: message:
"We were unable to automatically build your code. Please provide manual build steps. " + "We were unable to automatically build your code. Please provide manual build steps. " +
"For more information, see " + "For more information, see " +