mirror of
https://github.com/github/codeql-action.git
synced 2026-10-31 09:59:43 +00:00
Eliminate core imports from post-actions
This commit is contained in:
684
lib/entry-points.js
generated
684
lib/entry-points.js
generated
File diff suppressed because it is too large
Load Diff
@@ -5,8 +5,6 @@
|
||||
*/
|
||||
import * as fs from "fs";
|
||||
|
||||
import * as core from "@actions/core";
|
||||
|
||||
import {
|
||||
ActionName,
|
||||
runInActions,
|
||||
@@ -28,7 +26,7 @@ import { checkGitHubVersionInRange, getErrorMessage } from "./util";
|
||||
* The main functionality of the `analyze` post-action is implemented by this function.
|
||||
* This is called once by {@link runInActions} after it is called in {@link runWrapper}.
|
||||
*/
|
||||
export async function run(action: ActionState<["Logger"]>) {
|
||||
export async function run(action: ActionState<["Logger", "Env", "Actions"]>) {
|
||||
// To capture errors appropriately, keep as much code within the try-catch as
|
||||
// possible, and only use safe functions outside.
|
||||
const logger = action.logger;
|
||||
@@ -39,7 +37,7 @@ export async function run(action: ActionState<["Logger"]>) {
|
||||
|
||||
// Upload SARIF artifacts if we determine that this is a first-party analysis run.
|
||||
// For third-party runs, this artifact will be uploaded in the `upload-sarif-post` step.
|
||||
if (process.env[EnvVar.INIT_ACTION_HAS_RUN] === "true") {
|
||||
if (action.env.getOptional(EnvVar.INIT_ACTION_HAS_RUN) === "true") {
|
||||
const config = await getConfig(
|
||||
actionsUtil.getTemporaryDirectory(),
|
||||
logger,
|
||||
@@ -71,7 +69,7 @@ export async function run(action: ActionState<["Logger"]>) {
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
core.setFailed(
|
||||
action.actions.setFailed(
|
||||
`analyze post-action step failed: ${getErrorMessage(error)}`,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -4,14 +4,8 @@
|
||||
* other `post:` hooks.
|
||||
*/
|
||||
|
||||
import * as core from "@actions/core";
|
||||
|
||||
import { runInActions, type Action, type ActionState } from "./action-common";
|
||||
import {
|
||||
getOptionalInput,
|
||||
getTemporaryDirectory,
|
||||
printDebugLogs,
|
||||
} from "./actions-util";
|
||||
import { getTemporaryDirectory, printDebugLogs } from "./actions-util";
|
||||
import { getGitHubVersion, wrapApiConfigurationError } from "./api-client";
|
||||
import { CachingKind } from "./caching-utils";
|
||||
import { getCodeQL } from "./codeql";
|
||||
@@ -48,7 +42,11 @@ interface InitPostStatusReport
|
||||
initActionPostHelper.JobStatusReport,
|
||||
initActionPostHelper.DependencyCachingUsageReport {}
|
||||
|
||||
async function run(action: ActionState<["Base", "Logger", "Env"]>) {
|
||||
/**
|
||||
* The main functionality of the `init` post-action is implemented by this function.
|
||||
* This is called once by {@link runInActions} after it is called in {@link runWrapper}.
|
||||
*/
|
||||
async function run(action: ActionState<["Base", "Logger", "Env", "Actions"]>) {
|
||||
// To capture errors appropriately, keep as much code within the try-catch as
|
||||
// possible, and only use safe functions outside.
|
||||
const logger = action.logger;
|
||||
@@ -63,7 +61,7 @@ async function run(action: ActionState<["Base", "Logger", "Env"]>) {
|
||||
// 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`
|
||||
// Action saw, which is always a success.
|
||||
const jobStatus = getOptionalInput("job-status");
|
||||
const jobStatus = action.actions.getOptionalInput("job-status");
|
||||
|
||||
const tmpDir = getTemporaryDirectory();
|
||||
config = await getConfig(tmpDir, logger);
|
||||
@@ -82,7 +80,7 @@ async function run(action: ActionState<["Base", "Logger", "Env"]>) {
|
||||
const features = initFeatures(
|
||||
gitHubVersion,
|
||||
repositoryNwo,
|
||||
getTemporaryDirectory(),
|
||||
config?.tempDir ?? tmpDir,
|
||||
logger,
|
||||
);
|
||||
|
||||
@@ -122,7 +120,7 @@ async function run(action: ActionState<["Base", "Logger", "Env"]>) {
|
||||
}
|
||||
} catch (unwrappedError) {
|
||||
const error = wrapApiConfigurationError(wrapError(unwrappedError));
|
||||
core.setFailed(error.message);
|
||||
action.actions.setFailed(error.message);
|
||||
|
||||
const statusReportBase = await createStatusReportBase(
|
||||
action.name,
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
* It will run after the all steps in this job, in reverse order in relation to
|
||||
* other `post:` hooks.
|
||||
*/
|
||||
import * as core from "@actions/core";
|
||||
|
||||
import {
|
||||
ActionName,
|
||||
runInActions,
|
||||
@@ -22,7 +20,7 @@ import { checkGitHubVersionInRange, getErrorMessage } from "./util";
|
||||
* The main functionality of the `start-proxy` post-action is implemented by this function.
|
||||
* This is called once by {@link runInActions} after it is called in {@link runWrapper}.
|
||||
*/
|
||||
export async function run(action: ActionState<["Logger"]>) {
|
||||
export async function run(action: ActionState<["Logger", "Actions"]>) {
|
||||
// To capture errors appropriately, keep as much code within the try-catch as
|
||||
// possible, and only use safe functions outside.
|
||||
|
||||
@@ -30,18 +28,16 @@ export async function run(action: ActionState<["Logger"]>) {
|
||||
|
||||
try {
|
||||
// Kill the running proxy
|
||||
const pid = core.getState("proxy-process-pid");
|
||||
const pid = action.actions.getState("proxy-process-pid");
|
||||
if (pid) {
|
||||
process.kill(Number(pid));
|
||||
}
|
||||
|
||||
const config = await configUtils.getConfig(
|
||||
actionsUtil.getTemporaryDirectory(),
|
||||
logger,
|
||||
);
|
||||
const tempDir = actionsUtil.getTemporaryDirectory();
|
||||
const config = await configUtils.getConfig(tempDir, logger);
|
||||
|
||||
if (config?.debugMode || core.isDebug()) {
|
||||
const logFilePath = core.getState("proxy-log-file");
|
||||
if (config?.debugMode || logger.isDebug()) {
|
||||
const logFilePath = action.actions.getState("proxy-log-file");
|
||||
logger.info(
|
||||
"Debug mode is on. Uploading proxy log as Actions debugging artifact...",
|
||||
);
|
||||
@@ -51,7 +47,7 @@ export async function run(action: ActionState<["Logger"]>) {
|
||||
await uploadArtifacts(
|
||||
logger,
|
||||
[logFilePath],
|
||||
actionsUtil.getTemporaryDirectory(),
|
||||
tempDir,
|
||||
"proxy-log-file",
|
||||
gitHubVersion.type,
|
||||
);
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
* It will run after the all steps in this job, in reverse order in relation to
|
||||
* other `post:` hooks.
|
||||
*/
|
||||
import * as core from "@actions/core";
|
||||
|
||||
import {
|
||||
ActionName,
|
||||
runInActions,
|
||||
@@ -21,7 +19,7 @@ import { checkGitHubVersionInRange, getErrorMessage } from "./util";
|
||||
* The main functionality of the `upload-sarif` post-action is implemented by this function.
|
||||
* This is called once by {@link runInActions} after it is called in {@link runWrapper}.
|
||||
*/
|
||||
export async function run(action: ActionState<["Logger"]>) {
|
||||
export async function run(action: ActionState<["Logger", "Env", "Actions"]>) {
|
||||
// To capture errors appropriately, keep as much code within the try-catch as
|
||||
// possible, and only use safe functions outside.
|
||||
const logger = action.logger;
|
||||
@@ -32,9 +30,9 @@ export async function run(action: ActionState<["Logger"]>) {
|
||||
|
||||
// Upload SARIF artifacts if we determine that this is a third-party analysis run.
|
||||
// For first-party runs, this artifact will be uploaded in the `analyze-post` step.
|
||||
if (process.env[EnvVar.INIT_ACTION_HAS_RUN] !== "true") {
|
||||
if (action.env.getOptional(EnvVar.INIT_ACTION_HAS_RUN) !== "true") {
|
||||
if (gitHubVersion.type === undefined) {
|
||||
core.warning(
|
||||
logger.warning(
|
||||
`Did not upload debug artifacts because cannot determine the GitHub variant running.`,
|
||||
);
|
||||
return;
|
||||
@@ -44,7 +42,7 @@ export async function run(action: ActionState<["Logger"]>) {
|
||||
);
|
||||
}
|
||||
} catch (error) {
|
||||
core.setFailed(
|
||||
action.actions.setFailed(
|
||||
`upload-sarif post-action step failed: ${getErrorMessage(error)}`,
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user