Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: don't update backportable check with queued status #291

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 1 addition & 11 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,17 +111,7 @@ const probotHandler: ApplicationFunction = async (robot, { getRouter }) => {
const targetBranch = labelToTargetBranch(label, PRStatus.TARGET);
const runName = `${CHECK_PREFIX}${targetBranch}`;
let checkRun = checkRuns.find((run) => run.name === runName);
if (checkRun) {
if (checkRun.conclusion !== 'neutral') continue;

await context.octokit.checks.update(
context.repo({
name: checkRun.name,
check_run_id: checkRun.id,
status: 'queued' as 'queued',
}),
);
} else {
if (!checkRun) {
const response = await context.octokit.checks.create(
context.repo({
name: runName,
Expand Down
18 changes: 4 additions & 14 deletions src/operations/backport-to-location.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,14 @@ import { backportImpl } from '../utils';
import { Probot } from 'probot';
import { SimpleWebHookRepoContext, WebHookPR } from '../types';

const createOrUpdateCheckRun = async (
const getOrCreateCheckRun = async (
context: SimpleWebHookRepoContext,
pr: WebHookPR,
targetBranch: string,
) => {
let check = await getCheckRun(context, pr, targetBranch);

if (check) {
if (check.conclusion === 'neutral') {
await context.octokit.checks.update(
context.repo({
name: check.name,
check_run_id: check.id,
status: 'queued' as 'queued',
}),
);
}
} else {
if (!check) {
const response = await context.octokit.checks.create(
context.repo({
name: `${CHECK_PREFIX}${targetBranch}`,
Expand Down Expand Up @@ -78,7 +68,7 @@ export const backportToLabel = async (
return;
}

const checkRun = await createOrUpdateCheckRun(context, pr, targetBranch);
const checkRun = await getOrCreateCheckRun(context, pr, targetBranch);

const labelToRemove = label.name;
const labelToAdd = label.name.replace(PRStatus.TARGET, PRStatus.IN_FLIGHT);
Expand Down Expand Up @@ -113,7 +103,7 @@ export const backportToBranch = async (
`Executing backport to branch '${targetBranch}'`,
);

const checkRun = await createOrUpdateCheckRun(context, pr, targetBranch);
const checkRun = await getOrCreateCheckRun(context, pr, targetBranch);

const labelToRemove = undefined;
const labelToAdd = PRStatus.IN_FLIGHT + targetBranch;
Expand Down