Use delay instead of wait
Need to also change the signature of delay to allow this to happen.
This commit is contained in:
parent
df9b50ee5f
commit
4e80a80354
6 changed files with 10 additions and 16 deletions
2
lib/init-action-post-helper.js
generated
2
lib/init-action-post-helper.js
generated
|
|
@ -139,7 +139,7 @@ async function removeUploadedSarif(uploadFailedSarifResult, logger) {
|
||||||
try {
|
try {
|
||||||
const repositoryNwo = (0, repository_1.parseRepositoryNwo)((0, util_1.getRequiredEnvParam)("GITHUB_REPOSITORY"));
|
const repositoryNwo = (0, repository_1.parseRepositoryNwo)((0, util_1.getRequiredEnvParam)("GITHUB_REPOSITORY"));
|
||||||
// Wait to make sure the analysis is ready for download before requesting it.
|
// Wait to make sure the analysis is ready for download before requesting it.
|
||||||
await (0, util_1.wait)(5000);
|
await (0, util_1.delay)(5000);
|
||||||
// Get the analysis associated with the uploaded sarif
|
// Get the analysis associated with the uploaded sarif
|
||||||
const analysisInfo = await client.request("GET /repos/:owner/:repo/code-scanning/analyses?sarif_id=:sarif_id", {
|
const analysisInfo = await client.request("GET /repos/:owner/:repo/code-scanning/analyses?sarif_id=:sarif_id", {
|
||||||
owner: repositoryNwo.owner,
|
owner: repositoryNwo.owner,
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
9
lib/util.js
generated
9
lib/util.js
generated
|
|
@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.checkDiskUsage = exports.prettyPrintPack = exports.wait = exports.getErrorMessage = exports.wrapError = exports.fixInvalidNotificationsInFile = exports.fixInvalidNotifications = exports.parseMatrixInput = exports.isHostedRunner = exports.checkForTimeout = exports.withTimeout = exports.tryGetFolderBytes = exports.listFolder = exports.doesDirectoryExist = exports.isInTestMode = exports.supportExpectDiscardedCache = exports.isGoodVersion = exports.delay = exports.bundleDb = exports.codeQlVersionAbove = exports.getCachedCodeQlVersion = exports.cacheCodeQlVersion = exports.isHTTPError = exports.UserError = exports.HTTPError = exports.getRequiredEnvParam = exports.initializeEnvironment = exports.assertNever = exports.apiVersionInRange = exports.DisallowedAPIVersionReason = exports.checkGitHubVersionInRange = exports.GitHubVariant = exports.parseGitHubUrl = exports.getCodeQLDatabasePath = exports.getThreadsFlag = exports.getThreadsFlagValue = exports.getAddSnippetsFlag = exports.getMemoryFlag = exports.getMemoryFlagValue = exports.getMemoryFlagValueForPlatform = exports.withTmpDir = exports.getToolNames = exports.getExtraOptionsEnvParam = exports.DEFAULT_DEBUG_DATABASE_NAME = exports.DEFAULT_DEBUG_ARTIFACT_NAME = exports.GITHUB_DOTCOM_URL = void 0;
|
exports.checkDiskUsage = exports.prettyPrintPack = exports.getErrorMessage = exports.wrapError = exports.fixInvalidNotificationsInFile = exports.fixInvalidNotifications = exports.parseMatrixInput = exports.isHostedRunner = exports.checkForTimeout = exports.withTimeout = exports.tryGetFolderBytes = exports.listFolder = exports.doesDirectoryExist = exports.isInTestMode = exports.supportExpectDiscardedCache = exports.isGoodVersion = exports.delay = exports.bundleDb = exports.codeQlVersionAbove = exports.getCachedCodeQlVersion = exports.cacheCodeQlVersion = exports.isHTTPError = exports.UserError = exports.HTTPError = exports.getRequiredEnvParam = exports.initializeEnvironment = exports.assertNever = exports.apiVersionInRange = exports.DisallowedAPIVersionReason = exports.checkGitHubVersionInRange = exports.GitHubVariant = exports.parseGitHubUrl = exports.getCodeQLDatabasePath = exports.getThreadsFlag = exports.getThreadsFlagValue = exports.getAddSnippetsFlag = exports.getMemoryFlag = exports.getMemoryFlagValue = exports.getMemoryFlagValueForPlatform = exports.withTmpDir = exports.getToolNames = exports.getExtraOptionsEnvParam = exports.DEFAULT_DEBUG_DATABASE_NAME = exports.DEFAULT_DEBUG_ARTIFACT_NAME = exports.GITHUB_DOTCOM_URL = void 0;
|
||||||
const fs = __importStar(require("fs"));
|
const fs = __importStar(require("fs"));
|
||||||
const os = __importStar(require("os"));
|
const os = __importStar(require("os"));
|
||||||
const path = __importStar(require("path"));
|
const path = __importStar(require("path"));
|
||||||
|
|
@ -465,7 +465,8 @@ exports.bundleDb = bundleDb;
|
||||||
* @param opts options
|
* @param opts options
|
||||||
* @param opts.allowProcessExit if true, the timer will not prevent the process from exiting
|
* @param opts.allowProcessExit if true, the timer will not prevent the process from exiting
|
||||||
*/
|
*/
|
||||||
async function delay(milliseconds, { allowProcessExit }) {
|
async function delay(milliseconds, opts) {
|
||||||
|
const { allowProcessExit } = opts || {};
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
const timer = setTimeout(resolve, milliseconds);
|
const timer = setTimeout(resolve, milliseconds);
|
||||||
if (allowProcessExit) {
|
if (allowProcessExit) {
|
||||||
|
|
@ -723,10 +724,6 @@ function getErrorMessage(error) {
|
||||||
return error instanceof Error ? error.toString() : String(error);
|
return error instanceof Error ? error.toString() : String(error);
|
||||||
}
|
}
|
||||||
exports.getErrorMessage = getErrorMessage;
|
exports.getErrorMessage = getErrorMessage;
|
||||||
async function wait(ms) {
|
|
||||||
await new Promise((resolve) => setTimeout(resolve, ms));
|
|
||||||
}
|
|
||||||
exports.wait = wait;
|
|
||||||
function prettyPrintPack(pack) {
|
function prettyPrintPack(pack) {
|
||||||
return `${pack.name}${pack.version ? `@${pack.version}` : ""}${pack.path ? `:${pack.path}` : ""}`;
|
return `${pack.name}${pack.version ? `@${pack.version}` : ""}${pack.path ? `:${pack.path}` : ""}`;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -9,11 +9,11 @@ import { RepositoryNwo, parseRepositoryNwo } from "./repository";
|
||||||
import * as uploadLib from "./upload-lib";
|
import * as uploadLib from "./upload-lib";
|
||||||
import {
|
import {
|
||||||
codeQlVersionAbove,
|
codeQlVersionAbove,
|
||||||
|
delay,
|
||||||
getErrorMessage,
|
getErrorMessage,
|
||||||
getRequiredEnvParam,
|
getRequiredEnvParam,
|
||||||
isInTestMode,
|
isInTestMode,
|
||||||
parseMatrixInput,
|
parseMatrixInput,
|
||||||
wait,
|
|
||||||
wrapError,
|
wrapError,
|
||||||
} from "./util";
|
} from "./util";
|
||||||
import {
|
import {
|
||||||
|
|
@ -222,7 +222,7 @@ async function removeUploadedSarif(
|
||||||
);
|
);
|
||||||
|
|
||||||
// Wait to make sure the analysis is ready for download before requesting it.
|
// Wait to make sure the analysis is ready for download before requesting it.
|
||||||
await wait(5000);
|
await delay(5000);
|
||||||
|
|
||||||
// Get the analysis associated with the uploaded sarif
|
// Get the analysis associated with the uploaded sarif
|
||||||
const analysisInfo = await client.request(
|
const analysisInfo = await client.request(
|
||||||
|
|
|
||||||
|
|
@ -624,8 +624,9 @@ export async function bundleDb(
|
||||||
*/
|
*/
|
||||||
export async function delay(
|
export async function delay(
|
||||||
milliseconds: number,
|
milliseconds: number,
|
||||||
{ allowProcessExit }: { allowProcessExit: boolean },
|
opts?: { allowProcessExit: boolean },
|
||||||
) {
|
) {
|
||||||
|
const { allowProcessExit } = opts || {};
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
const timer = setTimeout(resolve, milliseconds);
|
const timer = setTimeout(resolve, milliseconds);
|
||||||
if (allowProcessExit) {
|
if (allowProcessExit) {
|
||||||
|
|
@ -913,10 +914,6 @@ export function getErrorMessage(error: unknown): string {
|
||||||
return error instanceof Error ? error.toString() : String(error);
|
return error instanceof Error ? error.toString() : String(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function wait(ms: number) {
|
|
||||||
await new Promise((resolve) => setTimeout(resolve, ms));
|
|
||||||
}
|
|
||||||
|
|
||||||
export function prettyPrintPack(pack: Pack) {
|
export function prettyPrintPack(pack: Pack) {
|
||||||
return `${pack.name}${pack.version ? `@${pack.version}` : ""}${
|
return `${pack.name}${pack.version ? `@${pack.version}` : ""}${
|
||||||
pack.path ? `:${pack.path}` : ""
|
pack.path ? `:${pack.path}` : ""
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue