Skip to content

Commit

Permalink
Revert "feat: use external_id instead of output text"
Browse files Browse the repository at this point in the history
This reverts commit 063833c.
  • Loading branch information
bugale committed May 26, 2024
1 parent 8079572 commit f634c21
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 20 deletions.
4 changes: 2 additions & 2 deletions dist/flag/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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 ?? ''}<!--BUGROUP_CHECKS_FLAG-${flag}-->`
output: { summary: selfChecks[0].output.summary ?? '', title: selfChecks[0].output.title ?? '', text: `<!--BUGROUP_CHECKS_FLAG-${flag}-->` }
});
}
catch (error) {
Expand Down
13 changes: 6 additions & 7 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: `<!--${jobIdentifier}-${github_1.context.runId}-->`,
output: { summary: '', title: status }
output: { summary: '', title: status, text: `<!--${jobIdentifier}-${github_1.context.runId}-->` }
});
}
catch (error) {
Expand All @@ -30825,8 +30824,8 @@ async function setStatus(octokit, status, jobIdentifier, selfId) {
}
}
}
function isFlagged(externalId, flags) {
return flags.some((flag) => externalId.includes(`<!--BUGROUP_CHECKS_FLAG-${flag}-->`));
function isFlagged(text, flags) {
return flags.some((flag) => text.includes(`<!--BUGROUP_CHECKS_FLAG-${flag}-->`));
}
async function run() {
try {
Expand Down Expand Up @@ -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)) {
Expand All @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion dist/rerun/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 `^<!--${jobIdentifier}-(\d+)-->$`))?.[1];
const runId = check.output.text?.match(new RegExp(String.raw `^<!--${jobIdentifier}-(\d+)-->$`))?.[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) });
Expand Down
4 changes: 2 additions & 2 deletions src/flag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { context, getOctokit } from '@actions/github'
import { getInput, debug, setFailed } from '@actions/core'

export async function run(): Promise<void> {
/* 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')
Expand All @@ -19,7 +19,7 @@ export async function run(): Promise<void> {
await octokit.rest.checks.update({
...context.repo,
check_run_id: selfChecks[0].id,
external_id: `${selfChecks[0].external_id ?? ''}<!--BUGROUP_CHECKS_FLAG-${flag}-->`
output: { summary: selfChecks[0].output.summary ?? '', title: selfChecks[0].output.title ?? '', text: `<!--BUGROUP_CHECKS_FLAG-${flag}-->` }
})
} catch (error) {
if (error instanceof Error) {
Expand Down
13 changes: 6 additions & 7 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<typeof getOctokit>, status: string, jobIdentifier: string, selfId?: number | null): Promise<void> {
/* 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: `<!--${jobIdentifier}-${context.runId}-->`,
output: { summary: '', title: status }
output: { summary: '', title: status, text: `<!--${jobIdentifier}-${context.runId}-->` }
})
} catch (error) {
if (error instanceof Error) {
Expand All @@ -20,8 +19,8 @@ async function setStatus(octokit: ReturnType<typeof getOctokit>, status: string,
}
}

function isFlagged(externalId: string, flags: string[]): boolean {
return flags.some((flag) => externalId.includes(`<!--BUGROUP_CHECKS_FLAG-${flag}-->`))
function isFlagged(text: string, flags: string[]): boolean {
return flags.some((flag) => text.includes(`<!--BUGROUP_CHECKS_FLAG-${flag}-->`))
}

export async function run(): Promise<void> {
Expand Down Expand Up @@ -72,7 +71,7 @@ export async function run(): Promise<void> {
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)) {
Expand All @@ -82,7 +81,7 @@ export async function run(): Promise<void> {
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))
Expand Down
2 changes: 1 addition & 1 deletion src/rerun.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export async function run(): Promise<void> {
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`^<!--${jobIdentifier}-(\d+)-->$`))?.[1]
const runId = check.output.text?.match(new RegExp(String.raw`^<!--${jobIdentifier}-(\d+)-->$`))?.[1]
if (runId !== undefined) {
debug(`runId: ${runId}`)
const { data: jobs } = await octokit.rest.actions.listJobsForWorkflowRun({ ...context.repo, run_id: parseInt(runId, 10) })
Expand Down

0 comments on commit f634c21

Please sign in to comment.