diff --git a/scripts/createOrUpdateDeployChecklist.ts b/scripts/createOrUpdateDeployChecklist.ts index a109693e1246..d32bb5102139 100644 --- a/scripts/createOrUpdateDeployChecklist.ts +++ b/scripts/createOrUpdateDeployChecklist.ts @@ -229,7 +229,8 @@ async function run(): Promise { const {mergedPRs: mergedPREntries, submoduleUpdates} = await GitUtils.getMergedPRsDeployedBetween(previousChecklistData.tag, newStagingTag, CONST.APP_REPO); const mergedPRs = mergedPREntries.map((pr) => pr.prNumber).sort((a, b) => a - b); - const previousPRNumbers = new Set(previousChecklistData.PRList.map((pr) => pr.number)); + // Previous PRs should include PRs and internalQA items + const previousPRNumbers = new Set([...previousChecklistData.PRList, ...previousChecklistData.internalQAPRList].map((pr) => pr.number)); const previousMobileExpensifyPRNumbers = new Set(previousChecklistData.PRListMobileExpensify.map((pr) => pr.number)); core.startGroup('Filtering PRs:'); core.info('mergedPRs includes cherry-picked PRs that have already been released with previous checklist, so we need to filter these out'); diff --git a/tests/tooling/createOrUpdateDeployChecklist.test.ts b/tests/tooling/createOrUpdateDeployChecklist.test.ts index d6dbc37437cf..3c367942ef7b 100644 --- a/tests/tooling/createOrUpdateDeployChecklist.test.ts +++ b/tests/tooling/createOrUpdateDeployChecklist.test.ts @@ -790,6 +790,67 @@ describe('createOrUpdateDeployChecklist', () => { mockGetDeployChecklistData.mockRestore(); }); + + test('filters out Internal QA PRs that were already included in previous checklist', async () => { + // Given a previous checklist where cherry-picked PR 8 sat in the Internal QA section rather than the main PR list + vol.reset(); + vol.fromJSON({ + [PATH_TO_PACKAGE_JSON]: JSON.stringify({version: '1.0.3-0'}), + }); + + mockGetInput.mockImplementation((arg) => (arg === 'GITHUB_TOKEN' ? 'fake_token' : '')); + mockGetMergedPRsDeployedBetween.mockImplementation(async (fromRef, toRef, repositoryName) => { + if (fromRef === '1.0.2-1-staging' && toRef === '1.0.3-0-staging') { + if (repositoryName === CONST.MOBILE_EXPENSIFY_REPO) { + return {mergedPRs: [], submoduleUpdates: []}; + } + return toMergedPRs([6, 8, 10, 11]); + } + return {mergedPRs: [], submoduleUpdates: []}; + }); + + const mockGetDeployChecklistData = jest.spyOn(DeployChecklistUtils, 'getDeployChecklistData'); + mockGetDeployChecklistData.mockImplementation(() => ({ + title: 'Previous Checklist', + url: `https://github.com/${process.env.GITHUB_REPOSITORY}/issues/29`, + number: 29, + labels: [LABELS.STAGING_DEPLOY_CASH], + PRList: [{url: `https://github.com/${process.env.GITHUB_REPOSITORY}/pull/6`, number: 6, isChecked: true}], + PRListMobileExpensify: [], + deployBlockers: [], + internalQAPRList: [{url: `https://github.com/${process.env.GITHUB_REPOSITORY}/pull/8`, number: 8, isChecked: true}], + isSentryChecked: true, + isGHStatusChecked: true, + version: '1.0.2-1', + tag: '1.0.2-1-staging', + })); + + mockDeployChecklistIssuesByLabel({ + [CONST.LABELS.STAGING_DEPLOY]: [ + { + number: 29, + state: 'closed', + labels: [LABELS.STAGING_DEPLOY_CASH], + }, + ], + }); + + // When a new checklist is created + await run(); + const createCall = mockCreateIssue.mock.lastCall; + if (!createCall || !createCall[0]) { + throw new Error('Expected issues.create to receive a request payload.'); + } + const createPayload = createCall[0]; + + // Then both previously released PRs are excluded, regardless of which section listed them + expect(createPayload.body).toContain('https://github.com/Expensify/App/pull/10'); + expect(createPayload.body).toContain('https://github.com/Expensify/App/pull/11'); + expect(createPayload.body).not.toContain('https://github.com/Expensify/App/pull/6'); + expect(createPayload.body).not.toContain('https://github.com/Expensify/App/pull/8'); + + mockGetDeployChecklistData.mockRestore(); + }); }); describe('chronological section with submodule updates', () => {