Move initializeEnvironment out of util.ts

This commit is contained in:
Michael B. Gale
2026-10-16 22:15:06 +01:00
parent a234b846e2
commit c252c71195
17 changed files with 93 additions and 80 deletions

48
lib/entry-points.js generated
View File

@@ -166182,6 +166182,17 @@ var Env = class extends ReadOnlyEnv {
core.exportVariable(name, val);
}
}
/**
* Set some initial environment variables that we can set even without
* knowing what version of CodeQL we're running.
*/
initialise(version) {
this.export("CODEQL_ACTION_FEATURE_MULTI_LANGUAGE" /* FEATURE_MULTI_LANGUAGE */, "false");
this.export("CODEQL_ACTION_FEATURE_SANDWICH" /* FEATURE_SANDWICH */, "false");
this.export("CODEQL_ACTION_FEATURE_SARIF_COMBINE" /* FEATURE_SARIF_COMBINE */, "true");
this.export("CODEQL_ACTION_FEATURE_WILL_UPLOAD" /* FEATURE_WILL_UPLOAD */, "true");
this.export("CODEQL_ACTION_VERSION" /* VERSION */, version);
}
/** Gets a value indicating whether `set` was called at least once. */
hasChanged() {
return this.changed;
@@ -169892,13 +169903,6 @@ var ExhaustivityCheckingError = class extends Error {
function assertNever(value) {
throw new ExhaustivityCheckingError(value);
}
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);
}
function getBaseDatabaseOidsFilePath(config) {
return path.join(config.dbLocation, BASE_DATABASE_OIDS_FILE_NAME);
}
@@ -180759,7 +180763,7 @@ async function run(action) {
let dependencyCacheResults;
let databaseUploadResults = [];
try {
initializeEnvironment(getActionVersion());
action.env.initialise(getActionVersion());
persistInputs();
const statusReportBase = await createStatusReportBase(
"finish" /* Analyze */,
@@ -185938,8 +185942,8 @@ async function runWrapper2() {
// src/autobuild-action.ts
var core17 = __toESM(require_core());
async function sendCompletedStatusReport(config, logger2, startedAt, allLanguages, failingLanguage, cause) {
initializeEnvironment(getActionVersion());
async function sendCompletedStatusReport(env, config, logger2, startedAt, allLanguages, failingLanguage, cause) {
env.initialise(getActionVersion());
const status = getActionsStatus(cause, failingLanguage);
const statusReportBase = await createStatusReportBase(
"autobuild" /* Autobuild */,
@@ -186011,6 +186015,7 @@ async function run2({
`We were unable to automatically build your code. Please replace the call to the autobuild action with your custom build steps. ${error3.message}`
);
await sendCompletedStatusReport(
env,
config,
logger2,
startedAt,
@@ -186021,7 +186026,13 @@ async function run2({
return;
}
env.export("CODEQL_ACTION_AUTOBUILD_DID_COMPLETE_SUCCESSFULLY" /* AUTOBUILD_DID_COMPLETE_SUCCESSFULLY */, "true");
await sendCompletedStatusReport(config, logger2, startedAt, languages ?? []);
await sendCompletedStatusReport(
env,
config,
logger2,
startedAt,
languages ?? []
);
}
var autobuild = {
name: "autobuild" /* Autobuild */,
@@ -186449,7 +186460,7 @@ async function run3(actionState) {
let toolsSource;
let toolsVersion;
try {
initializeEnvironment(getActionVersion());
actionState.env.initialise(getActionVersion());
persistInputs();
apiDetails = {
auth: getRequiredInput("token"),
@@ -187492,7 +187503,7 @@ async function run6(actionState) {
let toolsSource;
let toolsVersion;
try {
initializeEnvironment(getActionVersion());
actionState.env.initialise(getActionVersion());
const apiDetails = {
auth: getRequiredInput("token"),
externalRepoAuth: getOptionalInput("external-repository-token"),
@@ -188444,9 +188455,10 @@ async function sendSuccessStatusReport2(startedAt, uploadStats, logger2) {
await sendStatusReport(statusReport);
}
}
async function run8({ startedAt, logger: logger2 }) {
async function run8(action) {
const logger2 = action.logger;
try {
initializeEnvironment(getActionVersion());
action.env.initialise(getActionVersion());
const gitHubVersion = await getGitHubVersion();
checkActionVersion(getActionVersion(), gitHubVersion);
persistInputs();
@@ -188460,7 +188472,7 @@ async function run8({ startedAt, logger: logger2 }) {
const startingStatusReportBase = await createStatusReportBase(
"upload-sarif" /* UploadSarif */,
"starting",
startedAt,
action.startedAt,
void 0,
await checkDiskUsage(logger2),
logger2
@@ -188503,7 +188515,7 @@ async function run8({ startedAt, logger: logger2 }) {
}
}
await sendSuccessStatusReport2(
startedAt,
action.startedAt,
codeScanningResult?.statusReport || {},
logger2
);
@@ -188514,7 +188526,7 @@ async function run8({ startedAt, logger: logger2 }) {
const errorStatusReportBase = await createStatusReportBase(
"upload-sarif" /* UploadSarif */,
getActionsStatus(error3),
startedAt,
action.startedAt,
void 0,
await checkDiskUsage(logger2),
logger2,