From f634c213066ac2315009b2263d4b7e493844f963 Mon Sep 17 00:00:00 2001 From: Bugale Bugalit Date: Sun, 26 May 2024 15:09:15 +0300 Subject: [PATCH] Revert "feat: use external_id instead of output text" This reverts commit 063833c490bf4cdfb9ba76a191798305a4660c43. --- dist/flag/index.js | 4 ++-- dist/index.js | 13 ++++++------- dist/rerun/index.js | 2 +- src/flag.ts | 4 ++-- src/index.ts | 13 ++++++------- src/rerun.ts | 2 +- 6 files changed, 18 insertions(+), 20 deletions(-) diff --git a/dist/flag/index.js b/dist/flag/index.js index 1835bd2..c38c20a 100644 --- a/dist/flag/index.js +++ b/dist/flag/index.js @@ -30807,7 +30807,7 @@ exports.run = void 0; const github_1 = __nccwpck_require__(5438); const core_1 = __nccwpck_require__(2186); async function run() { - /* eslint camelcase: ["error", {allow: ['^check_run_id$', '^external_id$']}] */ + /* eslint camelcase: ["error", {allow: ['^check_run_id$']}] */ try { const githubToken = (0, core_1.getInput)('githubToken'); const ref = (0, core_1.getInput)('ref'); @@ -30824,7 +30824,7 @@ async function run() { await octokit.rest.checks.update({ ...github_1.context.repo, check_run_id: selfChecks[0].id, - external_id: `${selfChecks[0].external_id ?? ''}` + output: { summary: selfChecks[0].output.summary ?? '', title: selfChecks[0].output.title ?? '', text: `` } }); } catch (error) { diff --git a/dist/index.js b/dist/index.js index b9fa220..065c0c1 100644 --- a/dist/index.js +++ b/dist/index.js @@ -30807,15 +30807,14 @@ exports.run = void 0; const github_1 = __nccwpck_require__(5438); const core_1 = __nccwpck_require__(2186); async function setStatus(octokit, status, jobIdentifier, selfId) { - /* eslint camelcase: ["error", {allow: ['^check_run_id$', '^external_id$']}] */ + /* eslint camelcase: ["error", {allow: ['^check_run_id$']}] */ (0, core_1.info)(status); if (selfId != null) { try { await octokit.rest.checks.update({ ...github_1.context.repo, check_run_id: selfId, - external_id: ``, - output: { summary: '', title: status } + output: { summary: '', title: status, text: `` } }); } catch (error) { @@ -30825,8 +30824,8 @@ async function setStatus(octokit, status, jobIdentifier, selfId) { } } } -function isFlagged(externalId, flags) { - return flags.some((flag) => externalId.includes(``)); +function isFlagged(text, flags) { + return flags.some((flag) => text.includes(``)); } async function run() { try { @@ -30869,7 +30868,7 @@ async function run() { !refChecks.check_runs.some((otherCheck) => otherCheck.name === check.name && otherCheck.id > check.id)); (0, core_1.debug)(`requiredChecks by ${JSON.stringify(checkRegexes)}-${JSON.stringify(excludedCheckRegexes)}: ${JSON.stringify(requiredChecks)}`); (0, core_1.setOutput)('requiredChecks', JSON.stringify(requiredChecks)); - const incompleteChecks = requiredChecks.filter((check) => check.status !== 'completed' && !isFlagged(check.external_id ?? '', flags)); + const incompleteChecks = requiredChecks.filter((check) => check.status !== 'completed' && !isFlagged(check.output.text ?? '', flags)); (0, core_1.debug)(`incompleteChecks: ${JSON.stringify(incompleteChecks)}`); if (incompleteChecks.length === 0) { if (noNewJobsCounter < 1 && (requiredChecksMaxCount !== 0 || requiredChecks.length >= requiredChecksMaxCount)) { @@ -30878,7 +30877,7 @@ async function run() { await new Promise((resolve) => setTimeout(resolve, delay * 1000)); // Wait for new jobs to start continue; } - const unsuccessfulChecks = requiredChecks.filter((check) => !requiredStatus.includes(check.conclusion ?? 'none') && !isFlagged(check.external_id ?? '', flags)); + const unsuccessfulChecks = requiredChecks.filter((check) => !requiredStatus.includes(check.conclusion ?? 'none') && !isFlagged(check.output.text ?? '', flags)); (0, core_1.debug)(`unsuccessfulChecks: ${JSON.stringify(unsuccessfulChecks)}`); (0, core_1.setOutput)('unsuccessfulChecks', JSON.stringify(unsuccessfulChecks)); if (unsuccessfulChecks.length === 0) { diff --git a/dist/rerun/index.js b/dist/rerun/index.js index 8f0965f..5cfe9bc 100644 --- a/dist/rerun/index.js +++ b/dist/rerun/index.js @@ -30816,7 +30816,7 @@ async function run() { const { data: refChecks } = await octokit.rest.checks.listForRef({ ...github_1.context.repo, ref }); (0, core_1.debug)(`refChecks for ${ref}: ${JSON.stringify(refChecks)}`); for (const check of refChecks.check_runs) { - const runId = check.external_id?.match(new RegExp(String.raw `^$`))?.[1]; + const runId = check.output.text?.match(new RegExp(String.raw `^$`))?.[1]; if (runId !== undefined) { (0, core_1.debug)(`runId: ${runId}`); const { data: jobs } = await octokit.rest.actions.listJobsForWorkflowRun({ ...github_1.context.repo, run_id: parseInt(runId, 10) }); diff --git a/src/flag.ts b/src/flag.ts index 2455c70..03f9565 100644 --- a/src/flag.ts +++ b/src/flag.ts @@ -2,7 +2,7 @@ import { context, getOctokit } from '@actions/github' import { getInput, debug, setFailed } from '@actions/core' export async function run(): Promise { - /* eslint camelcase: ["error", {allow: ['^check_run_id$', '^external_id$']}] */ + /* eslint camelcase: ["error", {allow: ['^check_run_id$']}] */ try { const githubToken = getInput('githubToken') const ref = getInput('ref') @@ -19,7 +19,7 @@ export async function run(): Promise { await octokit.rest.checks.update({ ...context.repo, check_run_id: selfChecks[0].id, - external_id: `${selfChecks[0].external_id ?? ''}` + output: { summary: selfChecks[0].output.summary ?? '', title: selfChecks[0].output.title ?? '', text: `` } }) } catch (error) { if (error instanceof Error) { diff --git a/src/index.ts b/src/index.ts index a8e3aef..ab06e80 100644 --- a/src/index.ts +++ b/src/index.ts @@ -2,15 +2,14 @@ import { context, getOctokit } from '@actions/github' import { getInput, getMultilineInput, debug, info, warning, setFailed, setOutput } from '@actions/core' async function setStatus(octokit: ReturnType, status: string, jobIdentifier: string, selfId?: number | null): Promise { - /* eslint camelcase: ["error", {allow: ['^check_run_id$', '^external_id$']}] */ + /* eslint camelcase: ["error", {allow: ['^check_run_id$']}] */ info(status) if (selfId != null) { try { await octokit.rest.checks.update({ ...context.repo, check_run_id: selfId, - external_id: ``, - output: { summary: '', title: status } + output: { summary: '', title: status, text: `` } }) } catch (error) { if (error instanceof Error) { @@ -20,8 +19,8 @@ async function setStatus(octokit: ReturnType, status: string, } } -function isFlagged(externalId: string, flags: string[]): boolean { - return flags.some((flag) => externalId.includes(``)) +function isFlagged(text: string, flags: string[]): boolean { + return flags.some((flag) => text.includes(``)) } export async function run(): Promise { @@ -72,7 +71,7 @@ export async function run(): Promise { debug(`requiredChecks by ${JSON.stringify(checkRegexes)}-${JSON.stringify(excludedCheckRegexes)}: ${JSON.stringify(requiredChecks)}`) setOutput('requiredChecks', JSON.stringify(requiredChecks)) - const incompleteChecks = requiredChecks.filter((check) => check.status !== 'completed' && !isFlagged(check.external_id ?? '', flags)) + const incompleteChecks = requiredChecks.filter((check) => check.status !== 'completed' && !isFlagged(check.output.text ?? '', flags)) debug(`incompleteChecks: ${JSON.stringify(incompleteChecks)}`) if (incompleteChecks.length === 0) { if (noNewJobsCounter < 1 && (requiredChecksMaxCount !== 0 || requiredChecks.length >= requiredChecksMaxCount)) { @@ -82,7 +81,7 @@ export async function run(): Promise { continue } const unsuccessfulChecks = requiredChecks.filter( - (check) => !requiredStatus.includes(check.conclusion ?? 'none') && !isFlagged(check.external_id ?? '', flags) + (check) => !requiredStatus.includes(check.conclusion ?? 'none') && !isFlagged(check.output.text ?? '', flags) ) debug(`unsuccessfulChecks: ${JSON.stringify(unsuccessfulChecks)}`) setOutput('unsuccessfulChecks', JSON.stringify(unsuccessfulChecks)) diff --git a/src/rerun.ts b/src/rerun.ts index bdfe055..3e4c676 100644 --- a/src/rerun.ts +++ b/src/rerun.ts @@ -11,7 +11,7 @@ export async function run(): Promise { const { data: refChecks } = await octokit.rest.checks.listForRef({ ...context.repo, ref }) debug(`refChecks for ${ref}: ${JSON.stringify(refChecks)}`) for (const check of refChecks.check_runs) { - const runId = check.external_id?.match(new RegExp(String.raw`^$`))?.[1] + const runId = check.output.text?.match(new RegExp(String.raw`^$`))?.[1] if (runId !== undefined) { debug(`runId: ${runId}`) const { data: jobs } = await octokit.rest.actions.listJobsForWorkflowRun({ ...context.repo, run_id: parseInt(runId, 10) })