Factor out test mode determination code
This commit is contained in:
parent
0c3c093eba
commit
7c2be06006
9 changed files with 27 additions and 12 deletions
|
|
@ -15,6 +15,7 @@ import {
|
|||
GITHUB_DOTCOM_URL,
|
||||
isGitHubGhesVersionBelow,
|
||||
isHTTPError,
|
||||
isInTestMode,
|
||||
UserError,
|
||||
} from "./util";
|
||||
|
||||
|
|
@ -763,8 +764,7 @@ export async function sendStatusReport<S extends StatusReportBase>(
|
|||
const statusReportJSON = JSON.stringify(statusReport);
|
||||
core.debug(`Sending status report: ${statusReportJSON}`);
|
||||
// If in test mode we don't want to upload the results
|
||||
const testMode = process.env["TEST_MODE"] === "true" || false;
|
||||
if (testMode) {
|
||||
if (isInTestMode()) {
|
||||
core.debug("In test mode. Status reports are not uploaded.");
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -98,8 +98,7 @@ async function uploadPayload(
|
|||
logger.info("Uploading results");
|
||||
|
||||
// If in test mode we don't want to upload the results
|
||||
const testMode = process.env["TEST_MODE"] === "true" || false;
|
||||
if (testMode) {
|
||||
if (util.isInTestMode()) {
|
||||
const payloadSaveFile = path.join(
|
||||
actionsUtil.getTemporaryDirectory(),
|
||||
"payload.json"
|
||||
|
|
|
|||
|
|
@ -742,3 +742,12 @@ export async function checkActionVersion(version: string) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns whether we are in test mode.
|
||||
*
|
||||
* In test mode, we don't upload SARIF results or status reports to the GitHub API.
|
||||
*/
|
||||
export function isInTestMode(): boolean {
|
||||
return process.env["TEST_MODE"] === "true" || false;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue