From ffebdc8cf857031dc721a97563af99d1b8ace016 Mon Sep 17 00:00:00 2001 From: "Michael B. Gale" Date: Fri, 22 May 2026 13:44:34 +0100 Subject: [PATCH] Move `isInTestMode` to `environment.ts` --- lib/entry-points.js | 8 +++++--- src/environment.ts | 9 +++++++++ src/util.ts | 13 +++---------- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/lib/entry-points.js b/lib/entry-points.js index e8ae31703..a97c1956b 100644 --- a/lib/entry-points.js +++ b/lib/entry-points.js @@ -147626,6 +147626,11 @@ var semver = __toESM(require_semver2()); var maximumVersion = "3.21"; var minimumVersion = "3.16"; +// src/environment.ts +function isInTestMode() { + return process.env["CODEQL_ACTION_TEST_MODE" /* TEST_MODE */] === "true"; +} + // src/json/index.ts function parseString(data) { return JSON.parse(data); @@ -148054,9 +148059,6 @@ async function delay(milliseconds, opts) { function isGoodVersion(versionSpec) { return !BROKEN_VERSIONS.includes(versionSpec); } -function isInTestMode() { - return process.env["CODEQL_ACTION_TEST_MODE" /* TEST_MODE */] === "true"; -} function shouldSkipSarifUpload() { return isInTestMode() || process.env["CODEQL_ACTION_SKIP_SARIF_UPLOAD" /* SKIP_SARIF_UPLOAD */] === "true"; } diff --git a/src/environment.ts b/src/environment.ts index ed44ddcff..b933332af 100644 --- a/src/environment.ts +++ b/src/environment.ts @@ -154,3 +154,12 @@ export enum EnvVar { /** Used by Code Scanning Risk Assessment to communicate the assessment ID to the CodeQL Action. */ RISK_ASSESSMENT_ID = "CODEQL_ACTION_RISK_ASSESSMENT_ID", } + +/** + * Returns whether we are in test mode. This is used by CodeQL Action PR checks. + * + * In test mode, we skip several uploads (SARIF results, status reports, DBs, ...). + */ +export function isInTestMode(): boolean { + return process.env[EnvVar.TEST_MODE] === "true"; +} diff --git a/src/util.ts b/src/util.ts index e2331461b..4e6bc5845 100644 --- a/src/util.ts +++ b/src/util.ts @@ -13,11 +13,13 @@ import * as apiCompatibility from "./api-compatibility.json"; import type { CodeQL, VersionInfo } from "./codeql"; import type { Pack } from "./config/db-config"; import type { Config } from "./config-utils"; -import { EnvVar } from "./environment"; +import { EnvVar, isInTestMode } from "./environment"; import * as json from "./json"; import { Language } from "./languages"; import { Logger } from "./logging"; +export { isInTestMode } from "./environment"; + /** * The name of the file containing the base database OIDs, as stored in the * root of the database location. @@ -708,15 +710,6 @@ export function isGoodVersion(versionSpec: string) { return !BROKEN_VERSIONS.includes(versionSpec); } -/** - * Returns whether we are in test mode. This is used by CodeQL Action PR checks. - * - * In test mode, we skip several uploads (SARIF results, status reports, DBs, ...). - */ -export function isInTestMode(): boolean { - return process.env[EnvVar.TEST_MODE] === "true"; -} - /** * Returns whether we specifically want to skip uploading SARIF files. */