mirror of
https://github.com/github/codeql-action.git
synced 2026-10-21 02:01:27 +00:00
Allow initializeEnvironment to accept Env
This commit is contained in:
12
lib/entry-points.js
generated
12
lib/entry-points.js
generated
@@ -169810,12 +169810,12 @@ var ExhaustivityCheckingError = class extends Error {
|
||||
function assertNever(value) {
|
||||
throw new ExhaustivityCheckingError(value);
|
||||
}
|
||||
function initializeEnvironment(version) {
|
||||
exportEnvVar("CODEQL_ACTION_FEATURE_MULTI_LANGUAGE" /* FEATURE_MULTI_LANGUAGE */, "false");
|
||||
exportEnvVar("CODEQL_ACTION_FEATURE_SANDWICH" /* FEATURE_SANDWICH */, "false");
|
||||
exportEnvVar("CODEQL_ACTION_FEATURE_SARIF_COMBINE" /* FEATURE_SARIF_COMBINE */, "true");
|
||||
exportEnvVar("CODEQL_ACTION_FEATURE_WILL_UPLOAD" /* FEATURE_WILL_UPLOAD */, "true");
|
||||
exportEnvVar("CODEQL_ACTION_VERSION" /* VERSION */, version);
|
||||
function initializeEnvironment(version, env = getEnv()) {
|
||||
env.export("CODEQL_ACTION_FEATURE_MULTI_LANGUAGE" /* FEATURE_MULTI_LANGUAGE */, "false");
|
||||
env.export("CODEQL_ACTION_FEATURE_SANDWICH" /* FEATURE_SANDWICH */, "false");
|
||||
env.export("CODEQL_ACTION_FEATURE_SARIF_COMBINE" /* FEATURE_SARIF_COMBINE */, "true");
|
||||
env.export("CODEQL_ACTION_FEATURE_WILL_UPLOAD" /* FEATURE_WILL_UPLOAD */, "true");
|
||||
env.export("CODEQL_ACTION_VERSION" /* VERSION */, version);
|
||||
}
|
||||
var HTTPError = class extends Error {
|
||||
status;
|
||||
|
||||
@@ -5,7 +5,7 @@ import * as sinon from "sinon";
|
||||
|
||||
import * as actionsUtil from "../actions-util";
|
||||
import { ActionsEnvVars } from "../environment";
|
||||
import { callee, setupTests } from "../testing-utils";
|
||||
import { callee, getTestEnv, setupTests } from "../testing-utils";
|
||||
import { initializeEnvironment } from "../util";
|
||||
|
||||
import { getCodeQLActionRepository } from "./repository";
|
||||
@@ -13,13 +13,14 @@ import { getCodeQLActionRepository } from "./repository";
|
||||
setupTests(test);
|
||||
|
||||
test.serial("getCodeQLActionRepository", async (t) => {
|
||||
initializeEnvironment("1.2.3");
|
||||
const initialEnv = getTestEnv({
|
||||
[ActionsEnvVars.RUNNER_TEMP]: path.dirname(__dirname),
|
||||
});
|
||||
initializeEnvironment("1.2.3", initialEnv);
|
||||
|
||||
const target = callee(getCodeQLActionRepository)
|
||||
.withArgs()
|
||||
.withEnv((env) => {
|
||||
env.set(ActionsEnvVars.RUNNER_TEMP, path.dirname(__dirname));
|
||||
});
|
||||
.withEnv(initialEnv);
|
||||
|
||||
// isRunningLocalAction() === true
|
||||
await target.passes(t.deepEqual, "github/codeql-action");
|
||||
|
||||
14
src/util.ts
14
src/util.ts
@@ -19,6 +19,8 @@ import {
|
||||
getRequiredEnvParam,
|
||||
isInTestMode,
|
||||
exportEnvVar,
|
||||
getEnv,
|
||||
type Env,
|
||||
} from "./environment";
|
||||
import * as json from "./json";
|
||||
import { Language } from "./languages";
|
||||
@@ -595,12 +597,12 @@ export function assertNever(value: never): never {
|
||||
* Set some initial environment variables that we can set even without
|
||||
* knowing what version of CodeQL we're running.
|
||||
*/
|
||||
export function initializeEnvironment(version: string) {
|
||||
exportEnvVar(EnvVar.FEATURE_MULTI_LANGUAGE, "false");
|
||||
exportEnvVar(EnvVar.FEATURE_SANDWICH, "false");
|
||||
exportEnvVar(EnvVar.FEATURE_SARIF_COMBINE, "true");
|
||||
exportEnvVar(EnvVar.FEATURE_WILL_UPLOAD, "true");
|
||||
exportEnvVar(EnvVar.VERSION, version);
|
||||
export function initializeEnvironment(version: string, env: Env = getEnv()) {
|
||||
env.export(EnvVar.FEATURE_MULTI_LANGUAGE, "false");
|
||||
env.export(EnvVar.FEATURE_SANDWICH, "false");
|
||||
env.export(EnvVar.FEATURE_SARIF_COMBINE, "true");
|
||||
env.export(EnvVar.FEATURE_WILL_UPLOAD, "true");
|
||||
env.export(EnvVar.VERSION, version);
|
||||
}
|
||||
|
||||
export class HTTPError extends Error {
|
||||
|
||||
Reference in New Issue
Block a user