mirror of
https://github.com/github/codeql-action.git
synced 2026-06-04 04:44:50 +00:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b37e12b418 | |||
| d40e417f3c | |||
| dfc14113e3 |
Generated
+16
-12
@@ -157473,22 +157473,20 @@ function dumpSarifFile(sarifPayload, outputDir, logger, uploadTarget) {
|
|||||||
logger.info(`Writing processed SARIF file to ${outputFile}`);
|
logger.info(`Writing processed SARIF file to ${outputFile}`);
|
||||||
fs21.writeFileSync(outputFile, sarifPayload);
|
fs21.writeFileSync(outputFile, sarifPayload);
|
||||||
}
|
}
|
||||||
var STATUS_CHECK_FREQUENCY_MILLISECONDS = 5 * 1e3;
|
var STATUS_CHECK_INITIAL_BACKOFF_MILLISECONDS = 5 * 1e3;
|
||||||
var STATUS_CHECK_TIMEOUT_MILLISECONDS = 2 * 60 * 1e3;
|
var STATUS_CHECK_BACKOFF_MULTIPLIER = 2;
|
||||||
|
var STATUS_CHECK_MAX_TRIES = 5;
|
||||||
async function waitForProcessing(repositoryNwo, sarifID, logger, options = {
|
async function waitForProcessing(repositoryNwo, sarifID, logger, options = {
|
||||||
isUnsuccessfulExecution: false
|
isUnsuccessfulExecution: false
|
||||||
}) {
|
}) {
|
||||||
logger.startGroup("Waiting for processing to finish");
|
logger.startGroup("Waiting for processing to finish");
|
||||||
try {
|
try {
|
||||||
const client = getApiClient();
|
const client = getApiClient();
|
||||||
const statusCheckingStarted = Date.now();
|
let statusCheckBackoff = STATUS_CHECK_INITIAL_BACKOFF_MILLISECONDS;
|
||||||
while (true) {
|
if (!isInTestMode()) {
|
||||||
if (Date.now() > statusCheckingStarted + STATUS_CHECK_TIMEOUT_MILLISECONDS) {
|
await delay(statusCheckBackoff, { allowProcessExit: false });
|
||||||
logger.warning(
|
|
||||||
"Timed out waiting for analysis to finish processing. Continuing."
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
for (let statusCheckCount = 1; statusCheckCount <= STATUS_CHECK_MAX_TRIES; statusCheckCount++) {
|
||||||
let response = void 0;
|
let response = void 0;
|
||||||
try {
|
try {
|
||||||
response = await client.request(
|
response = await client.request(
|
||||||
@@ -157526,9 +157524,15 @@ ${response.data.errors}`;
|
|||||||
} else {
|
} else {
|
||||||
assertNever(status);
|
assertNever(status);
|
||||||
}
|
}
|
||||||
await delay(STATUS_CHECK_FREQUENCY_MILLISECONDS, {
|
if (statusCheckCount === STATUS_CHECK_MAX_TRIES) {
|
||||||
allowProcessExit: false
|
logger.warning(
|
||||||
});
|
"Timed out waiting for analysis to finish processing. Continuing."
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
statusCheckBackoff *= STATUS_CHECK_BACKOFF_MULTIPLIER;
|
||||||
|
await delay(statusCheckBackoff, { allowProcessExit: false });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
logger.endGroup();
|
logger.endGroup();
|
||||||
|
|||||||
+27
-18
@@ -36,6 +36,7 @@ import {
|
|||||||
getRequiredEnvParam,
|
getRequiredEnvParam,
|
||||||
GitHubVariant,
|
GitHubVariant,
|
||||||
GitHubVersion,
|
GitHubVersion,
|
||||||
|
isInTestMode,
|
||||||
satisfiesGHESVersion,
|
satisfiesGHESVersion,
|
||||||
} from "./util";
|
} from "./util";
|
||||||
|
|
||||||
@@ -829,8 +830,10 @@ function dumpSarifFile(
|
|||||||
fs.writeFileSync(outputFile, sarifPayload);
|
fs.writeFileSync(outputFile, sarifPayload);
|
||||||
}
|
}
|
||||||
|
|
||||||
const STATUS_CHECK_FREQUENCY_MILLISECONDS = 5 * 1000;
|
// Should lead to status checks after 5s, 15s, 35s, 75s, and 155s.
|
||||||
const STATUS_CHECK_TIMEOUT_MILLISECONDS = 2 * 60 * 1000;
|
const STATUS_CHECK_INITIAL_BACKOFF_MILLISECONDS = 5 * 1000;
|
||||||
|
const STATUS_CHECK_BACKOFF_MULTIPLIER = 2;
|
||||||
|
const STATUS_CHECK_MAX_TRIES = 5;
|
||||||
|
|
||||||
type ProcessingStatus = "pending" | "complete" | "failed";
|
type ProcessingStatus = "pending" | "complete" | "failed";
|
||||||
|
|
||||||
@@ -854,20 +857,17 @@ export async function waitForProcessing(
|
|||||||
try {
|
try {
|
||||||
const client = api.getApiClient();
|
const client = api.getApiClient();
|
||||||
|
|
||||||
const statusCheckingStarted = Date.now();
|
// Do an initial wait because processing will always take a minimum of 2-3 seconds
|
||||||
while (true) {
|
let statusCheckBackoff = STATUS_CHECK_INITIAL_BACKOFF_MILLISECONDS;
|
||||||
if (
|
if (!isInTestMode()) {
|
||||||
Date.now() >
|
await util.delay(statusCheckBackoff, { allowProcessExit: false });
|
||||||
statusCheckingStarted + STATUS_CHECK_TIMEOUT_MILLISECONDS
|
|
||||||
) {
|
|
||||||
// If the analysis hasn't finished processing in the allotted time, we continue anyway rather than failing.
|
|
||||||
// It's possible the analysis will eventually finish processing, but it's not worth spending more
|
|
||||||
// Actions time waiting.
|
|
||||||
logger.warning(
|
|
||||||
"Timed out waiting for analysis to finish processing. Continuing.",
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (
|
||||||
|
let statusCheckCount = 1;
|
||||||
|
statusCheckCount <= STATUS_CHECK_MAX_TRIES;
|
||||||
|
statusCheckCount++
|
||||||
|
) {
|
||||||
let response: OctokitResponse<any> | undefined = undefined;
|
let response: OctokitResponse<any> | undefined = undefined;
|
||||||
try {
|
try {
|
||||||
response = await client.request(
|
response = await client.request(
|
||||||
@@ -912,9 +912,18 @@ export async function waitForProcessing(
|
|||||||
util.assertNever(status);
|
util.assertNever(status);
|
||||||
}
|
}
|
||||||
|
|
||||||
await util.delay(STATUS_CHECK_FREQUENCY_MILLISECONDS, {
|
if (statusCheckCount === STATUS_CHECK_MAX_TRIES) {
|
||||||
allowProcessExit: false,
|
// If the analysis hasn't finished processing in the allotted time, we continue anyway rather than failing.
|
||||||
});
|
// It's possible the analysis will eventually finish processing, but it's not worth spending more
|
||||||
|
// Actions time waiting.
|
||||||
|
logger.warning(
|
||||||
|
"Timed out waiting for analysis to finish processing. Continuing.",
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
statusCheckBackoff *= STATUS_CHECK_BACKOFF_MULTIPLIER;
|
||||||
|
await util.delay(statusCheckBackoff, { allowProcessExit: false });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
logger.endGroup();
|
logger.endGroup();
|
||||||
|
|||||||
Reference in New Issue
Block a user