Skip to content

Commit 0f3e632

Browse files
committed
Rename secondary run to uploadFailureInfo
1 parent b0ed4de commit 0f3e632

File tree

4 files changed

+66
-52
lines changed

4 files changed

+66
-52
lines changed

lib/init-action-post.js

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

src/init-action-post-helper.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ test("init-post action with debug mode off", async (t) => {
4545
const uploadAllAvailableDebugArtifactsSpy = sinon.spy();
4646
const printDebugLogsSpy = sinon.spy();
4747

48-
await initActionPostHelper.run(
48+
await initActionPostHelper.uploadFailureInfo(
4949
uploadAllAvailableDebugArtifactsSpy,
5050
printDebugLogsSpy,
5151
codeql.createStubCodeQL({}),
@@ -68,7 +68,7 @@ test("init-post action with debug mode on", async (t) => {
6868
const uploadAllAvailableDebugArtifactsSpy = sinon.spy();
6969
const printDebugLogsSpy = sinon.spy();
7070

71-
await initActionPostHelper.run(
71+
await initActionPostHelper.uploadFailureInfo(
7272
uploadAllAvailableDebugArtifactsSpy,
7373
printDebugLogsSpy,
7474
codeql.createStubCodeQL({}),
@@ -332,7 +332,7 @@ test("saves overlay status when overlay-base analysis did not complete successfu
332332

333333
const stubCodeQL = codeql.createStubCodeQL({});
334334

335-
await initActionPostHelper.run(
335+
await initActionPostHelper.uploadFailureInfo(
336336
sinon.spy(),
337337
sinon.spy(),
338338
stubCodeQL,
@@ -392,7 +392,7 @@ test("does not save overlay status when OverlayAnalysisStatusSave feature flag i
392392
.stub(overlayStatus, "saveOverlayStatus")
393393
.resolves(true);
394394

395-
await initActionPostHelper.run(
395+
await initActionPostHelper.uploadFailureInfo(
396396
sinon.spy(),
397397
sinon.spy(),
398398
codeql.createStubCodeQL({}),
@@ -429,7 +429,7 @@ test("does not save overlay status when build successful", async (t) => {
429429
.stub(overlayStatus, "saveOverlayStatus")
430430
.resolves(true);
431431

432-
await initActionPostHelper.run(
432+
await initActionPostHelper.uploadFailureInfo(
433433
sinon.spy(),
434434
sinon.spy(),
435435
codeql.createStubCodeQL({}),
@@ -465,7 +465,7 @@ test("does not save overlay status when overlay not enabled", async (t) => {
465465
.stub(overlayStatus, "saveOverlayStatus")
466466
.resolves(true);
467467

468-
await initActionPostHelper.run(
468+
await initActionPostHelper.uploadFailureInfo(
469469
sinon.spy(),
470470
sinon.spy(),
471471
codeql.createStubCodeQL({}),

src/init-action-post-helper.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,21 @@ export async function tryUploadSarifIfRunFailed(
158158
}
159159
}
160160

161-
export async function run(
161+
/**
162+
* Handles the majority of the `post-init` step logic which, depending on the configuration,
163+
* mainly involves uploading a SARIF file with information about the failued run, debug
164+
* artifacts, and performing clean-up operations.
165+
*
166+
* @param uploadAllAvailableDebugArtifacts A function with which to upload debug artifacts.
167+
* @param printDebugLogs A function with which to print debug logs.
168+
* @param codeql The CodeQL CLI instance.
169+
* @param config The CodeQL Action configuration.
170+
* @param repositoryNwo The name and owner of the repository.
171+
* @param features Information about enabled features.
172+
* @param logger The logger to use.
173+
* @returns The results of uploading the SARIF file for the failure.
174+
*/
175+
export async function uploadFailureInfo(
162176
uploadAllAvailableDebugArtifacts: (
163177
codeql: CodeQL,
164178
config: Config,
@@ -171,7 +185,7 @@ export async function run(
171185
repositoryNwo: RepositoryNwo,
172186
features: FeatureEnablement,
173187
logger: Logger,
174-
) {
188+
): Promise<UploadFailedSarifResult> {
175189
await recordOverlayStatus(codeql, config, features, logger);
176190

177191
const uploadFailedSarifResult = await tryUploadSarifIfRunFailed(

src/init-action-post.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ async function run(startedAt: Date) {
7777
} else {
7878
const codeql = await getCodeQL(config.codeQLCmd);
7979

80-
uploadFailedSarifResult = await initActionPostHelper.run(
80+
uploadFailedSarifResult = await initActionPostHelper.uploadFailureInfo(
8181
debugArtifacts.tryUploadAllAvailableDebugArtifacts,
8282
printDebugLogs,
8383
codeql,

0 commit comments

Comments
 (0)