mirror of
https://github.com/github/codeql-action.git
synced 2026-10-21 02:01:27 +00:00
Replace deprecated functions in init-action.post.ts
This commit is contained in:
18
lib/entry-points.js
generated
18
lib/entry-points.js
generated
@@ -187255,7 +187255,7 @@ async function run4(action) {
|
||||
repositoryNwo,
|
||||
features,
|
||||
jobStatus2,
|
||||
getEnv(),
|
||||
action.env,
|
||||
logger2
|
||||
);
|
||||
if (await isAnalyzingDefaultBranch() && hasConfigKey(config, "dependencyCachingEnabled") && config.dependencyCachingEnabled !== "none" /* None */) {
|
||||
@@ -187280,7 +187280,7 @@ async function run4(action) {
|
||||
}
|
||||
return;
|
||||
}
|
||||
const jobStatus = getFinalJobStatus(config);
|
||||
const jobStatus = getFinalJobStatus(action, config);
|
||||
logger2.info(`CodeQL job status was ${getJobStatusDisplayName(jobStatus)}.`);
|
||||
const statusReportBase = await createStatusReportBase(
|
||||
action.name,
|
||||
@@ -187302,25 +187302,25 @@ async function run4(action) {
|
||||
logger2.info("Status report sent for init-post step.");
|
||||
}
|
||||
}
|
||||
function getFinalJobStatus(config) {
|
||||
const existingJobStatus = getJobStatusFromEnvironment();
|
||||
function getFinalJobStatus(action, config) {
|
||||
const existingJobStatus = getJobStatusFromEnvironment(action.env);
|
||||
if (existingJobStatus !== void 0) {
|
||||
return existingJobStatus;
|
||||
}
|
||||
let jobStatus;
|
||||
if (process.env["CODEQL_ACTION_ANALYZE_DID_COMPLETE_SUCCESSFULLY" /* ANALYZE_DID_COMPLETE_SUCCESSFULLY */] === "true") {
|
||||
exportEnvVar("CODEQL_ACTION_JOB_STATUS" /* JOB_STATUS */, "JOB_STATUS_SUCCESS" /* SuccessStatus */);
|
||||
if (action.env.getOptional("CODEQL_ACTION_ANALYZE_DID_COMPLETE_SUCCESSFULLY" /* ANALYZE_DID_COMPLETE_SUCCESSFULLY */) === "true") {
|
||||
action.env.export("CODEQL_ACTION_JOB_STATUS" /* JOB_STATUS */, "JOB_STATUS_SUCCESS" /* SuccessStatus */);
|
||||
jobStatus = "JOB_STATUS_SUCCESS" /* SuccessStatus */;
|
||||
} else if (config !== void 0) {
|
||||
jobStatus = "JOB_STATUS_CONFIGURATION_ERROR" /* ConfigErrorStatus */;
|
||||
} else {
|
||||
jobStatus = "JOB_STATUS_UNKNOWN" /* UnknownStatus */;
|
||||
}
|
||||
exportEnvVar("CODEQL_ACTION_JOB_STATUS" /* JOB_STATUS */, jobStatus);
|
||||
action.env.export("CODEQL_ACTION_JOB_STATUS" /* JOB_STATUS */, jobStatus);
|
||||
return jobStatus;
|
||||
}
|
||||
function getJobStatusFromEnvironment() {
|
||||
const jobStatusFromEnvironment = process.env["CODEQL_ACTION_JOB_STATUS" /* JOB_STATUS */];
|
||||
function getJobStatusFromEnvironment(env) {
|
||||
const jobStatusFromEnvironment = env.getOptional("CODEQL_ACTION_JOB_STATUS" /* JOB_STATUS */);
|
||||
if (jobStatusFromEnvironment !== void 0) {
|
||||
if (Object.values(JobStatus).includes(jobStatusFromEnvironment)) {
|
||||
return jobStatusFromEnvironment;
|
||||
|
||||
@@ -27,7 +27,7 @@ import {
|
||||
DependencyCachingUsageReport,
|
||||
getDependencyCacheUsage,
|
||||
} from "./dependency-caching";
|
||||
import { EnvVar, getEnv, exportEnvVar } from "./environment";
|
||||
import { EnvVar, type ReadOnlyEnv } from "./environment";
|
||||
import { initFeatures } from "./feature-flags";
|
||||
import * as gitUtils from "./git-utils";
|
||||
import * as initActionPostHelper from "./init-action-post-helper";
|
||||
@@ -49,7 +49,7 @@ interface InitPostStatusReport
|
||||
initActionPostHelper.JobStatusReport,
|
||||
initActionPostHelper.DependencyCachingUsageReport {}
|
||||
|
||||
async function run(action: ActionState<["Base", "Logger"]>) {
|
||||
async function run(action: ActionState<["Base", "Logger", "Env"]>) {
|
||||
// To capture errors appropriately, keep as much code within the try-catch as
|
||||
// possible, and only use safe functions outside.
|
||||
const logger = action.logger;
|
||||
@@ -105,7 +105,7 @@ async function run(action: ActionState<["Base", "Logger"]>) {
|
||||
repositoryNwo,
|
||||
features,
|
||||
jobStatus,
|
||||
getEnv(),
|
||||
action.env,
|
||||
logger,
|
||||
);
|
||||
|
||||
@@ -140,7 +140,7 @@ async function run(action: ActionState<["Base", "Logger"]>) {
|
||||
}
|
||||
return;
|
||||
}
|
||||
const jobStatus = getFinalJobStatus(config);
|
||||
const jobStatus = getFinalJobStatus(action, config);
|
||||
logger.info(`CodeQL job status was ${getJobStatusDisplayName(jobStatus)}.`);
|
||||
|
||||
const statusReportBase = await createStatusReportBase(
|
||||
@@ -171,16 +171,21 @@ async function run(action: ActionState<["Base", "Logger"]>) {
|
||||
* Otherwise, we determine the job status based on whether the analyze step
|
||||
* completed successfully and whether we have a valid CodeQL config.
|
||||
*/
|
||||
function getFinalJobStatus(config: Partial<Config> | undefined): JobStatus {
|
||||
const existingJobStatus = getJobStatusFromEnvironment();
|
||||
function getFinalJobStatus(
|
||||
action: ActionState<["Env"]>,
|
||||
config: Partial<Config> | undefined,
|
||||
): JobStatus {
|
||||
const existingJobStatus = getJobStatusFromEnvironment(action.env);
|
||||
if (existingJobStatus !== undefined) {
|
||||
return existingJobStatus;
|
||||
}
|
||||
|
||||
let jobStatus: JobStatus;
|
||||
|
||||
if (process.env[EnvVar.ANALYZE_DID_COMPLETE_SUCCESSFULLY] === "true") {
|
||||
exportEnvVar(EnvVar.JOB_STATUS, JobStatus.SuccessStatus);
|
||||
if (
|
||||
action.env.getOptional(EnvVar.ANALYZE_DID_COMPLETE_SUCCESSFULLY) === "true"
|
||||
) {
|
||||
action.env.export(EnvVar.JOB_STATUS, JobStatus.SuccessStatus);
|
||||
jobStatus = JobStatus.SuccessStatus;
|
||||
} else if (config !== undefined) {
|
||||
// - We have computed a CodeQL config
|
||||
@@ -205,7 +210,7 @@ function getFinalJobStatus(config: Partial<Config> | undefined): JobStatus {
|
||||
|
||||
// This shouldn't be necessary, but in the odd case that we run more than one
|
||||
// `init` post step, ensure the job status is consistent between them.
|
||||
exportEnvVar(EnvVar.JOB_STATUS, jobStatus);
|
||||
action.env.export(EnvVar.JOB_STATUS, jobStatus);
|
||||
return jobStatus;
|
||||
}
|
||||
|
||||
@@ -214,8 +219,8 @@ function getFinalJobStatus(config: Partial<Config> | undefined): JobStatus {
|
||||
*
|
||||
* If the job status is invalid, return `UnknownStatus`.
|
||||
*/
|
||||
function getJobStatusFromEnvironment(): JobStatus | undefined {
|
||||
const jobStatusFromEnvironment = process.env[EnvVar.JOB_STATUS];
|
||||
function getJobStatusFromEnvironment(env: ReadOnlyEnv): JobStatus | undefined {
|
||||
const jobStatusFromEnvironment = env.getOptional(EnvVar.JOB_STATUS);
|
||||
|
||||
if (jobStatusFromEnvironment !== undefined) {
|
||||
// Validate the job status from the environment. If it is invalid, return unknown.
|
||||
|
||||
Reference in New Issue
Block a user