Skip to content

Commit 25c8db9

Browse files
committed
Revert "Specify reason for skipping SARIF upload in logs"
This reverts commit 680b070.
1 parent 680b070 commit 25c8db9

File tree

9 files changed

+31
-75
lines changed

9 files changed

+31
-75
lines changed

lib/analyze-action.js

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

lib/init-action-post.js

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

lib/upload-lib.js

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

lib/upload-sarif-action.js

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

src/environment.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ export enum EnvVar {
131131

132132
/**
133133
* Whether to skip uploading SARIF results to GitHub. Intended for testing purposes.
134-
* This setting is implied by `CODEQL_ACTION_TEST_MODE`, but is more specific.
134+
* This setting is implied by but is more specific than `CODEQL_ACTION_TEST_MODE`.
135135
*/
136136
SKIP_SARIF_UPLOAD = "CODEQL_ACTION_SKIP_SARIF_UPLOAD",
137137
}

src/init-action-post-helper.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import {
2020
getErrorMessage,
2121
getRequiredEnvParam,
2222
parseMatrixInput,
23-
getSarifUploadSkipReason,
23+
shouldSkipSarifUpload,
2424
wrapError,
2525
} from "./util";
2626
import {
@@ -80,14 +80,11 @@ async function maybeUploadFailedSarif(
8080
if (
8181
!["always", "failure-only"].includes(
8282
actionsUtil.getUploadValue(shouldUpload),
83-
)
83+
) ||
84+
shouldSkipSarifUpload()
8485
) {
8586
return { upload_failed_run_skipped_because: "SARIF upload is disabled" };
8687
}
87-
const skipReason = getSarifUploadSkipReason();
88-
if (skipReason) {
89-
return { upload_failed_run_skipped_because: skipReason };
90-
}
9188
const category = getCategoryInputOrThrow(workflow, jobName, matrix);
9289
const checkoutPath = getCheckoutPathInputOrThrow(workflow, jobName, matrix);
9390
const databasePath = config.dbLocation;

src/upload-lib.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -357,13 +357,12 @@ async function uploadPayload(
357357
logger.info("Uploading results");
358358

359359
// If in test mode we don't want to upload the results,
360-
const skipReason = util.getSarifUploadSkipReason();
361-
if (skipReason) {
360+
if (util.shouldSkipSarifUpload()) {
362361
const payloadSaveFile = path.join(
363362
actionsUtil.getTemporaryDirectory(),
364363
"payload.json",
365364
);
366-
logger.info(`${skipReason}. Saving to ${payloadSaveFile}`);
365+
logger.info(`SARIF upload disabled. Saving to ${payloadSaveFile}`);
367366
logger.info(`Payload: ${JSON.stringify(payload, null, 2)}`);
368367
fs.writeFileSync(payloadSaveFile, JSON.stringify(payload, null, 2));
369368
return "dummy-sarif-id";

src/upload-sarif-action.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import {
2323
checkDiskUsage,
2424
getErrorMessage,
2525
initializeEnvironment,
26-
getSarifUploadSkipReason,
26+
shouldSkipSarifUpload,
2727
wrapError,
2828
} from "./util";
2929

@@ -113,9 +113,8 @@ async function run() {
113113
core.setOutput("sarif-ids", JSON.stringify(uploadResults));
114114

115115
// We don't upload results in test mode, so don't wait for processing
116-
const skipReason = getSarifUploadSkipReason();
117-
if (skipReason) {
118-
core.debug(`${skipReason}. Waiting for processing is disabled.`);
116+
if (shouldSkipSarifUpload()) {
117+
core.debug("SARIF upload disabled. Waiting for processing is disabled.");
119118
} else if (actionsUtil.getRequiredInput("wait-for-processing") === "true") {
120119
if (codeScanningResult !== undefined) {
121120
await upload_lib.waitForProcessing(

src/util.ts

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -771,16 +771,10 @@ export function isInTestMode(): boolean {
771771
}
772772

773773
/**
774-
* Returns whether we specifically want to skip uploading SARIF files, and if so, why.
774+
* Returns whether we specifically want to skip uploading SARIF files.
775775
*/
776-
export function getSarifUploadSkipReason(): string | null {
777-
if (isInTestMode()) {
778-
return `SARIF upload is disabled via ${EnvVar.TEST_MODE}`;
779-
}
780-
if (process.env[EnvVar.SKIP_SARIF_UPLOAD] === "true") {
781-
return `SARIF upload is disabled via ${EnvVar.SKIP_SARIF_UPLOAD}`;
782-
}
783-
return null;
776+
export function shouldSkipSarifUpload(): boolean {
777+
return isInTestMode() || process.env[EnvVar.SKIP_SARIF_UPLOAD] === "true";
784778
}
785779

786780
/**

0 commit comments

Comments
 (0)