8000 Add `workload_run_attempt` to analysis upload (#1658) · github/codeql-action@da583b0 · GitHub
[go: up one dir, main page]

Skip to content

Commit da583b0

Browse files
authored
Add workload_run_attempt to analysis upload (#1658)
* Refactor status report upload logic Previously we had duplicated the logic to check `GITHUB_RUN_ID`. We now call the `getWorkflowRunID()` method for the status report upload method, and move the logic for the run attempt to `getWorkflowRunAttempt()` * Add `workflow_run_attempt` to analysis payload * Stop allowing `undefined` run IDs and attempts Because we already throw an error if the ID or attempt aren't numbers, we don't have to allow `undefined` values into the payload.
1 parent a9648ea commit da583b0

12 files changed

+85
-42
lines changed

lib/actions-util.js

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

lib/actions-util.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/upload-lib.js

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

lib/upload-lib.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/upload-lib.test.js

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

lib/upload-lib.test.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/workflow.js

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

lib/workflow.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/actions-util.ts

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@ import {
2121
parseMatrixInput,
2222
UserError,
2323
} from "./util";
24-
import { getWorkflowRelativePath } from "./workflow";
24+
import {
25+
getWorkflowRunID,
26+
getWorkflowRunAttempt,
27+
getWorkflowRelativePath,
28+
} from "./workflow";
2529

2630
// eslint-disable-next-line import/no-commonjs
2731
const pkg = require("../package.json") as JSONSchemaForNPMPackageJsonFiles;
@@ -407,16 +411,8 @@ export async function createStatusReportBase(
407411
): Promise<StatusReportBase> {
408412
const commitOid = getOptionalInput("sha") || process.env["GITHUB_SHA"] || "";
409413
const ref = await getRef();
410-
const workflowRunIDStr = process.env["GITHUB_RUN_ID"];
411-
let workflowRunID = -1;
412-
if (workflowRunIDStr) {
413-
workflowRunID = parseInt(workflowRunIDStr, 10);
414-
}
415-
const workflowRunAttemptStr = process.env["GITHUB_RUN_ATTEMPT"];
416-
let workflowRunAttempt = -1;
417-
if (workflowRunAttemptStr) {
418-
workflowRunAttempt = parseInt(workflowRunAttemptStr, 10);
419-
}
414+
const workflowRunID = getWorkflowRunID();
415+
const workflowRunAttempt = getWorkflowRunAttempt();
420416
const workflowName = process.env["GITHUB_WORKFLOW"] || "";
421417
const jobName = process.env["GITHUB_JOB"] || "";
422418
const analysis_key = await getAnalysisKey();

src/upload-lib.test.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ test("validate correct payload used for push, PR merge commit, and PR head", asy
3737
"key",
3838
undefined,
3939
"",
40-
undefined,
40+
1234,
41+
1,
4142
"/opt/src",
4243
undefined,
4344
["CodeQL", "eslint"],
@@ -59,7 +60,8 @@ test("validate correct payload used for push, PR merge commit, and PR head", asy
5960
"key",
6061
undefined,
6162
"",
62-
undefined,
63+
1234,
64+
1,
6365
"/opt/src",
6466
undefined,
6567
["CodeQL", "eslint"],
@@ -75,7 +77,8 @@ test("validate correct payload used for push, PR merge commit, and PR head", asy
7577
"key",
7678
undefined,
7779
"",
78-
undefined,
80+
1234,
81+
1,
7982
"/opt/src",
8083
undefined,
8184
["CodeQL", "eslint"],

0 commit comments

Comments
 (0)
0