Skip to content

Commit badb286

Browse files
authored
Merge pull request #271 from github/daverlo/fail-analyze
Fail the analyze action when some language fails to run the queries
2 parents 6ac5978 + d628762 commit badb286

6 files changed

Lines changed: 39 additions & 7 deletions

File tree

lib/analyze-action.js

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

lib/analyze-action.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.

lib/analyze.js

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

lib/analyze.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/analyze-action.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
import * as core from "@actions/core";
22

33
import * as actionsUtil from "./actions-util";
4-
import { AnalysisStatusReport, runAnalyze } from "./analyze";
4+
import {
5+
AnalysisStatusReport,
6+
runAnalyze,
7+
CodeQLAnalysisError,
8+
} from "./analyze";
59
import { getConfig } from "./config-utils";
610
import { getActionsLogger } from "./logging";
711
import { parseRepositoryNwo } from "./repository";
@@ -84,6 +88,11 @@ async function run() {
8488
} catch (error) {
8589
core.setFailed(error.message);
8690
console.log(error);
91+
92+
if (error instanceof CodeQLAnalysisError) {
93+
stats = { ...error.queriesStatusReport };
94+
}
95+
8796
await sendStatusReport(startedAt, stats, error);
8897
return;
8998
}

src/analyze.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,17 @@ import * as sharedEnv from "./shared-environment";
1313
import * as upload_lib from "./upload-lib";
1414
import * as util from "./util";
1515

16+
export class CodeQLAnalysisError extends Error {
17+
queriesStatusReport: QueriesStatusReport;
18+
19+
constructor(queriesStatusReport: QueriesStatusReport, message: string) {
20+
super(message);
21+
22+
this.name = "CodeQLAnalysisError";
23+
this.queriesStatusReport = queriesStatusReport;
24+
}
25+
}
26+
1627
export interface QueriesStatusReport {
1728
// Time taken in ms to analyze builtin queries for cpp (or undefined if this language was not analyzed)
1829
analyze_builtin_queries_cpp_duration_ms?: number;
@@ -190,10 +201,12 @@ export async function runQueries(
190201
}
191202
}
192203
} catch (e) {
193-
logger.error(`Error running analysis for ${language}: ${e}`);
194204
logger.info(e);
195205
statusReport.analyze_failure_language = language;
196-
return statusReport;
206+
throw new CodeQLAnalysisError(
207+
statusReport,
208+
`Error running analysis for ${language}: ${e}`
209+
);
197210
}
198211
}
199212

0 commit comments

Comments
 (0)