From dd63ff388058780a3b1db59592a557a506dfd3a5 Mon Sep 17 00:00:00 2001 From: Michael J Mulligan Date: Tue, 6 Apr 2021 18:03:47 +0100 Subject: [PATCH] Reserve using Search Token for multi-case. --- dist/post_run/index.js | 12 +++++------- dist/run/index.js | 12 +++++------- src/run.ts | 11 ++++------- 3 files changed, 14 insertions(+), 21 deletions(-) diff --git a/dist/post_run/index.js b/dist/post_run/index.js index 175817e..4109431 100644 --- a/dist/post_run/index.js +++ b/dist/post_run/index.js @@ -6825,13 +6825,12 @@ const logLintIssues = (issues) => { }); }; function resolveCheckRunId() { - var _a, _b, _c; + var _a, _b; return __awaiter(this, void 0, void 0, function* () { let checkRunId = -1; if (process.env.GITHUB_ACTIONS === `true`) { try { - const searchToken = uuid_1.v4(); - core.info(`::warning::Resolving GitHub CheckRunID (${searchToken})`); + core.info(`Attempting to resolve GitHub Check Run`); const ctx = github.context; const ref = (_a = ctx.payload.after) !== null && _a !== void 0 ? _a : ctx.sha; const octokit = github.getOctokit(core.getInput(`github-token`, { required: true })); @@ -6846,9 +6845,8 @@ function resolveCheckRunId() { checkRuns = (_b = checkRuns.filter((run) => run.name.includes(ctx.job))) !== null && _b !== void 0 ? _b : checkRuns; } if (checkRuns.length > 1) { - checkRuns = (_c = checkRuns.filter((run) => run.output.annotations_count > 0)) !== null && _c !== void 0 ? _c : checkRuns; - } - if (checkRuns.length > 1) { + const searchToken = uuid_1.v4(); + core.info(`::warning::[ignore] Resolving GitHub Check Run with Search Token: ${searchToken}`); for (const run of checkRuns) { try { if ((yield octokit.checks.listAnnotations(Object.assign(Object.assign({}, ctx.repo), { check_run_id: run.id }))).data.findIndex((annotation) => annotation.message.includes(searchToken)) !== -1) { @@ -6863,7 +6861,7 @@ function resolveCheckRunId() { } else if (checkRuns[0]) { checkRunId = checkRuns[0].id; - core.info(`Current Check Run is: ${checkRunId}`); + core.info(`Current Check Run: ${checkRunId}`); } else { throw `Unable to resolve GitHub Check Run`; diff --git a/dist/run/index.js b/dist/run/index.js index 54b58fc..461a8d9 100644 --- a/dist/run/index.js +++ b/dist/run/index.js @@ -6835,13 +6835,12 @@ const logLintIssues = (issues) => { }); }; function resolveCheckRunId() { - var _a, _b, _c; + var _a, _b; return __awaiter(this, void 0, void 0, function* () { let checkRunId = -1; if (process.env.GITHUB_ACTIONS === `true`) { try { - const searchToken = uuid_1.v4(); - core.info(`::warning::Resolving GitHub CheckRunID (${searchToken})`); + core.info(`Attempting to resolve GitHub Check Run`); const ctx = github.context; const ref = (_a = ctx.payload.after) !== null && _a !== void 0 ? _a : ctx.sha; const octokit = github.getOctokit(core.getInput(`github-token`, { required: true })); @@ -6856,9 +6855,8 @@ function resolveCheckRunId() { checkRuns = (_b = checkRuns.filter((run) => run.name.includes(ctx.job))) !== null && _b !== void 0 ? _b : checkRuns; } if (checkRuns.length > 1) { - checkRuns = (_c = checkRuns.filter((run) => run.output.annotations_count > 0)) !== null && _c !== void 0 ? _c : checkRuns; - } - if (checkRuns.length > 1) { + const searchToken = uuid_1.v4(); + core.info(`::warning::[ignore] Resolving GitHub Check Run with Search Token: ${searchToken}`); for (const run of checkRuns) { try { if ((yield octokit.checks.listAnnotations(Object.assign(Object.assign({}, ctx.repo), { check_run_id: run.id }))).data.findIndex((annotation) => annotation.message.includes(searchToken)) !== -1) { @@ -6873,7 +6871,7 @@ function resolveCheckRunId() { } else if (checkRuns[0]) { checkRunId = checkRuns[0].id; - core.info(`Current Check Run is: ${checkRunId}`); + core.info(`Current Check Run: ${checkRunId}`); } else { throw `Unable to resolve GitHub Check Run`; diff --git a/src/run.ts b/src/run.ts index 78d0875..7fa065c 100644 --- a/src/run.ts +++ b/src/run.ts @@ -260,9 +260,7 @@ async function resolveCheckRunId(): Promise { if (process.env.GITHUB_ACTIONS === `true`) { try { - const searchToken = uuidv4() - core.info(`::warning::Resolving GitHub CheckRunID (${searchToken})`) - + core.info(`Attempting to resolve GitHub Check Run`) const ctx = github.context const ref = ctx.payload.after ?? ctx.sha @@ -284,9 +282,8 @@ async function resolveCheckRunId(): Promise { checkRuns = checkRuns.filter((run) => run.name.includes(ctx.job)) ?? checkRuns } if (checkRuns.length > 1) { - checkRuns = checkRuns.filter((run) => run.output.annotations_count > 0) ?? checkRuns - } - if (checkRuns.length > 1) { + const searchToken = uuidv4() + core.info(`::warning::[ignore] Resolving GitHub Check Run with Search Token: ${searchToken}`) for (const run of checkRuns) { try { if ( @@ -306,7 +303,7 @@ async function resolveCheckRunId(): Promise { } } else if (checkRuns[0]) { checkRunId = checkRuns[0].id - core.info(`Current Check Run is: ${checkRunId}`) + core.info(`Current Check Run: ${checkRunId}`) } else { throw `Unable to resolve GitHub Check Run` }