Add ML-powered query enablement info to analyze finish status report

This commit is contained in:
Henry Mercer
2022-02-15 14:42:55 +00:00
parent 2c6b76bc5a
commit bcdaad245b
13 changed files with 38 additions and 22 deletions

View File

@@ -576,6 +576,12 @@ export interface StatusReportBase {
completed_at?: string;
/** State this action is currently in. */
status: ActionStatus;
/**
* Information about the enablement of the ML-powered JS query pack.
*
* @see {@link util.getMlPoweredJsQueriesStatus}
*/
ml_powered_javascript_queries?: string;
/** Cause of the failure (or undefined if status is not failure). */
cause?: string;
/** Stack trace of the failure (or undefined if status is not failure). */

View File

@@ -31,6 +31,7 @@ test("analyze action with RAM & threads from environment variables", async (t) =
sinon.stub(configUtils, "getConfig").resolves({
gitHubVersion: { type: util.GitHubVariant.DOTCOM },
languages: [],
packs: [],
} as unknown as configUtils.Config);
const requiredInputStub = sinon.stub(actionsUtil, "getRequiredInput");
requiredInputStub.withArgs("token").returns("fake-token");

View File

@@ -31,6 +31,7 @@ test("analyze action with RAM & threads from action inputs", async (t) => {
sinon.stub(configUtils, "getConfig").resolves({
gitHubVersion: { type: util.GitHubVariant.DOTCOM },
languages: [],
packs: [],
} as unknown as configUtils.Config);
const requiredInputStub = sinon.stub(actionsUtil, "getRequiredInput");
requiredInputStub.withArgs("token").returns("fake-token");

View File

@@ -36,6 +36,7 @@ interface FinishStatusReport
export async function sendStatusReport(
startedAt: Date,
config: Config | undefined,
stats: AnalysisStatusReport | undefined,
error?: Error
) {
@@ -52,6 +53,12 @@ export async function sendStatusReport(
);
const statusReport: FinishStatusReport = {
...statusReportBase,
...(config
? {
ml_powered_javascript_queries:
util.getMlPoweredJsQueriesStatus(config),
}
: {}),
...(stats || {}),
};
await actionsUtil.sendStatusReport(statusReport);
@@ -220,9 +227,9 @@ async function run() {
if (error instanceof CodeQLAnalysisError) {
const stats = { ...error.queriesStatusReport };
await sendStatusReport(startedAt, stats, error);
await sendStatusReport(startedAt, config, stats, error);
} else {
await sendStatusReport(startedAt, undefined, error);
await sendStatusReport(startedAt, config, undefined, error);
}
return;
@@ -279,14 +286,14 @@ async function run() {
}
if (runStats && uploadResult) {
await sendStatusReport(startedAt, {
await sendStatusReport(startedAt, config, {
...runStats,
...uploadResult.statusReport,
});
} else if (runStats) {
await sendStatusReport(startedAt, { ...runStats });
await sendStatusReport(startedAt, config, { ...runStats });
} else {
await sendStatusReport(startedAt, undefined);
await sendStatusReport(startedAt, config, undefined);
}
}

View File

@@ -53,12 +53,6 @@ interface InitSuccessStatusReport extends StatusReportBase {
* This may be from the workflow file or may be calculated from repository contents
*/
languages: string;
/**
* Information about the enablement of the ML-powered JS query pack.
*
* @see {@link getMlPoweredJsQueriesStatus}
*/
ml_powered_javascript_queries: string;
/** Comma-separated list of paths, from the 'paths' config field. */
paths: string;
/** Comma-separated list of paths, from the 'paths-ignore' config field. */