Skip to content

Commit

Permalink
Add ML-powered query enablement info to analyze finish status report
Browse files Browse the repository at this point in the history
  • Loading branch information
henrymercer committed Feb 15, 2022
1 parent 2c6b76b commit c2e40b5
Show file tree
Hide file tree
Showing 11 changed files with 37 additions and 15 deletions.
2 changes: 1 addition & 1 deletion lib/actions-util.js.map

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions lib/analyze-action-env.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/analyze-action-env.test.js.map

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

1 change: 1 addition & 0 deletions lib/analyze-action-input.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/analyze-action-input.test.js.map

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

17 changes: 11 additions & 6 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

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions src/actions-util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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). */
Expand Down
1 change: 1 addition & 0 deletions src/analyze-action-env.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
1 change: 1 addition & 0 deletions src/analyze-action-input.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
17 changes: 12 additions & 5 deletions src/analyze-action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ interface FinishStatusReport

export async function sendStatusReport(
startedAt: Date,
config: Config | undefined,
stats: AnalysisStatusReport | undefined,
error?: Error
) {
Expand All @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
}

Expand Down

0 comments on commit c2e40b5

Please sign in to comment.