mirror of
https://github.com/github/codeql-action.git
synced 2026-10-21 02:01:27 +00:00
Allow to explicitly not skip the SARIF upload
This commit is contained in:
5
lib/entry-points.js
generated
5
lib/entry-points.js
generated
@@ -169889,8 +169889,9 @@ async function delay(milliseconds, opts) {
|
||||
function isGoodVersion(versionSpec) {
|
||||
return !BROKEN_VERSIONS.includes(versionSpec);
|
||||
}
|
||||
function shouldSkipSarifUpload() {
|
||||
return isInTestMode() || process.env["CODEQL_ACTION_SKIP_SARIF_UPLOAD" /* SKIP_SARIF_UPLOAD */] === "true";
|
||||
function shouldSkipSarifUpload(env = getEnv()) {
|
||||
const skipSarifUpload = env.getOptional("CODEQL_ACTION_SKIP_SARIF_UPLOAD" /* SKIP_SARIF_UPLOAD */);
|
||||
return skipSarifUpload !== "false" && (env.isSkippingUploadsInTests() || skipSarifUpload === "true");
|
||||
}
|
||||
function getTestingEnvironment() {
|
||||
const testingEnvironment = process.env["CODEQL_ACTION_TESTING_ENVIRONMENT" /* TESTING_ENVIRONMENT */] || "";
|
||||
|
||||
@@ -11,7 +11,7 @@ import * as sinon from "sinon";
|
||||
import * as api from "./api-client";
|
||||
import { EnvVar } from "./environment";
|
||||
import { getRunnerLogger } from "./logging";
|
||||
import { setupTests } from "./testing-utils";
|
||||
import { getTestEnv, setupTests } from "./testing-utils";
|
||||
import * as util from "./util";
|
||||
|
||||
setupTests(test);
|
||||
@@ -493,3 +493,31 @@ test("Failure.orElse returns the default value for a failure result", (t) => {
|
||||
const result = new util.Failure(new Error("test error"));
|
||||
t.is(result.orElse("default value"), "default value");
|
||||
});
|
||||
|
||||
test("shouldSkipSarifUpload", (t) => {
|
||||
const env = getTestEnv();
|
||||
|
||||
// Don't skip by default
|
||||
t.is(util.shouldSkipSarifUpload(env), false);
|
||||
|
||||
// Skip in test mode
|
||||
env.setAll({
|
||||
[EnvVar.TEST_MODE]: "true",
|
||||
[EnvVar.SKIP_SARIF_UPLOAD]: undefined,
|
||||
});
|
||||
t.is(util.shouldSkipSarifUpload(env), true);
|
||||
|
||||
// Skip if explicitly requested
|
||||
env.setAll({
|
||||
[EnvVar.TEST_MODE]: undefined,
|
||||
[EnvVar.SKIP_SARIF_UPLOAD]: "true",
|
||||
});
|
||||
t.is(util.shouldSkipSarifUpload(env), true);
|
||||
|
||||
// Don't skip if explicitly requested
|
||||
env.setAll({
|
||||
[EnvVar.TEST_MODE]: "true",
|
||||
[EnvVar.SKIP_SARIF_UPLOAD]: "false",
|
||||
});
|
||||
t.is(util.shouldSkipSarifUpload(env), false);
|
||||
});
|
||||
|
||||
10
src/util.ts
10
src/util.ts
@@ -18,10 +18,10 @@ import type { Config } from "./config-utils";
|
||||
import {
|
||||
EnvVar,
|
||||
getRequiredEnvParam,
|
||||
isInTestMode,
|
||||
exportEnvVar,
|
||||
getEnv,
|
||||
type Env,
|
||||
type ReadOnlyEnv,
|
||||
} from "./environment";
|
||||
import * as json from "./json";
|
||||
import { Language } from "./languages";
|
||||
@@ -687,8 +687,12 @@ export function isGoodVersion(versionSpec: string) {
|
||||
/**
|
||||
* Returns whether we specifically want to skip uploading SARIF files.
|
||||
*/
|
||||
export function shouldSkipSarifUpload(): boolean {
|
||||
return isInTestMode() || process.env[EnvVar.SKIP_SARIF_UPLOAD] === "true";
|
||||
export function shouldSkipSarifUpload(env: ReadOnlyEnv = getEnv()): boolean {
|
||||
const skipSarifUpload = env.getOptional(EnvVar.SKIP_SARIF_UPLOAD);
|
||||
return (
|
||||
skipSarifUpload !== "false" &&
|
||||
(env.isSkippingUploadsInTests() || skipSarifUpload === "true")
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user