mirror of
https://github.com/github/codeql-action.git
synced 2026-10-21 02:01:27 +00:00
Use runInActions for init-post
This commit is contained in:
35
lib/entry-points.js
generated
35
lib/entry-points.js
generated
@@ -171404,6 +171404,8 @@ function getAddressString(address) {
|
||||
function getDisplayActionName(actionName) {
|
||||
if (actionName === "finish" /* Analyze */) {
|
||||
return "analyze";
|
||||
} else if (actionName === "init-post" /* InitPost */) {
|
||||
return "init post";
|
||||
}
|
||||
return actionName;
|
||||
}
|
||||
@@ -187108,15 +187110,16 @@ async function removeUploadedSarif(uploadFailedSarifResult, logger2) {
|
||||
}
|
||||
|
||||
// src/init-action-post.ts
|
||||
async function run4(startedAt) {
|
||||
const logger2 = getActionsLogger();
|
||||
async function run4(action) {
|
||||
const logger2 = action.logger;
|
||||
let config;
|
||||
let uploadFailedSarifResult;
|
||||
let dependencyCachingUsage;
|
||||
try {
|
||||
const jobStatus2 = getOptionalInput("job-status");
|
||||
restoreInputs(logger2);
|
||||
config = await getConfig(getTemporaryDirectory(), logger2);
|
||||
const tmpDir = getTemporaryDirectory();
|
||||
config = await getConfig(tmpDir, logger2);
|
||||
const gitHubVersion = config?.gitHubVersion ?? await getGitHubVersion();
|
||||
checkGitHubVersionInRange(gitHubVersion, logger2);
|
||||
const repositoryNwo = getRepositoryNwo();
|
||||
@@ -187151,9 +187154,9 @@ async function run4(startedAt) {
|
||||
const error3 = wrapApiConfigurationError(wrapError(unwrappedError));
|
||||
core20.setFailed(error3.message);
|
||||
const statusReportBase2 = await createStatusReportBase(
|
||||
"init-post" /* InitPost */,
|
||||
action.name,
|
||||
getActionsStatus(error3),
|
||||
startedAt,
|
||||
action.startedAt,
|
||||
config,
|
||||
await checkDiskUsage(logger2),
|
||||
logger2,
|
||||
@@ -187168,9 +187171,9 @@ async function run4(startedAt) {
|
||||
const jobStatus = getFinalJobStatus(config);
|
||||
logger2.info(`CodeQL job status was ${getJobStatusDisplayName(jobStatus)}.`);
|
||||
const statusReportBase = await createStatusReportBase(
|
||||
"init-post" /* InitPost */,
|
||||
action.name,
|
||||
"success",
|
||||
startedAt,
|
||||
action.startedAt,
|
||||
config,
|
||||
await checkDiskUsage(logger2),
|
||||
logger2
|
||||
@@ -187214,20 +187217,12 @@ function getJobStatusFromEnvironment() {
|
||||
}
|
||||
return void 0;
|
||||
}
|
||||
var initPost = {
|
||||
name: "init-post" /* InitPost */,
|
||||
run: run4
|
||||
};
|
||||
async function runWrapper5() {
|
||||
const startedAt = /* @__PURE__ */ new Date();
|
||||
const logger2 = getActionsLogger();
|
||||
try {
|
||||
await run4(startedAt);
|
||||
} catch (error3) {
|
||||
core20.setFailed(`init post action failed: ${wrapError(error3).message}`);
|
||||
await sendUnhandledErrorStatusReport(
|
||||
"init-post" /* InitPost */,
|
||||
startedAt,
|
||||
error3,
|
||||
logger2
|
||||
);
|
||||
}
|
||||
return await runInActions(initPost);
|
||||
}
|
||||
|
||||
// src/resolve-environment-action.ts
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
import * as core from "@actions/core";
|
||||
|
||||
import { runInActions, type Action, type ActionState } from "./action-common";
|
||||
import {
|
||||
restoreInputs,
|
||||
getOptionalInput,
|
||||
@@ -25,12 +26,10 @@ import { EnvVar, getEnv, exportEnvVar } from "./environment";
|
||||
import { initFeatures } from "./feature-flags";
|
||||
import * as gitUtils from "./git-utils";
|
||||
import * as initActionPostHelper from "./init-action-post-helper";
|
||||
import { getActionsLogger } from "./logging";
|
||||
import { getRepositoryNwo } from "./repository";
|
||||
import {
|
||||
StatusReportBase,
|
||||
sendStatusReport,
|
||||
sendUnhandledErrorStatusReport,
|
||||
createStatusReportBase,
|
||||
getActionsStatus,
|
||||
ActionName,
|
||||
@@ -45,16 +44,17 @@ interface InitPostStatusReport
|
||||
initActionPostHelper.JobStatusReport,
|
||||
initActionPostHelper.DependencyCachingUsageReport {}
|
||||
|
||||
async function run(startedAt: Date) {
|
||||
async function run(action: ActionState<["Base", "Logger"]>) {
|
||||
// To capture errors appropriately, keep as much code within the try-catch as
|
||||
// possible, and only use safe functions outside.
|
||||
const logger = action.logger;
|
||||
|
||||
const logger = getActionsLogger();
|
||||
let config: Config | undefined;
|
||||
let uploadFailedSarifResult:
|
||||
| initActionPostHelper.UploadFailedSarifResult
|
||||
| undefined;
|
||||
let dependencyCachingUsage: DependencyCachingUsageReport | undefined;
|
||||
|
||||
try {
|
||||
// Read the job status before restoring inputs, since it is provided by the Actions runtime
|
||||
// environment for this step and would otherwise be overwritten by the value that the `init`
|
||||
@@ -64,7 +64,8 @@ async function run(startedAt: Date) {
|
||||
// Restore inputs from `init` Action.
|
||||
restoreInputs(logger);
|
||||
|
||||
config = await getConfig(getTemporaryDirectory(), logger);
|
||||
const tmpDir = getTemporaryDirectory();
|
||||
config = await getConfig(tmpDir, logger);
|
||||
|
||||
const gitHubVersion = config?.gitHubVersion ?? (await getGitHubVersion());
|
||||
checkGitHubVersionInRange(gitHubVersion, logger);
|
||||
@@ -112,9 +113,9 @@ async function run(startedAt: Date) {
|
||||
core.setFailed(error.message);
|
||||
|
||||
const statusReportBase = await createStatusReportBase(
|
||||
ActionName.InitPost,
|
||||
action.name,
|
||||
getActionsStatus(error),
|
||||
startedAt,
|
||||
action.startedAt,
|
||||
config,
|
||||
await checkDiskUsage(logger),
|
||||
logger,
|
||||
@@ -130,9 +131,9 @@ async function run(startedAt: Date) {
|
||||
logger.info(`CodeQL job status was ${getJobStatusDisplayName(jobStatus)}.`);
|
||||
|
||||
const statusReportBase = await createStatusReportBase(
|
||||
ActionName.InitPost,
|
||||
action.name,
|
||||
"success",
|
||||
startedAt,
|
||||
action.startedAt,
|
||||
config,
|
||||
await checkDiskUsage(logger),
|
||||
logger,
|
||||
@@ -216,18 +217,11 @@ function getJobStatusFromEnvironment(): JobStatus | undefined {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const initPost: Action = {
|
||||
name: ActionName.InitPost,
|
||||
run,
|
||||
};
|
||||
|
||||
export async function runWrapper() {
|
||||
const startedAt = new Date();
|
||||
const logger = getActionsLogger();
|
||||
try {
|
||||
await run(startedAt);
|
||||
} catch (error) {
|
||||
core.setFailed(`init post action failed: ${wrapError(error).message}`);
|
||||
await sendUnhandledErrorStatusReport(
|
||||
ActionName.InitPost,
|
||||
startedAt,
|
||||
error,
|
||||
logger,
|
||||
);
|
||||
}
|
||||
return await runInActions(initPost);
|
||||
}
|
||||
|
||||
@@ -68,6 +68,8 @@ export enum ActionName {
|
||||
export function getDisplayActionName(actionName: ActionName): string {
|
||||
if (actionName === ActionName.Analyze) {
|
||||
return "analyze";
|
||||
} else if (actionName === ActionName.InitPost) {
|
||||
return "init post";
|
||||
}
|
||||
return actionName;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user