Skip to content

Commit 7c2be06

Browse files
committed
Factor out test mode determination code
1 parent 0c3c093 commit 7c2be06

File tree

9 files changed

+27
-12
lines changed

9 files changed

+27
-12
lines changed

lib/actions-util.js

Lines changed: 1 addition & 2 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: 1 addition & 2 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/util.js

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

lib/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.

src/actions-util.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
GITHUB_DOTCOM_URL,
1616
isGitHubGhesVersionBelow,
1717
isHTTPError,
18+
isInTestMode,
1819
UserError,
1920
} from "./util";
2021

@@ -763,8 +764,7 @@ export async function sendStatusReport<S extends StatusReportBase>(
763764
const statusReportJSON = JSON.stringify(statusReport);
764765
core.debug(`Sending status report: ${statusReportJSON}`);
765766
// If in test mode we don't want to upload the results
766-
const testMode = process.env["TEST_MODE"] === "true" || false;
767-
if (testMode) {
767+
if (isInTestMode()) {
768768
core.debug("In test mode. Status reports are not uploaded.");
769769
return true;
770770
}

src/upload-lib.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,7 @@ async function uploadPayload(
9898
logger.info("Uploading results");
9999

100100
// If in test mode we don't want to upload the results
101-
const testMode = process.env["TEST_MODE"] === "true" || false;
102-
if (testMode) {
101+
if (util.isInTestMode()) {
103102
const payloadSaveFile = path.join(
104103
actionsUtil.getTemporaryDirectory(),
105104
"payload.json"

src/util.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -742,3 +742,12 @@ export async function checkActionVersion(version: string) {
742742
}
743743
}
744744
}
745+
746+
/*
747+
* Returns whether we are in test mode.
748+
*
749+
* In test mode, we don't upload SARIF results or status reports to the GitHub API.
750+
*/
751+
export function isInTestMode(): boolean {
752+
return process.env["TEST_MODE"] === "true" || false;
753+
}

0 commit comments

Comments
 (0)