Skip to content

Commit c208f33

Browse files
committed
Add analyses field with comma-separated list of analysis kinds to status reports
1 parent d6621b9 commit c208f33

File tree

6 files changed

+46
-2
lines changed

6 files changed

+46
-2
lines changed

lib/analyses.js

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

lib/analyses.js.map

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

lib/status-report.js

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

lib/status-report.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/analyses.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export enum AnalysisKind {
2+
CodeScanning = "code-scanning",
3+
CodeQuality = "code-quality",
4+
}

src/status-report.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ import {
1111
getRequiredInput,
1212
isSelfHostedRunner,
1313
} from "./actions-util";
14+
import { AnalysisKind } from "./analyses";
1415
import { getAnalysisKey, getApiClient } from "./api-client";
15-
import { type Config } from "./config-utils";
16+
import { isCodeQualityEnabled, type Config } from "./config-utils";
1617
import { DocUrl } from "./doc-url";
1718
import { EnvVar } from "./environment";
1819
import { getRef } from "./git-utils";
@@ -91,6 +92,8 @@ export interface StatusReportBase {
9192
action_version: string;
9293
/** The name of the Actions event that triggered the workflow. */
9394
actions_event_name?: string;
95+
/** Comma-separated list of the kinds of analyses we are performing. */
96+
analyses?: string;
9497
/** Analysis key, normally composed from the workflow path and job name. */
9598
analysis_key: string;
9699
/** Build mode, if specified. */
@@ -287,12 +290,26 @@ export async function createStatusReportBase(
287290
const isSteadyStateDefaultSetupRun =
288291
process.env["CODE_SCANNING_IS_STEADY_STATE_DEFAULT_SETUP"] === "true";
289292

293+
// We leave `analyses` empty if we don't have a `config`, so that we don't
294+
// accidentally report only `code-scanning` when we can't tell whether `code-quality`
295+
// is enabled or not.
296+
const analyses: AnalysisKind[] = [];
297+
298+
if (config !== undefined) {
299+
analyses.push(AnalysisKind.CodeScanning);
300+
301+
if (isCodeQualityEnabled(config)) {
302+
analyses.push(AnalysisKind.CodeQuality);
303+
}
304+
}
305+
290306
const statusReport: StatusReportBase = {
291307
action_name: actionName,
292308
action_oid: "unknown", // TODO decide if it's possible to fill this in
293309
action_ref: actionRef,
294310
action_started_at: actionStartedAt.toISOString(),
295311
action_version: getActionVersion(),
312+
analyses: analyses.join(","),
296313
analysis_key,
297314
build_mode: config?.buildMode,
298315
commit_oid: commitOid,

0 commit comments

Comments
 (0)