Use runInActions for the start-proxy post-action

This commit is contained in:
Michael B. Gale
2026-10-19 19:33:52 +01:00
parent a4c1eb2b5f
commit 1907698e19
2 changed files with 79 additions and 49 deletions

100
lib/entry-points.js generated
View File

@@ -28816,7 +28816,7 @@ var require_light = __commonJS({
}
return this.Events.trigger("scheduled", { args: this.args, options: this.options });
}
async doExecute(chained, clearGlobalState, run9, free) {
async doExecute(chained, clearGlobalState, run10, free) {
var error3, eventInfo, passed;
if (this.retryCount === 0) {
this._assertStatus("RUNNING");
@@ -28836,10 +28836,10 @@ var require_light = __commonJS({
}
} catch (error1) {
error3 = error1;
return this._onFailure(error3, eventInfo, clearGlobalState, run9, free);
return this._onFailure(error3, eventInfo, clearGlobalState, run10, free);
}
}
doExpire(clearGlobalState, run9, free) {
doExpire(clearGlobalState, run10, free) {
var error3, eventInfo;
if (this._states.jobStatus(this.options.id === "RUNNING")) {
this._states.next(this.options.id);
@@ -28847,9 +28847,9 @@ var require_light = __commonJS({
this._assertStatus("EXECUTING");
eventInfo = { args: this.args, options: this.options, retryCount: this.retryCount };
error3 = new BottleneckError$1(`This job timed out after ${this.options.expiration} ms.`);
return this._onFailure(error3, eventInfo, clearGlobalState, run9, free);
return this._onFailure(error3, eventInfo, clearGlobalState, run10, free);
}
async _onFailure(error3, eventInfo, clearGlobalState, run9, free) {
async _onFailure(error3, eventInfo, clearGlobalState, run10, free) {
var retry2, retryAfter;
if (clearGlobalState()) {
retry2 = await this.Events.trigger("failed", error3, eventInfo);
@@ -28857,7 +28857,7 @@ var require_light = __commonJS({
retryAfter = ~~retry2;
this.Events.trigger("retry", `Retrying ${this.options.id} after ${retryAfter} ms`, eventInfo);
this.retryCount++;
return run9(retryAfter);
return run10(retryAfter);
} else {
this.doDone(eventInfo);
await free(this.options, eventInfo);
@@ -29495,17 +29495,17 @@ var require_light = __commonJS({
}
}
_run(index2, job, wait) {
var clearGlobalState, free, run9;
var clearGlobalState, free, run10;
job.doRun();
clearGlobalState = this._clearGlobalState.bind(this, index2);
run9 = this._run.bind(this, index2, job);
run10 = this._run.bind(this, index2, job);
free = this._free.bind(this, index2, job);
return this._scheduled[index2] = {
timeout: setTimeout(() => {
return job.doExecute(this._limiter, clearGlobalState, run9, free);
return job.doExecute(this._limiter, clearGlobalState, run10, free);
}, wait),
expiration: job.options.expiration != null ? setTimeout(function() {
return job.doExpire(clearGlobalState, run9, free);
return job.doExpire(clearGlobalState, run10, free);
}, wait + job.options.expiration) : void 0,
job
};
@@ -51046,14 +51046,14 @@ var require_crc64 = __commonJS({
missingLibrarySymbols.forEach(missingLibrarySymbol);
var calledRun;
dependenciesFulfilled = function runCaller() {
if (!calledRun) run9();
if (!calledRun) run10();
if (!calledRun) dependenciesFulfilled = runCaller;
};
function stackCheckInit() {
_emscripten_stack_init();
writeStackCookie();
}
function run9(args) {
function run10(args) {
args = args || arguments_;
if (runDependencies > 0) {
return;
@@ -51111,7 +51111,7 @@ var require_crc64 = __commonJS({
Module["preInit"].pop()();
}
}
run9();
run10();
function WrapperObject() {
}
WrapperObject.prototype = Object.create(WrapperObject.prototype);
@@ -114994,8 +114994,8 @@ var require_async = __commonJS({
return callback(null, results);
}
while (readyTasks.length && runningTasks < concurrency) {
var run9 = readyTasks.shift();
run9();
var run10 = readyTasks.shift();
run10();
}
}
function addListener(taskName, fn) {
@@ -179643,9 +179643,9 @@ async function addFingerprints(sarifLog, sourceRoot, logger2) {
`Adding fingerprints to SARIF file. See ${"https://docs.github.com/en/code-security/reference/code-scanning/sarif-support-for-code-scanning#data-for-preventing-duplicated-alerts" /* TRACK_CODE_SCANNING_ALERTS_ACROSS_RUNS */} for more information.`
);
const callbacksByFile = {};
for (const run9 of sarifLog.runs || []) {
const artifacts = run9.artifacts || [];
for (const result of run9.results || []) {
for (const run10 of sarifLog.runs || []) {
const artifacts = run10.artifacts || [];
for (const result of run10.results || []) {
const primaryLocation = (result.locations || [])[0];
if (!primaryLocation?.physicalLocation?.artifactLocation) {
logger2.debug(
@@ -179920,8 +179920,8 @@ var InvalidSarifUploadError = class extends Error {
};
function getToolNames(sarifFile) {
const toolNames = {};
for (const run9 of sarifFile.runs || []) {
const tool = run9.tool || {};
for (const run10 of sarifFile.runs || []) {
const tool = run10.tool || {};
const driver = tool.driver || {};
if (typeof driver.name === "string" && driver.name.length > 0) {
toolNames[driver.name] = true;
@@ -179961,17 +179961,17 @@ function combineSarifFiles(sarifFiles, logger2) {
}
function areAllRunsProducedByCodeQL(sarifLogs) {
return sarifLogs.every((sarifLog) => {
return sarifLog.runs?.every((run9) => run9.tool?.driver?.name === "CodeQL");
return sarifLog.runs?.every((run10) => run10.tool?.driver?.name === "CodeQL");
});
}
function createRunKey(run9) {
function createRunKey(run10) {
return {
name: run9.tool?.driver?.name,
fullName: run9.tool?.driver?.fullName,
version: run9.tool?.driver?.version,
semanticVersion: run9.tool?.driver?.semanticVersion,
guid: run9.tool?.driver?.guid,
automationId: run9.automationDetails?.id
name: run10.tool?.driver?.name,
fullName: run10.tool?.driver?.fullName,
version: run10.tool?.driver?.version,
semanticVersion: run10.tool?.driver?.semanticVersion,
guid: run10.tool?.driver?.guid,
automationId: run10.automationDetails?.id
};
}
function areAllRunsUnique(sarifLogs) {
@@ -179980,8 +179980,8 @@ function areAllRunsUnique(sarifLogs) {
if (sarifLog.runs === void 0) {
continue;
}
for (const run9 of sarifLog.runs) {
const key = JSON.stringify(createRunKey(run9));
for (const run10 of sarifLog.runs) {
const key = JSON.stringify(createRunKey(run10));
if (keys.has(key)) {
return false;
}
@@ -180084,9 +180084,9 @@ async function combineSarifFilesUsingCLI(sarifFiles, gitHubVersion, features, lo
function populateRunAutomationDetails(sarifFile, category, analysis_key, environment) {
const automationID = getAutomationID2(category, analysis_key, environment);
if (automationID !== void 0) {
for (const run9 of sarifFile.runs || []) {
if (run9.automationDetails === void 0) {
run9.automationDetails = {
for (const run10 of sarifFile.runs || []) {
if (run10.automationDetails === void 0) {
run10.automationDetails = {
id: automationID
};
}
@@ -180233,13 +180233,13 @@ function countResultsInSarif(sarifLog) {
if (!Array.isArray(parsedSarif.runs)) {
throw new InvalidSarifUploadError("Invalid SARIF. Missing 'runs' array.");
}
for (const run9 of parsedSarif.runs) {
if (!Array.isArray(run9.results)) {
for (const run10 of parsedSarif.runs) {
if (!Array.isArray(run10.results)) {
throw new InvalidSarifUploadError(
"Invalid SARIF. Missing 'results' array in run."
);
}
numResults += run9.results.length;
numResults += run10.results.length;
}
return numResults;
}
@@ -180566,9 +180566,9 @@ function handleProcessingResultForUnsuccessfulExecution(response, status, logger
}
function validateUniqueCategory(sarifLog, sentinelPrefix) {
const categories = {};
for (const run9 of sarifLog.runs || []) {
const id = run9?.automationDetails?.id;
const tool = run9.tool?.driver?.name;
for (const run10 of sarifLog.runs || []) {
const id = run10?.automationDetails?.id;
const tool = run10.tool?.driver?.name;
const category = `${sanitize(id)}_${sanitize(tool)}`;
categories[category] = { id, tool };
}
@@ -180593,9 +180593,9 @@ function filterAlertsByDiffRange(logger2, sarifLog) {
if (sarifLog.runs === void 0) {
return sarifLog;
}
for (const run9 of sarifLog.runs) {
if (run9.results) {
run9.results = run9.results.filter((result) => {
for (const run10 of sarifLog.runs) {
if (run10.results) {
run10.results = run10.results.filter((result) => {
const locations = [
...(result.locations || []).map((loc) => loc.physicalLocation),
...(result.relatedLocations || []).map((loc) => loc.physicalLocation)
@@ -188394,8 +188394,8 @@ async function startProxy(binPath, config, logFilePath, logger2) {
// src/start-proxy-action-post.ts
var core26 = __toESM(require_core());
async function runWrapper9() {
const logger2 = getActionsLogger();
async function run8(action) {
const logger2 = action.logger;
try {
restoreInputs(logger2);
const pid = core26.getState("proxy-process-pid");
@@ -188427,6 +188427,14 @@ async function runWrapper9() {
);
}
}
var startProxyPostAction = {
name: "start-proxy-post" /* StartProxyPost */,
run: run8,
transformTelemetryError: getSafeErrorMessage
};
async function runWrapper9() {
await runInActions(startProxyPostAction);
}
// src/upload-sarif-action.ts
var core27 = __toESM(require_core());
@@ -188447,7 +188455,7 @@ async function sendSuccessStatusReport2(startedAt, uploadStats, logger2) {
await sendStatusReport(statusReport);
}
}
async function run8({ startedAt, logger: logger2 }) {
async function run9({ startedAt, logger: logger2 }) {
try {
initializeEnvironment(getActionVersion());
const gitHubVersion = await getGitHubVersion();
@@ -188532,7 +188540,7 @@ async function run8({ startedAt, logger: logger2 }) {
}
var uploadSarif = {
name: "upload-sarif" /* UploadSarif */,
run: run8
run: run9
};
async function runWrapper10() {
await runInActions(uploadSarif);

View File

@@ -5,18 +5,28 @@
*/
import * as core from "@actions/core";
import {
ActionName,
runInActions,
type Action,
type ActionState,
} from "./action-common";
import * as actionsUtil from "./actions-util";
import { getGitHubVersion } from "./api-client";
import * as configUtils from "./config-utils";
import { uploadArtifacts } from "./debug-artifacts";
import { getActionsLogger } from "./logging";
import { getSafeErrorMessage } from "./start-proxy/status-report";
import { checkGitHubVersionInRange, getErrorMessage } from "./util";
export async function runWrapper() {
/**
* 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"]>) {
// To capture errors appropriately, keep as much code within the try-catch as
// possible, and only use safe functions outside.
const logger = getActionsLogger();
const logger = action.logger;
try {
// Restore inputs from `start-proxy` Action.
@@ -56,3 +66,15 @@ export async function runWrapper() {
);
}
}
/** Defines the `start-proxy` post-action. */
const startProxyPostAction: Action = {
name: ActionName.StartProxyPost,
run,
transformTelemetryError: getSafeErrorMessage,
};
/** The main entry point for the `start-proxy` post-action. */
export async function runWrapper() {
await runInActions(startProxyPostAction);
}