Skip to content

Commit

Permalink
Merge pull request #271 from github/daverlo/fail-analyze
Browse files Browse the repository at this point in the history
Fail the analyze action when some language fails to run the queries
  • Loading branch information
David Verdeguer authored and GitHub committed Oct 22, 2020
2 parents 6ac5978 + d628762 commit badb286
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 7 deletions.
3 changes: 3 additions & 0 deletions lib/analyze-action.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/analyze-action.js.map

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

11 changes: 9 additions & 2 deletions lib/analyze.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/analyze.js.map

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

11 changes: 10 additions & 1 deletion src/analyze-action.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import * as core from "@actions/core";

import * as actionsUtil from "./actions-util";
import { AnalysisStatusReport, runAnalyze } from "./analyze";
import {
AnalysisStatusReport,
runAnalyze,
CodeQLAnalysisError,
} from "./analyze";
import { getConfig } from "./config-utils";
import { getActionsLogger } from "./logging";
import { parseRepositoryNwo } from "./repository";
Expand Down Expand Up @@ -84,6 +88,11 @@ async function run() {
} catch (error) {
core.setFailed(error.message);
console.log(error);

if (error instanceof CodeQLAnalysisError) {
stats = { ...error.queriesStatusReport };
}

await sendStatusReport(startedAt, stats, error);
return;
}
Expand Down
17 changes: 15 additions & 2 deletions src/analyze.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,17 @@ import * as sharedEnv from "./shared-environment";
import * as upload_lib from "./upload-lib";
import * as util from "./util";

export class CodeQLAnalysisError extends Error {
queriesStatusReport: QueriesStatusReport;

constructor(queriesStatusReport: QueriesStatusReport, message: string) {
super(message);

this.name = "CodeQLAnalysisError";
this.queriesStatusReport = queriesStatusReport;
}
}

export interface QueriesStatusReport {
// Time taken in ms to analyze builtin queries for cpp (or undefined if this language was not analyzed)
analyze_builtin_queries_cpp_duration_ms?: number;
Expand Down Expand Up @@ -190,10 +201,12 @@ export async function runQueries(
}
}
} catch (e) {
logger.error(`Error running analysis for ${language}: ${e}`);
logger.info(e);
statusReport.analyze_failure_language = language;
return statusReport;
throw new CodeQLAnalysisError(
statusReport,
`Error running analysis for ${language}: ${e}`
);
}
}

Expand Down

0 comments on commit badb286

Please sign in to comment.