From e7dea25e5dac19c4c7f78c85de014f4c3a68c770 Mon Sep 17 00:00:00 2001 From: Alice Zhao Date: Sun, 21 Apr 2024 13:47:15 -0700 Subject: [PATCH 1/6] feat: add new check to make sure manual backport release notes match original --- src/operations/update-manual-backport.ts | 14 ++++- src/utils.ts | 66 +++++++++++++++++------- 2 files changed, 60 insertions(+), 20 deletions(-) diff --git a/src/operations/update-manual-backport.ts b/src/operations/update-manual-backport.ts index a28b14b..d112373 100644 --- a/src/operations/update-manual-backport.ts +++ b/src/operations/update-manual-backport.ts @@ -4,8 +4,12 @@ import { SKIP_CHECK_LABEL, } from '../constants'; import { PRChange, PRStatus, LogLevel } from '../enums'; -import { WebHookPRContext } from '../types'; -import { isSemverMinorPR, tagBackportReviewers } from '../utils'; +import { WebHookPR, WebHookPRContext } from '../types'; +import { + isSemverMinorPR, + tagBackportReviewers, + updateManualBackportReleaseNotes, +} from '../utils'; import * as labelUtils from '../utils/label-utils'; import { log } from '../utils/log-util'; @@ -68,6 +72,12 @@ export const updateManualBackport = async ( context.repo({ pull_number: oldPRNumber }), ); + // Update backport PR release notes if it does not match original PR + await updateManualBackportReleaseNotes( + context, + pr, + originalPR as WebHookPR, + ); // Propagate semver label from the original PR if the maintainer didn't add it. const originalPRSemverLabel = labelUtils.getSemverLabel(originalPR); if (originalPRSemverLabel) { diff --git a/src/utils.ts b/src/utils.ts index cf205e2..29f539c 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -29,7 +29,7 @@ import { WebHookPR, WebHookRepoContext, } from './types'; -import { Context, Probot } from 'probot'; +import { Probot } from 'probot'; const { parse: parseDiff } = require('what-the-diff'); @@ -298,7 +298,7 @@ export const getPRNumbersFromPRBody = (pr: WebHookPR, checkNotBot = false) => { * @param context Context * @param pr Pull Request */ -const getOriginalBackportNumber = async ( +export const getOriginalBackportNumber = async ( context: SimpleWebHookRepoContext, pr: WebHookPR, ) => { @@ -365,6 +365,23 @@ const checkUserHasWriteAccess = async ( return ['write', 'admin'].includes(userInfo.permission); }; +const getReleaseNotes = (pr: Pick) => { + const onelineMatch = pr.body?.match( + /(?:(?:\r?\n)|^)notes: (.+?)(?:(?:\r?\n)|$)/gi, + ); + const multilineMatch = pr.body?.match( + /(?:(?:\r?\n)Notes:(?:\r?\n)((?:\*.+(?:(?:\r?\n)|$))+))/gi, + ); + + if (onelineMatch && onelineMatch[0]) { + return `\n\n${onelineMatch[0]}`; + } else if (multilineMatch && multilineMatch[0]) { + return `\n\n${multilineMatch[0]}`; + } else { + return '\n\nNotes: no-notes'; + } +}; + const createBackportComment = async ( context: SimpleWebHookRepoContext, pr: WebHookPR, @@ -377,23 +394,9 @@ const createBackportComment = async ( `Creating backport comment for #${prNumber}`, ); - let body = `Backport of #${prNumber}\n\nSee that PR for details.`; - - const onelineMatch = pr.body?.match( - /(?:(?:\r?\n)|^)notes: (.+?)(?:(?:\r?\n)|$)/gi, - ); - const multilineMatch = pr.body?.match( - /(?:(?:\r?\n)Notes:(?:\r?\n)((?:\*.+(?:(?:\r?\n)|$))+))/gi, - ); - + const releaseNotes = getReleaseNotes(pr); // attach release notes to backport PR body - if (onelineMatch && onelineMatch[0]) { - body += `\n\n${onelineMatch[0]}`; - } else if (multilineMatch && multilineMatch[0]) { - body += `\n\n${multilineMatch[0]}`; - } else { - body += '\n\nNotes: no-notes'; - } + const body = `Backport of #${prNumber}\n\nSee that PR for details.${releaseNotes}`; return body; }; @@ -798,3 +801,30 @@ export const backportImpl = async ( }, ); }; + +export const updateManualBackportReleaseNotes = async ( + context: SimpleWebHookRepoContext, + backportPr: WebHookPR, + originalPr: WebHookPR, +) => { + const backportPRReleaseNotes = getReleaseNotes(backportPr); + const originalPRReleaseNotes = getReleaseNotes(originalPr); + // If release notes match, do nothing + if (backportPRReleaseNotes === originalPRReleaseNotes) { + return; + } + + log( + 'updateManualBackport', + LogLevel.WARN, + `Manual backport does not match the release notes of the original PR.`, + ); + + // Update backport PR with new description that includes matching release notes to original PR + await context.octokit.pulls.update( + context.repo({ + pull_number: backportPr.number, + body: await createBackportComment(context, originalPr), + }), + ); +}; From 441ab204563228e8e76cc2dcb4af6c7f1d8bcef7 Mon Sep 17 00:00:00 2001 From: Alice Zhao Date: Sun, 21 Apr 2024 13:47:38 -0700 Subject: [PATCH 2/6] test: update fixtures --- spec/fixtures/backport_pull_request.merged.json | 2 +- spec/fixtures/pull_request.opened.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/fixtures/backport_pull_request.merged.json b/spec/fixtures/backport_pull_request.merged.json index 00f857d..4124bc1 100644 --- a/spec/fixtures/backport_pull_request.merged.json +++ b/spec/fixtures/backport_pull_request.merged.json @@ -18,7 +18,7 @@ "default_branch": "main" } }, - "body": "Backport of #14\nSee that PR for details.\nNotes: ", + "body": "Backport of #14\nSee that PR for details.\nNotes: new cool stuff added", "created_at": "2018-11-01T17:29:51Z", "merged_at": "2018-11-01T17:30:11Z", "labels": [ diff --git a/spec/fixtures/pull_request.opened.json b/spec/fixtures/pull_request.opened.json index 5269d3d..7edca67 100644 --- a/spec/fixtures/pull_request.opened.json +++ b/spec/fixtures/pull_request.opened.json @@ -10,7 +10,7 @@ "user": { "login": "codebytere" }, - "body": "New cool stuff", + "body": "New cool stuff \nNotes: new cool stuff added", "labels": [], "head": { "sha": "ABC" From 26811f0ba0545eb94987f5af99df82034a68dfcf Mon Sep 17 00:00:00 2001 From: Alice Zhao Date: Sun, 21 Apr 2024 13:47:54 -0700 Subject: [PATCH 3/6] test: add and update tests --- spec/index.spec.ts | 2 +- spec/operations.spec.ts | 1 + spec/utils.spec.ts | 59 +++++++++++++++++++++++++++++++++++++++-- 3 files changed, 59 insertions(+), 3 deletions(-) diff --git a/spec/index.spec.ts b/spec/index.spec.ts index 259ca9b..54c152f 100644 --- a/spec/index.spec.ts +++ b/spec/index.spec.ts @@ -430,7 +430,7 @@ Notes: `, const pr = { body: `Backport of #14 See that PR for details. -Notes: `, +Notes: new cool stuff added`, created_at: '2018-11-01T17:29:51Z', head: { ref: '123456789iuytdxcvbnjhfdriuyfedfgy54escghjnbg', diff --git a/spec/operations.spec.ts b/spec/operations.spec.ts index 1f4c971..8dfc3fd 100644 --- a/spec/operations.spec.ts +++ b/spec/operations.spec.ts @@ -24,6 +24,7 @@ const backportPROpenedEvent = require('./fixtures/backport_pull_request.opened.j jest.mock('../src/utils', () => ({ tagBackportReviewers: jest.fn().mockReturnValue(Promise.resolve()), isSemverMinorPR: jest.fn().mockReturnValue(false), + updateManualBackportReleaseNotes: jest.fn(), })); jest.mock('../src/utils/label-utils', () => ({ diff --git a/spec/utils.spec.ts b/spec/utils.spec.ts index 2fb7b03..bc2d3f7 100644 --- a/spec/utils.spec.ts +++ b/spec/utils.spec.ts @@ -1,8 +1,14 @@ -import * as logUtils from '../src/utils/log-util'; import { LogLevel } from '../src/enums'; -import { tagBackportReviewers } from '../src/utils'; +import { + tagBackportReviewers, + updateManualBackportReleaseNotes, +} from '../src/utils'; +import * as utils from '../src/utils'; +import * as logUtils from '../src/utils/log-util'; const backportPROpenedEvent = require('./fixtures/backport_pull_request.opened.json'); +const backportPRMergedEvent = require('./fixtures/backport_pull_request.merged.json'); +const PROpenedEvent = require('./fixtures/pull_request.opened.json'); jest.mock('../src/constants', () => ({ ...jest.requireActual('../src/constants'), @@ -74,4 +80,53 @@ describe('utils', () => { ); }); }); + + describe('updateManualBackportReleaseNotes', () => { + const octokit = { + pulls: { + update: jest.fn(), + get: jest.fn(), + }, + }; + + const context = { + octokit, + repo: jest.fn((obj) => obj), + ...backportPROpenedEvent, + }; + + const backportPRMissingReleaseNotes = + backportPROpenedEvent.payload.pull_request; + const backportPRWithReleaseNotes = + backportPRMergedEvent.payload.pull_request; + const originalPRWithReleaseNotes = PROpenedEvent.payload.pull_request; + + beforeEach(() => { + jest.clearAllMocks(); + }); + + it('should not update backport PR if release notes match original PR', async () => { + await updateManualBackportReleaseNotes( + context, + backportPRWithReleaseNotes, + originalPRWithReleaseNotes, + ); + + expect(context.octokit.pulls.update).not.toHaveBeenCalled(); + }); + + it('should update backport PR if release notes do not match original PR', async () => { + jest.spyOn(utils, 'getOriginalBackportNumber').mockResolvedValue(1234); + await updateManualBackportReleaseNotes( + context, + backportPRMissingReleaseNotes, + originalPRWithReleaseNotes, + ); + + expect(context.octokit.pulls.update).toHaveBeenCalledWith({ + pull_number: 7, + body: 'Backport of #1234\n\nSee that PR for details.\n\n\nNotes: new cool stuff added', + }); + }); + }); }); From 4fb7f24754b21f39b9609c7e0798a8728f1c0352 Mon Sep 17 00:00:00 2001 From: Alice Zhao Date: Mon, 22 Apr 2024 20:03:27 -0700 Subject: [PATCH 4/6] fix: update implementation of check release notes validity --- spec/operations.spec.ts | 1 - spec/utils.spec.ts | 79 ++++++++++++------------ src/index.ts | 23 ++++++- src/operations/update-manual-backport.ts | 12 +--- src/utils.ts | 31 +++------- 5 files changed, 69 insertions(+), 77 deletions(-) diff --git a/spec/operations.spec.ts b/spec/operations.spec.ts index 8dfc3fd..1f4c971 100644 --- a/spec/operations.spec.ts +++ b/spec/operations.spec.ts @@ -24,7 +24,6 @@ const backportPROpenedEvent = require('./fixtures/backport_pull_request.opened.j jest.mock('../src/utils', () => ({ tagBackportReviewers: jest.fn().mockReturnValue(Promise.resolve()), isSemverMinorPR: jest.fn().mockReturnValue(false), - updateManualBackportReleaseNotes: jest.fn(), })); jest.mock('../src/utils/label-utils', () => ({ diff --git a/spec/utils.spec.ts b/spec/utils.spec.ts index bc2d3f7..c2be816 100644 --- a/spec/utils.spec.ts +++ b/spec/utils.spec.ts @@ -1,7 +1,7 @@ import { LogLevel } from '../src/enums'; import { tagBackportReviewers, - updateManualBackportReleaseNotes, + isValidManualBackportReleaseNotes, } from '../src/utils'; import * as utils from '../src/utils'; import * as logUtils from '../src/utils/log-util'; @@ -9,6 +9,7 @@ import * as logUtils from '../src/utils/log-util'; const backportPROpenedEvent = require('./fixtures/backport_pull_request.opened.json'); const backportPRMergedEvent = require('./fixtures/backport_pull_request.merged.json'); const PROpenedEvent = require('./fixtures/pull_request.opened.json'); +const PRClosedEvent = require('./fixtures/pull_request.closed.json'); jest.mock('../src/constants', () => ({ ...jest.requireActual('../src/constants'), @@ -81,52 +82,50 @@ describe('utils', () => { }); }); - describe('updateManualBackportReleaseNotes', () => { - const octokit = { - pulls: { - update: jest.fn(), - get: jest.fn(), - }, - }; - - const context = { - octokit, - repo: jest.fn((obj) => obj), - ...backportPROpenedEvent, - }; - - const backportPRMissingReleaseNotes = - backportPROpenedEvent.payload.pull_request; - const backportPRWithReleaseNotes = - backportPRMergedEvent.payload.pull_request; + describe('isValidManualBackportReleaseNotes', () => { + const backportPRMissingReleaseNotes = backportPROpenedEvent; + const backportPRWithReleaseNotes = backportPRMergedEvent; const originalPRWithReleaseNotes = PROpenedEvent.payload.pull_request; + const originalPRMissingReleaseNotes = PRClosedEvent.payload.pull_request; + const originalPRWithReleaseNotes2 = + backportPRMergedEvent.payload.pull_request; - beforeEach(() => { - jest.clearAllMocks(); + it('should return valid if release notes match original PR for single PR', async () => { + const context = { ...backportPRWithReleaseNotes }; + expect( + await isValidManualBackportReleaseNotes(context, [ + originalPRWithReleaseNotes, + ]), + ).toBe(true); }); - it('should not update backport PR if release notes match original PR', async () => { - await updateManualBackportReleaseNotes( - context, - backportPRWithReleaseNotes, - originalPRWithReleaseNotes, - ); - - expect(context.octokit.pulls.update).not.toHaveBeenCalled(); + it('should return valid if release notes match original PR for multiple PR', async () => { + const context = { ...backportPRWithReleaseNotes }; + expect( + await isValidManualBackportReleaseNotes(context, [ + originalPRWithReleaseNotes, + originalPRMissingReleaseNotes, + ]), + ).toBe(true); }); - it('should update backport PR if release notes do not match original PR', async () => { - jest.spyOn(utils, 'getOriginalBackportNumber').mockResolvedValue(1234); - await updateManualBackportReleaseNotes( - context, - backportPRMissingReleaseNotes, - originalPRWithReleaseNotes, - ); + it('should update backport PR if release notes do not match original PR for single PR', async () => { + const context = { ...backportPRMissingReleaseNotes }; + expect( + await isValidManualBackportReleaseNotes(context, [ + originalPRWithReleaseNotes, + ]), + ).toBe(false); + }); - expect(context.octokit.pulls.update).toHaveBeenCalledWith({ - pull_number: 7, - body: 'Backport of #1234\n\nSee that PR for details.\n\n\nNotes: new cool stuff added', - }); + it('should update backport PR if release notes do not match original PR for multiple PR', async () => { + const context = { ...backportPRMissingReleaseNotes }; + expect( + await isValidManualBackportReleaseNotes(context, [ + originalPRWithReleaseNotes, + originalPRWithReleaseNotes2, + ]), + ).toBe(false); }); }); }); diff --git a/src/index.ts b/src/index.ts index fb3f796..9f08739 100644 --- a/src/index.ts +++ b/src/index.ts @@ -4,6 +4,7 @@ import { backportImpl, getPRNumbersFromPRBody, isAuthorizedUser, + isValidManualBackportReleaseNotes, labelClosedPR, } from './utils'; import { @@ -287,6 +288,7 @@ const probotHandler: ApplicationFunction = async (robot, { getRouter }) => { `#${pr.number} has backport numbers - checking their validity now`, ); const supported = await getSupportedBranches(context); + const oldPRs = []; for (const oldPRNumber of oldPRNumbers) { robot.log(`Checking validity of #${oldPRNumber}`); @@ -295,7 +297,7 @@ const probotHandler: ApplicationFunction = async (robot, { getRouter }) => { pull_number: oldPRNumber, }), ); - + oldPRs.push(oldPR); // The current PR is only valid if the PR it is backporting // was merged to main or to a supported release branch. if ( @@ -312,6 +314,25 @@ const probotHandler: ApplicationFunction = async (robot, { getRouter }) => { failureMap.set(oldPRNumber, cause); } } + + if (['opened', 'edited'].includes(action)) { + robot.log(`Checking validity of release notes`); + // Check to make sure backport PR has the same release notes as at least on of the old prs + const isValidReleaseNotes = await isValidManualBackportReleaseNotes( + context, + oldPRs as WebHookPR[], + ); + + if (!isValidReleaseNotes) { + await updateBackportValidityCheck(context, checkRun, { + title: 'Invalid Backport', + summary: `The release notes of the backport PR do not match those of ${oldPRNumbers + .map((pr) => `#${pr}`) + .join(', ')}.`, + conclusion: CheckRunStatus.FAILURE, + }); + } + } } for (const oldPRNumber of oldPRNumbers) { diff --git a/src/operations/update-manual-backport.ts b/src/operations/update-manual-backport.ts index d112373..6113a38 100644 --- a/src/operations/update-manual-backport.ts +++ b/src/operations/update-manual-backport.ts @@ -5,11 +5,7 @@ import { } from '../constants'; import { PRChange, PRStatus, LogLevel } from '../enums'; import { WebHookPR, WebHookPRContext } from '../types'; -import { - isSemverMinorPR, - tagBackportReviewers, - updateManualBackportReleaseNotes, -} from '../utils'; +import { isSemverMinorPR, tagBackportReviewers } from '../utils'; import * as labelUtils from '../utils/label-utils'; import { log } from '../utils/log-util'; @@ -72,12 +68,6 @@ export const updateManualBackport = async ( context.repo({ pull_number: oldPRNumber }), ); - // Update backport PR release notes if it does not match original PR - await updateManualBackportReleaseNotes( - context, - pr, - originalPR as WebHookPR, - ); // Propagate semver label from the original PR if the maintainer didn't add it. const originalPRSemverLabel = labelUtils.getSemverLabel(originalPR); if (originalPRSemverLabel) { diff --git a/src/utils.ts b/src/utils.ts index 29f539c..ea19b83 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -27,6 +27,7 @@ import { SimpleWebHookRepoContext, WebHookIssueContext, WebHookPR, + WebHookPRContext, WebHookRepoContext, } from './types'; import { Probot } from 'probot'; @@ -802,29 +803,11 @@ export const backportImpl = async ( ); }; -export const updateManualBackportReleaseNotes = async ( - context: SimpleWebHookRepoContext, - backportPr: WebHookPR, - originalPr: WebHookPR, +export const isValidManualBackportReleaseNotes = async ( + context: WebHookPRContext, + oldPRs: WebHookPR[], ) => { - const backportPRReleaseNotes = getReleaseNotes(backportPr); - const originalPRReleaseNotes = getReleaseNotes(originalPr); - // If release notes match, do nothing - if (backportPRReleaseNotes === originalPRReleaseNotes) { - return; - } - - log( - 'updateManualBackport', - LogLevel.WARN, - `Manual backport does not match the release notes of the original PR.`, - ); - - // Update backport PR with new description that includes matching release notes to original PR - await context.octokit.pulls.update( - context.repo({ - pull_number: backportPr.number, - body: await createBackportComment(context, originalPr), - }), - ); + console.log(context, oldPRs); + const backportPRReleaseNotes = getReleaseNotes(context.payload.pull_request); + return oldPRs.some((pr) => getReleaseNotes(pr) === backportPRReleaseNotes); }; From 06b5caa16e49f48e3f0a90a41fd9b01aa576fda4 Mon Sep 17 00:00:00 2001 From: Alice Zhao Date: Mon, 22 Apr 2024 20:06:22 -0700 Subject: [PATCH 5/6] refactor: remove console log --- src/utils.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/utils.ts b/src/utils.ts index ea19b83..5e9b745 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -807,7 +807,6 @@ export const isValidManualBackportReleaseNotes = async ( context: WebHookPRContext, oldPRs: WebHookPR[], ) => { - console.log(context, oldPRs); const backportPRReleaseNotes = getReleaseNotes(context.payload.pull_request); return oldPRs.some((pr) => getReleaseNotes(pr) === backportPRReleaseNotes); }; From f143e829319a1aa11fd4a1e085003b184f7aa9d9 Mon Sep 17 00:00:00 2001 From: Alice Zhao Date: Thu, 25 Apr 2024 15:45:48 -0700 Subject: [PATCH 6/6] refactor: move release notes check after failureMap --- spec/utils.spec.ts | 4 ++-- src/index.ts | 55 +++++++++++++++++++++++----------------------- 2 files changed, 30 insertions(+), 29 deletions(-) diff --git a/spec/utils.spec.ts b/spec/utils.spec.ts index c2be816..e9f765b 100644 --- a/spec/utils.spec.ts +++ b/spec/utils.spec.ts @@ -109,7 +109,7 @@ describe('utils', () => { ).toBe(true); }); - it('should update backport PR if release notes do not match original PR for single PR', async () => { + it('should return not valid if release notes do not match original PR for single PR', async () => { const context = { ...backportPRMissingReleaseNotes }; expect( await isValidManualBackportReleaseNotes(context, [ @@ -118,7 +118,7 @@ describe('utils', () => { ).toBe(false); }); - it('should update backport PR if release notes do not match original PR for multiple PR', async () => { + it('should return not valid if release notes do not match original PR for multiple PR', async () => { const context = { ...backportPRMissingReleaseNotes }; expect( await isValidManualBackportReleaseNotes(context, [ diff --git a/src/index.ts b/src/index.ts index 9f08739..e25d6ab 100644 --- a/src/index.ts +++ b/src/index.ts @@ -250,8 +250,6 @@ const probotHandler: ApplicationFunction = async (robot, { getRouter }) => { ]; const FASTTRACK_LABELS: string[] = ['fast-track 🚅']; - const failureMap = new Map(); - // There are several types of PRs which might not target main yet which are // inherently valid; e.g roller-bot PRs. Check for and allow those here. if (oldPRNumbers.length === 0) { @@ -287,6 +285,7 @@ const probotHandler: ApplicationFunction = async (robot, { getRouter }) => { robot.log( `#${pr.number} has backport numbers - checking their validity now`, ); + const failureMap = new Map(); const supported = await getSupportedBranches(context); const oldPRs = []; @@ -297,7 +296,9 @@ const probotHandler: ApplicationFunction = async (robot, { getRouter }) => { pull_number: oldPRNumber, }), ); + oldPRs.push(oldPR); + // The current PR is only valid if the PR it is backporting // was merged to main or to a supported release branch. if ( @@ -315,9 +316,33 @@ const probotHandler: ApplicationFunction = async (robot, { getRouter }) => { } } + for (const oldPRNumber of oldPRNumbers) { + if (failureMap.has(oldPRNumber)) { + robot.log( + `#${pr.number} is targeting a branch that is not ${ + pr.base.repo.default_branch + } - ${failureMap.get(oldPRNumber)}`, + ); + await updateBackportValidityCheck(context, checkRun, { + title: 'Invalid Backport', + summary: `This PR is targeting a branch that is not ${ + pr.base.repo.default_branch + } but ${failureMap.get(oldPRNumber)}`, + conclusion: CheckRunStatus.FAILURE, + }); + } else { + robot.log(`#${pr.number} is a valid backport of #${oldPRNumber}`); + await updateBackportValidityCheck(context, checkRun, { + title: 'Valid Backport', + summary: `This PR is declared as backporting "#${oldPRNumber}" which is a valid PR that has been merged into ${pr.base.repo.default_branch}`, + conclusion: CheckRunStatus.SUCCESS, + }); + } + } + if (['opened', 'edited'].includes(action)) { robot.log(`Checking validity of release notes`); - // Check to make sure backport PR has the same release notes as at least on of the old prs + // Check to make sure backport PR has the same release notes as at least one of the old prs const isValidReleaseNotes = await isValidManualBackportReleaseNotes( context, oldPRs as WebHookPR[], @@ -334,30 +359,6 @@ const probotHandler: ApplicationFunction = async (robot, { getRouter }) => { } } } - - for (const oldPRNumber of oldPRNumbers) { - if (failureMap.has(oldPRNumber)) { - robot.log( - `#${pr.number} is targeting a branch that is not ${ - pr.base.repo.default_branch - } - ${failureMap.get(oldPRNumber)}`, - ); - await updateBackportValidityCheck(context, checkRun, { - title: 'Invalid Backport', - summary: `This PR is targeting a branch that is not ${ - pr.base.repo.default_branch - } but ${failureMap.get(oldPRNumber)}`, - conclusion: CheckRunStatus.FAILURE, - }); - } else { - robot.log(`#${pr.number} is a valid backport of #${oldPRNumber}`); - await updateBackportValidityCheck(context, checkRun, { - title: 'Valid Backport', - summary: `This PR is declared as backporting "#${oldPRNumber}" which is a valid PR that has been merged into ${pr.base.repo.default_branch}`, - conclusion: CheckRunStatus.SUCCESS, - }); - } - } } else { // If we're somehow targeting main and have a check run, // we mark this check as cancelled.