mirror of
https://github.com/github/codeql-action.git
synced 2026-10-31 18:09:43 +00:00
Introduce actions-util.ts
This commit is contained in:
@@ -1,13 +1,13 @@
|
||||
import * as core from "@actions/core";
|
||||
|
||||
import * as actionsUtil from "./actions-util";
|
||||
import { CodeQL } from "./codeql";
|
||||
import * as configUtils from "./config-utils";
|
||||
import { initCodeQL, initConfig, injectWindowsTracer, runInit } from "./init";
|
||||
import { getActionsLogger } from "./logging";
|
||||
import { parseRepositoryNwo } from "./repository";
|
||||
import * as util from "./util";
|
||||
|
||||
interface InitSuccessStatusReport extends util.StatusReportBase {
|
||||
interface InitSuccessStatusReport extends actionsUtil.StatusReportBase {
|
||||
// Comma-separated list of languages that analysis was run for
|
||||
// This may be from the workflow file or may be calculated from repository contents
|
||||
languages: string;
|
||||
@@ -27,7 +27,7 @@ async function sendSuccessStatusReport(
|
||||
startedAt: Date,
|
||||
config: configUtils.Config
|
||||
) {
|
||||
const statusReportBase = await util.createStatusReportBase(
|
||||
const statusReportBase = await actionsUtil.createStatusReportBase(
|
||||
"init",
|
||||
"success",
|
||||
startedAt
|
||||
@@ -58,7 +58,7 @@ async function sendSuccessStatusReport(
|
||||
queries,
|
||||
};
|
||||
|
||||
await util.sendStatusReport(statusReport);
|
||||
await actionsUtil.sendStatusReport(statusReport);
|
||||
}
|
||||
|
||||
async function run() {
|
||||
@@ -68,10 +68,10 @@ async function run() {
|
||||
let codeql: CodeQL;
|
||||
|
||||
try {
|
||||
util.prepareLocalRunEnvironment();
|
||||
actionsUtil.prepareLocalRunEnvironment();
|
||||
if (
|
||||
!(await util.sendStatusReport(
|
||||
await util.createStatusReportBase("init", "starting", startedAt),
|
||||
!(await actionsUtil.sendStatusReport(
|
||||
await actionsUtil.createStatusReportBase("init", "starting", startedAt),
|
||||
true
|
||||
))
|
||||
) {
|
||||
@@ -81,9 +81,9 @@ async function run() {
|
||||
codeql = await initCodeQL(
|
||||
core.getInput("tools"),
|
||||
core.getInput("token"),
|
||||
util.getRequiredEnvParam("GITHUB_SERVER_URL"),
|
||||
util.getRequiredEnvParam("RUNNER_TEMP"),
|
||||
util.getRequiredEnvParam("RUNNER_TOOL_CACHE"),
|
||||
actionsUtil.getRequiredEnvParam("GITHUB_SERVER_URL"),
|
||||
actionsUtil.getRequiredEnvParam("RUNNER_TEMP"),
|
||||
actionsUtil.getRequiredEnvParam("RUNNER_TOOL_CACHE"),
|
||||
"actions",
|
||||
logger
|
||||
);
|
||||
@@ -91,20 +91,25 @@ async function run() {
|
||||
core.getInput("languages"),
|
||||
core.getInput("queries"),
|
||||
core.getInput("config-file"),
|
||||
parseRepositoryNwo(util.getRequiredEnvParam("GITHUB_REPOSITORY")),
|
||||
util.getRequiredEnvParam("RUNNER_TEMP"),
|
||||
util.getRequiredEnvParam("RUNNER_TOOL_CACHE"),
|
||||
parseRepositoryNwo(actionsUtil.getRequiredEnvParam("GITHUB_REPOSITORY")),
|
||||
actionsUtil.getRequiredEnvParam("RUNNER_TEMP"),
|
||||
actionsUtil.getRequiredEnvParam("RUNNER_TOOL_CACHE"),
|
||||
codeql,
|
||||
util.getRequiredEnvParam("GITHUB_WORKSPACE"),
|
||||
actionsUtil.getRequiredEnvParam("GITHUB_WORKSPACE"),
|
||||
core.getInput("token"),
|
||||
util.getRequiredEnvParam("GITHUB_SERVER_URL"),
|
||||
actionsUtil.getRequiredEnvParam("GITHUB_SERVER_URL"),
|
||||
logger
|
||||
);
|
||||
} catch (e) {
|
||||
core.setFailed(e.message);
|
||||
console.log(e);
|
||||
await util.sendStatusReport(
|
||||
await util.createStatusReportBase("init", "aborted", startedAt, e.message)
|
||||
await actionsUtil.sendStatusReport(
|
||||
await actionsUtil.createStatusReportBase(
|
||||
"init",
|
||||
"aborted",
|
||||
startedAt,
|
||||
e.message
|
||||
)
|
||||
);
|
||||
return;
|
||||
}
|
||||
@@ -142,8 +147,8 @@ async function run() {
|
||||
} catch (error) {
|
||||
core.setFailed(error.message);
|
||||
console.log(error);
|
||||
await util.sendStatusReport(
|
||||
await util.createStatusReportBase(
|
||||
await actionsUtil.sendStatusReport(
|
||||
await actionsUtil.createStatusReportBase(
|
||||
"init",
|
||||
"failure",
|
||||
startedAt,
|
||||
|
||||
Reference in New Issue
Block a user