From 3e8f1b38e1c58f953f0fb6a8c3c5e255213fb7e5 Mon Sep 17 00:00:00 2001 From: tienifr Date: Tue, 12 Mar 2024 17:09:02 +0700 Subject: [PATCH 01/29] fix mention with the same front name --- src/CONST.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CONST.ts b/src/CONST.ts index a163c63404a7..0ded50f39aff 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -1579,7 +1579,7 @@ const CONST = { POLICY_ID_FROM_PATH: /\/w\/([a-zA-Z0-9]+)(\/|$)/, - SHORT_MENTION: new RegExp(`@[\\w\\-\\+\\'#]+(?:\\.[\\w\\-\\'\\+]+)*`, 'gim'), + SHORT_MENTION: new RegExp(`@[\\w\\-\\+\\'#@]+(?:\\.[\\w\\-\\'\\+]+)*`, 'gim'), }, PRONOUNS: { From f227a8436f3d8fa0051a50bb4f1129ffaabca495 Mon Sep 17 00:00:00 2001 From: Carlos Martins Date: Wed, 13 Mar 2024 12:43:29 -0600 Subject: [PATCH 02/29] fix pay button show conditions --- src/libs/ReportUtils.ts | 2 +- src/libs/actions/IOU.ts | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 8dc1c9967f13..30ae15610744 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -1271,7 +1271,7 @@ function isPayer(session: OnyxEntry, iouReport: OnyxEntry) { if (isPaidGroupPolicy(iouReport)) { if (policy?.reimbursementChoice === CONST.POLICY.REIMBURSEMENT_CHOICES.REIMBURSEMENT_YES) { const isReimburser = session?.email === policy?.reimburserEmail; - return isReimburser && (isApproved || isManager); + return (!policy?.reimburserEmail || isReimburser) && (isApproved || isManager); } if (policy?.reimbursementChoice === CONST.POLICY.REIMBURSEMENT_CHOICES.REIMBURSEMENT_MANUAL) { return isAdmin && (isApproved || isManager); diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index af5c40836c74..450d6a38eed4 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -3666,6 +3666,10 @@ function canIOUBePaid(iouReport: OnyxEntry | EmptyObject, chat return false; } + if (policy?.reimbursementChoice === CONST.POLICY.REIMBURSEMENT_CHOICES.REIMBURSEMENT_NO) { + return false; + } + const isPayer = ReportUtils.isPayer( { email: currentUserEmail, From 44c4842f5e50e71c261333ecc2890a08344e8460 Mon Sep 17 00:00:00 2001 From: Carlos Martins Date: Wed, 13 Mar 2024 13:21:08 -0600 Subject: [PATCH 03/29] fix more conditionals --- src/components/SettlementButton.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/components/SettlementButton.tsx b/src/components/SettlementButton.tsx index 6b6ad3af737a..6f5b507eda9e 100644 --- a/src/components/SettlementButton.tsx +++ b/src/components/SettlementButton.tsx @@ -135,13 +135,12 @@ function SettlementButton({ PaymentMethods.openWalletPage(); }, []); - const policy = ReportUtils.getPolicy(policyID); const session = useSession(); const chatReport = ReportUtils.getReport(chatReportID); const isPaidGroupPolicy = ReportUtils.isPaidGroupPolicyExpenseChat(chatReport as OnyxEntry); const shouldShowPaywithExpensifyOption = !isPaidGroupPolicy || - (!shouldHidePaymentOptions && policy?.reimbursementChoice === CONST.POLICY.REIMBURSEMENT_CHOICES.REIMBURSEMENT_YES && policy?.reimburserEmail === session?.email); + (!shouldHidePaymentOptions && ReportUtils.isPayer(session, iouReport as OnyxEntry)); const paymentButtonOptions = useMemo(() => { const buttonOptions = []; const isExpenseReport = ReportUtils.isExpenseReport(iouReport); From facdc0ad01f293deca2825bcc2c06b78820ef6db Mon Sep 17 00:00:00 2001 From: Carlos Martins Date: Wed, 13 Mar 2024 13:25:37 -0600 Subject: [PATCH 04/29] add manul reimburse case --- src/components/SettlementButton.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/components/SettlementButton.tsx b/src/components/SettlementButton.tsx index 6f5b507eda9e..5a9cd637dcab 100644 --- a/src/components/SettlementButton.tsx +++ b/src/components/SettlementButton.tsx @@ -135,6 +135,7 @@ function SettlementButton({ PaymentMethods.openWalletPage(); }, []); + const policy = ReportUtils.getPolicy(policyID); const session = useSession(); const chatReport = ReportUtils.getReport(chatReportID); const isPaidGroupPolicy = ReportUtils.isPaidGroupPolicyExpenseChat(chatReport as OnyxEntry); @@ -183,7 +184,9 @@ function SettlementButton({ if (isExpenseReport && shouldShowPaywithExpensifyOption) { buttonOptions.push(paymentMethods[CONST.IOU.PAYMENT_TYPE.VBBA]); } - buttonOptions.push(paymentMethods[CONST.IOU.PAYMENT_TYPE.ELSEWHERE]); + if (isExpenseReport && policy?.reimbursementChoice === CONST.POLICY.REIMBURSEMENT_CHOICES.REIMBURSEMENT_MANUAL) { + buttonOptions.push(paymentMethods[CONST.IOU.PAYMENT_TYPE.ELSEWHERE]); + } if (shouldShowApproveButton) { buttonOptions.push(approveButtonOption); From e305eadd87d863c2db8a24576e34813448f1d5b2 Mon Sep 17 00:00:00 2001 From: rayane-djouah <77965000+rayane-djouah@users.noreply.github.com> Date: Sat, 16 Mar 2024 02:03:48 +0100 Subject: [PATCH 05/29] Fix error --- .github/libs/GithubUtils.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/libs/GithubUtils.js b/.github/libs/GithubUtils.js index e988167850ec..66da959d944c 100644 --- a/.github/libs/GithubUtils.js +++ b/.github/libs/GithubUtils.js @@ -256,8 +256,13 @@ class GithubUtils { const internalQAPRMap = _.reduce( _.filter(data, (pr) => !_.isEmpty(_.findWhere(pr.labels, {name: CONST.LABELS.INTERNAL_QA}))), (map, pr) => { + const {data: prData} = await GithubUtils.octokit.pulls.get({ + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, + pull_number: pr.number, + }); // eslint-disable-next-line no-param-reassign - map[pr.html_url] = pr.merged_by.login; + map[pr.html_url] = prData.merged_by.login; return map; }, {}, From 9cf10ab14325a9fd95230b37dbe70ae44cfa1308 Mon Sep 17 00:00:00 2001 From: rayane-djouah <77965000+rayane-djouah@users.noreply.github.com> Date: Sat, 16 Mar 2024 12:26:28 +0100 Subject: [PATCH 06/29] Fix: Expensify engineer is not tagged and assigned in Deploy Checklist to complete the QA for PRs with Internal QA. --- .../createOrUpdateStagingDeploy.js | 11 +++- .github/libs/GithubUtils.js | 18 +++--- tests/unit/GithubUtilsTest.ts | 61 ++++++++++--------- 3 files changed, 50 insertions(+), 40 deletions(-) diff --git a/.github/actions/javascript/createOrUpdateStagingDeploy/createOrUpdateStagingDeploy.js b/.github/actions/javascript/createOrUpdateStagingDeploy/createOrUpdateStagingDeploy.js index 4441348a3c36..63398614fd11 100644 --- a/.github/actions/javascript/createOrUpdateStagingDeploy/createOrUpdateStagingDeploy.js +++ b/.github/actions/javascript/createOrUpdateStagingDeploy/createOrUpdateStagingDeploy.js @@ -40,8 +40,11 @@ async function run() { // Next, we generate the checklist body let checklistBody = ''; + let checklistAssignees = []; if (shouldCreateNewDeployChecklist) { - checklistBody = await GithubUtils.generateStagingDeployCashBody(newVersionTag, _.map(mergedPRs, GithubUtils.getPullRequestURLFromNumber)); + const {issueBody, issueAssignees} = await GithubUtils.generateStagingDeployCashBodyAndAssignees(newVersionTag, _.map(mergedPRs, GithubUtils.getPullRequestURLFromNumber)); + checklistBody = issueBody; + checklistAssignees = issueAssignees; } else { // Generate the updated PR list, preserving the previous state of `isVerified` for existing PRs const PRList = _.reduce( @@ -94,7 +97,7 @@ async function run() { } const didVersionChange = newVersionTag !== currentChecklistData.tag; - checklistBody = await GithubUtils.generateStagingDeployCashBody( + const {issueBody, issueAssignees} = await GithubUtils.generateStagingDeployCashBodyAndAssignees( newVersionTag, _.pluck(PRList, 'url'), _.pluck(_.where(PRList, {isVerified: true}), 'url'), @@ -105,6 +108,8 @@ async function run() { didVersionChange ? false : currentChecklistData.isFirebaseChecked, didVersionChange ? false : currentChecklistData.isGHStatusChecked, ); + checklistBody = issueBody; + checklistAssignees = issueAssignees; } // Finally, create or update the checklist @@ -119,7 +124,7 @@ async function run() { ...defaultPayload, title: `Deploy Checklist: New Expensify ${format(new Date(), CONST.DATE_FORMAT_STRING)}`, labels: [CONST.LABELS.STAGING_DEPLOY], - assignees: [CONST.APPLAUSE_BOT], + assignees: [CONST.APPLAUSE_BOT].concat(checklistAssignees), }); console.log(`Successfully created new StagingDeployCash! 🎉 ${newChecklist.html_url}`); return newChecklist; diff --git a/.github/libs/GithubUtils.js b/.github/libs/GithubUtils.js index 567f734dad35..2664c6399947 100644 --- a/.github/libs/GithubUtils.js +++ b/.github/libs/GithubUtils.js @@ -222,7 +222,7 @@ class GithubUtils { } /** - * Generate the issue body for a StagingDeployCash. + * Generate the issue body and assignees for a StagingDeployCash. * * @param {String} tag * @param {Array} PRList - The list of PR URLs which are included in this StagingDeployCash @@ -235,7 +235,7 @@ class GithubUtils { * @param {Boolean} [isGHStatusChecked] * @returns {Promise} */ - static generateStagingDeployCashBody( + static generateStagingDeployCashBodyAndAssignees( tag, PRList, verifiedPRList = [], @@ -250,8 +250,8 @@ class GithubUtils { .then((data) => { // The format of this map is following: // { - // 'https://github.com/Expensify/App/pull/9641': [ 'PauloGasparSv', 'kidroca' ], - // 'https://github.com/Expensify/App/pull/9642': [ 'mountiny', 'kidroca' ] + // 'https://github.com/Expensify/App/pull/9641': 'PauloGasparSv', + // 'https://github.com/Expensify/App/pull/9642': 'mountiny' // } const internalQAPRMap = _.reduce( _.filter(data, (pr) => !_.isEmpty(_.findWhere(pr.labels, {name: CONST.LABELS.INTERNAL_QA}))), @@ -297,11 +297,11 @@ class GithubUtils { if (!_.isEmpty(internalQAPRMap)) { console.log('Found the following verified Internal QA PRs:', resolvedInternalQAPRs); issueBody += '**Internal QA:**\r\n'; - _.each(internalQAPRMap, (assignees, URL) => { - const assigneeMentions = _.reduce(assignees, (memo, assignee) => `${memo} @${assignee}`, ''); + _.each(internalQAPRMap, (merger, URL) => { + const mergerMention = `@${merger}`; issueBody += `${_.contains(resolvedInternalQAPRs, URL) ? '- [x]' : '- [ ]'} `; issueBody += `${URL}`; - issueBody += ` -${assigneeMentions}`; + issueBody += ` - ${mergerMention}`; issueBody += '\r\n'; }); issueBody += '\r\n\r\n'; @@ -331,7 +331,9 @@ class GithubUtils { issueBody += `\r\n- [${isGHStatusChecked ? 'x' : ' '}] I checked [GitHub Status](https://www.githubstatus.com/) and verified there is no reported incident with Actions.`; issueBody += '\r\n\r\ncc @Expensify/applauseleads\r\n'; - return issueBody; + const issueAssignees = _.values(internalQAPRMap); + const issue = {issueBody, issueAssignees}; + return issue; }) .catch((err) => console.warn('Error generating StagingDeployCash issue body! Continuing...', err)); } diff --git a/tests/unit/GithubUtilsTest.ts b/tests/unit/GithubUtilsTest.ts index 794139286527..927234ff5c60 100644 --- a/tests/unit/GithubUtilsTest.ts +++ b/tests/unit/GithubUtilsTest.ts @@ -392,14 +392,8 @@ describe('GithubUtils', () => { color: 'f29513', }, ], - assignees: [ - { - login: 'octocat', - }, - { - login: 'hubot', - }, - ], + assignees: [], + merged_by: {login: 'hubot'}, }, ]; const mockGithub = jest.fn(() => ({ @@ -446,7 +440,8 @@ describe('GithubUtils', () => { const internalQAHeader = '\r\n\r\n**Internal QA:**'; const lineBreak = '\r\n'; const lineBreakDouble = '\r\n\r\n'; - const assignOctocatHubot = ' - @octocat @hubot'; + const assignOctocat = ' - @octocat'; + const assignHubot = ' - @hubot'; const deployerVerificationsHeader = '\r\n**Deployer verifications:**'; // eslint-disable-next-line max-len const timingDashboardVerification = @@ -468,8 +463,8 @@ describe('GithubUtils', () => { `${lineBreak}`; test('Test no verified PRs', () => { - githubUtils.generateStagingDeployCashBody(tag, basePRList).then((issueBody: string) => { - expect(issueBody).toBe( + githubUtils.generateStagingDeployCashBodyAndAssignees(tag, basePRList).then((issue) => { + expect(issue.issueBody).toBe( `${baseExpectedOutput}` + `${openCheckbox}${basePRList[2]}` + `${lineBreak}${openCheckbox}${basePRList[0]}` + @@ -482,12 +477,13 @@ describe('GithubUtils', () => { `${lineBreak}${openCheckbox}${ghVerification}` + `${lineBreakDouble}${ccApplauseLeads}`, ); + expect(issue.issueAssignees).toEqual([]); }); }); test('Test some verified PRs', () => { - githubUtils.generateStagingDeployCashBody(tag, basePRList, [basePRList[0]]).then((issueBody: string) => { - expect(issueBody).toBe( + githubUtils.generateStagingDeployCashBodyAndAssignees(tag, basePRList, [basePRList[0]]).then((issue) => { + expect(issue.issueBody).toBe( `${baseExpectedOutput}` + `${openCheckbox}${basePRList[2]}` + `${lineBreak}${closedCheckbox}${basePRList[0]}` + @@ -500,12 +496,13 @@ describe('GithubUtils', () => { `${lineBreak}${openCheckbox}${ghVerification}` + `${lineBreakDouble}${ccApplauseLeads}`, ); + expect(issue.issueAssignees).toEqual([]); }); }); test('Test all verified PRs', () => { - githubUtils.generateStagingDeployCashBody(tag, basePRList, basePRList).then((issueBody: string) => { - expect(issueBody).toBe( + githubUtils.generateStagingDeployCashBodyAndAssignees(tag, basePRList, basePRList).then((issue) => { + expect(issue.issueBody).toBe( `${allVerifiedExpectedOutput}` + `${lineBreak}${deployerVerificationsHeader}` + `${lineBreak}${openCheckbox}${timingDashboardVerification}` + @@ -513,12 +510,13 @@ describe('GithubUtils', () => { `${lineBreak}${openCheckbox}${ghVerification}` + `${lineBreakDouble}${ccApplauseLeads}`, ); + expect(issue.issueAssignees).toEqual([]); }); }); test('Test no resolved deploy blockers', () => { - githubUtils.generateStagingDeployCashBody(tag, basePRList, basePRList, baseDeployBlockerList).then((issueBody: string) => { - expect(issueBody).toBe( + githubUtils.generateStagingDeployCashBodyAndAssignees(tag, basePRList, basePRList, baseDeployBlockerList).then((issue) => { + expect(issue.issueBody).toBe( `${allVerifiedExpectedOutput}` + `${lineBreak}${deployBlockerHeader}` + `${lineBreak}${openCheckbox}${baseDeployBlockerList[0]}` + @@ -529,12 +527,13 @@ describe('GithubUtils', () => { `${lineBreak}${openCheckbox}${ghVerification}${lineBreak}` + `${lineBreak}${ccApplauseLeads}`, ); + expect(issue.issueAssignees).toEqual([]); }); }); test('Test some resolved deploy blockers', () => { - githubUtils.generateStagingDeployCashBody(tag, basePRList, basePRList, baseDeployBlockerList, [baseDeployBlockerList[0]]).then((issueBody: string) => { - expect(issueBody).toBe( + githubUtils.generateStagingDeployCashBodyAndAssignees(tag, basePRList, basePRList, baseDeployBlockerList, [baseDeployBlockerList[0]]).then((issue) => { + expect(issue.issueBody).toBe( `${allVerifiedExpectedOutput}` + `${lineBreak}${deployBlockerHeader}` + `${lineBreak}${closedCheckbox}${baseDeployBlockerList[0]}` + @@ -545,12 +544,13 @@ describe('GithubUtils', () => { `${lineBreak}${openCheckbox}${ghVerification}` + `${lineBreakDouble}${ccApplauseLeads}`, ); + expect(issue.issueAssignees).toEqual([]); }); }); test('Test all resolved deploy blockers', () => { - githubUtils.generateStagingDeployCashBody(tag, basePRList, basePRList, baseDeployBlockerList, baseDeployBlockerList).then((issueBody: string) => { - expect(issueBody).toBe( + githubUtils.generateStagingDeployCashBodyAndAssignees(tag, basePRList, basePRList, baseDeployBlockerList, baseDeployBlockerList).then((issue) => { + expect(issue.issueBody).toBe( `${baseExpectedOutput}` + `${closedCheckbox}${basePRList[2]}` + `${lineBreak}${closedCheckbox}${basePRList[0]}` + @@ -566,12 +566,13 @@ describe('GithubUtils', () => { `${lineBreak}${openCheckbox}${ghVerification}` + `${lineBreakDouble}${ccApplauseLeads}`, ); + expect(issue.issueAssignees).toEqual([]); }); }); test('Test internalQA PRs', () => { - githubUtils.generateStagingDeployCashBody(tag, [...basePRList, ...internalQAPRList]).then((issueBody: string) => { - expect(issueBody).toBe( + githubUtils.generateStagingDeployCashBodyAndAssignees(tag, [...basePRList, ...internalQAPRList]).then((issue) => { + expect(issue.issueBody).toBe( `${baseExpectedOutput}` + `${openCheckbox}${basePRList[2]}` + `${lineBreak}${openCheckbox}${basePRList[0]}` + @@ -579,20 +580,21 @@ describe('GithubUtils', () => { `${lineBreak}${closedCheckbox}${basePRList[4]}` + `${lineBreak}${closedCheckbox}${basePRList[5]}` + `${lineBreak}${internalQAHeader}` + - `${lineBreak}${openCheckbox}${internalQAPRList[0]}${assignOctocatHubot}` + - `${lineBreak}${openCheckbox}${internalQAPRList[1]}${assignOctocatHubot}` + + `${lineBreak}${openCheckbox}${internalQAPRList[0]}${assignOctocat}` + + `${lineBreak}${openCheckbox}${internalQAPRList[1]}${assignHubot}` + `${lineBreakDouble}${deployerVerificationsHeader}` + `${lineBreak}${openCheckbox}${timingDashboardVerification}` + `${lineBreak}${openCheckbox}${firebaseVerification}` + `${lineBreak}${openCheckbox}${ghVerification}` + `${lineBreakDouble}${ccApplauseLeads}`, ); + expect(issue.issueAssignees).toEqual(['octocat', 'hubot']); }); }); test('Test some verified internalQA PRs', () => { - githubUtils.generateStagingDeployCashBody(tag, [...basePRList, ...internalQAPRList], [], [], [], [internalQAPRList[0]]).then((issueBody: string) => { - expect(issueBody).toBe( + githubUtils.generateStagingDeployCashBodyAndAssignees(tag, [...basePRList, ...internalQAPRList], [], [], [], [internalQAPRList[0]]).then((issue) => { + expect(issue.issueBody).toBe( `${baseExpectedOutput}` + `${openCheckbox}${basePRList[2]}` + `${lineBreak}${openCheckbox}${basePRList[0]}` + @@ -600,14 +602,15 @@ describe('GithubUtils', () => { `${lineBreak}${closedCheckbox}${basePRList[4]}` + `${lineBreak}${closedCheckbox}${basePRList[5]}` + `${lineBreak}${internalQAHeader}` + - `${lineBreak}${closedCheckbox}${internalQAPRList[0]}${assignOctocatHubot}` + - `${lineBreak}${openCheckbox}${internalQAPRList[1]}${assignOctocatHubot}` + + `${lineBreak}${closedCheckbox}${internalQAPRList[0]}${assignOctocat}` + + `${lineBreak}${openCheckbox}${internalQAPRList[1]}${assignHubot}` + `${lineBreakDouble}${deployerVerificationsHeader}` + `${lineBreak}${openCheckbox}${timingDashboardVerification}` + `${lineBreak}${openCheckbox}${firebaseVerification}` + `${lineBreak}${openCheckbox}${ghVerification}` + `${lineBreakDouble}${ccApplauseLeads}`, ); + expect(issue.issueAssignees).toEqual(['octocat', 'hubot']); }); }); }); From b34367a1dc6dbf9e50730d20d6adef7d54b3ea67 Mon Sep 17 00:00:00 2001 From: rayane-djouah <77965000+rayane-djouah@users.noreply.github.com> Date: Sat, 16 Mar 2024 12:48:38 +0100 Subject: [PATCH 07/29] Fix error --- .github/libs/GithubUtils.js | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/.github/libs/GithubUtils.js b/.github/libs/GithubUtils.js index 2664c6399947..e14d343a5eac 100644 --- a/.github/libs/GithubUtils.js +++ b/.github/libs/GithubUtils.js @@ -256,14 +256,11 @@ class GithubUtils { const internalQAPRMap = _.reduce( _.filter(data, (pr) => !_.isEmpty(_.findWhere(pr.labels, {name: CONST.LABELS.INTERNAL_QA}))), (map, pr) => { - const {data: prData} = await GithubUtils.octokit.pulls.get({ - owner: CONST.GITHUB_OWNER, - repo: CONST.APP_REPO, - pull_number: pr.number, + this.getPullRequestMergerLogin(pr.number).then((mergerLogin) => { + // eslint-disable-next-line no-param-reassign + map[pr.html_url] = mergerLogin; + return map; }); - // eslint-disable-next-line no-param-reassign - map[pr.html_url] = prData.merged_by.login; - return map; }, {}, ); @@ -367,6 +364,20 @@ class GithubUtils { .catch((err) => console.error('Failed to get PR list', err)); } + /** + * @param {Number} pullRequestNumber + * @returns {Promise} + */ + static getPullRequestMergerLogin(pullRequestNumber) { + return this.octokit.pulls + .get({ + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, + pull_number: pullRequestNumber, + }) + .then(({data: pullRequest}) => pullRequest.merged_by.login); + } + /** * @param {Number} pullRequestNumber * @returns {Promise} From 33becded357f07041daf13e86f9a7d55069f9334 Mon Sep 17 00:00:00 2001 From: rayane-djouah <77965000+rayane-djouah@users.noreply.github.com> Date: Sat, 16 Mar 2024 13:59:17 +0100 Subject: [PATCH 08/29] Fix errors --- .github/libs/GithubUtils.js | 167 +++++++++++++++++----------------- tests/unit/GithubUtilsTest.ts | 25 ++--- 2 files changed, 94 insertions(+), 98 deletions(-) diff --git a/.github/libs/GithubUtils.js b/.github/libs/GithubUtils.js index e14d343a5eac..4e1981aceb4b 100644 --- a/.github/libs/GithubUtils.js +++ b/.github/libs/GithubUtils.js @@ -248,93 +248,94 @@ class GithubUtils { ) { return this.fetchAllPullRequests(_.map(PRList, this.getPullRequestNumberFromURL)) .then((data) => { - // The format of this map is following: - // { - // 'https://github.com/Expensify/App/pull/9641': 'PauloGasparSv', - // 'https://github.com/Expensify/App/pull/9642': 'mountiny' - // } - const internalQAPRMap = _.reduce( - _.filter(data, (pr) => !_.isEmpty(_.findWhere(pr.labels, {name: CONST.LABELS.INTERNAL_QA}))), - (map, pr) => { - this.getPullRequestMergerLogin(pr.number).then((mergerLogin) => { - // eslint-disable-next-line no-param-reassign - map[pr.html_url] = mergerLogin; - return map; + const internalQAPRs = data.filter((pr) => !_.isEmpty(_.findWhere(pr.labels, {name: CONST.LABELS.INTERNAL_QA}))); + return Promise.all( + internalQAPRs.map((pr) => { + return this.getPullRequestMergerLogin(pr.number).then((mergerLogin) => { + return {url: pr.html_url, mergerLogin}; }); - }, - {}, - ); - console.log('Found the following Internal QA PRs:', internalQAPRMap); - - const noQAPRs = _.pluck( - _.filter(data, (PR) => /\[No\s?QA]/i.test(PR.title)), - 'html_url', - ); - console.log('Found the following NO QA PRs:', noQAPRs); - const verifiedOrNoQAPRs = _.union(verifiedPRList, noQAPRs); - - const sortedPRList = _.chain(PRList).difference(_.keys(internalQAPRMap)).unique().sortBy(GithubUtils.getPullRequestNumberFromURL).value(); - const sortedDeployBlockers = _.sortBy(_.unique(deployBlockers), GithubUtils.getIssueOrPullRequestNumberFromURL); - - // Tag version and comparison URL - // eslint-disable-next-line max-len - let issueBody = `**Release Version:** \`${tag}\`\r\n**Compare Changes:** https://github.com/Expensify/App/compare/production...staging\r\n`; - - // PR list - if (!_.isEmpty(sortedPRList)) { - issueBody += '\r\n**This release contains changes from the following pull requests:**\r\n'; - _.each(sortedPRList, (URL) => { - issueBody += _.contains(verifiedOrNoQAPRs, URL) ? '- [x]' : '- [ ]'; - issueBody += ` ${URL}\r\n`; - }); - issueBody += '\r\n\r\n'; - } - - // Internal QA PR list - if (!_.isEmpty(internalQAPRMap)) { - console.log('Found the following verified Internal QA PRs:', resolvedInternalQAPRs); - issueBody += '**Internal QA:**\r\n'; - _.each(internalQAPRMap, (merger, URL) => { - const mergerMention = `@${merger}`; - issueBody += `${_.contains(resolvedInternalQAPRs, URL) ? '- [x]' : '- [ ]'} `; - issueBody += `${URL}`; - issueBody += ` - ${mergerMention}`; - issueBody += '\r\n'; - }); - issueBody += '\r\n\r\n'; - } - - // Deploy blockers - if (!_.isEmpty(deployBlockers)) { - issueBody += '**Deploy Blockers:**\r\n'; - _.each(sortedDeployBlockers, (URL) => { - issueBody += _.contains(resolvedDeployBlockers, URL) ? '- [x] ' : '- [ ] '; - issueBody += URL; - issueBody += '\r\n'; - }); - issueBody += '\r\n\r\n'; - } - - issueBody += '**Deployer verifications:**'; - // eslint-disable-next-line max-len - issueBody += `\r\n- [${ - isTimingDashboardChecked ? 'x' : ' ' - }] I checked the [App Timing Dashboard](https://graphs.expensify.com/grafana/d/yj2EobAGz/app-timing?orgId=1) and verified this release does not cause a noticeable performance regression.`; - // eslint-disable-next-line max-len - issueBody += `\r\n- [${ - isFirebaseChecked ? 'x' : ' ' - }] I checked [Firebase Crashlytics](https://console.firebase.google.com/u/0/project/expensify-chat/crashlytics/app/android:com.expensify.chat/issues?state=open&time=last-seven-days&tag=all) and verified that this release does not introduce any new crashes. More detailed instructions on this verification can be found [here](https://stackoverflowteams.com/c/expensify/questions/15095/15096).`; - // eslint-disable-next-line max-len - issueBody += `\r\n- [${isGHStatusChecked ? 'x' : ' '}] I checked [GitHub Status](https://www.githubstatus.com/) and verified there is no reported incident with Actions.`; - - issueBody += '\r\n\r\ncc @Expensify/applauseleads\r\n'; - const issueAssignees = _.values(internalQAPRMap); - const issue = {issueBody, issueAssignees}; - return issue; + }), + ).then((results) => { + // The format of this map is following: + // { + // 'https://github.com/Expensify/App/pull/9641': 'PauloGasparSv', + // 'https://github.com/Expensify/App/pull/9642': 'mountiny' + // } + const internalQAPRMap = results.reduce((map, {url, mergerLogin}) => { + map[url] = mergerLogin; + return map; + }, {}); + console.log('Found the following Internal QA PRs:', internalQAPRMap); + + const noQAPRs = _.pluck( + _.filter(data, (PR) => /\[No\s?QA]/i.test(PR.title)), + 'html_url', + ); + console.log('Found the following NO QA PRs:', noQAPRs); + const verifiedOrNoQAPRs = _.union(verifiedPRList, noQAPRs); + + const sortedPRList = _.chain(PRList).difference(_.keys(internalQAPRMap)).unique().sortBy(GithubUtils.getPullRequestNumberFromURL).value(); + const sortedDeployBlockers = _.sortBy(_.unique(deployBlockers), GithubUtils.getIssueOrPullRequestNumberFromURL); + + // Tag version and comparison URL + // eslint-disable-next-line max-len + let issueBody = `**Release Version:** \`${tag}\`\r\n**Compare Changes:** https://github.com/Expensify/App/compare/production...staging\r\n`; + + // PR list + if (!_.isEmpty(sortedPRList)) { + issueBody += '\r\n**This release contains changes from the following pull requests:**\r\n'; + _.each(sortedPRList, (URL) => { + issueBody += _.contains(verifiedOrNoQAPRs, URL) ? '- [x]' : '- [ ]'; + issueBody += ` ${URL}\r\n`; + }); + issueBody += '\r\n\r\n'; + } + + // Internal QA PR list + if (!_.isEmpty(internalQAPRMap)) { + console.log('Found the following verified Internal QA PRs:', resolvedInternalQAPRs); + issueBody += '**Internal QA:**\r\n'; + _.each(internalQAPRMap, (merger, URL) => { + const mergerMention = `@${merger}`; + issueBody += `${_.contains(resolvedInternalQAPRs, URL) ? '- [x]' : '- [ ]'} `; + issueBody += `${URL}`; + issueBody += ` - ${mergerMention}`; + issueBody += '\r\n'; + }); + issueBody += '\r\n\r\n'; + } + + // Deploy blockers + if (!_.isEmpty(deployBlockers)) { + issueBody += '**Deploy Blockers:**\r\n'; + _.each(sortedDeployBlockers, (URL) => { + issueBody += _.contains(resolvedDeployBlockers, URL) ? '- [x] ' : '- [ ] '; + issueBody += URL; + issueBody += '\r\n'; + }); + issueBody += '\r\n\r\n'; + } + + issueBody += '**Deployer verifications:**'; + // eslint-disable-next-line max-len + issueBody += `\r\n- [${ + isTimingDashboardChecked ? 'x' : ' ' + }] I checked the [App Timing Dashboard](https://graphs.expensify.com/grafana/d/yj2EobAGz/app-timing?orgId=1) and verified this release does not cause a noticeable performance regression.`; + // eslint-disable-next-line max-len + issueBody += `\r\n- [${ + isFirebaseChecked ? 'x' : ' ' + }] I checked [Firebase Crashlytics](https://console.firebase.google.com/u/0/project/expensify-chat/crashlytics/app/android:com.expensify.chat/issues?state=open&time=last-seven-days&tag=all) and verified that this release does not introduce any new crashes. More detailed instructions on this verification can be found [here](https://stackoverflowteams.com/c/expensify/questions/15095/15096).`; + // eslint-disable-next-line max-len + issueBody += `\r\n- [${isGHStatusChecked ? 'x' : ' '}] I checked [GitHub Status](https://www.githubstatus.com/) and verified there is no reported incident with Actions.`; + + issueBody += '\r\n\r\ncc @Expensify/applauseleads\r\n'; + const issueAssignees = _.uniq(_.values(internalQAPRMap)); + const issue = {issueBody, issueAssignees}; + return issue; + }); }) .catch((err) => console.warn('Error generating StagingDeployCash issue body! Continuing...', err)); } - /** * Fetch all pull requests given a list of PR numbers. * diff --git a/tests/unit/GithubUtilsTest.ts b/tests/unit/GithubUtilsTest.ts index 927234ff5c60..8267b26d3d0f 100644 --- a/tests/unit/GithubUtilsTest.ts +++ b/tests/unit/GithubUtilsTest.ts @@ -355,7 +355,7 @@ describe('GithubUtils', () => { }, { number: 6, - title: '[Internal QA] Test Internal QA PR', + title: '[Internal QA] Another Test Internal QA PR', html_url: 'https://github.com/Expensify/App/pull/6', user: {login: 'testUser'}, labels: [ @@ -368,14 +368,7 @@ describe('GithubUtils', () => { color: 'f29513', }, ], - assignees: [ - { - login: 'octocat', - }, - { - login: 'hubot', - }, - ], + assignees: [], }, { number: 7, @@ -393,9 +386,11 @@ describe('GithubUtils', () => { }, ], assignees: [], - merged_by: {login: 'hubot'}, }, ]; + const mockInternalQaPR = { + merged_by: {login: 'octocat'}, + }; const mockGithub = jest.fn(() => ({ getOctokit: () => ({ rest: { @@ -404,6 +399,7 @@ describe('GithubUtils', () => { }, pulls: { list: jest.fn().mockResolvedValue({data: mockPRs}), + get: jest.fn().mockResolvedValue({data: mockInternalQaPR}), }, }, paginate: jest.fn().mockImplementation((objectMethod: () => Promise>) => objectMethod().then(({data}) => data)), @@ -441,7 +437,6 @@ describe('GithubUtils', () => { const lineBreak = '\r\n'; const lineBreakDouble = '\r\n\r\n'; const assignOctocat = ' - @octocat'; - const assignHubot = ' - @hubot'; const deployerVerificationsHeader = '\r\n**Deployer verifications:**'; // eslint-disable-next-line max-len const timingDashboardVerification = @@ -581,14 +576,14 @@ describe('GithubUtils', () => { `${lineBreak}${closedCheckbox}${basePRList[5]}` + `${lineBreak}${internalQAHeader}` + `${lineBreak}${openCheckbox}${internalQAPRList[0]}${assignOctocat}` + - `${lineBreak}${openCheckbox}${internalQAPRList[1]}${assignHubot}` + + `${lineBreak}${openCheckbox}${internalQAPRList[1]}${assignOctocat}` + `${lineBreakDouble}${deployerVerificationsHeader}` + `${lineBreak}${openCheckbox}${timingDashboardVerification}` + `${lineBreak}${openCheckbox}${firebaseVerification}` + `${lineBreak}${openCheckbox}${ghVerification}` + `${lineBreakDouble}${ccApplauseLeads}`, ); - expect(issue.issueAssignees).toEqual(['octocat', 'hubot']); + expect(issue.issueAssignees).toEqual(['octocat']); }); }); @@ -603,14 +598,14 @@ describe('GithubUtils', () => { `${lineBreak}${closedCheckbox}${basePRList[5]}` + `${lineBreak}${internalQAHeader}` + `${lineBreak}${closedCheckbox}${internalQAPRList[0]}${assignOctocat}` + - `${lineBreak}${openCheckbox}${internalQAPRList[1]}${assignHubot}` + + `${lineBreak}${openCheckbox}${internalQAPRList[1]}${assignOctocat}` + `${lineBreakDouble}${deployerVerificationsHeader}` + `${lineBreak}${openCheckbox}${timingDashboardVerification}` + `${lineBreak}${openCheckbox}${firebaseVerification}` + `${lineBreak}${openCheckbox}${ghVerification}` + `${lineBreakDouble}${ccApplauseLeads}`, ); - expect(issue.issueAssignees).toEqual(['octocat', 'hubot']); + expect(issue.issueAssignees).toEqual(['octocat']); }); }); }); From 3485ea7213872058efb0b828b5cbdda3ce74895e Mon Sep 17 00:00:00 2001 From: rayane-djouah <77965000+rayane-djouah@users.noreply.github.com> Date: Sat, 16 Mar 2024 14:15:05 +0100 Subject: [PATCH 09/29] Fix lint errors --- .github/libs/GithubUtils.js | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/.github/libs/GithubUtils.js b/.github/libs/GithubUtils.js index 4e1981aceb4b..637cca1cab61 100644 --- a/.github/libs/GithubUtils.js +++ b/.github/libs/GithubUtils.js @@ -248,20 +248,15 @@ class GithubUtils { ) { return this.fetchAllPullRequests(_.map(PRList, this.getPullRequestNumberFromURL)) .then((data) => { - const internalQAPRs = data.filter((pr) => !_.isEmpty(_.findWhere(pr.labels, {name: CONST.LABELS.INTERNAL_QA}))); - return Promise.all( - internalQAPRs.map((pr) => { - return this.getPullRequestMergerLogin(pr.number).then((mergerLogin) => { - return {url: pr.html_url, mergerLogin}; - }); - }), - ).then((results) => { + const internalQAPRs = _.filter(data, (pr) => !_.isEmpty(_.findWhere(pr.labels, {name: CONST.LABELS.INTERNAL_QA}))); + return Promise.all(_.map(internalQAPRs, (pr) => this.getPullRequestMergerLogin(pr.number).then((mergerLogin) => ({url: pr.html_url, mergerLogin})))).then((results) => { // The format of this map is following: // { // 'https://github.com/Expensify/App/pull/9641': 'PauloGasparSv', // 'https://github.com/Expensify/App/pull/9642': 'mountiny' // } - const internalQAPRMap = results.reduce((map, {url, mergerLogin}) => { + const internalQAPRMap = results.reduce((acc, {url, mergerLogin}) => { + const map = {...acc}; map[url] = mergerLogin; return map; }, {}); From 6f3a4ed3c91c843d845c1b3780c08a41da2029bd Mon Sep 17 00:00:00 2001 From: rayane-djouah <77965000+rayane-djouah@users.noreply.github.com> Date: Sat, 16 Mar 2024 14:30:08 +0100 Subject: [PATCH 10/29] Fix lint errors --- .github/libs/GithubUtils.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/.github/libs/GithubUtils.js b/.github/libs/GithubUtils.js index 637cca1cab61..47ad2440c165 100644 --- a/.github/libs/GithubUtils.js +++ b/.github/libs/GithubUtils.js @@ -255,11 +255,14 @@ class GithubUtils { // 'https://github.com/Expensify/App/pull/9641': 'PauloGasparSv', // 'https://github.com/Expensify/App/pull/9642': 'mountiny' // } - const internalQAPRMap = results.reduce((acc, {url, mergerLogin}) => { - const map = {...acc}; - map[url] = mergerLogin; - return map; - }, {}); + const internalQAPRMap = _.reduce( + results, + (acc, {url, mergerLogin}) => { + acc[url] = mergerLogin; + return acc; + }, + {}, + ); console.log('Found the following Internal QA PRs:', internalQAPRMap); const noQAPRs = _.pluck( @@ -331,6 +334,7 @@ class GithubUtils { }) .catch((err) => console.warn('Error generating StagingDeployCash issue body! Continuing...', err)); } + /** * Fetch all pull requests given a list of PR numbers. * From 56b09262497812f319d99013bc61f952ac48ba1f Mon Sep 17 00:00:00 2001 From: rayane-djouah <77965000+rayane-djouah@users.noreply.github.com> Date: Sat, 16 Mar 2024 15:08:49 +0100 Subject: [PATCH 11/29] Build Actions --- .../javascript/awaitStagingDeploys/index.js | 174 ++++++++++-------- .../javascript/checkDeployBlockers/index.js | 174 ++++++++++-------- .../javascript/getArtifactInfo/index.js | 174 ++++++++++-------- .../javascript/getPullRequestDetails/index.js | 174 ++++++++++-------- .../javascript/getReleaseBody/index.js | 174 ++++++++++-------- .../javascript/isStagingDeployLocked/index.js | 174 ++++++++++-------- .../markPullRequestsAsDeployed/index.js | 174 ++++++++++-------- .../javascript/postTestBuildComment/index.js | 174 ++++++++++-------- .../reopenIssueWithComment/index.js | 174 ++++++++++-------- .../javascript/reviewerChecklist/index.js | 174 ++++++++++-------- .../javascript/verifySignedCommits/index.js | 174 ++++++++++-------- 11 files changed, 1056 insertions(+), 858 deletions(-) diff --git a/.github/actions/javascript/awaitStagingDeploys/index.js b/.github/actions/javascript/awaitStagingDeploys/index.js index f042dbb38a91..6b8401a08d6d 100644 --- a/.github/actions/javascript/awaitStagingDeploys/index.js +++ b/.github/actions/javascript/awaitStagingDeploys/index.js @@ -367,7 +367,7 @@ class GithubUtils { } /** - * Generate the issue body for a StagingDeployCash. + * Generate the issue body and assignees for a StagingDeployCash. * * @param {String} tag * @param {Array} PRList - The list of PR URLs which are included in this StagingDeployCash @@ -380,7 +380,7 @@ class GithubUtils { * @param {Boolean} [isGHStatusChecked] * @returns {Promise} */ - static generateStagingDeployCashBody( + static generateStagingDeployCashBodyAndAssignees( tag, PRList, verifiedPRList = [], @@ -393,85 +393,89 @@ class GithubUtils { ) { return this.fetchAllPullRequests(_.map(PRList, this.getPullRequestNumberFromURL)) .then((data) => { - // The format of this map is following: - // { - // 'https://github.com/Expensify/App/pull/9641': [ 'PauloGasparSv', 'kidroca' ], - // 'https://github.com/Expensify/App/pull/9642': [ 'mountiny', 'kidroca' ] - // } - const internalQAPRMap = _.reduce( - _.filter(data, (pr) => !_.isEmpty(_.findWhere(pr.labels, {name: CONST.LABELS.INTERNAL_QA}))), - (map, pr) => { - // eslint-disable-next-line no-param-reassign - map[pr.html_url] = _.compact(_.pluck(pr.assignees, 'login')); - return map; - }, - {}, - ); - console.log('Found the following Internal QA PRs:', internalQAPRMap); - - const noQAPRs = _.pluck( - _.filter(data, (PR) => /\[No\s?QA]/i.test(PR.title)), - 'html_url', - ); - console.log('Found the following NO QA PRs:', noQAPRs); - const verifiedOrNoQAPRs = _.union(verifiedPRList, noQAPRs); - - const sortedPRList = _.chain(PRList).difference(_.keys(internalQAPRMap)).unique().sortBy(GithubUtils.getPullRequestNumberFromURL).value(); - const sortedDeployBlockers = _.sortBy(_.unique(deployBlockers), GithubUtils.getIssueOrPullRequestNumberFromURL); - - // Tag version and comparison URL - // eslint-disable-next-line max-len - let issueBody = `**Release Version:** \`${tag}\`\r\n**Compare Changes:** https://github.com/Expensify/App/compare/production...staging\r\n`; - - // PR list - if (!_.isEmpty(sortedPRList)) { - issueBody += '\r\n**This release contains changes from the following pull requests:**\r\n'; - _.each(sortedPRList, (URL) => { - issueBody += _.contains(verifiedOrNoQAPRs, URL) ? '- [x]' : '- [ ]'; - issueBody += ` ${URL}\r\n`; - }); - issueBody += '\r\n\r\n'; - } + const internalQAPRs = _.filter(data, (pr) => !_.isEmpty(_.findWhere(pr.labels, {name: CONST.LABELS.INTERNAL_QA}))); + return Promise.all(_.map(internalQAPRs, (pr) => this.getPullRequestMergerLogin(pr.number).then((mergerLogin) => ({url: pr.html_url, mergerLogin})))).then((results) => { + // The format of this map is following: + // { + // 'https://github.com/Expensify/App/pull/9641': 'PauloGasparSv', + // 'https://github.com/Expensify/App/pull/9642': 'mountiny' + // } + const internalQAPRMap = _.reduce( + results, + (acc, {url, mergerLogin}) => { + acc[url] = mergerLogin; + return acc; + }, + {}, + ); + console.log('Found the following Internal QA PRs:', internalQAPRMap); + + const noQAPRs = _.pluck( + _.filter(data, (PR) => /\[No\s?QA]/i.test(PR.title)), + 'html_url', + ); + console.log('Found the following NO QA PRs:', noQAPRs); + const verifiedOrNoQAPRs = _.union(verifiedPRList, noQAPRs); + + const sortedPRList = _.chain(PRList).difference(_.keys(internalQAPRMap)).unique().sortBy(GithubUtils.getPullRequestNumberFromURL).value(); + const sortedDeployBlockers = _.sortBy(_.unique(deployBlockers), GithubUtils.getIssueOrPullRequestNumberFromURL); + + // Tag version and comparison URL + // eslint-disable-next-line max-len + let issueBody = `**Release Version:** \`${tag}\`\r\n**Compare Changes:** https://github.com/Expensify/App/compare/production...staging\r\n`; + + // PR list + if (!_.isEmpty(sortedPRList)) { + issueBody += '\r\n**This release contains changes from the following pull requests:**\r\n'; + _.each(sortedPRList, (URL) => { + issueBody += _.contains(verifiedOrNoQAPRs, URL) ? '- [x]' : '- [ ]'; + issueBody += ` ${URL}\r\n`; + }); + issueBody += '\r\n\r\n'; + } - // Internal QA PR list - if (!_.isEmpty(internalQAPRMap)) { - console.log('Found the following verified Internal QA PRs:', resolvedInternalQAPRs); - issueBody += '**Internal QA:**\r\n'; - _.each(internalQAPRMap, (assignees, URL) => { - const assigneeMentions = _.reduce(assignees, (memo, assignee) => `${memo} @${assignee}`, ''); - issueBody += `${_.contains(resolvedInternalQAPRs, URL) ? '- [x]' : '- [ ]'} `; - issueBody += `${URL}`; - issueBody += ` -${assigneeMentions}`; - issueBody += '\r\n'; - }); - issueBody += '\r\n\r\n'; - } + // Internal QA PR list + if (!_.isEmpty(internalQAPRMap)) { + console.log('Found the following verified Internal QA PRs:', resolvedInternalQAPRs); + issueBody += '**Internal QA:**\r\n'; + _.each(internalQAPRMap, (merger, URL) => { + const mergerMention = `@${merger}`; + issueBody += `${_.contains(resolvedInternalQAPRs, URL) ? '- [x]' : '- [ ]'} `; + issueBody += `${URL}`; + issueBody += ` - ${mergerMention}`; + issueBody += '\r\n'; + }); + issueBody += '\r\n\r\n'; + } - // Deploy blockers - if (!_.isEmpty(deployBlockers)) { - issueBody += '**Deploy Blockers:**\r\n'; - _.each(sortedDeployBlockers, (URL) => { - issueBody += _.contains(resolvedDeployBlockers, URL) ? '- [x] ' : '- [ ] '; - issueBody += URL; - issueBody += '\r\n'; - }); - issueBody += '\r\n\r\n'; - } + // Deploy blockers + if (!_.isEmpty(deployBlockers)) { + issueBody += '**Deploy Blockers:**\r\n'; + _.each(sortedDeployBlockers, (URL) => { + issueBody += _.contains(resolvedDeployBlockers, URL) ? '- [x] ' : '- [ ] '; + issueBody += URL; + issueBody += '\r\n'; + }); + issueBody += '\r\n\r\n'; + } - issueBody += '**Deployer verifications:**'; - // eslint-disable-next-line max-len - issueBody += `\r\n- [${ - isTimingDashboardChecked ? 'x' : ' ' - }] I checked the [App Timing Dashboard](https://graphs.expensify.com/grafana/d/yj2EobAGz/app-timing?orgId=1) and verified this release does not cause a noticeable performance regression.`; - // eslint-disable-next-line max-len - issueBody += `\r\n- [${ - isFirebaseChecked ? 'x' : ' ' - }] I checked [Firebase Crashlytics](https://console.firebase.google.com/u/0/project/expensify-chat/crashlytics/app/android:com.expensify.chat/issues?state=open&time=last-seven-days&tag=all) and verified that this release does not introduce any new crashes. More detailed instructions on this verification can be found [here](https://stackoverflowteams.com/c/expensify/questions/15095/15096).`; - // eslint-disable-next-line max-len - issueBody += `\r\n- [${isGHStatusChecked ? 'x' : ' '}] I checked [GitHub Status](https://www.githubstatus.com/) and verified there is no reported incident with Actions.`; - - issueBody += '\r\n\r\ncc @Expensify/applauseleads\r\n'; - return issueBody; + issueBody += '**Deployer verifications:**'; + // eslint-disable-next-line max-len + issueBody += `\r\n- [${ + isTimingDashboardChecked ? 'x' : ' ' + }] I checked the [App Timing Dashboard](https://graphs.expensify.com/grafana/d/yj2EobAGz/app-timing?orgId=1) and verified this release does not cause a noticeable performance regression.`; + // eslint-disable-next-line max-len + issueBody += `\r\n- [${ + isFirebaseChecked ? 'x' : ' ' + }] I checked [Firebase Crashlytics](https://console.firebase.google.com/u/0/project/expensify-chat/crashlytics/app/android:com.expensify.chat/issues?state=open&time=last-seven-days&tag=all) and verified that this release does not introduce any new crashes. More detailed instructions on this verification can be found [here](https://stackoverflowteams.com/c/expensify/questions/15095/15096).`; + // eslint-disable-next-line max-len + issueBody += `\r\n- [${isGHStatusChecked ? 'x' : ' '}] I checked [GitHub Status](https://www.githubstatus.com/) and verified there is no reported incident with Actions.`; + + issueBody += '\r\n\r\ncc @Expensify/applauseleads\r\n'; + const issueAssignees = _.uniq(_.values(internalQAPRMap)); + const issue = {issueBody, issueAssignees}; + return issue; + }); }) .catch((err) => console.warn('Error generating StagingDeployCash issue body! Continuing...', err)); } @@ -505,6 +509,20 @@ class GithubUtils { .catch((err) => console.error('Failed to get PR list', err)); } + /** + * @param {Number} pullRequestNumber + * @returns {Promise} + */ + static getPullRequestMergerLogin(pullRequestNumber) { + return this.octokit.pulls + .get({ + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, + pull_number: pullRequestNumber, + }) + .then(({data: pullRequest}) => pullRequest.merged_by.login); + } + /** * @param {Number} pullRequestNumber * @returns {Promise} diff --git a/.github/actions/javascript/checkDeployBlockers/index.js b/.github/actions/javascript/checkDeployBlockers/index.js index 8e10f8b1d8b6..dffc089ea5c5 100644 --- a/.github/actions/javascript/checkDeployBlockers/index.js +++ b/.github/actions/javascript/checkDeployBlockers/index.js @@ -334,7 +334,7 @@ class GithubUtils { } /** - * Generate the issue body for a StagingDeployCash. + * Generate the issue body and assignees for a StagingDeployCash. * * @param {String} tag * @param {Array} PRList - The list of PR URLs which are included in this StagingDeployCash @@ -347,7 +347,7 @@ class GithubUtils { * @param {Boolean} [isGHStatusChecked] * @returns {Promise} */ - static generateStagingDeployCashBody( + static generateStagingDeployCashBodyAndAssignees( tag, PRList, verifiedPRList = [], @@ -360,85 +360,89 @@ class GithubUtils { ) { return this.fetchAllPullRequests(_.map(PRList, this.getPullRequestNumberFromURL)) .then((data) => { - // The format of this map is following: - // { - // 'https://github.com/Expensify/App/pull/9641': [ 'PauloGasparSv', 'kidroca' ], - // 'https://github.com/Expensify/App/pull/9642': [ 'mountiny', 'kidroca' ] - // } - const internalQAPRMap = _.reduce( - _.filter(data, (pr) => !_.isEmpty(_.findWhere(pr.labels, {name: CONST.LABELS.INTERNAL_QA}))), - (map, pr) => { - // eslint-disable-next-line no-param-reassign - map[pr.html_url] = _.compact(_.pluck(pr.assignees, 'login')); - return map; - }, - {}, - ); - console.log('Found the following Internal QA PRs:', internalQAPRMap); - - const noQAPRs = _.pluck( - _.filter(data, (PR) => /\[No\s?QA]/i.test(PR.title)), - 'html_url', - ); - console.log('Found the following NO QA PRs:', noQAPRs); - const verifiedOrNoQAPRs = _.union(verifiedPRList, noQAPRs); - - const sortedPRList = _.chain(PRList).difference(_.keys(internalQAPRMap)).unique().sortBy(GithubUtils.getPullRequestNumberFromURL).value(); - const sortedDeployBlockers = _.sortBy(_.unique(deployBlockers), GithubUtils.getIssueOrPullRequestNumberFromURL); - - // Tag version and comparison URL - // eslint-disable-next-line max-len - let issueBody = `**Release Version:** \`${tag}\`\r\n**Compare Changes:** https://github.com/Expensify/App/compare/production...staging\r\n`; - - // PR list - if (!_.isEmpty(sortedPRList)) { - issueBody += '\r\n**This release contains changes from the following pull requests:**\r\n'; - _.each(sortedPRList, (URL) => { - issueBody += _.contains(verifiedOrNoQAPRs, URL) ? '- [x]' : '- [ ]'; - issueBody += ` ${URL}\r\n`; - }); - issueBody += '\r\n\r\n'; - } + const internalQAPRs = _.filter(data, (pr) => !_.isEmpty(_.findWhere(pr.labels, {name: CONST.LABELS.INTERNAL_QA}))); + return Promise.all(_.map(internalQAPRs, (pr) => this.getPullRequestMergerLogin(pr.number).then((mergerLogin) => ({url: pr.html_url, mergerLogin})))).then((results) => { + // The format of this map is following: + // { + // 'https://github.com/Expensify/App/pull/9641': 'PauloGasparSv', + // 'https://github.com/Expensify/App/pull/9642': 'mountiny' + // } + const internalQAPRMap = _.reduce( + results, + (acc, {url, mergerLogin}) => { + acc[url] = mergerLogin; + return acc; + }, + {}, + ); + console.log('Found the following Internal QA PRs:', internalQAPRMap); + + const noQAPRs = _.pluck( + _.filter(data, (PR) => /\[No\s?QA]/i.test(PR.title)), + 'html_url', + ); + console.log('Found the following NO QA PRs:', noQAPRs); + const verifiedOrNoQAPRs = _.union(verifiedPRList, noQAPRs); + + const sortedPRList = _.chain(PRList).difference(_.keys(internalQAPRMap)).unique().sortBy(GithubUtils.getPullRequestNumberFromURL).value(); + const sortedDeployBlockers = _.sortBy(_.unique(deployBlockers), GithubUtils.getIssueOrPullRequestNumberFromURL); + + // Tag version and comparison URL + // eslint-disable-next-line max-len + let issueBody = `**Release Version:** \`${tag}\`\r\n**Compare Changes:** https://github.com/Expensify/App/compare/production...staging\r\n`; + + // PR list + if (!_.isEmpty(sortedPRList)) { + issueBody += '\r\n**This release contains changes from the following pull requests:**\r\n'; + _.each(sortedPRList, (URL) => { + issueBody += _.contains(verifiedOrNoQAPRs, URL) ? '- [x]' : '- [ ]'; + issueBody += ` ${URL}\r\n`; + }); + issueBody += '\r\n\r\n'; + } - // Internal QA PR list - if (!_.isEmpty(internalQAPRMap)) { - console.log('Found the following verified Internal QA PRs:', resolvedInternalQAPRs); - issueBody += '**Internal QA:**\r\n'; - _.each(internalQAPRMap, (assignees, URL) => { - const assigneeMentions = _.reduce(assignees, (memo, assignee) => `${memo} @${assignee}`, ''); - issueBody += `${_.contains(resolvedInternalQAPRs, URL) ? '- [x]' : '- [ ]'} `; - issueBody += `${URL}`; - issueBody += ` -${assigneeMentions}`; - issueBody += '\r\n'; - }); - issueBody += '\r\n\r\n'; - } + // Internal QA PR list + if (!_.isEmpty(internalQAPRMap)) { + console.log('Found the following verified Internal QA PRs:', resolvedInternalQAPRs); + issueBody += '**Internal QA:**\r\n'; + _.each(internalQAPRMap, (merger, URL) => { + const mergerMention = `@${merger}`; + issueBody += `${_.contains(resolvedInternalQAPRs, URL) ? '- [x]' : '- [ ]'} `; + issueBody += `${URL}`; + issueBody += ` - ${mergerMention}`; + issueBody += '\r\n'; + }); + issueBody += '\r\n\r\n'; + } - // Deploy blockers - if (!_.isEmpty(deployBlockers)) { - issueBody += '**Deploy Blockers:**\r\n'; - _.each(sortedDeployBlockers, (URL) => { - issueBody += _.contains(resolvedDeployBlockers, URL) ? '- [x] ' : '- [ ] '; - issueBody += URL; - issueBody += '\r\n'; - }); - issueBody += '\r\n\r\n'; - } + // Deploy blockers + if (!_.isEmpty(deployBlockers)) { + issueBody += '**Deploy Blockers:**\r\n'; + _.each(sortedDeployBlockers, (URL) => { + issueBody += _.contains(resolvedDeployBlockers, URL) ? '- [x] ' : '- [ ] '; + issueBody += URL; + issueBody += '\r\n'; + }); + issueBody += '\r\n\r\n'; + } - issueBody += '**Deployer verifications:**'; - // eslint-disable-next-line max-len - issueBody += `\r\n- [${ - isTimingDashboardChecked ? 'x' : ' ' - }] I checked the [App Timing Dashboard](https://graphs.expensify.com/grafana/d/yj2EobAGz/app-timing?orgId=1) and verified this release does not cause a noticeable performance regression.`; - // eslint-disable-next-line max-len - issueBody += `\r\n- [${ - isFirebaseChecked ? 'x' : ' ' - }] I checked [Firebase Crashlytics](https://console.firebase.google.com/u/0/project/expensify-chat/crashlytics/app/android:com.expensify.chat/issues?state=open&time=last-seven-days&tag=all) and verified that this release does not introduce any new crashes. More detailed instructions on this verification can be found [here](https://stackoverflowteams.com/c/expensify/questions/15095/15096).`; - // eslint-disable-next-line max-len - issueBody += `\r\n- [${isGHStatusChecked ? 'x' : ' '}] I checked [GitHub Status](https://www.githubstatus.com/) and verified there is no reported incident with Actions.`; - - issueBody += '\r\n\r\ncc @Expensify/applauseleads\r\n'; - return issueBody; + issueBody += '**Deployer verifications:**'; + // eslint-disable-next-line max-len + issueBody += `\r\n- [${ + isTimingDashboardChecked ? 'x' : ' ' + }] I checked the [App Timing Dashboard](https://graphs.expensify.com/grafana/d/yj2EobAGz/app-timing?orgId=1) and verified this release does not cause a noticeable performance regression.`; + // eslint-disable-next-line max-len + issueBody += `\r\n- [${ + isFirebaseChecked ? 'x' : ' ' + }] I checked [Firebase Crashlytics](https://console.firebase.google.com/u/0/project/expensify-chat/crashlytics/app/android:com.expensify.chat/issues?state=open&time=last-seven-days&tag=all) and verified that this release does not introduce any new crashes. More detailed instructions on this verification can be found [here](https://stackoverflowteams.com/c/expensify/questions/15095/15096).`; + // eslint-disable-next-line max-len + issueBody += `\r\n- [${isGHStatusChecked ? 'x' : ' '}] I checked [GitHub Status](https://www.githubstatus.com/) and verified there is no reported incident with Actions.`; + + issueBody += '\r\n\r\ncc @Expensify/applauseleads\r\n'; + const issueAssignees = _.uniq(_.values(internalQAPRMap)); + const issue = {issueBody, issueAssignees}; + return issue; + }); }) .catch((err) => console.warn('Error generating StagingDeployCash issue body! Continuing...', err)); } @@ -472,6 +476,20 @@ class GithubUtils { .catch((err) => console.error('Failed to get PR list', err)); } + /** + * @param {Number} pullRequestNumber + * @returns {Promise} + */ + static getPullRequestMergerLogin(pullRequestNumber) { + return this.octokit.pulls + .get({ + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, + pull_number: pullRequestNumber, + }) + .then(({data: pullRequest}) => pullRequest.merged_by.login); + } + /** * @param {Number} pullRequestNumber * @returns {Promise} diff --git a/.github/actions/javascript/getArtifactInfo/index.js b/.github/actions/javascript/getArtifactInfo/index.js index ea56ff5f4ebd..b8cb062feba5 100644 --- a/.github/actions/javascript/getArtifactInfo/index.js +++ b/.github/actions/javascript/getArtifactInfo/index.js @@ -293,7 +293,7 @@ class GithubUtils { } /** - * Generate the issue body for a StagingDeployCash. + * Generate the issue body and assignees for a StagingDeployCash. * * @param {String} tag * @param {Array} PRList - The list of PR URLs which are included in this StagingDeployCash @@ -306,7 +306,7 @@ class GithubUtils { * @param {Boolean} [isGHStatusChecked] * @returns {Promise} */ - static generateStagingDeployCashBody( + static generateStagingDeployCashBodyAndAssignees( tag, PRList, verifiedPRList = [], @@ -319,85 +319,89 @@ class GithubUtils { ) { return this.fetchAllPullRequests(_.map(PRList, this.getPullRequestNumberFromURL)) .then((data) => { - // The format of this map is following: - // { - // 'https://github.com/Expensify/App/pull/9641': [ 'PauloGasparSv', 'kidroca' ], - // 'https://github.com/Expensify/App/pull/9642': [ 'mountiny', 'kidroca' ] - // } - const internalQAPRMap = _.reduce( - _.filter(data, (pr) => !_.isEmpty(_.findWhere(pr.labels, {name: CONST.LABELS.INTERNAL_QA}))), - (map, pr) => { - // eslint-disable-next-line no-param-reassign - map[pr.html_url] = _.compact(_.pluck(pr.assignees, 'login')); - return map; - }, - {}, - ); - console.log('Found the following Internal QA PRs:', internalQAPRMap); - - const noQAPRs = _.pluck( - _.filter(data, (PR) => /\[No\s?QA]/i.test(PR.title)), - 'html_url', - ); - console.log('Found the following NO QA PRs:', noQAPRs); - const verifiedOrNoQAPRs = _.union(verifiedPRList, noQAPRs); - - const sortedPRList = _.chain(PRList).difference(_.keys(internalQAPRMap)).unique().sortBy(GithubUtils.getPullRequestNumberFromURL).value(); - const sortedDeployBlockers = _.sortBy(_.unique(deployBlockers), GithubUtils.getIssueOrPullRequestNumberFromURL); - - // Tag version and comparison URL - // eslint-disable-next-line max-len - let issueBody = `**Release Version:** \`${tag}\`\r\n**Compare Changes:** https://github.com/Expensify/App/compare/production...staging\r\n`; - - // PR list - if (!_.isEmpty(sortedPRList)) { - issueBody += '\r\n**This release contains changes from the following pull requests:**\r\n'; - _.each(sortedPRList, (URL) => { - issueBody += _.contains(verifiedOrNoQAPRs, URL) ? '- [x]' : '- [ ]'; - issueBody += ` ${URL}\r\n`; - }); - issueBody += '\r\n\r\n'; - } + const internalQAPRs = _.filter(data, (pr) => !_.isEmpty(_.findWhere(pr.labels, {name: CONST.LABELS.INTERNAL_QA}))); + return Promise.all(_.map(internalQAPRs, (pr) => this.getPullRequestMergerLogin(pr.number).then((mergerLogin) => ({url: pr.html_url, mergerLogin})))).then((results) => { + // The format of this map is following: + // { + // 'https://github.com/Expensify/App/pull/9641': 'PauloGasparSv', + // 'https://github.com/Expensify/App/pull/9642': 'mountiny' + // } + const internalQAPRMap = _.reduce( + results, + (acc, {url, mergerLogin}) => { + acc[url] = mergerLogin; + return acc; + }, + {}, + ); + console.log('Found the following Internal QA PRs:', internalQAPRMap); + + const noQAPRs = _.pluck( + _.filter(data, (PR) => /\[No\s?QA]/i.test(PR.title)), + 'html_url', + ); + console.log('Found the following NO QA PRs:', noQAPRs); + const verifiedOrNoQAPRs = _.union(verifiedPRList, noQAPRs); + + const sortedPRList = _.chain(PRList).difference(_.keys(internalQAPRMap)).unique().sortBy(GithubUtils.getPullRequestNumberFromURL).value(); + const sortedDeployBlockers = _.sortBy(_.unique(deployBlockers), GithubUtils.getIssueOrPullRequestNumberFromURL); + + // Tag version and comparison URL + // eslint-disable-next-line max-len + let issueBody = `**Release Version:** \`${tag}\`\r\n**Compare Changes:** https://github.com/Expensify/App/compare/production...staging\r\n`; + + // PR list + if (!_.isEmpty(sortedPRList)) { + issueBody += '\r\n**This release contains changes from the following pull requests:**\r\n'; + _.each(sortedPRList, (URL) => { + issueBody += _.contains(verifiedOrNoQAPRs, URL) ? '- [x]' : '- [ ]'; + issueBody += ` ${URL}\r\n`; + }); + issueBody += '\r\n\r\n'; + } - // Internal QA PR list - if (!_.isEmpty(internalQAPRMap)) { - console.log('Found the following verified Internal QA PRs:', resolvedInternalQAPRs); - issueBody += '**Internal QA:**\r\n'; - _.each(internalQAPRMap, (assignees, URL) => { - const assigneeMentions = _.reduce(assignees, (memo, assignee) => `${memo} @${assignee}`, ''); - issueBody += `${_.contains(resolvedInternalQAPRs, URL) ? '- [x]' : '- [ ]'} `; - issueBody += `${URL}`; - issueBody += ` -${assigneeMentions}`; - issueBody += '\r\n'; - }); - issueBody += '\r\n\r\n'; - } + // Internal QA PR list + if (!_.isEmpty(internalQAPRMap)) { + console.log('Found the following verified Internal QA PRs:', resolvedInternalQAPRs); + issueBody += '**Internal QA:**\r\n'; + _.each(internalQAPRMap, (merger, URL) => { + const mergerMention = `@${merger}`; + issueBody += `${_.contains(resolvedInternalQAPRs, URL) ? '- [x]' : '- [ ]'} `; + issueBody += `${URL}`; + issueBody += ` - ${mergerMention}`; + issueBody += '\r\n'; + }); + issueBody += '\r\n\r\n'; + } - // Deploy blockers - if (!_.isEmpty(deployBlockers)) { - issueBody += '**Deploy Blockers:**\r\n'; - _.each(sortedDeployBlockers, (URL) => { - issueBody += _.contains(resolvedDeployBlockers, URL) ? '- [x] ' : '- [ ] '; - issueBody += URL; - issueBody += '\r\n'; - }); - issueBody += '\r\n\r\n'; - } + // Deploy blockers + if (!_.isEmpty(deployBlockers)) { + issueBody += '**Deploy Blockers:**\r\n'; + _.each(sortedDeployBlockers, (URL) => { + issueBody += _.contains(resolvedDeployBlockers, URL) ? '- [x] ' : '- [ ] '; + issueBody += URL; + issueBody += '\r\n'; + }); + issueBody += '\r\n\r\n'; + } - issueBody += '**Deployer verifications:**'; - // eslint-disable-next-line max-len - issueBody += `\r\n- [${ - isTimingDashboardChecked ? 'x' : ' ' - }] I checked the [App Timing Dashboard](https://graphs.expensify.com/grafana/d/yj2EobAGz/app-timing?orgId=1) and verified this release does not cause a noticeable performance regression.`; - // eslint-disable-next-line max-len - issueBody += `\r\n- [${ - isFirebaseChecked ? 'x' : ' ' - }] I checked [Firebase Crashlytics](https://console.firebase.google.com/u/0/project/expensify-chat/crashlytics/app/android:com.expensify.chat/issues?state=open&time=last-seven-days&tag=all) and verified that this release does not introduce any new crashes. More detailed instructions on this verification can be found [here](https://stackoverflowteams.com/c/expensify/questions/15095/15096).`; - // eslint-disable-next-line max-len - issueBody += `\r\n- [${isGHStatusChecked ? 'x' : ' '}] I checked [GitHub Status](https://www.githubstatus.com/) and verified there is no reported incident with Actions.`; - - issueBody += '\r\n\r\ncc @Expensify/applauseleads\r\n'; - return issueBody; + issueBody += '**Deployer verifications:**'; + // eslint-disable-next-line max-len + issueBody += `\r\n- [${ + isTimingDashboardChecked ? 'x' : ' ' + }] I checked the [App Timing Dashboard](https://graphs.expensify.com/grafana/d/yj2EobAGz/app-timing?orgId=1) and verified this release does not cause a noticeable performance regression.`; + // eslint-disable-next-line max-len + issueBody += `\r\n- [${ + isFirebaseChecked ? 'x' : ' ' + }] I checked [Firebase Crashlytics](https://console.firebase.google.com/u/0/project/expensify-chat/crashlytics/app/android:com.expensify.chat/issues?state=open&time=last-seven-days&tag=all) and verified that this release does not introduce any new crashes. More detailed instructions on this verification can be found [here](https://stackoverflowteams.com/c/expensify/questions/15095/15096).`; + // eslint-disable-next-line max-len + issueBody += `\r\n- [${isGHStatusChecked ? 'x' : ' '}] I checked [GitHub Status](https://www.githubstatus.com/) and verified there is no reported incident with Actions.`; + + issueBody += '\r\n\r\ncc @Expensify/applauseleads\r\n'; + const issueAssignees = _.uniq(_.values(internalQAPRMap)); + const issue = {issueBody, issueAssignees}; + return issue; + }); }) .catch((err) => console.warn('Error generating StagingDeployCash issue body! Continuing...', err)); } @@ -431,6 +435,20 @@ class GithubUtils { .catch((err) => console.error('Failed to get PR list', err)); } + /** + * @param {Number} pullRequestNumber + * @returns {Promise} + */ + static getPullRequestMergerLogin(pullRequestNumber) { + return this.octokit.pulls + .get({ + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, + pull_number: pullRequestNumber, + }) + .then(({data: pullRequest}) => pullRequest.merged_by.login); + } + /** * @param {Number} pullRequestNumber * @returns {Promise} diff --git a/.github/actions/javascript/getPullRequestDetails/index.js b/.github/actions/javascript/getPullRequestDetails/index.js index b8d7d821d64e..9eb608a8cc05 100644 --- a/.github/actions/javascript/getPullRequestDetails/index.js +++ b/.github/actions/javascript/getPullRequestDetails/index.js @@ -301,7 +301,7 @@ class GithubUtils { } /** - * Generate the issue body for a StagingDeployCash. + * Generate the issue body and assignees for a StagingDeployCash. * * @param {String} tag * @param {Array} PRList - The list of PR URLs which are included in this StagingDeployCash @@ -314,7 +314,7 @@ class GithubUtils { * @param {Boolean} [isGHStatusChecked] * @returns {Promise} */ - static generateStagingDeployCashBody( + static generateStagingDeployCashBodyAndAssignees( tag, PRList, verifiedPRList = [], @@ -327,85 +327,89 @@ class GithubUtils { ) { return this.fetchAllPullRequests(_.map(PRList, this.getPullRequestNumberFromURL)) .then((data) => { - // The format of this map is following: - // { - // 'https://github.com/Expensify/App/pull/9641': [ 'PauloGasparSv', 'kidroca' ], - // 'https://github.com/Expensify/App/pull/9642': [ 'mountiny', 'kidroca' ] - // } - const internalQAPRMap = _.reduce( - _.filter(data, (pr) => !_.isEmpty(_.findWhere(pr.labels, {name: CONST.LABELS.INTERNAL_QA}))), - (map, pr) => { - // eslint-disable-next-line no-param-reassign - map[pr.html_url] = _.compact(_.pluck(pr.assignees, 'login')); - return map; - }, - {}, - ); - console.log('Found the following Internal QA PRs:', internalQAPRMap); - - const noQAPRs = _.pluck( - _.filter(data, (PR) => /\[No\s?QA]/i.test(PR.title)), - 'html_url', - ); - console.log('Found the following NO QA PRs:', noQAPRs); - const verifiedOrNoQAPRs = _.union(verifiedPRList, noQAPRs); - - const sortedPRList = _.chain(PRList).difference(_.keys(internalQAPRMap)).unique().sortBy(GithubUtils.getPullRequestNumberFromURL).value(); - const sortedDeployBlockers = _.sortBy(_.unique(deployBlockers), GithubUtils.getIssueOrPullRequestNumberFromURL); - - // Tag version and comparison URL - // eslint-disable-next-line max-len - let issueBody = `**Release Version:** \`${tag}\`\r\n**Compare Changes:** https://github.com/Expensify/App/compare/production...staging\r\n`; - - // PR list - if (!_.isEmpty(sortedPRList)) { - issueBody += '\r\n**This release contains changes from the following pull requests:**\r\n'; - _.each(sortedPRList, (URL) => { - issueBody += _.contains(verifiedOrNoQAPRs, URL) ? '- [x]' : '- [ ]'; - issueBody += ` ${URL}\r\n`; - }); - issueBody += '\r\n\r\n'; - } + const internalQAPRs = _.filter(data, (pr) => !_.isEmpty(_.findWhere(pr.labels, {name: CONST.LABELS.INTERNAL_QA}))); + return Promise.all(_.map(internalQAPRs, (pr) => this.getPullRequestMergerLogin(pr.number).then((mergerLogin) => ({url: pr.html_url, mergerLogin})))).then((results) => { + // The format of this map is following: + // { + // 'https://github.com/Expensify/App/pull/9641': 'PauloGasparSv', + // 'https://github.com/Expensify/App/pull/9642': 'mountiny' + // } + const internalQAPRMap = _.reduce( + results, + (acc, {url, mergerLogin}) => { + acc[url] = mergerLogin; + return acc; + }, + {}, + ); + console.log('Found the following Internal QA PRs:', internalQAPRMap); + + const noQAPRs = _.pluck( + _.filter(data, (PR) => /\[No\s?QA]/i.test(PR.title)), + 'html_url', + ); + console.log('Found the following NO QA PRs:', noQAPRs); + const verifiedOrNoQAPRs = _.union(verifiedPRList, noQAPRs); + + const sortedPRList = _.chain(PRList).difference(_.keys(internalQAPRMap)).unique().sortBy(GithubUtils.getPullRequestNumberFromURL).value(); + const sortedDeployBlockers = _.sortBy(_.unique(deployBlockers), GithubUtils.getIssueOrPullRequestNumberFromURL); + + // Tag version and comparison URL + // eslint-disable-next-line max-len + let issueBody = `**Release Version:** \`${tag}\`\r\n**Compare Changes:** https://github.com/Expensify/App/compare/production...staging\r\n`; + + // PR list + if (!_.isEmpty(sortedPRList)) { + issueBody += '\r\n**This release contains changes from the following pull requests:**\r\n'; + _.each(sortedPRList, (URL) => { + issueBody += _.contains(verifiedOrNoQAPRs, URL) ? '- [x]' : '- [ ]'; + issueBody += ` ${URL}\r\n`; + }); + issueBody += '\r\n\r\n'; + } - // Internal QA PR list - if (!_.isEmpty(internalQAPRMap)) { - console.log('Found the following verified Internal QA PRs:', resolvedInternalQAPRs); - issueBody += '**Internal QA:**\r\n'; - _.each(internalQAPRMap, (assignees, URL) => { - const assigneeMentions = _.reduce(assignees, (memo, assignee) => `${memo} @${assignee}`, ''); - issueBody += `${_.contains(resolvedInternalQAPRs, URL) ? '- [x]' : '- [ ]'} `; - issueBody += `${URL}`; - issueBody += ` -${assigneeMentions}`; - issueBody += '\r\n'; - }); - issueBody += '\r\n\r\n'; - } + // Internal QA PR list + if (!_.isEmpty(internalQAPRMap)) { + console.log('Found the following verified Internal QA PRs:', resolvedInternalQAPRs); + issueBody += '**Internal QA:**\r\n'; + _.each(internalQAPRMap, (merger, URL) => { + const mergerMention = `@${merger}`; + issueBody += `${_.contains(resolvedInternalQAPRs, URL) ? '- [x]' : '- [ ]'} `; + issueBody += `${URL}`; + issueBody += ` - ${mergerMention}`; + issueBody += '\r\n'; + }); + issueBody += '\r\n\r\n'; + } - // Deploy blockers - if (!_.isEmpty(deployBlockers)) { - issueBody += '**Deploy Blockers:**\r\n'; - _.each(sortedDeployBlockers, (URL) => { - issueBody += _.contains(resolvedDeployBlockers, URL) ? '- [x] ' : '- [ ] '; - issueBody += URL; - issueBody += '\r\n'; - }); - issueBody += '\r\n\r\n'; - } + // Deploy blockers + if (!_.isEmpty(deployBlockers)) { + issueBody += '**Deploy Blockers:**\r\n'; + _.each(sortedDeployBlockers, (URL) => { + issueBody += _.contains(resolvedDeployBlockers, URL) ? '- [x] ' : '- [ ] '; + issueBody += URL; + issueBody += '\r\n'; + }); + issueBody += '\r\n\r\n'; + } - issueBody += '**Deployer verifications:**'; - // eslint-disable-next-line max-len - issueBody += `\r\n- [${ - isTimingDashboardChecked ? 'x' : ' ' - }] I checked the [App Timing Dashboard](https://graphs.expensify.com/grafana/d/yj2EobAGz/app-timing?orgId=1) and verified this release does not cause a noticeable performance regression.`; - // eslint-disable-next-line max-len - issueBody += `\r\n- [${ - isFirebaseChecked ? 'x' : ' ' - }] I checked [Firebase Crashlytics](https://console.firebase.google.com/u/0/project/expensify-chat/crashlytics/app/android:com.expensify.chat/issues?state=open&time=last-seven-days&tag=all) and verified that this release does not introduce any new crashes. More detailed instructions on this verification can be found [here](https://stackoverflowteams.com/c/expensify/questions/15095/15096).`; - // eslint-disable-next-line max-len - issueBody += `\r\n- [${isGHStatusChecked ? 'x' : ' '}] I checked [GitHub Status](https://www.githubstatus.com/) and verified there is no reported incident with Actions.`; - - issueBody += '\r\n\r\ncc @Expensify/applauseleads\r\n'; - return issueBody; + issueBody += '**Deployer verifications:**'; + // eslint-disable-next-line max-len + issueBody += `\r\n- [${ + isTimingDashboardChecked ? 'x' : ' ' + }] I checked the [App Timing Dashboard](https://graphs.expensify.com/grafana/d/yj2EobAGz/app-timing?orgId=1) and verified this release does not cause a noticeable performance regression.`; + // eslint-disable-next-line max-len + issueBody += `\r\n- [${ + isFirebaseChecked ? 'x' : ' ' + }] I checked [Firebase Crashlytics](https://console.firebase.google.com/u/0/project/expensify-chat/crashlytics/app/android:com.expensify.chat/issues?state=open&time=last-seven-days&tag=all) and verified that this release does not introduce any new crashes. More detailed instructions on this verification can be found [here](https://stackoverflowteams.com/c/expensify/questions/15095/15096).`; + // eslint-disable-next-line max-len + issueBody += `\r\n- [${isGHStatusChecked ? 'x' : ' '}] I checked [GitHub Status](https://www.githubstatus.com/) and verified there is no reported incident with Actions.`; + + issueBody += '\r\n\r\ncc @Expensify/applauseleads\r\n'; + const issueAssignees = _.uniq(_.values(internalQAPRMap)); + const issue = {issueBody, issueAssignees}; + return issue; + }); }) .catch((err) => console.warn('Error generating StagingDeployCash issue body! Continuing...', err)); } @@ -439,6 +443,20 @@ class GithubUtils { .catch((err) => console.error('Failed to get PR list', err)); } + /** + * @param {Number} pullRequestNumber + * @returns {Promise} + */ + static getPullRequestMergerLogin(pullRequestNumber) { + return this.octokit.pulls + .get({ + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, + pull_number: pullRequestNumber, + }) + .then(({data: pullRequest}) => pullRequest.merged_by.login); + } + /** * @param {Number} pullRequestNumber * @returns {Promise} diff --git a/.github/actions/javascript/getReleaseBody/index.js b/.github/actions/javascript/getReleaseBody/index.js index cc1321ce5cd5..ea12ef5f0df0 100644 --- a/.github/actions/javascript/getReleaseBody/index.js +++ b/.github/actions/javascript/getReleaseBody/index.js @@ -301,7 +301,7 @@ class GithubUtils { } /** - * Generate the issue body for a StagingDeployCash. + * Generate the issue body and assignees for a StagingDeployCash. * * @param {String} tag * @param {Array} PRList - The list of PR URLs which are included in this StagingDeployCash @@ -314,7 +314,7 @@ class GithubUtils { * @param {Boolean} [isGHStatusChecked] * @returns {Promise} */ - static generateStagingDeployCashBody( + static generateStagingDeployCashBodyAndAssignees( tag, PRList, verifiedPRList = [], @@ -327,85 +327,89 @@ class GithubUtils { ) { return this.fetchAllPullRequests(_.map(PRList, this.getPullRequestNumberFromURL)) .then((data) => { - // The format of this map is following: - // { - // 'https://github.com/Expensify/App/pull/9641': [ 'PauloGasparSv', 'kidroca' ], - // 'https://github.com/Expensify/App/pull/9642': [ 'mountiny', 'kidroca' ] - // } - const internalQAPRMap = _.reduce( - _.filter(data, (pr) => !_.isEmpty(_.findWhere(pr.labels, {name: CONST.LABELS.INTERNAL_QA}))), - (map, pr) => { - // eslint-disable-next-line no-param-reassign - map[pr.html_url] = _.compact(_.pluck(pr.assignees, 'login')); - return map; - }, - {}, - ); - console.log('Found the following Internal QA PRs:', internalQAPRMap); - - const noQAPRs = _.pluck( - _.filter(data, (PR) => /\[No\s?QA]/i.test(PR.title)), - 'html_url', - ); - console.log('Found the following NO QA PRs:', noQAPRs); - const verifiedOrNoQAPRs = _.union(verifiedPRList, noQAPRs); - - const sortedPRList = _.chain(PRList).difference(_.keys(internalQAPRMap)).unique().sortBy(GithubUtils.getPullRequestNumberFromURL).value(); - const sortedDeployBlockers = _.sortBy(_.unique(deployBlockers), GithubUtils.getIssueOrPullRequestNumberFromURL); - - // Tag version and comparison URL - // eslint-disable-next-line max-len - let issueBody = `**Release Version:** \`${tag}\`\r\n**Compare Changes:** https://github.com/Expensify/App/compare/production...staging\r\n`; - - // PR list - if (!_.isEmpty(sortedPRList)) { - issueBody += '\r\n**This release contains changes from the following pull requests:**\r\n'; - _.each(sortedPRList, (URL) => { - issueBody += _.contains(verifiedOrNoQAPRs, URL) ? '- [x]' : '- [ ]'; - issueBody += ` ${URL}\r\n`; - }); - issueBody += '\r\n\r\n'; - } + const internalQAPRs = _.filter(data, (pr) => !_.isEmpty(_.findWhere(pr.labels, {name: CONST.LABELS.INTERNAL_QA}))); + return Promise.all(_.map(internalQAPRs, (pr) => this.getPullRequestMergerLogin(pr.number).then((mergerLogin) => ({url: pr.html_url, mergerLogin})))).then((results) => { + // The format of this map is following: + // { + // 'https://github.com/Expensify/App/pull/9641': 'PauloGasparSv', + // 'https://github.com/Expensify/App/pull/9642': 'mountiny' + // } + const internalQAPRMap = _.reduce( + results, + (acc, {url, mergerLogin}) => { + acc[url] = mergerLogin; + return acc; + }, + {}, + ); + console.log('Found the following Internal QA PRs:', internalQAPRMap); + + const noQAPRs = _.pluck( + _.filter(data, (PR) => /\[No\s?QA]/i.test(PR.title)), + 'html_url', + ); + console.log('Found the following NO QA PRs:', noQAPRs); + const verifiedOrNoQAPRs = _.union(verifiedPRList, noQAPRs); + + const sortedPRList = _.chain(PRList).difference(_.keys(internalQAPRMap)).unique().sortBy(GithubUtils.getPullRequestNumberFromURL).value(); + const sortedDeployBlockers = _.sortBy(_.unique(deployBlockers), GithubUtils.getIssueOrPullRequestNumberFromURL); + + // Tag version and comparison URL + // eslint-disable-next-line max-len + let issueBody = `**Release Version:** \`${tag}\`\r\n**Compare Changes:** https://github.com/Expensify/App/compare/production...staging\r\n`; + + // PR list + if (!_.isEmpty(sortedPRList)) { + issueBody += '\r\n**This release contains changes from the following pull requests:**\r\n'; + _.each(sortedPRList, (URL) => { + issueBody += _.contains(verifiedOrNoQAPRs, URL) ? '- [x]' : '- [ ]'; + issueBody += ` ${URL}\r\n`; + }); + issueBody += '\r\n\r\n'; + } - // Internal QA PR list - if (!_.isEmpty(internalQAPRMap)) { - console.log('Found the following verified Internal QA PRs:', resolvedInternalQAPRs); - issueBody += '**Internal QA:**\r\n'; - _.each(internalQAPRMap, (assignees, URL) => { - const assigneeMentions = _.reduce(assignees, (memo, assignee) => `${memo} @${assignee}`, ''); - issueBody += `${_.contains(resolvedInternalQAPRs, URL) ? '- [x]' : '- [ ]'} `; - issueBody += `${URL}`; - issueBody += ` -${assigneeMentions}`; - issueBody += '\r\n'; - }); - issueBody += '\r\n\r\n'; - } + // Internal QA PR list + if (!_.isEmpty(internalQAPRMap)) { + console.log('Found the following verified Internal QA PRs:', resolvedInternalQAPRs); + issueBody += '**Internal QA:**\r\n'; + _.each(internalQAPRMap, (merger, URL) => { + const mergerMention = `@${merger}`; + issueBody += `${_.contains(resolvedInternalQAPRs, URL) ? '- [x]' : '- [ ]'} `; + issueBody += `${URL}`; + issueBody += ` - ${mergerMention}`; + issueBody += '\r\n'; + }); + issueBody += '\r\n\r\n'; + } - // Deploy blockers - if (!_.isEmpty(deployBlockers)) { - issueBody += '**Deploy Blockers:**\r\n'; - _.each(sortedDeployBlockers, (URL) => { - issueBody += _.contains(resolvedDeployBlockers, URL) ? '- [x] ' : '- [ ] '; - issueBody += URL; - issueBody += '\r\n'; - }); - issueBody += '\r\n\r\n'; - } + // Deploy blockers + if (!_.isEmpty(deployBlockers)) { + issueBody += '**Deploy Blockers:**\r\n'; + _.each(sortedDeployBlockers, (URL) => { + issueBody += _.contains(resolvedDeployBlockers, URL) ? '- [x] ' : '- [ ] '; + issueBody += URL; + issueBody += '\r\n'; + }); + issueBody += '\r\n\r\n'; + } - issueBody += '**Deployer verifications:**'; - // eslint-disable-next-line max-len - issueBody += `\r\n- [${ - isTimingDashboardChecked ? 'x' : ' ' - }] I checked the [App Timing Dashboard](https://graphs.expensify.com/grafana/d/yj2EobAGz/app-timing?orgId=1) and verified this release does not cause a noticeable performance regression.`; - // eslint-disable-next-line max-len - issueBody += `\r\n- [${ - isFirebaseChecked ? 'x' : ' ' - }] I checked [Firebase Crashlytics](https://console.firebase.google.com/u/0/project/expensify-chat/crashlytics/app/android:com.expensify.chat/issues?state=open&time=last-seven-days&tag=all) and verified that this release does not introduce any new crashes. More detailed instructions on this verification can be found [here](https://stackoverflowteams.com/c/expensify/questions/15095/15096).`; - // eslint-disable-next-line max-len - issueBody += `\r\n- [${isGHStatusChecked ? 'x' : ' '}] I checked [GitHub Status](https://www.githubstatus.com/) and verified there is no reported incident with Actions.`; - - issueBody += '\r\n\r\ncc @Expensify/applauseleads\r\n'; - return issueBody; + issueBody += '**Deployer verifications:**'; + // eslint-disable-next-line max-len + issueBody += `\r\n- [${ + isTimingDashboardChecked ? 'x' : ' ' + }] I checked the [App Timing Dashboard](https://graphs.expensify.com/grafana/d/yj2EobAGz/app-timing?orgId=1) and verified this release does not cause a noticeable performance regression.`; + // eslint-disable-next-line max-len + issueBody += `\r\n- [${ + isFirebaseChecked ? 'x' : ' ' + }] I checked [Firebase Crashlytics](https://console.firebase.google.com/u/0/project/expensify-chat/crashlytics/app/android:com.expensify.chat/issues?state=open&time=last-seven-days&tag=all) and verified that this release does not introduce any new crashes. More detailed instructions on this verification can be found [here](https://stackoverflowteams.com/c/expensify/questions/15095/15096).`; + // eslint-disable-next-line max-len + issueBody += `\r\n- [${isGHStatusChecked ? 'x' : ' '}] I checked [GitHub Status](https://www.githubstatus.com/) and verified there is no reported incident with Actions.`; + + issueBody += '\r\n\r\ncc @Expensify/applauseleads\r\n'; + const issueAssignees = _.uniq(_.values(internalQAPRMap)); + const issue = {issueBody, issueAssignees}; + return issue; + }); }) .catch((err) => console.warn('Error generating StagingDeployCash issue body! Continuing...', err)); } @@ -439,6 +443,20 @@ class GithubUtils { .catch((err) => console.error('Failed to get PR list', err)); } + /** + * @param {Number} pullRequestNumber + * @returns {Promise} + */ + static getPullRequestMergerLogin(pullRequestNumber) { + return this.octokit.pulls + .get({ + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, + pull_number: pullRequestNumber, + }) + .then(({data: pullRequest}) => pullRequest.merged_by.login); + } + /** * @param {Number} pullRequestNumber * @returns {Promise} diff --git a/.github/actions/javascript/isStagingDeployLocked/index.js b/.github/actions/javascript/isStagingDeployLocked/index.js index 8124c5795a5a..32b8b64d7b82 100644 --- a/.github/actions/javascript/isStagingDeployLocked/index.js +++ b/.github/actions/javascript/isStagingDeployLocked/index.js @@ -285,7 +285,7 @@ class GithubUtils { } /** - * Generate the issue body for a StagingDeployCash. + * Generate the issue body and assignees for a StagingDeployCash. * * @param {String} tag * @param {Array} PRList - The list of PR URLs which are included in this StagingDeployCash @@ -298,7 +298,7 @@ class GithubUtils { * @param {Boolean} [isGHStatusChecked] * @returns {Promise} */ - static generateStagingDeployCashBody( + static generateStagingDeployCashBodyAndAssignees( tag, PRList, verifiedPRList = [], @@ -311,85 +311,89 @@ class GithubUtils { ) { return this.fetchAllPullRequests(_.map(PRList, this.getPullRequestNumberFromURL)) .then((data) => { - // The format of this map is following: - // { - // 'https://github.com/Expensify/App/pull/9641': [ 'PauloGasparSv', 'kidroca' ], - // 'https://github.com/Expensify/App/pull/9642': [ 'mountiny', 'kidroca' ] - // } - const internalQAPRMap = _.reduce( - _.filter(data, (pr) => !_.isEmpty(_.findWhere(pr.labels, {name: CONST.LABELS.INTERNAL_QA}))), - (map, pr) => { - // eslint-disable-next-line no-param-reassign - map[pr.html_url] = _.compact(_.pluck(pr.assignees, 'login')); - return map; - }, - {}, - ); - console.log('Found the following Internal QA PRs:', internalQAPRMap); - - const noQAPRs = _.pluck( - _.filter(data, (PR) => /\[No\s?QA]/i.test(PR.title)), - 'html_url', - ); - console.log('Found the following NO QA PRs:', noQAPRs); - const verifiedOrNoQAPRs = _.union(verifiedPRList, noQAPRs); - - const sortedPRList = _.chain(PRList).difference(_.keys(internalQAPRMap)).unique().sortBy(GithubUtils.getPullRequestNumberFromURL).value(); - const sortedDeployBlockers = _.sortBy(_.unique(deployBlockers), GithubUtils.getIssueOrPullRequestNumberFromURL); - - // Tag version and comparison URL - // eslint-disable-next-line max-len - let issueBody = `**Release Version:** \`${tag}\`\r\n**Compare Changes:** https://github.com/Expensify/App/compare/production...staging\r\n`; - - // PR list - if (!_.isEmpty(sortedPRList)) { - issueBody += '\r\n**This release contains changes from the following pull requests:**\r\n'; - _.each(sortedPRList, (URL) => { - issueBody += _.contains(verifiedOrNoQAPRs, URL) ? '- [x]' : '- [ ]'; - issueBody += ` ${URL}\r\n`; - }); - issueBody += '\r\n\r\n'; - } + const internalQAPRs = _.filter(data, (pr) => !_.isEmpty(_.findWhere(pr.labels, {name: CONST.LABELS.INTERNAL_QA}))); + return Promise.all(_.map(internalQAPRs, (pr) => this.getPullRequestMergerLogin(pr.number).then((mergerLogin) => ({url: pr.html_url, mergerLogin})))).then((results) => { + // The format of this map is following: + // { + // 'https://github.com/Expensify/App/pull/9641': 'PauloGasparSv', + // 'https://github.com/Expensify/App/pull/9642': 'mountiny' + // } + const internalQAPRMap = _.reduce( + results, + (acc, {url, mergerLogin}) => { + acc[url] = mergerLogin; + return acc; + }, + {}, + ); + console.log('Found the following Internal QA PRs:', internalQAPRMap); + + const noQAPRs = _.pluck( + _.filter(data, (PR) => /\[No\s?QA]/i.test(PR.title)), + 'html_url', + ); + console.log('Found the following NO QA PRs:', noQAPRs); + const verifiedOrNoQAPRs = _.union(verifiedPRList, noQAPRs); + + const sortedPRList = _.chain(PRList).difference(_.keys(internalQAPRMap)).unique().sortBy(GithubUtils.getPullRequestNumberFromURL).value(); + const sortedDeployBlockers = _.sortBy(_.unique(deployBlockers), GithubUtils.getIssueOrPullRequestNumberFromURL); + + // Tag version and comparison URL + // eslint-disable-next-line max-len + let issueBody = `**Release Version:** \`${tag}\`\r\n**Compare Changes:** https://github.com/Expensify/App/compare/production...staging\r\n`; + + // PR list + if (!_.isEmpty(sortedPRList)) { + issueBody += '\r\n**This release contains changes from the following pull requests:**\r\n'; + _.each(sortedPRList, (URL) => { + issueBody += _.contains(verifiedOrNoQAPRs, URL) ? '- [x]' : '- [ ]'; + issueBody += ` ${URL}\r\n`; + }); + issueBody += '\r\n\r\n'; + } - // Internal QA PR list - if (!_.isEmpty(internalQAPRMap)) { - console.log('Found the following verified Internal QA PRs:', resolvedInternalQAPRs); - issueBody += '**Internal QA:**\r\n'; - _.each(internalQAPRMap, (assignees, URL) => { - const assigneeMentions = _.reduce(assignees, (memo, assignee) => `${memo} @${assignee}`, ''); - issueBody += `${_.contains(resolvedInternalQAPRs, URL) ? '- [x]' : '- [ ]'} `; - issueBody += `${URL}`; - issueBody += ` -${assigneeMentions}`; - issueBody += '\r\n'; - }); - issueBody += '\r\n\r\n'; - } + // Internal QA PR list + if (!_.isEmpty(internalQAPRMap)) { + console.log('Found the following verified Internal QA PRs:', resolvedInternalQAPRs); + issueBody += '**Internal QA:**\r\n'; + _.each(internalQAPRMap, (merger, URL) => { + const mergerMention = `@${merger}`; + issueBody += `${_.contains(resolvedInternalQAPRs, URL) ? '- [x]' : '- [ ]'} `; + issueBody += `${URL}`; + issueBody += ` - ${mergerMention}`; + issueBody += '\r\n'; + }); + issueBody += '\r\n\r\n'; + } - // Deploy blockers - if (!_.isEmpty(deployBlockers)) { - issueBody += '**Deploy Blockers:**\r\n'; - _.each(sortedDeployBlockers, (URL) => { - issueBody += _.contains(resolvedDeployBlockers, URL) ? '- [x] ' : '- [ ] '; - issueBody += URL; - issueBody += '\r\n'; - }); - issueBody += '\r\n\r\n'; - } + // Deploy blockers + if (!_.isEmpty(deployBlockers)) { + issueBody += '**Deploy Blockers:**\r\n'; + _.each(sortedDeployBlockers, (URL) => { + issueBody += _.contains(resolvedDeployBlockers, URL) ? '- [x] ' : '- [ ] '; + issueBody += URL; + issueBody += '\r\n'; + }); + issueBody += '\r\n\r\n'; + } - issueBody += '**Deployer verifications:**'; - // eslint-disable-next-line max-len - issueBody += `\r\n- [${ - isTimingDashboardChecked ? 'x' : ' ' - }] I checked the [App Timing Dashboard](https://graphs.expensify.com/grafana/d/yj2EobAGz/app-timing?orgId=1) and verified this release does not cause a noticeable performance regression.`; - // eslint-disable-next-line max-len - issueBody += `\r\n- [${ - isFirebaseChecked ? 'x' : ' ' - }] I checked [Firebase Crashlytics](https://console.firebase.google.com/u/0/project/expensify-chat/crashlytics/app/android:com.expensify.chat/issues?state=open&time=last-seven-days&tag=all) and verified that this release does not introduce any new crashes. More detailed instructions on this verification can be found [here](https://stackoverflowteams.com/c/expensify/questions/15095/15096).`; - // eslint-disable-next-line max-len - issueBody += `\r\n- [${isGHStatusChecked ? 'x' : ' '}] I checked [GitHub Status](https://www.githubstatus.com/) and verified there is no reported incident with Actions.`; - - issueBody += '\r\n\r\ncc @Expensify/applauseleads\r\n'; - return issueBody; + issueBody += '**Deployer verifications:**'; + // eslint-disable-next-line max-len + issueBody += `\r\n- [${ + isTimingDashboardChecked ? 'x' : ' ' + }] I checked the [App Timing Dashboard](https://graphs.expensify.com/grafana/d/yj2EobAGz/app-timing?orgId=1) and verified this release does not cause a noticeable performance regression.`; + // eslint-disable-next-line max-len + issueBody += `\r\n- [${ + isFirebaseChecked ? 'x' : ' ' + }] I checked [Firebase Crashlytics](https://console.firebase.google.com/u/0/project/expensify-chat/crashlytics/app/android:com.expensify.chat/issues?state=open&time=last-seven-days&tag=all) and verified that this release does not introduce any new crashes. More detailed instructions on this verification can be found [here](https://stackoverflowteams.com/c/expensify/questions/15095/15096).`; + // eslint-disable-next-line max-len + issueBody += `\r\n- [${isGHStatusChecked ? 'x' : ' '}] I checked [GitHub Status](https://www.githubstatus.com/) and verified there is no reported incident with Actions.`; + + issueBody += '\r\n\r\ncc @Expensify/applauseleads\r\n'; + const issueAssignees = _.uniq(_.values(internalQAPRMap)); + const issue = {issueBody, issueAssignees}; + return issue; + }); }) .catch((err) => console.warn('Error generating StagingDeployCash issue body! Continuing...', err)); } @@ -423,6 +427,20 @@ class GithubUtils { .catch((err) => console.error('Failed to get PR list', err)); } + /** + * @param {Number} pullRequestNumber + * @returns {Promise} + */ + static getPullRequestMergerLogin(pullRequestNumber) { + return this.octokit.pulls + .get({ + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, + pull_number: pullRequestNumber, + }) + .then(({data: pullRequest}) => pullRequest.merged_by.login); + } + /** * @param {Number} pullRequestNumber * @returns {Promise} diff --git a/.github/actions/javascript/markPullRequestsAsDeployed/index.js b/.github/actions/javascript/markPullRequestsAsDeployed/index.js index 36cd0aaefe4a..d275edf9d789 100644 --- a/.github/actions/javascript/markPullRequestsAsDeployed/index.js +++ b/.github/actions/javascript/markPullRequestsAsDeployed/index.js @@ -450,7 +450,7 @@ class GithubUtils { } /** - * Generate the issue body for a StagingDeployCash. + * Generate the issue body and assignees for a StagingDeployCash. * * @param {String} tag * @param {Array} PRList - The list of PR URLs which are included in this StagingDeployCash @@ -463,7 +463,7 @@ class GithubUtils { * @param {Boolean} [isGHStatusChecked] * @returns {Promise} */ - static generateStagingDeployCashBody( + static generateStagingDeployCashBodyAndAssignees( tag, PRList, verifiedPRList = [], @@ -476,85 +476,89 @@ class GithubUtils { ) { return this.fetchAllPullRequests(_.map(PRList, this.getPullRequestNumberFromURL)) .then((data) => { - // The format of this map is following: - // { - // 'https://github.com/Expensify/App/pull/9641': [ 'PauloGasparSv', 'kidroca' ], - // 'https://github.com/Expensify/App/pull/9642': [ 'mountiny', 'kidroca' ] - // } - const internalQAPRMap = _.reduce( - _.filter(data, (pr) => !_.isEmpty(_.findWhere(pr.labels, {name: CONST.LABELS.INTERNAL_QA}))), - (map, pr) => { - // eslint-disable-next-line no-param-reassign - map[pr.html_url] = _.compact(_.pluck(pr.assignees, 'login')); - return map; - }, - {}, - ); - console.log('Found the following Internal QA PRs:', internalQAPRMap); - - const noQAPRs = _.pluck( - _.filter(data, (PR) => /\[No\s?QA]/i.test(PR.title)), - 'html_url', - ); - console.log('Found the following NO QA PRs:', noQAPRs); - const verifiedOrNoQAPRs = _.union(verifiedPRList, noQAPRs); - - const sortedPRList = _.chain(PRList).difference(_.keys(internalQAPRMap)).unique().sortBy(GithubUtils.getPullRequestNumberFromURL).value(); - const sortedDeployBlockers = _.sortBy(_.unique(deployBlockers), GithubUtils.getIssueOrPullRequestNumberFromURL); - - // Tag version and comparison URL - // eslint-disable-next-line max-len - let issueBody = `**Release Version:** \`${tag}\`\r\n**Compare Changes:** https://github.com/Expensify/App/compare/production...staging\r\n`; - - // PR list - if (!_.isEmpty(sortedPRList)) { - issueBody += '\r\n**This release contains changes from the following pull requests:**\r\n'; - _.each(sortedPRList, (URL) => { - issueBody += _.contains(verifiedOrNoQAPRs, URL) ? '- [x]' : '- [ ]'; - issueBody += ` ${URL}\r\n`; - }); - issueBody += '\r\n\r\n'; - } + const internalQAPRs = _.filter(data, (pr) => !_.isEmpty(_.findWhere(pr.labels, {name: CONST.LABELS.INTERNAL_QA}))); + return Promise.all(_.map(internalQAPRs, (pr) => this.getPullRequestMergerLogin(pr.number).then((mergerLogin) => ({url: pr.html_url, mergerLogin})))).then((results) => { + // The format of this map is following: + // { + // 'https://github.com/Expensify/App/pull/9641': 'PauloGasparSv', + // 'https://github.com/Expensify/App/pull/9642': 'mountiny' + // } + const internalQAPRMap = _.reduce( + results, + (acc, {url, mergerLogin}) => { + acc[url] = mergerLogin; + return acc; + }, + {}, + ); + console.log('Found the following Internal QA PRs:', internalQAPRMap); + + const noQAPRs = _.pluck( + _.filter(data, (PR) => /\[No\s?QA]/i.test(PR.title)), + 'html_url', + ); + console.log('Found the following NO QA PRs:', noQAPRs); + const verifiedOrNoQAPRs = _.union(verifiedPRList, noQAPRs); + + const sortedPRList = _.chain(PRList).difference(_.keys(internalQAPRMap)).unique().sortBy(GithubUtils.getPullRequestNumberFromURL).value(); + const sortedDeployBlockers = _.sortBy(_.unique(deployBlockers), GithubUtils.getIssueOrPullRequestNumberFromURL); + + // Tag version and comparison URL + // eslint-disable-next-line max-len + let issueBody = `**Release Version:** \`${tag}\`\r\n**Compare Changes:** https://github.com/Expensify/App/compare/production...staging\r\n`; + + // PR list + if (!_.isEmpty(sortedPRList)) { + issueBody += '\r\n**This release contains changes from the following pull requests:**\r\n'; + _.each(sortedPRList, (URL) => { + issueBody += _.contains(verifiedOrNoQAPRs, URL) ? '- [x]' : '- [ ]'; + issueBody += ` ${URL}\r\n`; + }); + issueBody += '\r\n\r\n'; + } - // Internal QA PR list - if (!_.isEmpty(internalQAPRMap)) { - console.log('Found the following verified Internal QA PRs:', resolvedInternalQAPRs); - issueBody += '**Internal QA:**\r\n'; - _.each(internalQAPRMap, (assignees, URL) => { - const assigneeMentions = _.reduce(assignees, (memo, assignee) => `${memo} @${assignee}`, ''); - issueBody += `${_.contains(resolvedInternalQAPRs, URL) ? '- [x]' : '- [ ]'} `; - issueBody += `${URL}`; - issueBody += ` -${assigneeMentions}`; - issueBody += '\r\n'; - }); - issueBody += '\r\n\r\n'; - } + // Internal QA PR list + if (!_.isEmpty(internalQAPRMap)) { + console.log('Found the following verified Internal QA PRs:', resolvedInternalQAPRs); + issueBody += '**Internal QA:**\r\n'; + _.each(internalQAPRMap, (merger, URL) => { + const mergerMention = `@${merger}`; + issueBody += `${_.contains(resolvedInternalQAPRs, URL) ? '- [x]' : '- [ ]'} `; + issueBody += `${URL}`; + issueBody += ` - ${mergerMention}`; + issueBody += '\r\n'; + }); + issueBody += '\r\n\r\n'; + } - // Deploy blockers - if (!_.isEmpty(deployBlockers)) { - issueBody += '**Deploy Blockers:**\r\n'; - _.each(sortedDeployBlockers, (URL) => { - issueBody += _.contains(resolvedDeployBlockers, URL) ? '- [x] ' : '- [ ] '; - issueBody += URL; - issueBody += '\r\n'; - }); - issueBody += '\r\n\r\n'; - } + // Deploy blockers + if (!_.isEmpty(deployBlockers)) { + issueBody += '**Deploy Blockers:**\r\n'; + _.each(sortedDeployBlockers, (URL) => { + issueBody += _.contains(resolvedDeployBlockers, URL) ? '- [x] ' : '- [ ] '; + issueBody += URL; + issueBody += '\r\n'; + }); + issueBody += '\r\n\r\n'; + } - issueBody += '**Deployer verifications:**'; - // eslint-disable-next-line max-len - issueBody += `\r\n- [${ - isTimingDashboardChecked ? 'x' : ' ' - }] I checked the [App Timing Dashboard](https://graphs.expensify.com/grafana/d/yj2EobAGz/app-timing?orgId=1) and verified this release does not cause a noticeable performance regression.`; - // eslint-disable-next-line max-len - issueBody += `\r\n- [${ - isFirebaseChecked ? 'x' : ' ' - }] I checked [Firebase Crashlytics](https://console.firebase.google.com/u/0/project/expensify-chat/crashlytics/app/android:com.expensify.chat/issues?state=open&time=last-seven-days&tag=all) and verified that this release does not introduce any new crashes. More detailed instructions on this verification can be found [here](https://stackoverflowteams.com/c/expensify/questions/15095/15096).`; - // eslint-disable-next-line max-len - issueBody += `\r\n- [${isGHStatusChecked ? 'x' : ' '}] I checked [GitHub Status](https://www.githubstatus.com/) and verified there is no reported incident with Actions.`; - - issueBody += '\r\n\r\ncc @Expensify/applauseleads\r\n'; - return issueBody; + issueBody += '**Deployer verifications:**'; + // eslint-disable-next-line max-len + issueBody += `\r\n- [${ + isTimingDashboardChecked ? 'x' : ' ' + }] I checked the [App Timing Dashboard](https://graphs.expensify.com/grafana/d/yj2EobAGz/app-timing?orgId=1) and verified this release does not cause a noticeable performance regression.`; + // eslint-disable-next-line max-len + issueBody += `\r\n- [${ + isFirebaseChecked ? 'x' : ' ' + }] I checked [Firebase Crashlytics](https://console.firebase.google.com/u/0/project/expensify-chat/crashlytics/app/android:com.expensify.chat/issues?state=open&time=last-seven-days&tag=all) and verified that this release does not introduce any new crashes. More detailed instructions on this verification can be found [here](https://stackoverflowteams.com/c/expensify/questions/15095/15096).`; + // eslint-disable-next-line max-len + issueBody += `\r\n- [${isGHStatusChecked ? 'x' : ' '}] I checked [GitHub Status](https://www.githubstatus.com/) and verified there is no reported incident with Actions.`; + + issueBody += '\r\n\r\ncc @Expensify/applauseleads\r\n'; + const issueAssignees = _.uniq(_.values(internalQAPRMap)); + const issue = {issueBody, issueAssignees}; + return issue; + }); }) .catch((err) => console.warn('Error generating StagingDeployCash issue body! Continuing...', err)); } @@ -588,6 +592,20 @@ class GithubUtils { .catch((err) => console.error('Failed to get PR list', err)); } + /** + * @param {Number} pullRequestNumber + * @returns {Promise} + */ + static getPullRequestMergerLogin(pullRequestNumber) { + return this.octokit.pulls + .get({ + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, + pull_number: pullRequestNumber, + }) + .then(({data: pullRequest}) => pullRequest.merged_by.login); + } + /** * @param {Number} pullRequestNumber * @returns {Promise} diff --git a/.github/actions/javascript/postTestBuildComment/index.js b/.github/actions/javascript/postTestBuildComment/index.js index 329e0d3aad5d..3bd3e6121be8 100644 --- a/.github/actions/javascript/postTestBuildComment/index.js +++ b/.github/actions/javascript/postTestBuildComment/index.js @@ -360,7 +360,7 @@ class GithubUtils { } /** - * Generate the issue body for a StagingDeployCash. + * Generate the issue body and assignees for a StagingDeployCash. * * @param {String} tag * @param {Array} PRList - The list of PR URLs which are included in this StagingDeployCash @@ -373,7 +373,7 @@ class GithubUtils { * @param {Boolean} [isGHStatusChecked] * @returns {Promise} */ - static generateStagingDeployCashBody( + static generateStagingDeployCashBodyAndAssignees( tag, PRList, verifiedPRList = [], @@ -386,85 +386,89 @@ class GithubUtils { ) { return this.fetchAllPullRequests(_.map(PRList, this.getPullRequestNumberFromURL)) .then((data) => { - // The format of this map is following: - // { - // 'https://github.com/Expensify/App/pull/9641': [ 'PauloGasparSv', 'kidroca' ], - // 'https://github.com/Expensify/App/pull/9642': [ 'mountiny', 'kidroca' ] - // } - const internalQAPRMap = _.reduce( - _.filter(data, (pr) => !_.isEmpty(_.findWhere(pr.labels, {name: CONST.LABELS.INTERNAL_QA}))), - (map, pr) => { - // eslint-disable-next-line no-param-reassign - map[pr.html_url] = _.compact(_.pluck(pr.assignees, 'login')); - return map; - }, - {}, - ); - console.log('Found the following Internal QA PRs:', internalQAPRMap); - - const noQAPRs = _.pluck( - _.filter(data, (PR) => /\[No\s?QA]/i.test(PR.title)), - 'html_url', - ); - console.log('Found the following NO QA PRs:', noQAPRs); - const verifiedOrNoQAPRs = _.union(verifiedPRList, noQAPRs); - - const sortedPRList = _.chain(PRList).difference(_.keys(internalQAPRMap)).unique().sortBy(GithubUtils.getPullRequestNumberFromURL).value(); - const sortedDeployBlockers = _.sortBy(_.unique(deployBlockers), GithubUtils.getIssueOrPullRequestNumberFromURL); - - // Tag version and comparison URL - // eslint-disable-next-line max-len - let issueBody = `**Release Version:** \`${tag}\`\r\n**Compare Changes:** https://github.com/Expensify/App/compare/production...staging\r\n`; - - // PR list - if (!_.isEmpty(sortedPRList)) { - issueBody += '\r\n**This release contains changes from the following pull requests:**\r\n'; - _.each(sortedPRList, (URL) => { - issueBody += _.contains(verifiedOrNoQAPRs, URL) ? '- [x]' : '- [ ]'; - issueBody += ` ${URL}\r\n`; - }); - issueBody += '\r\n\r\n'; - } + const internalQAPRs = _.filter(data, (pr) => !_.isEmpty(_.findWhere(pr.labels, {name: CONST.LABELS.INTERNAL_QA}))); + return Promise.all(_.map(internalQAPRs, (pr) => this.getPullRequestMergerLogin(pr.number).then((mergerLogin) => ({url: pr.html_url, mergerLogin})))).then((results) => { + // The format of this map is following: + // { + // 'https://github.com/Expensify/App/pull/9641': 'PauloGasparSv', + // 'https://github.com/Expensify/App/pull/9642': 'mountiny' + // } + const internalQAPRMap = _.reduce( + results, + (acc, {url, mergerLogin}) => { + acc[url] = mergerLogin; + return acc; + }, + {}, + ); + console.log('Found the following Internal QA PRs:', internalQAPRMap); + + const noQAPRs = _.pluck( + _.filter(data, (PR) => /\[No\s?QA]/i.test(PR.title)), + 'html_url', + ); + console.log('Found the following NO QA PRs:', noQAPRs); + const verifiedOrNoQAPRs = _.union(verifiedPRList, noQAPRs); + + const sortedPRList = _.chain(PRList).difference(_.keys(internalQAPRMap)).unique().sortBy(GithubUtils.getPullRequestNumberFromURL).value(); + const sortedDeployBlockers = _.sortBy(_.unique(deployBlockers), GithubUtils.getIssueOrPullRequestNumberFromURL); + + // Tag version and comparison URL + // eslint-disable-next-line max-len + let issueBody = `**Release Version:** \`${tag}\`\r\n**Compare Changes:** https://github.com/Expensify/App/compare/production...staging\r\n`; + + // PR list + if (!_.isEmpty(sortedPRList)) { + issueBody += '\r\n**This release contains changes from the following pull requests:**\r\n'; + _.each(sortedPRList, (URL) => { + issueBody += _.contains(verifiedOrNoQAPRs, URL) ? '- [x]' : '- [ ]'; + issueBody += ` ${URL}\r\n`; + }); + issueBody += '\r\n\r\n'; + } - // Internal QA PR list - if (!_.isEmpty(internalQAPRMap)) { - console.log('Found the following verified Internal QA PRs:', resolvedInternalQAPRs); - issueBody += '**Internal QA:**\r\n'; - _.each(internalQAPRMap, (assignees, URL) => { - const assigneeMentions = _.reduce(assignees, (memo, assignee) => `${memo} @${assignee}`, ''); - issueBody += `${_.contains(resolvedInternalQAPRs, URL) ? '- [x]' : '- [ ]'} `; - issueBody += `${URL}`; - issueBody += ` -${assigneeMentions}`; - issueBody += '\r\n'; - }); - issueBody += '\r\n\r\n'; - } + // Internal QA PR list + if (!_.isEmpty(internalQAPRMap)) { + console.log('Found the following verified Internal QA PRs:', resolvedInternalQAPRs); + issueBody += '**Internal QA:**\r\n'; + _.each(internalQAPRMap, (merger, URL) => { + const mergerMention = `@${merger}`; + issueBody += `${_.contains(resolvedInternalQAPRs, URL) ? '- [x]' : '- [ ]'} `; + issueBody += `${URL}`; + issueBody += ` - ${mergerMention}`; + issueBody += '\r\n'; + }); + issueBody += '\r\n\r\n'; + } - // Deploy blockers - if (!_.isEmpty(deployBlockers)) { - issueBody += '**Deploy Blockers:**\r\n'; - _.each(sortedDeployBlockers, (URL) => { - issueBody += _.contains(resolvedDeployBlockers, URL) ? '- [x] ' : '- [ ] '; - issueBody += URL; - issueBody += '\r\n'; - }); - issueBody += '\r\n\r\n'; - } + // Deploy blockers + if (!_.isEmpty(deployBlockers)) { + issueBody += '**Deploy Blockers:**\r\n'; + _.each(sortedDeployBlockers, (URL) => { + issueBody += _.contains(resolvedDeployBlockers, URL) ? '- [x] ' : '- [ ] '; + issueBody += URL; + issueBody += '\r\n'; + }); + issueBody += '\r\n\r\n'; + } - issueBody += '**Deployer verifications:**'; - // eslint-disable-next-line max-len - issueBody += `\r\n- [${ - isTimingDashboardChecked ? 'x' : ' ' - }] I checked the [App Timing Dashboard](https://graphs.expensify.com/grafana/d/yj2EobAGz/app-timing?orgId=1) and verified this release does not cause a noticeable performance regression.`; - // eslint-disable-next-line max-len - issueBody += `\r\n- [${ - isFirebaseChecked ? 'x' : ' ' - }] I checked [Firebase Crashlytics](https://console.firebase.google.com/u/0/project/expensify-chat/crashlytics/app/android:com.expensify.chat/issues?state=open&time=last-seven-days&tag=all) and verified that this release does not introduce any new crashes. More detailed instructions on this verification can be found [here](https://stackoverflowteams.com/c/expensify/questions/15095/15096).`; - // eslint-disable-next-line max-len - issueBody += `\r\n- [${isGHStatusChecked ? 'x' : ' '}] I checked [GitHub Status](https://www.githubstatus.com/) and verified there is no reported incident with Actions.`; - - issueBody += '\r\n\r\ncc @Expensify/applauseleads\r\n'; - return issueBody; + issueBody += '**Deployer verifications:**'; + // eslint-disable-next-line max-len + issueBody += `\r\n- [${ + isTimingDashboardChecked ? 'x' : ' ' + }] I checked the [App Timing Dashboard](https://graphs.expensify.com/grafana/d/yj2EobAGz/app-timing?orgId=1) and verified this release does not cause a noticeable performance regression.`; + // eslint-disable-next-line max-len + issueBody += `\r\n- [${ + isFirebaseChecked ? 'x' : ' ' + }] I checked [Firebase Crashlytics](https://console.firebase.google.com/u/0/project/expensify-chat/crashlytics/app/android:com.expensify.chat/issues?state=open&time=last-seven-days&tag=all) and verified that this release does not introduce any new crashes. More detailed instructions on this verification can be found [here](https://stackoverflowteams.com/c/expensify/questions/15095/15096).`; + // eslint-disable-next-line max-len + issueBody += `\r\n- [${isGHStatusChecked ? 'x' : ' '}] I checked [GitHub Status](https://www.githubstatus.com/) and verified there is no reported incident with Actions.`; + + issueBody += '\r\n\r\ncc @Expensify/applauseleads\r\n'; + const issueAssignees = _.uniq(_.values(internalQAPRMap)); + const issue = {issueBody, issueAssignees}; + return issue; + }); }) .catch((err) => console.warn('Error generating StagingDeployCash issue body! Continuing...', err)); } @@ -498,6 +502,20 @@ class GithubUtils { .catch((err) => console.error('Failed to get PR list', err)); } + /** + * @param {Number} pullRequestNumber + * @returns {Promise} + */ + static getPullRequestMergerLogin(pullRequestNumber) { + return this.octokit.pulls + .get({ + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, + pull_number: pullRequestNumber, + }) + .then(({data: pullRequest}) => pullRequest.merged_by.login); + } + /** * @param {Number} pullRequestNumber * @returns {Promise} diff --git a/.github/actions/javascript/reopenIssueWithComment/index.js b/.github/actions/javascript/reopenIssueWithComment/index.js index 6a5f89badb5e..9c740914dc1b 100644 --- a/.github/actions/javascript/reopenIssueWithComment/index.js +++ b/.github/actions/javascript/reopenIssueWithComment/index.js @@ -255,7 +255,7 @@ class GithubUtils { } /** - * Generate the issue body for a StagingDeployCash. + * Generate the issue body and assignees for a StagingDeployCash. * * @param {String} tag * @param {Array} PRList - The list of PR URLs which are included in this StagingDeployCash @@ -268,7 +268,7 @@ class GithubUtils { * @param {Boolean} [isGHStatusChecked] * @returns {Promise} */ - static generateStagingDeployCashBody( + static generateStagingDeployCashBodyAndAssignees( tag, PRList, verifiedPRList = [], @@ -281,85 +281,89 @@ class GithubUtils { ) { return this.fetchAllPullRequests(_.map(PRList, this.getPullRequestNumberFromURL)) .then((data) => { - // The format of this map is following: - // { - // 'https://github.com/Expensify/App/pull/9641': [ 'PauloGasparSv', 'kidroca' ], - // 'https://github.com/Expensify/App/pull/9642': [ 'mountiny', 'kidroca' ] - // } - const internalQAPRMap = _.reduce( - _.filter(data, (pr) => !_.isEmpty(_.findWhere(pr.labels, {name: CONST.LABELS.INTERNAL_QA}))), - (map, pr) => { - // eslint-disable-next-line no-param-reassign - map[pr.html_url] = _.compact(_.pluck(pr.assignees, 'login')); - return map; - }, - {}, - ); - console.log('Found the following Internal QA PRs:', internalQAPRMap); - - const noQAPRs = _.pluck( - _.filter(data, (PR) => /\[No\s?QA]/i.test(PR.title)), - 'html_url', - ); - console.log('Found the following NO QA PRs:', noQAPRs); - const verifiedOrNoQAPRs = _.union(verifiedPRList, noQAPRs); - - const sortedPRList = _.chain(PRList).difference(_.keys(internalQAPRMap)).unique().sortBy(GithubUtils.getPullRequestNumberFromURL).value(); - const sortedDeployBlockers = _.sortBy(_.unique(deployBlockers), GithubUtils.getIssueOrPullRequestNumberFromURL); - - // Tag version and comparison URL - // eslint-disable-next-line max-len - let issueBody = `**Release Version:** \`${tag}\`\r\n**Compare Changes:** https://github.com/Expensify/App/compare/production...staging\r\n`; - - // PR list - if (!_.isEmpty(sortedPRList)) { - issueBody += '\r\n**This release contains changes from the following pull requests:**\r\n'; - _.each(sortedPRList, (URL) => { - issueBody += _.contains(verifiedOrNoQAPRs, URL) ? '- [x]' : '- [ ]'; - issueBody += ` ${URL}\r\n`; - }); - issueBody += '\r\n\r\n'; - } + const internalQAPRs = _.filter(data, (pr) => !_.isEmpty(_.findWhere(pr.labels, {name: CONST.LABELS.INTERNAL_QA}))); + return Promise.all(_.map(internalQAPRs, (pr) => this.getPullRequestMergerLogin(pr.number).then((mergerLogin) => ({url: pr.html_url, mergerLogin})))).then((results) => { + // The format of this map is following: + // { + // 'https://github.com/Expensify/App/pull/9641': 'PauloGasparSv', + // 'https://github.com/Expensify/App/pull/9642': 'mountiny' + // } + const internalQAPRMap = _.reduce( + results, + (acc, {url, mergerLogin}) => { + acc[url] = mergerLogin; + return acc; + }, + {}, + ); + console.log('Found the following Internal QA PRs:', internalQAPRMap); + + const noQAPRs = _.pluck( + _.filter(data, (PR) => /\[No\s?QA]/i.test(PR.title)), + 'html_url', + ); + console.log('Found the following NO QA PRs:', noQAPRs); + const verifiedOrNoQAPRs = _.union(verifiedPRList, noQAPRs); + + const sortedPRList = _.chain(PRList).difference(_.keys(internalQAPRMap)).unique().sortBy(GithubUtils.getPullRequestNumberFromURL).value(); + const sortedDeployBlockers = _.sortBy(_.unique(deployBlockers), GithubUtils.getIssueOrPullRequestNumberFromURL); + + // Tag version and comparison URL + // eslint-disable-next-line max-len + let issueBody = `**Release Version:** \`${tag}\`\r\n**Compare Changes:** https://github.com/Expensify/App/compare/production...staging\r\n`; + + // PR list + if (!_.isEmpty(sortedPRList)) { + issueBody += '\r\n**This release contains changes from the following pull requests:**\r\n'; + _.each(sortedPRList, (URL) => { + issueBody += _.contains(verifiedOrNoQAPRs, URL) ? '- [x]' : '- [ ]'; + issueBody += ` ${URL}\r\n`; + }); + issueBody += '\r\n\r\n'; + } - // Internal QA PR list - if (!_.isEmpty(internalQAPRMap)) { - console.log('Found the following verified Internal QA PRs:', resolvedInternalQAPRs); - issueBody += '**Internal QA:**\r\n'; - _.each(internalQAPRMap, (assignees, URL) => { - const assigneeMentions = _.reduce(assignees, (memo, assignee) => `${memo} @${assignee}`, ''); - issueBody += `${_.contains(resolvedInternalQAPRs, URL) ? '- [x]' : '- [ ]'} `; - issueBody += `${URL}`; - issueBody += ` -${assigneeMentions}`; - issueBody += '\r\n'; - }); - issueBody += '\r\n\r\n'; - } + // Internal QA PR list + if (!_.isEmpty(internalQAPRMap)) { + console.log('Found the following verified Internal QA PRs:', resolvedInternalQAPRs); + issueBody += '**Internal QA:**\r\n'; + _.each(internalQAPRMap, (merger, URL) => { + const mergerMention = `@${merger}`; + issueBody += `${_.contains(resolvedInternalQAPRs, URL) ? '- [x]' : '- [ ]'} `; + issueBody += `${URL}`; + issueBody += ` - ${mergerMention}`; + issueBody += '\r\n'; + }); + issueBody += '\r\n\r\n'; + } - // Deploy blockers - if (!_.isEmpty(deployBlockers)) { - issueBody += '**Deploy Blockers:**\r\n'; - _.each(sortedDeployBlockers, (URL) => { - issueBody += _.contains(resolvedDeployBlockers, URL) ? '- [x] ' : '- [ ] '; - issueBody += URL; - issueBody += '\r\n'; - }); - issueBody += '\r\n\r\n'; - } + // Deploy blockers + if (!_.isEmpty(deployBlockers)) { + issueBody += '**Deploy Blockers:**\r\n'; + _.each(sortedDeployBlockers, (URL) => { + issueBody += _.contains(resolvedDeployBlockers, URL) ? '- [x] ' : '- [ ] '; + issueBody += URL; + issueBody += '\r\n'; + }); + issueBody += '\r\n\r\n'; + } - issueBody += '**Deployer verifications:**'; - // eslint-disable-next-line max-len - issueBody += `\r\n- [${ - isTimingDashboardChecked ? 'x' : ' ' - }] I checked the [App Timing Dashboard](https://graphs.expensify.com/grafana/d/yj2EobAGz/app-timing?orgId=1) and verified this release does not cause a noticeable performance regression.`; - // eslint-disable-next-line max-len - issueBody += `\r\n- [${ - isFirebaseChecked ? 'x' : ' ' - }] I checked [Firebase Crashlytics](https://console.firebase.google.com/u/0/project/expensify-chat/crashlytics/app/android:com.expensify.chat/issues?state=open&time=last-seven-days&tag=all) and verified that this release does not introduce any new crashes. More detailed instructions on this verification can be found [here](https://stackoverflowteams.com/c/expensify/questions/15095/15096).`; - // eslint-disable-next-line max-len - issueBody += `\r\n- [${isGHStatusChecked ? 'x' : ' '}] I checked [GitHub Status](https://www.githubstatus.com/) and verified there is no reported incident with Actions.`; - - issueBody += '\r\n\r\ncc @Expensify/applauseleads\r\n'; - return issueBody; + issueBody += '**Deployer verifications:**'; + // eslint-disable-next-line max-len + issueBody += `\r\n- [${ + isTimingDashboardChecked ? 'x' : ' ' + }] I checked the [App Timing Dashboard](https://graphs.expensify.com/grafana/d/yj2EobAGz/app-timing?orgId=1) and verified this release does not cause a noticeable performance regression.`; + // eslint-disable-next-line max-len + issueBody += `\r\n- [${ + isFirebaseChecked ? 'x' : ' ' + }] I checked [Firebase Crashlytics](https://console.firebase.google.com/u/0/project/expensify-chat/crashlytics/app/android:com.expensify.chat/issues?state=open&time=last-seven-days&tag=all) and verified that this release does not introduce any new crashes. More detailed instructions on this verification can be found [here](https://stackoverflowteams.com/c/expensify/questions/15095/15096).`; + // eslint-disable-next-line max-len + issueBody += `\r\n- [${isGHStatusChecked ? 'x' : ' '}] I checked [GitHub Status](https://www.githubstatus.com/) and verified there is no reported incident with Actions.`; + + issueBody += '\r\n\r\ncc @Expensify/applauseleads\r\n'; + const issueAssignees = _.uniq(_.values(internalQAPRMap)); + const issue = {issueBody, issueAssignees}; + return issue; + }); }) .catch((err) => console.warn('Error generating StagingDeployCash issue body! Continuing...', err)); } @@ -393,6 +397,20 @@ class GithubUtils { .catch((err) => console.error('Failed to get PR list', err)); } + /** + * @param {Number} pullRequestNumber + * @returns {Promise} + */ + static getPullRequestMergerLogin(pullRequestNumber) { + return this.octokit.pulls + .get({ + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, + pull_number: pullRequestNumber, + }) + .then(({data: pullRequest}) => pullRequest.merged_by.login); + } + /** * @param {Number} pullRequestNumber * @returns {Promise} diff --git a/.github/actions/javascript/reviewerChecklist/index.js b/.github/actions/javascript/reviewerChecklist/index.js index 322b529b89bf..7b162f06840d 100644 --- a/.github/actions/javascript/reviewerChecklist/index.js +++ b/.github/actions/javascript/reviewerChecklist/index.js @@ -255,7 +255,7 @@ class GithubUtils { } /** - * Generate the issue body for a StagingDeployCash. + * Generate the issue body and assignees for a StagingDeployCash. * * @param {String} tag * @param {Array} PRList - The list of PR URLs which are included in this StagingDeployCash @@ -268,7 +268,7 @@ class GithubUtils { * @param {Boolean} [isGHStatusChecked] * @returns {Promise} */ - static generateStagingDeployCashBody( + static generateStagingDeployCashBodyAndAssignees( tag, PRList, verifiedPRList = [], @@ -281,85 +281,89 @@ class GithubUtils { ) { return this.fetchAllPullRequests(_.map(PRList, this.getPullRequestNumberFromURL)) .then((data) => { - // The format of this map is following: - // { - // 'https://github.com/Expensify/App/pull/9641': [ 'PauloGasparSv', 'kidroca' ], - // 'https://github.com/Expensify/App/pull/9642': [ 'mountiny', 'kidroca' ] - // } - const internalQAPRMap = _.reduce( - _.filter(data, (pr) => !_.isEmpty(_.findWhere(pr.labels, {name: CONST.LABELS.INTERNAL_QA}))), - (map, pr) => { - // eslint-disable-next-line no-param-reassign - map[pr.html_url] = _.compact(_.pluck(pr.assignees, 'login')); - return map; - }, - {}, - ); - console.log('Found the following Internal QA PRs:', internalQAPRMap); - - const noQAPRs = _.pluck( - _.filter(data, (PR) => /\[No\s?QA]/i.test(PR.title)), - 'html_url', - ); - console.log('Found the following NO QA PRs:', noQAPRs); - const verifiedOrNoQAPRs = _.union(verifiedPRList, noQAPRs); - - const sortedPRList = _.chain(PRList).difference(_.keys(internalQAPRMap)).unique().sortBy(GithubUtils.getPullRequestNumberFromURL).value(); - const sortedDeployBlockers = _.sortBy(_.unique(deployBlockers), GithubUtils.getIssueOrPullRequestNumberFromURL); - - // Tag version and comparison URL - // eslint-disable-next-line max-len - let issueBody = `**Release Version:** \`${tag}\`\r\n**Compare Changes:** https://github.com/Expensify/App/compare/production...staging\r\n`; - - // PR list - if (!_.isEmpty(sortedPRList)) { - issueBody += '\r\n**This release contains changes from the following pull requests:**\r\n'; - _.each(sortedPRList, (URL) => { - issueBody += _.contains(verifiedOrNoQAPRs, URL) ? '- [x]' : '- [ ]'; - issueBody += ` ${URL}\r\n`; - }); - issueBody += '\r\n\r\n'; - } + const internalQAPRs = _.filter(data, (pr) => !_.isEmpty(_.findWhere(pr.labels, {name: CONST.LABELS.INTERNAL_QA}))); + return Promise.all(_.map(internalQAPRs, (pr) => this.getPullRequestMergerLogin(pr.number).then((mergerLogin) => ({url: pr.html_url, mergerLogin})))).then((results) => { + // The format of this map is following: + // { + // 'https://github.com/Expensify/App/pull/9641': 'PauloGasparSv', + // 'https://github.com/Expensify/App/pull/9642': 'mountiny' + // } + const internalQAPRMap = _.reduce( + results, + (acc, {url, mergerLogin}) => { + acc[url] = mergerLogin; + return acc; + }, + {}, + ); + console.log('Found the following Internal QA PRs:', internalQAPRMap); + + const noQAPRs = _.pluck( + _.filter(data, (PR) => /\[No\s?QA]/i.test(PR.title)), + 'html_url', + ); + console.log('Found the following NO QA PRs:', noQAPRs); + const verifiedOrNoQAPRs = _.union(verifiedPRList, noQAPRs); + + const sortedPRList = _.chain(PRList).difference(_.keys(internalQAPRMap)).unique().sortBy(GithubUtils.getPullRequestNumberFromURL).value(); + const sortedDeployBlockers = _.sortBy(_.unique(deployBlockers), GithubUtils.getIssueOrPullRequestNumberFromURL); + + // Tag version and comparison URL + // eslint-disable-next-line max-len + let issueBody = `**Release Version:** \`${tag}\`\r\n**Compare Changes:** https://github.com/Expensify/App/compare/production...staging\r\n`; + + // PR list + if (!_.isEmpty(sortedPRList)) { + issueBody += '\r\n**This release contains changes from the following pull requests:**\r\n'; + _.each(sortedPRList, (URL) => { + issueBody += _.contains(verifiedOrNoQAPRs, URL) ? '- [x]' : '- [ ]'; + issueBody += ` ${URL}\r\n`; + }); + issueBody += '\r\n\r\n'; + } - // Internal QA PR list - if (!_.isEmpty(internalQAPRMap)) { - console.log('Found the following verified Internal QA PRs:', resolvedInternalQAPRs); - issueBody += '**Internal QA:**\r\n'; - _.each(internalQAPRMap, (assignees, URL) => { - const assigneeMentions = _.reduce(assignees, (memo, assignee) => `${memo} @${assignee}`, ''); - issueBody += `${_.contains(resolvedInternalQAPRs, URL) ? '- [x]' : '- [ ]'} `; - issueBody += `${URL}`; - issueBody += ` -${assigneeMentions}`; - issueBody += '\r\n'; - }); - issueBody += '\r\n\r\n'; - } + // Internal QA PR list + if (!_.isEmpty(internalQAPRMap)) { + console.log('Found the following verified Internal QA PRs:', resolvedInternalQAPRs); + issueBody += '**Internal QA:**\r\n'; + _.each(internalQAPRMap, (merger, URL) => { + const mergerMention = `@${merger}`; + issueBody += `${_.contains(resolvedInternalQAPRs, URL) ? '- [x]' : '- [ ]'} `; + issueBody += `${URL}`; + issueBody += ` - ${mergerMention}`; + issueBody += '\r\n'; + }); + issueBody += '\r\n\r\n'; + } - // Deploy blockers - if (!_.isEmpty(deployBlockers)) { - issueBody += '**Deploy Blockers:**\r\n'; - _.each(sortedDeployBlockers, (URL) => { - issueBody += _.contains(resolvedDeployBlockers, URL) ? '- [x] ' : '- [ ] '; - issueBody += URL; - issueBody += '\r\n'; - }); - issueBody += '\r\n\r\n'; - } + // Deploy blockers + if (!_.isEmpty(deployBlockers)) { + issueBody += '**Deploy Blockers:**\r\n'; + _.each(sortedDeployBlockers, (URL) => { + issueBody += _.contains(resolvedDeployBlockers, URL) ? '- [x] ' : '- [ ] '; + issueBody += URL; + issueBody += '\r\n'; + }); + issueBody += '\r\n\r\n'; + } - issueBody += '**Deployer verifications:**'; - // eslint-disable-next-line max-len - issueBody += `\r\n- [${ - isTimingDashboardChecked ? 'x' : ' ' - }] I checked the [App Timing Dashboard](https://graphs.expensify.com/grafana/d/yj2EobAGz/app-timing?orgId=1) and verified this release does not cause a noticeable performance regression.`; - // eslint-disable-next-line max-len - issueBody += `\r\n- [${ - isFirebaseChecked ? 'x' : ' ' - }] I checked [Firebase Crashlytics](https://console.firebase.google.com/u/0/project/expensify-chat/crashlytics/app/android:com.expensify.chat/issues?state=open&time=last-seven-days&tag=all) and verified that this release does not introduce any new crashes. More detailed instructions on this verification can be found [here](https://stackoverflowteams.com/c/expensify/questions/15095/15096).`; - // eslint-disable-next-line max-len - issueBody += `\r\n- [${isGHStatusChecked ? 'x' : ' '}] I checked [GitHub Status](https://www.githubstatus.com/) and verified there is no reported incident with Actions.`; - - issueBody += '\r\n\r\ncc @Expensify/applauseleads\r\n'; - return issueBody; + issueBody += '**Deployer verifications:**'; + // eslint-disable-next-line max-len + issueBody += `\r\n- [${ + isTimingDashboardChecked ? 'x' : ' ' + }] I checked the [App Timing Dashboard](https://graphs.expensify.com/grafana/d/yj2EobAGz/app-timing?orgId=1) and verified this release does not cause a noticeable performance regression.`; + // eslint-disable-next-line max-len + issueBody += `\r\n- [${ + isFirebaseChecked ? 'x' : ' ' + }] I checked [Firebase Crashlytics](https://console.firebase.google.com/u/0/project/expensify-chat/crashlytics/app/android:com.expensify.chat/issues?state=open&time=last-seven-days&tag=all) and verified that this release does not introduce any new crashes. More detailed instructions on this verification can be found [here](https://stackoverflowteams.com/c/expensify/questions/15095/15096).`; + // eslint-disable-next-line max-len + issueBody += `\r\n- [${isGHStatusChecked ? 'x' : ' '}] I checked [GitHub Status](https://www.githubstatus.com/) and verified there is no reported incident with Actions.`; + + issueBody += '\r\n\r\ncc @Expensify/applauseleads\r\n'; + const issueAssignees = _.uniq(_.values(internalQAPRMap)); + const issue = {issueBody, issueAssignees}; + return issue; + }); }) .catch((err) => console.warn('Error generating StagingDeployCash issue body! Continuing...', err)); } @@ -393,6 +397,20 @@ class GithubUtils { .catch((err) => console.error('Failed to get PR list', err)); } + /** + * @param {Number} pullRequestNumber + * @returns {Promise} + */ + static getPullRequestMergerLogin(pullRequestNumber) { + return this.octokit.pulls + .get({ + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, + pull_number: pullRequestNumber, + }) + .then(({data: pullRequest}) => pullRequest.merged_by.login); + } + /** * @param {Number} pullRequestNumber * @returns {Promise} diff --git a/.github/actions/javascript/verifySignedCommits/index.js b/.github/actions/javascript/verifySignedCommits/index.js index ba188d3a2b86..07173cb19bc5 100644 --- a/.github/actions/javascript/verifySignedCommits/index.js +++ b/.github/actions/javascript/verifySignedCommits/index.js @@ -255,7 +255,7 @@ class GithubUtils { } /** - * Generate the issue body for a StagingDeployCash. + * Generate the issue body and assignees for a StagingDeployCash. * * @param {String} tag * @param {Array} PRList - The list of PR URLs which are included in this StagingDeployCash @@ -268,7 +268,7 @@ class GithubUtils { * @param {Boolean} [isGHStatusChecked] * @returns {Promise} */ - static generateStagingDeployCashBody( + static generateStagingDeployCashBodyAndAssignees( tag, PRList, verifiedPRList = [], @@ -281,85 +281,89 @@ class GithubUtils { ) { return this.fetchAllPullRequests(_.map(PRList, this.getPullRequestNumberFromURL)) .then((data) => { - // The format of this map is following: - // { - // 'https://github.com/Expensify/App/pull/9641': [ 'PauloGasparSv', 'kidroca' ], - // 'https://github.com/Expensify/App/pull/9642': [ 'mountiny', 'kidroca' ] - // } - const internalQAPRMap = _.reduce( - _.filter(data, (pr) => !_.isEmpty(_.findWhere(pr.labels, {name: CONST.LABELS.INTERNAL_QA}))), - (map, pr) => { - // eslint-disable-next-line no-param-reassign - map[pr.html_url] = _.compact(_.pluck(pr.assignees, 'login')); - return map; - }, - {}, - ); - console.log('Found the following Internal QA PRs:', internalQAPRMap); - - const noQAPRs = _.pluck( - _.filter(data, (PR) => /\[No\s?QA]/i.test(PR.title)), - 'html_url', - ); - console.log('Found the following NO QA PRs:', noQAPRs); - const verifiedOrNoQAPRs = _.union(verifiedPRList, noQAPRs); - - const sortedPRList = _.chain(PRList).difference(_.keys(internalQAPRMap)).unique().sortBy(GithubUtils.getPullRequestNumberFromURL).value(); - const sortedDeployBlockers = _.sortBy(_.unique(deployBlockers), GithubUtils.getIssueOrPullRequestNumberFromURL); - - // Tag version and comparison URL - // eslint-disable-next-line max-len - let issueBody = `**Release Version:** \`${tag}\`\r\n**Compare Changes:** https://github.com/Expensify/App/compare/production...staging\r\n`; - - // PR list - if (!_.isEmpty(sortedPRList)) { - issueBody += '\r\n**This release contains changes from the following pull requests:**\r\n'; - _.each(sortedPRList, (URL) => { - issueBody += _.contains(verifiedOrNoQAPRs, URL) ? '- [x]' : '- [ ]'; - issueBody += ` ${URL}\r\n`; - }); - issueBody += '\r\n\r\n'; - } + const internalQAPRs = _.filter(data, (pr) => !_.isEmpty(_.findWhere(pr.labels, {name: CONST.LABELS.INTERNAL_QA}))); + return Promise.all(_.map(internalQAPRs, (pr) => this.getPullRequestMergerLogin(pr.number).then((mergerLogin) => ({url: pr.html_url, mergerLogin})))).then((results) => { + // The format of this map is following: + // { + // 'https://github.com/Expensify/App/pull/9641': 'PauloGasparSv', + // 'https://github.com/Expensify/App/pull/9642': 'mountiny' + // } + const internalQAPRMap = _.reduce( + results, + (acc, {url, mergerLogin}) => { + acc[url] = mergerLogin; + return acc; + }, + {}, + ); + console.log('Found the following Internal QA PRs:', internalQAPRMap); + + const noQAPRs = _.pluck( + _.filter(data, (PR) => /\[No\s?QA]/i.test(PR.title)), + 'html_url', + ); + console.log('Found the following NO QA PRs:', noQAPRs); + const verifiedOrNoQAPRs = _.union(verifiedPRList, noQAPRs); + + const sortedPRList = _.chain(PRList).difference(_.keys(internalQAPRMap)).unique().sortBy(GithubUtils.getPullRequestNumberFromURL).value(); + const sortedDeployBlockers = _.sortBy(_.unique(deployBlockers), GithubUtils.getIssueOrPullRequestNumberFromURL); + + // Tag version and comparison URL + // eslint-disable-next-line max-len + let issueBody = `**Release Version:** \`${tag}\`\r\n**Compare Changes:** https://github.com/Expensify/App/compare/production...staging\r\n`; + + // PR list + if (!_.isEmpty(sortedPRList)) { + issueBody += '\r\n**This release contains changes from the following pull requests:**\r\n'; + _.each(sortedPRList, (URL) => { + issueBody += _.contains(verifiedOrNoQAPRs, URL) ? '- [x]' : '- [ ]'; + issueBody += ` ${URL}\r\n`; + }); + issueBody += '\r\n\r\n'; + } - // Internal QA PR list - if (!_.isEmpty(internalQAPRMap)) { - console.log('Found the following verified Internal QA PRs:', resolvedInternalQAPRs); - issueBody += '**Internal QA:**\r\n'; - _.each(internalQAPRMap, (assignees, URL) => { - const assigneeMentions = _.reduce(assignees, (memo, assignee) => `${memo} @${assignee}`, ''); - issueBody += `${_.contains(resolvedInternalQAPRs, URL) ? '- [x]' : '- [ ]'} `; - issueBody += `${URL}`; - issueBody += ` -${assigneeMentions}`; - issueBody += '\r\n'; - }); - issueBody += '\r\n\r\n'; - } + // Internal QA PR list + if (!_.isEmpty(internalQAPRMap)) { + console.log('Found the following verified Internal QA PRs:', resolvedInternalQAPRs); + issueBody += '**Internal QA:**\r\n'; + _.each(internalQAPRMap, (merger, URL) => { + const mergerMention = `@${merger}`; + issueBody += `${_.contains(resolvedInternalQAPRs, URL) ? '- [x]' : '- [ ]'} `; + issueBody += `${URL}`; + issueBody += ` - ${mergerMention}`; + issueBody += '\r\n'; + }); + issueBody += '\r\n\r\n'; + } - // Deploy blockers - if (!_.isEmpty(deployBlockers)) { - issueBody += '**Deploy Blockers:**\r\n'; - _.each(sortedDeployBlockers, (URL) => { - issueBody += _.contains(resolvedDeployBlockers, URL) ? '- [x] ' : '- [ ] '; - issueBody += URL; - issueBody += '\r\n'; - }); - issueBody += '\r\n\r\n'; - } + // Deploy blockers + if (!_.isEmpty(deployBlockers)) { + issueBody += '**Deploy Blockers:**\r\n'; + _.each(sortedDeployBlockers, (URL) => { + issueBody += _.contains(resolvedDeployBlockers, URL) ? '- [x] ' : '- [ ] '; + issueBody += URL; + issueBody += '\r\n'; + }); + issueBody += '\r\n\r\n'; + } - issueBody += '**Deployer verifications:**'; - // eslint-disable-next-line max-len - issueBody += `\r\n- [${ - isTimingDashboardChecked ? 'x' : ' ' - }] I checked the [App Timing Dashboard](https://graphs.expensify.com/grafana/d/yj2EobAGz/app-timing?orgId=1) and verified this release does not cause a noticeable performance regression.`; - // eslint-disable-next-line max-len - issueBody += `\r\n- [${ - isFirebaseChecked ? 'x' : ' ' - }] I checked [Firebase Crashlytics](https://console.firebase.google.com/u/0/project/expensify-chat/crashlytics/app/android:com.expensify.chat/issues?state=open&time=last-seven-days&tag=all) and verified that this release does not introduce any new crashes. More detailed instructions on this verification can be found [here](https://stackoverflowteams.com/c/expensify/questions/15095/15096).`; - // eslint-disable-next-line max-len - issueBody += `\r\n- [${isGHStatusChecked ? 'x' : ' '}] I checked [GitHub Status](https://www.githubstatus.com/) and verified there is no reported incident with Actions.`; - - issueBody += '\r\n\r\ncc @Expensify/applauseleads\r\n'; - return issueBody; + issueBody += '**Deployer verifications:**'; + // eslint-disable-next-line max-len + issueBody += `\r\n- [${ + isTimingDashboardChecked ? 'x' : ' ' + }] I checked the [App Timing Dashboard](https://graphs.expensify.com/grafana/d/yj2EobAGz/app-timing?orgId=1) and verified this release does not cause a noticeable performance regression.`; + // eslint-disable-next-line max-len + issueBody += `\r\n- [${ + isFirebaseChecked ? 'x' : ' ' + }] I checked [Firebase Crashlytics](https://console.firebase.google.com/u/0/project/expensify-chat/crashlytics/app/android:com.expensify.chat/issues?state=open&time=last-seven-days&tag=all) and verified that this release does not introduce any new crashes. More detailed instructions on this verification can be found [here](https://stackoverflowteams.com/c/expensify/questions/15095/15096).`; + // eslint-disable-next-line max-len + issueBody += `\r\n- [${isGHStatusChecked ? 'x' : ' '}] I checked [GitHub Status](https://www.githubstatus.com/) and verified there is no reported incident with Actions.`; + + issueBody += '\r\n\r\ncc @Expensify/applauseleads\r\n'; + const issueAssignees = _.uniq(_.values(internalQAPRMap)); + const issue = {issueBody, issueAssignees}; + return issue; + }); }) .catch((err) => console.warn('Error generating StagingDeployCash issue body! Continuing...', err)); } @@ -393,6 +397,20 @@ class GithubUtils { .catch((err) => console.error('Failed to get PR list', err)); } + /** + * @param {Number} pullRequestNumber + * @returns {Promise} + */ + static getPullRequestMergerLogin(pullRequestNumber) { + return this.octokit.pulls + .get({ + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, + pull_number: pullRequestNumber, + }) + .then(({data: pullRequest}) => pullRequest.merged_by.login); + } + /** * @param {Number} pullRequestNumber * @returns {Promise} From 0ad44d14866b6739d456fd130a1b716481d8c8d7 Mon Sep 17 00:00:00 2001 From: rayane-djouah <77965000+rayane-djouah@users.noreply.github.com> Date: Sat, 16 Mar 2024 15:26:05 +0100 Subject: [PATCH 12/29] Build Actions --- .../javascript/authorChecklist/index.js | 174 ++++++++-------- .../createOrUpdateStagingDeploy/index.js | 185 ++++++++++-------- .../getDeployPullRequestList/index.js | 174 ++++++++-------- 3 files changed, 296 insertions(+), 237 deletions(-) diff --git a/.github/actions/javascript/authorChecklist/index.js b/.github/actions/javascript/authorChecklist/index.js index 528a0a11498a..b20cc83498ba 100644 --- a/.github/actions/javascript/authorChecklist/index.js +++ b/.github/actions/javascript/authorChecklist/index.js @@ -255,7 +255,7 @@ class GithubUtils { } /** - * Generate the issue body for a StagingDeployCash. + * Generate the issue body and assignees for a StagingDeployCash. * * @param {String} tag * @param {Array} PRList - The list of PR URLs which are included in this StagingDeployCash @@ -268,7 +268,7 @@ class GithubUtils { * @param {Boolean} [isGHStatusChecked] * @returns {Promise} */ - static generateStagingDeployCashBody( + static generateStagingDeployCashBodyAndAssignees( tag, PRList, verifiedPRList = [], @@ -281,85 +281,89 @@ class GithubUtils { ) { return this.fetchAllPullRequests(_.map(PRList, this.getPullRequestNumberFromURL)) .then((data) => { - // The format of this map is following: - // { - // 'https://github.com/Expensify/App/pull/9641': [ 'PauloGasparSv', 'kidroca' ], - // 'https://github.com/Expensify/App/pull/9642': [ 'mountiny', 'kidroca' ] - // } - const internalQAPRMap = _.reduce( - _.filter(data, (pr) => !_.isEmpty(_.findWhere(pr.labels, {name: CONST.LABELS.INTERNAL_QA}))), - (map, pr) => { - // eslint-disable-next-line no-param-reassign - map[pr.html_url] = _.compact(_.pluck(pr.assignees, 'login')); - return map; - }, - {}, - ); - console.log('Found the following Internal QA PRs:', internalQAPRMap); - - const noQAPRs = _.pluck( - _.filter(data, (PR) => /\[No\s?QA]/i.test(PR.title)), - 'html_url', - ); - console.log('Found the following NO QA PRs:', noQAPRs); - const verifiedOrNoQAPRs = _.union(verifiedPRList, noQAPRs); - - const sortedPRList = _.chain(PRList).difference(_.keys(internalQAPRMap)).unique().sortBy(GithubUtils.getPullRequestNumberFromURL).value(); - const sortedDeployBlockers = _.sortBy(_.unique(deployBlockers), GithubUtils.getIssueOrPullRequestNumberFromURL); - - // Tag version and comparison URL - // eslint-disable-next-line max-len - let issueBody = `**Release Version:** \`${tag}\`\r\n**Compare Changes:** https://github.com/Expensify/App/compare/production...staging\r\n`; - - // PR list - if (!_.isEmpty(sortedPRList)) { - issueBody += '\r\n**This release contains changes from the following pull requests:**\r\n'; - _.each(sortedPRList, (URL) => { - issueBody += _.contains(verifiedOrNoQAPRs, URL) ? '- [x]' : '- [ ]'; - issueBody += ` ${URL}\r\n`; - }); - issueBody += '\r\n\r\n'; - } + const internalQAPRs = _.filter(data, (pr) => !_.isEmpty(_.findWhere(pr.labels, {name: CONST.LABELS.INTERNAL_QA}))); + return Promise.all(_.map(internalQAPRs, (pr) => this.getPullRequestMergerLogin(pr.number).then((mergerLogin) => ({url: pr.html_url, mergerLogin})))).then((results) => { + // The format of this map is following: + // { + // 'https://github.com/Expensify/App/pull/9641': 'PauloGasparSv', + // 'https://github.com/Expensify/App/pull/9642': 'mountiny' + // } + const internalQAPRMap = _.reduce( + results, + (acc, {url, mergerLogin}) => { + acc[url] = mergerLogin; + return acc; + }, + {}, + ); + console.log('Found the following Internal QA PRs:', internalQAPRMap); + + const noQAPRs = _.pluck( + _.filter(data, (PR) => /\[No\s?QA]/i.test(PR.title)), + 'html_url', + ); + console.log('Found the following NO QA PRs:', noQAPRs); + const verifiedOrNoQAPRs = _.union(verifiedPRList, noQAPRs); + + const sortedPRList = _.chain(PRList).difference(_.keys(internalQAPRMap)).unique().sortBy(GithubUtils.getPullRequestNumberFromURL).value(); + const sortedDeployBlockers = _.sortBy(_.unique(deployBlockers), GithubUtils.getIssueOrPullRequestNumberFromURL); + + // Tag version and comparison URL + // eslint-disable-next-line max-len + let issueBody = `**Release Version:** \`${tag}\`\r\n**Compare Changes:** https://github.com/Expensify/App/compare/production...staging\r\n`; + + // PR list + if (!_.isEmpty(sortedPRList)) { + issueBody += '\r\n**This release contains changes from the following pull requests:**\r\n'; + _.each(sortedPRList, (URL) => { + issueBody += _.contains(verifiedOrNoQAPRs, URL) ? '- [x]' : '- [ ]'; + issueBody += ` ${URL}\r\n`; + }); + issueBody += '\r\n\r\n'; + } - // Internal QA PR list - if (!_.isEmpty(internalQAPRMap)) { - console.log('Found the following verified Internal QA PRs:', resolvedInternalQAPRs); - issueBody += '**Internal QA:**\r\n'; - _.each(internalQAPRMap, (assignees, URL) => { - const assigneeMentions = _.reduce(assignees, (memo, assignee) => `${memo} @${assignee}`, ''); - issueBody += `${_.contains(resolvedInternalQAPRs, URL) ? '- [x]' : '- [ ]'} `; - issueBody += `${URL}`; - issueBody += ` -${assigneeMentions}`; - issueBody += '\r\n'; - }); - issueBody += '\r\n\r\n'; - } + // Internal QA PR list + if (!_.isEmpty(internalQAPRMap)) { + console.log('Found the following verified Internal QA PRs:', resolvedInternalQAPRs); + issueBody += '**Internal QA:**\r\n'; + _.each(internalQAPRMap, (merger, URL) => { + const mergerMention = `@${merger}`; + issueBody += `${_.contains(resolvedInternalQAPRs, URL) ? '- [x]' : '- [ ]'} `; + issueBody += `${URL}`; + issueBody += ` - ${mergerMention}`; + issueBody += '\r\n'; + }); + issueBody += '\r\n\r\n'; + } - // Deploy blockers - if (!_.isEmpty(deployBlockers)) { - issueBody += '**Deploy Blockers:**\r\n'; - _.each(sortedDeployBlockers, (URL) => { - issueBody += _.contains(resolvedDeployBlockers, URL) ? '- [x] ' : '- [ ] '; - issueBody += URL; - issueBody += '\r\n'; - }); - issueBody += '\r\n\r\n'; - } + // Deploy blockers + if (!_.isEmpty(deployBlockers)) { + issueBody += '**Deploy Blockers:**\r\n'; + _.each(sortedDeployBlockers, (URL) => { + issueBody += _.contains(resolvedDeployBlockers, URL) ? '- [x] ' : '- [ ] '; + issueBody += URL; + issueBody += '\r\n'; + }); + issueBody += '\r\n\r\n'; + } - issueBody += '**Deployer verifications:**'; - // eslint-disable-next-line max-len - issueBody += `\r\n- [${ - isTimingDashboardChecked ? 'x' : ' ' - }] I checked the [App Timing Dashboard](https://graphs.expensify.com/grafana/d/yj2EobAGz/app-timing?orgId=1) and verified this release does not cause a noticeable performance regression.`; - // eslint-disable-next-line max-len - issueBody += `\r\n- [${ - isFirebaseChecked ? 'x' : ' ' - }] I checked [Firebase Crashlytics](https://console.firebase.google.com/u/0/project/expensify-chat/crashlytics/app/android:com.expensify.chat/issues?state=open&time=last-seven-days&tag=all) and verified that this release does not introduce any new crashes. More detailed instructions on this verification can be found [here](https://stackoverflowteams.com/c/expensify/questions/15095/15096).`; - // eslint-disable-next-line max-len - issueBody += `\r\n- [${isGHStatusChecked ? 'x' : ' '}] I checked [GitHub Status](https://www.githubstatus.com/) and verified there is no reported incident with Actions.`; - - issueBody += '\r\n\r\ncc @Expensify/applauseleads\r\n'; - return issueBody; + issueBody += '**Deployer verifications:**'; + // eslint-disable-next-line max-len + issueBody += `\r\n- [${ + isTimingDashboardChecked ? 'x' : ' ' + }] I checked the [App Timing Dashboard](https://graphs.expensify.com/grafana/d/yj2EobAGz/app-timing?orgId=1) and verified this release does not cause a noticeable performance regression.`; + // eslint-disable-next-line max-len + issueBody += `\r\n- [${ + isFirebaseChecked ? 'x' : ' ' + }] I checked [Firebase Crashlytics](https://console.firebase.google.com/u/0/project/expensify-chat/crashlytics/app/android:com.expensify.chat/issues?state=open&time=last-seven-days&tag=all) and verified that this release does not introduce any new crashes. More detailed instructions on this verification can be found [here](https://stackoverflowteams.com/c/expensify/questions/15095/15096).`; + // eslint-disable-next-line max-len + issueBody += `\r\n- [${isGHStatusChecked ? 'x' : ' '}] I checked [GitHub Status](https://www.githubstatus.com/) and verified there is no reported incident with Actions.`; + + issueBody += '\r\n\r\ncc @Expensify/applauseleads\r\n'; + const issueAssignees = _.uniq(_.values(internalQAPRMap)); + const issue = {issueBody, issueAssignees}; + return issue; + }); }) .catch((err) => console.warn('Error generating StagingDeployCash issue body! Continuing...', err)); } @@ -393,6 +397,20 @@ class GithubUtils { .catch((err) => console.error('Failed to get PR list', err)); } + /** + * @param {Number} pullRequestNumber + * @returns {Promise} + */ + static getPullRequestMergerLogin(pullRequestNumber) { + return this.octokit.pulls + .get({ + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, + pull_number: pullRequestNumber, + }) + .then(({data: pullRequest}) => pullRequest.merged_by.login); + } + /** * @param {Number} pullRequestNumber * @returns {Promise} diff --git a/.github/actions/javascript/createOrUpdateStagingDeploy/index.js b/.github/actions/javascript/createOrUpdateStagingDeploy/index.js index 154dacbdc3c3..60ec0b9f0ae3 100644 --- a/.github/actions/javascript/createOrUpdateStagingDeploy/index.js +++ b/.github/actions/javascript/createOrUpdateStagingDeploy/index.js @@ -49,8 +49,11 @@ async function run() { // Next, we generate the checklist body let checklistBody = ''; + let checklistAssignees = []; if (shouldCreateNewDeployChecklist) { - checklistBody = await GithubUtils.generateStagingDeployCashBody(newVersionTag, _.map(mergedPRs, GithubUtils.getPullRequestURLFromNumber)); + const {issueBody, issueAssignees} = await GithubUtils.generateStagingDeployCashBodyAndAssignees(newVersionTag, _.map(mergedPRs, GithubUtils.getPullRequestURLFromNumber)); + checklistBody = issueBody; + checklistAssignees = issueAssignees; } else { // Generate the updated PR list, preserving the previous state of `isVerified` for existing PRs const PRList = _.reduce( @@ -103,7 +106,7 @@ async function run() { } const didVersionChange = newVersionTag !== currentChecklistData.tag; - checklistBody = await GithubUtils.generateStagingDeployCashBody( + const {issueBody, issueAssignees} = await GithubUtils.generateStagingDeployCashBodyAndAssignees( newVersionTag, _.pluck(PRList, 'url'), _.pluck(_.where(PRList, {isVerified: true}), 'url'), @@ -114,6 +117,8 @@ async function run() { didVersionChange ? false : currentChecklistData.isFirebaseChecked, didVersionChange ? false : currentChecklistData.isGHStatusChecked, ); + checklistBody = issueBody; + checklistAssignees = issueAssignees; } // Finally, create or update the checklist @@ -128,7 +133,7 @@ async function run() { ...defaultPayload, title: `Deploy Checklist: New Expensify ${format(new Date(), CONST.DATE_FORMAT_STRING)}`, labels: [CONST.LABELS.STAGING_DEPLOY], - assignees: [CONST.APPLAUSE_BOT], + assignees: [CONST.APPLAUSE_BOT].concat(checklistAssignees), }); console.log(`Successfully created new StagingDeployCash! 🎉 ${newChecklist.html_url}`); return newChecklist; @@ -406,7 +411,7 @@ class GithubUtils { } /** - * Generate the issue body for a StagingDeployCash. + * Generate the issue body and assignees for a StagingDeployCash. * * @param {String} tag * @param {Array} PRList - The list of PR URLs which are included in this StagingDeployCash @@ -419,7 +424,7 @@ class GithubUtils { * @param {Boolean} [isGHStatusChecked] * @returns {Promise} */ - static generateStagingDeployCashBody( + static generateStagingDeployCashBodyAndAssignees( tag, PRList, verifiedPRList = [], @@ -432,85 +437,89 @@ class GithubUtils { ) { return this.fetchAllPullRequests(_.map(PRList, this.getPullRequestNumberFromURL)) .then((data) => { - // The format of this map is following: - // { - // 'https://github.com/Expensify/App/pull/9641': [ 'PauloGasparSv', 'kidroca' ], - // 'https://github.com/Expensify/App/pull/9642': [ 'mountiny', 'kidroca' ] - // } - const internalQAPRMap = _.reduce( - _.filter(data, (pr) => !_.isEmpty(_.findWhere(pr.labels, {name: CONST.LABELS.INTERNAL_QA}))), - (map, pr) => { - // eslint-disable-next-line no-param-reassign - map[pr.html_url] = _.compact(_.pluck(pr.assignees, 'login')); - return map; - }, - {}, - ); - console.log('Found the following Internal QA PRs:', internalQAPRMap); - - const noQAPRs = _.pluck( - _.filter(data, (PR) => /\[No\s?QA]/i.test(PR.title)), - 'html_url', - ); - console.log('Found the following NO QA PRs:', noQAPRs); - const verifiedOrNoQAPRs = _.union(verifiedPRList, noQAPRs); - - const sortedPRList = _.chain(PRList).difference(_.keys(internalQAPRMap)).unique().sortBy(GithubUtils.getPullRequestNumberFromURL).value(); - const sortedDeployBlockers = _.sortBy(_.unique(deployBlockers), GithubUtils.getIssueOrPullRequestNumberFromURL); - - // Tag version and comparison URL - // eslint-disable-next-line max-len - let issueBody = `**Release Version:** \`${tag}\`\r\n**Compare Changes:** https://github.com/Expensify/App/compare/production...staging\r\n`; - - // PR list - if (!_.isEmpty(sortedPRList)) { - issueBody += '\r\n**This release contains changes from the following pull requests:**\r\n'; - _.each(sortedPRList, (URL) => { - issueBody += _.contains(verifiedOrNoQAPRs, URL) ? '- [x]' : '- [ ]'; - issueBody += ` ${URL}\r\n`; - }); - issueBody += '\r\n\r\n'; - } + const internalQAPRs = _.filter(data, (pr) => !_.isEmpty(_.findWhere(pr.labels, {name: CONST.LABELS.INTERNAL_QA}))); + return Promise.all(_.map(internalQAPRs, (pr) => this.getPullRequestMergerLogin(pr.number).then((mergerLogin) => ({url: pr.html_url, mergerLogin})))).then((results) => { + // The format of this map is following: + // { + // 'https://github.com/Expensify/App/pull/9641': 'PauloGasparSv', + // 'https://github.com/Expensify/App/pull/9642': 'mountiny' + // } + const internalQAPRMap = _.reduce( + results, + (acc, {url, mergerLogin}) => { + acc[url] = mergerLogin; + return acc; + }, + {}, + ); + console.log('Found the following Internal QA PRs:', internalQAPRMap); + + const noQAPRs = _.pluck( + _.filter(data, (PR) => /\[No\s?QA]/i.test(PR.title)), + 'html_url', + ); + console.log('Found the following NO QA PRs:', noQAPRs); + const verifiedOrNoQAPRs = _.union(verifiedPRList, noQAPRs); + + const sortedPRList = _.chain(PRList).difference(_.keys(internalQAPRMap)).unique().sortBy(GithubUtils.getPullRequestNumberFromURL).value(); + const sortedDeployBlockers = _.sortBy(_.unique(deployBlockers), GithubUtils.getIssueOrPullRequestNumberFromURL); + + // Tag version and comparison URL + // eslint-disable-next-line max-len + let issueBody = `**Release Version:** \`${tag}\`\r\n**Compare Changes:** https://github.com/Expensify/App/compare/production...staging\r\n`; + + // PR list + if (!_.isEmpty(sortedPRList)) { + issueBody += '\r\n**This release contains changes from the following pull requests:**\r\n'; + _.each(sortedPRList, (URL) => { + issueBody += _.contains(verifiedOrNoQAPRs, URL) ? '- [x]' : '- [ ]'; + issueBody += ` ${URL}\r\n`; + }); + issueBody += '\r\n\r\n'; + } - // Internal QA PR list - if (!_.isEmpty(internalQAPRMap)) { - console.log('Found the following verified Internal QA PRs:', resolvedInternalQAPRs); - issueBody += '**Internal QA:**\r\n'; - _.each(internalQAPRMap, (assignees, URL) => { - const assigneeMentions = _.reduce(assignees, (memo, assignee) => `${memo} @${assignee}`, ''); - issueBody += `${_.contains(resolvedInternalQAPRs, URL) ? '- [x]' : '- [ ]'} `; - issueBody += `${URL}`; - issueBody += ` -${assigneeMentions}`; - issueBody += '\r\n'; - }); - issueBody += '\r\n\r\n'; - } + // Internal QA PR list + if (!_.isEmpty(internalQAPRMap)) { + console.log('Found the following verified Internal QA PRs:', resolvedInternalQAPRs); + issueBody += '**Internal QA:**\r\n'; + _.each(internalQAPRMap, (merger, URL) => { + const mergerMention = `@${merger}`; + issueBody += `${_.contains(resolvedInternalQAPRs, URL) ? '- [x]' : '- [ ]'} `; + issueBody += `${URL}`; + issueBody += ` - ${mergerMention}`; + issueBody += '\r\n'; + }); + issueBody += '\r\n\r\n'; + } - // Deploy blockers - if (!_.isEmpty(deployBlockers)) { - issueBody += '**Deploy Blockers:**\r\n'; - _.each(sortedDeployBlockers, (URL) => { - issueBody += _.contains(resolvedDeployBlockers, URL) ? '- [x] ' : '- [ ] '; - issueBody += URL; - issueBody += '\r\n'; - }); - issueBody += '\r\n\r\n'; - } + // Deploy blockers + if (!_.isEmpty(deployBlockers)) { + issueBody += '**Deploy Blockers:**\r\n'; + _.each(sortedDeployBlockers, (URL) => { + issueBody += _.contains(resolvedDeployBlockers, URL) ? '- [x] ' : '- [ ] '; + issueBody += URL; + issueBody += '\r\n'; + }); + issueBody += '\r\n\r\n'; + } - issueBody += '**Deployer verifications:**'; - // eslint-disable-next-line max-len - issueBody += `\r\n- [${ - isTimingDashboardChecked ? 'x' : ' ' - }] I checked the [App Timing Dashboard](https://graphs.expensify.com/grafana/d/yj2EobAGz/app-timing?orgId=1) and verified this release does not cause a noticeable performance regression.`; - // eslint-disable-next-line max-len - issueBody += `\r\n- [${ - isFirebaseChecked ? 'x' : ' ' - }] I checked [Firebase Crashlytics](https://console.firebase.google.com/u/0/project/expensify-chat/crashlytics/app/android:com.expensify.chat/issues?state=open&time=last-seven-days&tag=all) and verified that this release does not introduce any new crashes. More detailed instructions on this verification can be found [here](https://stackoverflowteams.com/c/expensify/questions/15095/15096).`; - // eslint-disable-next-line max-len - issueBody += `\r\n- [${isGHStatusChecked ? 'x' : ' '}] I checked [GitHub Status](https://www.githubstatus.com/) and verified there is no reported incident with Actions.`; - - issueBody += '\r\n\r\ncc @Expensify/applauseleads\r\n'; - return issueBody; + issueBody += '**Deployer verifications:**'; + // eslint-disable-next-line max-len + issueBody += `\r\n- [${ + isTimingDashboardChecked ? 'x' : ' ' + }] I checked the [App Timing Dashboard](https://graphs.expensify.com/grafana/d/yj2EobAGz/app-timing?orgId=1) and verified this release does not cause a noticeable performance regression.`; + // eslint-disable-next-line max-len + issueBody += `\r\n- [${ + isFirebaseChecked ? 'x' : ' ' + }] I checked [Firebase Crashlytics](https://console.firebase.google.com/u/0/project/expensify-chat/crashlytics/app/android:com.expensify.chat/issues?state=open&time=last-seven-days&tag=all) and verified that this release does not introduce any new crashes. More detailed instructions on this verification can be found [here](https://stackoverflowteams.com/c/expensify/questions/15095/15096).`; + // eslint-disable-next-line max-len + issueBody += `\r\n- [${isGHStatusChecked ? 'x' : ' '}] I checked [GitHub Status](https://www.githubstatus.com/) and verified there is no reported incident with Actions.`; + + issueBody += '\r\n\r\ncc @Expensify/applauseleads\r\n'; + const issueAssignees = _.uniq(_.values(internalQAPRMap)); + const issue = {issueBody, issueAssignees}; + return issue; + }); }) .catch((err) => console.warn('Error generating StagingDeployCash issue body! Continuing...', err)); } @@ -544,6 +553,20 @@ class GithubUtils { .catch((err) => console.error('Failed to get PR list', err)); } + /** + * @param {Number} pullRequestNumber + * @returns {Promise} + */ + static getPullRequestMergerLogin(pullRequestNumber) { + return this.octokit.pulls + .get({ + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, + pull_number: pullRequestNumber, + }) + .then(({data: pullRequest}) => pullRequest.merged_by.login); + } + /** * @param {Number} pullRequestNumber * @returns {Promise} diff --git a/.github/actions/javascript/getDeployPullRequestList/index.js b/.github/actions/javascript/getDeployPullRequestList/index.js index f272929d536a..c57ebf0fefe4 100644 --- a/.github/actions/javascript/getDeployPullRequestList/index.js +++ b/.github/actions/javascript/getDeployPullRequestList/index.js @@ -349,7 +349,7 @@ class GithubUtils { } /** - * Generate the issue body for a StagingDeployCash. + * Generate the issue body and assignees for a StagingDeployCash. * * @param {String} tag * @param {Array} PRList - The list of PR URLs which are included in this StagingDeployCash @@ -362,7 +362,7 @@ class GithubUtils { * @param {Boolean} [isGHStatusChecked] * @returns {Promise} */ - static generateStagingDeployCashBody( + static generateStagingDeployCashBodyAndAssignees( tag, PRList, verifiedPRList = [], @@ -375,85 +375,89 @@ class GithubUtils { ) { return this.fetchAllPullRequests(_.map(PRList, this.getPullRequestNumberFromURL)) .then((data) => { - // The format of this map is following: - // { - // 'https://github.com/Expensify/App/pull/9641': [ 'PauloGasparSv', 'kidroca' ], - // 'https://github.com/Expensify/App/pull/9642': [ 'mountiny', 'kidroca' ] - // } - const internalQAPRMap = _.reduce( - _.filter(data, (pr) => !_.isEmpty(_.findWhere(pr.labels, {name: CONST.LABELS.INTERNAL_QA}))), - (map, pr) => { - // eslint-disable-next-line no-param-reassign - map[pr.html_url] = _.compact(_.pluck(pr.assignees, 'login')); - return map; - }, - {}, - ); - console.log('Found the following Internal QA PRs:', internalQAPRMap); - - const noQAPRs = _.pluck( - _.filter(data, (PR) => /\[No\s?QA]/i.test(PR.title)), - 'html_url', - ); - console.log('Found the following NO QA PRs:', noQAPRs); - const verifiedOrNoQAPRs = _.union(verifiedPRList, noQAPRs); - - const sortedPRList = _.chain(PRList).difference(_.keys(internalQAPRMap)).unique().sortBy(GithubUtils.getPullRequestNumberFromURL).value(); - const sortedDeployBlockers = _.sortBy(_.unique(deployBlockers), GithubUtils.getIssueOrPullRequestNumberFromURL); - - // Tag version and comparison URL - // eslint-disable-next-line max-len - let issueBody = `**Release Version:** \`${tag}\`\r\n**Compare Changes:** https://github.com/Expensify/App/compare/production...staging\r\n`; - - // PR list - if (!_.isEmpty(sortedPRList)) { - issueBody += '\r\n**This release contains changes from the following pull requests:**\r\n'; - _.each(sortedPRList, (URL) => { - issueBody += _.contains(verifiedOrNoQAPRs, URL) ? '- [x]' : '- [ ]'; - issueBody += ` ${URL}\r\n`; - }); - issueBody += '\r\n\r\n'; - } + const internalQAPRs = _.filter(data, (pr) => !_.isEmpty(_.findWhere(pr.labels, {name: CONST.LABELS.INTERNAL_QA}))); + return Promise.all(_.map(internalQAPRs, (pr) => this.getPullRequestMergerLogin(pr.number).then((mergerLogin) => ({url: pr.html_url, mergerLogin})))).then((results) => { + // The format of this map is following: + // { + // 'https://github.com/Expensify/App/pull/9641': 'PauloGasparSv', + // 'https://github.com/Expensify/App/pull/9642': 'mountiny' + // } + const internalQAPRMap = _.reduce( + results, + (acc, {url, mergerLogin}) => { + acc[url] = mergerLogin; + return acc; + }, + {}, + ); + console.log('Found the following Internal QA PRs:', internalQAPRMap); + + const noQAPRs = _.pluck( + _.filter(data, (PR) => /\[No\s?QA]/i.test(PR.title)), + 'html_url', + ); + console.log('Found the following NO QA PRs:', noQAPRs); + const verifiedOrNoQAPRs = _.union(verifiedPRList, noQAPRs); + + const sortedPRList = _.chain(PRList).difference(_.keys(internalQAPRMap)).unique().sortBy(GithubUtils.getPullRequestNumberFromURL).value(); + const sortedDeployBlockers = _.sortBy(_.unique(deployBlockers), GithubUtils.getIssueOrPullRequestNumberFromURL); + + // Tag version and comparison URL + // eslint-disable-next-line max-len + let issueBody = `**Release Version:** \`${tag}\`\r\n**Compare Changes:** https://github.com/Expensify/App/compare/production...staging\r\n`; + + // PR list + if (!_.isEmpty(sortedPRList)) { + issueBody += '\r\n**This release contains changes from the following pull requests:**\r\n'; + _.each(sortedPRList, (URL) => { + issueBody += _.contains(verifiedOrNoQAPRs, URL) ? '- [x]' : '- [ ]'; + issueBody += ` ${URL}\r\n`; + }); + issueBody += '\r\n\r\n'; + } - // Internal QA PR list - if (!_.isEmpty(internalQAPRMap)) { - console.log('Found the following verified Internal QA PRs:', resolvedInternalQAPRs); - issueBody += '**Internal QA:**\r\n'; - _.each(internalQAPRMap, (assignees, URL) => { - const assigneeMentions = _.reduce(assignees, (memo, assignee) => `${memo} @${assignee}`, ''); - issueBody += `${_.contains(resolvedInternalQAPRs, URL) ? '- [x]' : '- [ ]'} `; - issueBody += `${URL}`; - issueBody += ` -${assigneeMentions}`; - issueBody += '\r\n'; - }); - issueBody += '\r\n\r\n'; - } + // Internal QA PR list + if (!_.isEmpty(internalQAPRMap)) { + console.log('Found the following verified Internal QA PRs:', resolvedInternalQAPRs); + issueBody += '**Internal QA:**\r\n'; + _.each(internalQAPRMap, (merger, URL) => { + const mergerMention = `@${merger}`; + issueBody += `${_.contains(resolvedInternalQAPRs, URL) ? '- [x]' : '- [ ]'} `; + issueBody += `${URL}`; + issueBody += ` - ${mergerMention}`; + issueBody += '\r\n'; + }); + issueBody += '\r\n\r\n'; + } - // Deploy blockers - if (!_.isEmpty(deployBlockers)) { - issueBody += '**Deploy Blockers:**\r\n'; - _.each(sortedDeployBlockers, (URL) => { - issueBody += _.contains(resolvedDeployBlockers, URL) ? '- [x] ' : '- [ ] '; - issueBody += URL; - issueBody += '\r\n'; - }); - issueBody += '\r\n\r\n'; - } + // Deploy blockers + if (!_.isEmpty(deployBlockers)) { + issueBody += '**Deploy Blockers:**\r\n'; + _.each(sortedDeployBlockers, (URL) => { + issueBody += _.contains(resolvedDeployBlockers, URL) ? '- [x] ' : '- [ ] '; + issueBody += URL; + issueBody += '\r\n'; + }); + issueBody += '\r\n\r\n'; + } - issueBody += '**Deployer verifications:**'; - // eslint-disable-next-line max-len - issueBody += `\r\n- [${ - isTimingDashboardChecked ? 'x' : ' ' - }] I checked the [App Timing Dashboard](https://graphs.expensify.com/grafana/d/yj2EobAGz/app-timing?orgId=1) and verified this release does not cause a noticeable performance regression.`; - // eslint-disable-next-line max-len - issueBody += `\r\n- [${ - isFirebaseChecked ? 'x' : ' ' - }] I checked [Firebase Crashlytics](https://console.firebase.google.com/u/0/project/expensify-chat/crashlytics/app/android:com.expensify.chat/issues?state=open&time=last-seven-days&tag=all) and verified that this release does not introduce any new crashes. More detailed instructions on this verification can be found [here](https://stackoverflowteams.com/c/expensify/questions/15095/15096).`; - // eslint-disable-next-line max-len - issueBody += `\r\n- [${isGHStatusChecked ? 'x' : ' '}] I checked [GitHub Status](https://www.githubstatus.com/) and verified there is no reported incident with Actions.`; - - issueBody += '\r\n\r\ncc @Expensify/applauseleads\r\n'; - return issueBody; + issueBody += '**Deployer verifications:**'; + // eslint-disable-next-line max-len + issueBody += `\r\n- [${ + isTimingDashboardChecked ? 'x' : ' ' + }] I checked the [App Timing Dashboard](https://graphs.expensify.com/grafana/d/yj2EobAGz/app-timing?orgId=1) and verified this release does not cause a noticeable performance regression.`; + // eslint-disable-next-line max-len + issueBody += `\r\n- [${ + isFirebaseChecked ? 'x' : ' ' + }] I checked [Firebase Crashlytics](https://console.firebase.google.com/u/0/project/expensify-chat/crashlytics/app/android:com.expensify.chat/issues?state=open&time=last-seven-days&tag=all) and verified that this release does not introduce any new crashes. More detailed instructions on this verification can be found [here](https://stackoverflowteams.com/c/expensify/questions/15095/15096).`; + // eslint-disable-next-line max-len + issueBody += `\r\n- [${isGHStatusChecked ? 'x' : ' '}] I checked [GitHub Status](https://www.githubstatus.com/) and verified there is no reported incident with Actions.`; + + issueBody += '\r\n\r\ncc @Expensify/applauseleads\r\n'; + const issueAssignees = _.uniq(_.values(internalQAPRMap)); + const issue = {issueBody, issueAssignees}; + return issue; + }); }) .catch((err) => console.warn('Error generating StagingDeployCash issue body! Continuing...', err)); } @@ -487,6 +491,20 @@ class GithubUtils { .catch((err) => console.error('Failed to get PR list', err)); } + /** + * @param {Number} pullRequestNumber + * @returns {Promise} + */ + static getPullRequestMergerLogin(pullRequestNumber) { + return this.octokit.pulls + .get({ + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, + pull_number: pullRequestNumber, + }) + .then(({data: pullRequest}) => pullRequest.merged_by.login); + } + /** * @param {Number} pullRequestNumber * @returns {Promise} From 623262315448705ac87991873c9d29515d0c887a Mon Sep 17 00:00:00 2001 From: tienifr Date: Wed, 20 Mar 2024 16:29:29 +0700 Subject: [PATCH 13/29] fix: no navigation object in state picker storybook --- src/components/HeaderWithBackButton/index.tsx | 5 +---- src/components/ScreenWrapper.tsx | 3 ++- src/stories/HeaderWithBackButton.stories.tsx | 11 ++++------- 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/src/components/HeaderWithBackButton/index.tsx b/src/components/HeaderWithBackButton/index.tsx index 21f3e9a3b605..f3293596aa46 100755 --- a/src/components/HeaderWithBackButton/index.tsx +++ b/src/components/HeaderWithBackButton/index.tsx @@ -15,7 +15,6 @@ import useStyleUtils from '@hooks/useStyleUtils'; import useTheme from '@hooks/useTheme'; import useThemeStyles from '@hooks/useThemeStyles'; import useThrottledButtonState from '@hooks/useThrottledButtonState'; -import useWaitForNavigation from '@hooks/useWaitForNavigation'; import getButtonState from '@libs/getButtonState'; import Navigation from '@libs/Navigation/Navigation'; import variables from '@styles/variables'; @@ -58,7 +57,6 @@ function HeaderWithBackButton({ children = null, shouldOverlayDots = false, shouldOverlay = false, - singleExecution = (func) => func, shouldNavigateToTopMostReport = false, style, }: HeaderWithBackButtonProps) { @@ -68,7 +66,6 @@ function HeaderWithBackButton({ const [isDownloadButtonActive, temporarilyDisableDownloadButton] = useThrottledButtonState(); const {translate} = useLocalize(); const {isKeyboardShown} = useKeyboardState(); - const waitForNavigate = useWaitForNavigation(); // If the icon is present, the header bar should be taller and use different font. const isCentralPaneSettings = !!icon; @@ -175,7 +172,7 @@ function HeaderWithBackButton({ Navigation.navigate(ROUTES.GET_ASSISTANCE.getRoute(guidesCallTaskID, Navigation.getActiveRoute()))))} + onPress={() => Navigation.navigate(ROUTES.GET_ASSISTANCE.getRoute(guidesCallTaskID, Navigation.getActiveRoute()))} style={[styles.touchableButtonImage]} role="button" accessibilityLabel={translate('getAssistancePage.questionMarkButtonTooltip')} diff --git a/src/components/ScreenWrapper.tsx b/src/components/ScreenWrapper.tsx index 827eec8088a6..b78e274371ca 100644 --- a/src/components/ScreenWrapper.tsx +++ b/src/components/ScreenWrapper.tsx @@ -23,6 +23,7 @@ import KeyboardAvoidingView from './KeyboardAvoidingView'; import OfflineIndicator from './OfflineIndicator'; import SafeAreaConsumer from './SafeAreaConsumer'; import TestToolsModal from './TestToolsModal'; +import withNavigationFallback from './withNavigationFallback'; type ChildrenProps = { insets: EdgeInsets; @@ -279,4 +280,4 @@ function ScreenWrapper( ScreenWrapper.displayName = 'ScreenWrapper'; -export default forwardRef(ScreenWrapper); +export default withNavigationFallback(forwardRef(ScreenWrapper)); diff --git a/src/stories/HeaderWithBackButton.stories.tsx b/src/stories/HeaderWithBackButton.stories.tsx index 8306d8e19225..ca723715d5f0 100644 --- a/src/stories/HeaderWithBackButton.stories.tsx +++ b/src/stories/HeaderWithBackButton.stories.tsx @@ -2,25 +2,22 @@ import type {ComponentMeta, ComponentStory} from '@storybook/react'; import React from 'react'; import HeaderWithBackButton from '@components/HeaderWithBackButton'; import type HeaderWithBackButtonProps from '@components/HeaderWithBackButton/types'; -import withNavigationFallback from '@components/withNavigationFallback'; -const HeaderWithBackButtonWithNavigation = withNavigationFallback(HeaderWithBackButton); - -type HeaderWithBackButtonStory = ComponentStory; +type HeaderWithBackButtonStory = ComponentStory; /** * We use the Component Story Format for writing stories. Follow the docs here: * * https://storybook.js.org/docs/react/writing-stories/introduction#component-story-format */ -const story: ComponentMeta = { +const story: ComponentMeta = { title: 'Components/HeaderWithBackButton', - component: HeaderWithBackButtonWithNavigation, + component: HeaderWithBackButton, }; function Template(props: HeaderWithBackButtonProps) { // eslint-disable-next-line react/jsx-props-no-spreading - return ; + return ; } // Arguments can be passed to the component by binding From 8dc39a9d9d7e0b330b872dbd86fb1b69561fba43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucien=20Akchot=C3=A9?= Date: Thu, 21 Mar 2024 10:39:55 +0100 Subject: [PATCH 14/29] do not show approve button if approvals disabled --- src/components/ReportActionItem/ReportPreview.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/components/ReportActionItem/ReportPreview.tsx b/src/components/ReportActionItem/ReportPreview.tsx index d183d27fefb8..ebc4e0b31486 100644 --- a/src/components/ReportActionItem/ReportPreview.tsx +++ b/src/components/ReportActionItem/ReportPreview.tsx @@ -207,8 +207,7 @@ function ReportPreview({ const shouldShowPayButton = useMemo(() => IOU.canIOUBePaid(iouReport, chatReport, policy), [iouReport, chatReport, policy]); - const shouldShowApproveButton = useMemo(() => IOU.canApproveIOU(iouReport, chatReport, policy), [iouReport, chatReport, policy]); - + const shouldShowApproveButton = useMemo(() => IOU.canApproveIOU(iouReport, chatReport, policy) && policy?.approvalMode !== CONST.POLICY.APPROVAL_MODE.OPTIONAL, [iouReport, chatReport, policy]); const shouldShowSettlementButton = shouldShowPayButton || shouldShowApproveButton; const shouldPromptUserToAddBankAccount = ReportUtils.hasMissingPaymentMethod(userWallet, iouReportID); From 71c5bdb3babe341eb0114d6ff570e49360840da5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucien=20Akchot=C3=A9?= Date: Thu, 21 Mar 2024 11:07:16 +0100 Subject: [PATCH 15/29] modify isAutoReimbursable to show pay button to be congruent with nextStepUtils step waiting for pay --- src/libs/actions/IOU.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index b65d81a228ef..f5944d3407f8 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -4510,7 +4510,7 @@ function canIOUBePaid(iouReport: OnyxEntry | EmptyObject, chat const iouSettled = ReportUtils.isSettled(iouReport?.reportID); const {reimbursableSpend} = ReportUtils.getMoneyRequestSpendBreakdown(iouReport); - const isAutoReimbursable = ReportUtils.canBeAutoReimbursed(iouReport, policy); + const isAutoReimbursable = policy?.reimbursementChoice === CONST.POLICY.REIMBURSEMENT_CHOICES.REIMBURSEMENT_YES ? false : ReportUtils.canBeAutoReimbursed(iouReport, policy); return isPayer && !isOpenExpenseReport && !iouSettled && !iouReport?.isWaitingOnBankAccount && reimbursableSpend !== 0 && !iouCanceled && !isAutoReimbursable; } From 9a1a1605560425ea720ad994e1c4e1a49fb6e437 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucien=20Akchot=C3=A9?= Date: Thu, 21 Mar 2024 11:07:32 +0100 Subject: [PATCH 16/29] do not show approve button if approvals disabled --- src/components/MoneyReportHeader.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/MoneyReportHeader.tsx b/src/components/MoneyReportHeader.tsx index 2bf346ec8de4..55f40bc2bfa8 100644 --- a/src/components/MoneyReportHeader.tsx +++ b/src/components/MoneyReportHeader.tsx @@ -65,7 +65,7 @@ function MoneyReportHeader({session, policy, chatReport, nextStep, report: money const shouldShowPayButton = useMemo(() => IOU.canIOUBePaid(moneyRequestReport, chatReport, policy), [moneyRequestReport, chatReport, policy]); - const shouldShowApproveButton = useMemo(() => IOU.canApproveIOU(moneyRequestReport, chatReport, policy), [moneyRequestReport, chatReport, policy]); + const shouldShowApproveButton = useMemo(() => IOU.canApproveIOU(moneyRequestReport, chatReport, policy) && policy?.approvalMode !== CONST.POLICY.APPROVAL_MODE.OPTIONAL, [moneyRequestReport, chatReport, policy]); const shouldShowSettlementButton = shouldShowPayButton || shouldShowApproveButton; From d9fa855480b5985134a3e2520bd41a3f6fd84ab3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucien=20Akchot=C3=A9?= Date: Thu, 21 Mar 2024 12:13:50 +0100 Subject: [PATCH 17/29] handle delay submissions and approvals enabled scenario --- src/libs/actions/IOU.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index f5944d3407f8..2af9a63c89e5 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -4511,7 +4511,12 @@ function canIOUBePaid(iouReport: OnyxEntry | EmptyObject, chat const {reimbursableSpend} = ReportUtils.getMoneyRequestSpendBreakdown(iouReport); const isAutoReimbursable = policy?.reimbursementChoice === CONST.POLICY.REIMBURSEMENT_CHOICES.REIMBURSEMENT_YES ? false : ReportUtils.canBeAutoReimbursed(iouReport, policy); - return isPayer && !isOpenExpenseReport && !iouSettled && !iouReport?.isWaitingOnBankAccount && reimbursableSpend !== 0 && !iouCanceled && !isAutoReimbursable; + let shouldBeApproved = false; + if (policy?.approvalMode !== CONST.POLICY.APPROVAL_MODE.OPTIONAL && iouReport.statusNum === CONST.REPORT.STATUS_NUM.SUBMITTED) { + shouldBeApproved = true; + } + + return isPayer && !isOpenExpenseReport && !iouSettled && !iouReport?.isWaitingOnBankAccount && reimbursableSpend !== 0 && !iouCanceled && !isAutoReimbursable && !shouldBeApproved; } function canApproveIOU(iouReport: OnyxEntry | EmptyObject, chatReport: OnyxEntry | EmptyObject, policy: OnyxEntry | EmptyObject) { From 3f3d761cb7b15e7876430302ef01dbf03df3d68c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucien=20Akchot=C3=A9?= Date: Thu, 21 Mar 2024 14:08:55 +0100 Subject: [PATCH 18/29] fix style --- src/components/MoneyReportHeader.tsx | 5 ++++- src/components/ReportActionItem/ReportPreview.tsx | 5 ++++- src/components/SettlementButton.tsx | 4 +--- src/libs/actions/IOU.ts | 2 +- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/components/MoneyReportHeader.tsx b/src/components/MoneyReportHeader.tsx index 55f40bc2bfa8..31182cd5ec5e 100644 --- a/src/components/MoneyReportHeader.tsx +++ b/src/components/MoneyReportHeader.tsx @@ -65,7 +65,10 @@ function MoneyReportHeader({session, policy, chatReport, nextStep, report: money const shouldShowPayButton = useMemo(() => IOU.canIOUBePaid(moneyRequestReport, chatReport, policy), [moneyRequestReport, chatReport, policy]); - const shouldShowApproveButton = useMemo(() => IOU.canApproveIOU(moneyRequestReport, chatReport, policy) && policy?.approvalMode !== CONST.POLICY.APPROVAL_MODE.OPTIONAL, [moneyRequestReport, chatReport, policy]); + const shouldShowApproveButton = useMemo( + () => IOU.canApproveIOU(moneyRequestReport, chatReport, policy) && policy?.approvalMode !== CONST.POLICY.APPROVAL_MODE.OPTIONAL, + [moneyRequestReport, chatReport, policy], + ); const shouldShowSettlementButton = shouldShowPayButton || shouldShowApproveButton; diff --git a/src/components/ReportActionItem/ReportPreview.tsx b/src/components/ReportActionItem/ReportPreview.tsx index ebc4e0b31486..036c7466dde0 100644 --- a/src/components/ReportActionItem/ReportPreview.tsx +++ b/src/components/ReportActionItem/ReportPreview.tsx @@ -207,7 +207,10 @@ function ReportPreview({ const shouldShowPayButton = useMemo(() => IOU.canIOUBePaid(iouReport, chatReport, policy), [iouReport, chatReport, policy]); - const shouldShowApproveButton = useMemo(() => IOU.canApproveIOU(iouReport, chatReport, policy) && policy?.approvalMode !== CONST.POLICY.APPROVAL_MODE.OPTIONAL, [iouReport, chatReport, policy]); + const shouldShowApproveButton = useMemo( + () => IOU.canApproveIOU(iouReport, chatReport, policy) && policy?.approvalMode !== CONST.POLICY.APPROVAL_MODE.OPTIONAL, + [iouReport, chatReport, policy], + ); const shouldShowSettlementButton = shouldShowPayButton || shouldShowApproveButton; const shouldPromptUserToAddBankAccount = ReportUtils.hasMissingPaymentMethod(userWallet, iouReportID); diff --git a/src/components/SettlementButton.tsx b/src/components/SettlementButton.tsx index 5a9cd637dcab..c6c3125aa02b 100644 --- a/src/components/SettlementButton.tsx +++ b/src/components/SettlementButton.tsx @@ -139,9 +139,7 @@ function SettlementButton({ const session = useSession(); const chatReport = ReportUtils.getReport(chatReportID); const isPaidGroupPolicy = ReportUtils.isPaidGroupPolicyExpenseChat(chatReport as OnyxEntry); - const shouldShowPaywithExpensifyOption = - !isPaidGroupPolicy || - (!shouldHidePaymentOptions && ReportUtils.isPayer(session, iouReport as OnyxEntry)); + const shouldShowPaywithExpensifyOption = !isPaidGroupPolicy || (!shouldHidePaymentOptions && ReportUtils.isPayer(session, iouReport as OnyxEntry)); const paymentButtonOptions = useMemo(() => { const buttonOptions = []; const isExpenseReport = ReportUtils.isExpenseReport(iouReport); diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index 2af9a63c89e5..114ed1ba70b6 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -4515,7 +4515,7 @@ function canIOUBePaid(iouReport: OnyxEntry | EmptyObject, chat if (policy?.approvalMode !== CONST.POLICY.APPROVAL_MODE.OPTIONAL && iouReport.statusNum === CONST.REPORT.STATUS_NUM.SUBMITTED) { shouldBeApproved = true; } - + return isPayer && !isOpenExpenseReport && !iouSettled && !iouReport?.isWaitingOnBankAccount && reimbursableSpend !== 0 && !iouCanceled && !isAutoReimbursable && !shouldBeApproved; } From 2319ff58fddc3e6fa98db4e7f16623413b334bfa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucien=20Akchot=C3=A9?= Date: Thu, 21 Mar 2024 15:26:20 +0100 Subject: [PATCH 19/29] improve code --- src/components/MoneyReportHeader.tsx | 2 +- src/components/ReportActionItem/ReportPreview.tsx | 2 +- src/libs/actions/IOU.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/MoneyReportHeader.tsx b/src/components/MoneyReportHeader.tsx index 31182cd5ec5e..0dfd48ffc660 100644 --- a/src/components/MoneyReportHeader.tsx +++ b/src/components/MoneyReportHeader.tsx @@ -66,7 +66,7 @@ function MoneyReportHeader({session, policy, chatReport, nextStep, report: money const shouldShowPayButton = useMemo(() => IOU.canIOUBePaid(moneyRequestReport, chatReport, policy), [moneyRequestReport, chatReport, policy]); const shouldShowApproveButton = useMemo( - () => IOU.canApproveIOU(moneyRequestReport, chatReport, policy) && policy?.approvalMode !== CONST.POLICY.APPROVAL_MODE.OPTIONAL, + () => IOU.canApproveIOU(moneyRequestReport, chatReport, policy), [moneyRequestReport, chatReport, policy], ); diff --git a/src/components/ReportActionItem/ReportPreview.tsx b/src/components/ReportActionItem/ReportPreview.tsx index 036c7466dde0..8af227d28725 100644 --- a/src/components/ReportActionItem/ReportPreview.tsx +++ b/src/components/ReportActionItem/ReportPreview.tsx @@ -208,7 +208,7 @@ function ReportPreview({ const shouldShowPayButton = useMemo(() => IOU.canIOUBePaid(iouReport, chatReport, policy), [iouReport, chatReport, policy]); const shouldShowApproveButton = useMemo( - () => IOU.canApproveIOU(iouReport, chatReport, policy) && policy?.approvalMode !== CONST.POLICY.APPROVAL_MODE.OPTIONAL, + () => IOU.canApproveIOU(iouReport, chatReport, policy), [iouReport, chatReport, policy], ); const shouldShowSettlementButton = shouldShowPayButton || shouldShowApproveButton; diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index 114ed1ba70b6..976a3c293c27 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -4512,7 +4512,7 @@ function canIOUBePaid(iouReport: OnyxEntry | EmptyObject, chat const {reimbursableSpend} = ReportUtils.getMoneyRequestSpendBreakdown(iouReport); const isAutoReimbursable = policy?.reimbursementChoice === CONST.POLICY.REIMBURSEMENT_CHOICES.REIMBURSEMENT_YES ? false : ReportUtils.canBeAutoReimbursed(iouReport, policy); let shouldBeApproved = false; - if (policy?.approvalMode !== CONST.POLICY.APPROVAL_MODE.OPTIONAL && iouReport.statusNum === CONST.REPORT.STATUS_NUM.SUBMITTED) { + if (iouReport.statusNum === CONST.REPORT.STATUS_NUM.SUBMITTED || iouReport.stateNum === CONST.REPORT.STATE_NUM.SUBMITTED) { shouldBeApproved = true; } From 55c3fb26be0d18a26b5e8bd457ec3cc0b41d6a1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucien=20Akchot=C3=A9?= Date: Thu, 21 Mar 2024 15:27:20 +0100 Subject: [PATCH 20/29] fix style --- src/components/MoneyReportHeader.tsx | 5 +---- src/components/ReportActionItem/ReportPreview.tsx | 5 +---- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/src/components/MoneyReportHeader.tsx b/src/components/MoneyReportHeader.tsx index 0dfd48ffc660..2bf346ec8de4 100644 --- a/src/components/MoneyReportHeader.tsx +++ b/src/components/MoneyReportHeader.tsx @@ -65,10 +65,7 @@ function MoneyReportHeader({session, policy, chatReport, nextStep, report: money const shouldShowPayButton = useMemo(() => IOU.canIOUBePaid(moneyRequestReport, chatReport, policy), [moneyRequestReport, chatReport, policy]); - const shouldShowApproveButton = useMemo( - () => IOU.canApproveIOU(moneyRequestReport, chatReport, policy), - [moneyRequestReport, chatReport, policy], - ); + const shouldShowApproveButton = useMemo(() => IOU.canApproveIOU(moneyRequestReport, chatReport, policy), [moneyRequestReport, chatReport, policy]); const shouldShowSettlementButton = shouldShowPayButton || shouldShowApproveButton; diff --git a/src/components/ReportActionItem/ReportPreview.tsx b/src/components/ReportActionItem/ReportPreview.tsx index 8af227d28725..216eb84016ab 100644 --- a/src/components/ReportActionItem/ReportPreview.tsx +++ b/src/components/ReportActionItem/ReportPreview.tsx @@ -207,10 +207,7 @@ function ReportPreview({ const shouldShowPayButton = useMemo(() => IOU.canIOUBePaid(iouReport, chatReport, policy), [iouReport, chatReport, policy]); - const shouldShowApproveButton = useMemo( - () => IOU.canApproveIOU(iouReport, chatReport, policy), - [iouReport, chatReport, policy], - ); + const shouldShowApproveButton = useMemo(() => IOU.canApproveIOU(iouReport, chatReport, policy), [iouReport, chatReport, policy]); const shouldShowSettlementButton = shouldShowPayButton || shouldShowApproveButton; const shouldPromptUserToAddBankAccount = ReportUtils.hasMissingPaymentMethod(userWallet, iouReportID); From ebce13b4df9dea9715c6e44d31d87c1814c383cd Mon Sep 17 00:00:00 2001 From: Carlos Martins Date: Thu, 21 Mar 2024 18:02:26 -0600 Subject: [PATCH 21/29] rm unnecessary change --- src/components/ReportActionItem/ReportPreview.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/ReportActionItem/ReportPreview.tsx b/src/components/ReportActionItem/ReportPreview.tsx index 216eb84016ab..d183d27fefb8 100644 --- a/src/components/ReportActionItem/ReportPreview.tsx +++ b/src/components/ReportActionItem/ReportPreview.tsx @@ -208,6 +208,7 @@ function ReportPreview({ const shouldShowPayButton = useMemo(() => IOU.canIOUBePaid(iouReport, chatReport, policy), [iouReport, chatReport, policy]); const shouldShowApproveButton = useMemo(() => IOU.canApproveIOU(iouReport, chatReport, policy), [iouReport, chatReport, policy]); + const shouldShowSettlementButton = shouldShowPayButton || shouldShowApproveButton; const shouldPromptUserToAddBankAccount = ReportUtils.hasMissingPaymentMethod(userWallet, iouReportID); From 432195f992ce4353f621f53d8ee6c73ab50ddbf1 Mon Sep 17 00:00:00 2001 From: Carlos Martins Date: Fri, 22 Mar 2024 15:22:00 -0600 Subject: [PATCH 22/29] fix iou, free policy pay --- src/libs/actions/IOU.ts | 57 +++++++++++++++++++---------------------- 1 file changed, 27 insertions(+), 30 deletions(-) diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index 93f5407f3566..5632268ef6ca 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -4484,6 +4484,32 @@ function sendMoneyWithWallet(report: OnyxTypes.Report, amount: number, currency: Report.notifyNewAction(params.chatReportID, managerID); } +function canApproveIOU(iouReport: OnyxEntry | EmptyObject, chatReport: OnyxEntry | EmptyObject, policy: OnyxEntry | EmptyObject) { + if (isEmptyObject(chatReport)) { + return false; + } + const isPaidGroupPolicy = ReportUtils.isPaidGroupPolicyExpenseChat(chatReport); + if (!isPaidGroupPolicy) { + return false; + } + + const isOnInstantSubmitPolicy = PolicyUtils.isInstantSubmitEnabled(policy); + const isOnSubmitAndClosePolicy = PolicyUtils.isSubmitAndClose(policy); + if (isOnInstantSubmitPolicy && isOnSubmitAndClosePolicy) { + return false; + } + + const managerID = iouReport?.managerID ?? 0; + const isCurrentUserManager = managerID === userAccountID; + const isPolicyExpenseChat = ReportUtils.isPolicyExpenseChat(chatReport); + + const isOpenExpenseReport = isPolicyExpenseChat && ReportUtils.isOpenExpenseReport(iouReport); + const isApproved = ReportUtils.isReportApproved(iouReport); + const iouSettled = ReportUtils.isSettled(iouReport?.reportID); + + return isCurrentUserManager && !isOpenExpenseReport && !isApproved && !iouSettled; +} + function canIOUBePaid(iouReport: OnyxEntry | EmptyObject, chatReport: OnyxEntry | EmptyObject, policy: OnyxEntry | EmptyObject) { const isPolicyExpenseChat = ReportUtils.isPolicyExpenseChat(chatReport); const iouCanceled = ReportUtils.isArchivedRoom(chatReport); @@ -4509,40 +4535,11 @@ function canIOUBePaid(iouReport: OnyxEntry | EmptyObject, chat const {reimbursableSpend} = ReportUtils.getMoneyRequestSpendBreakdown(iouReport); const isAutoReimbursable = policy?.reimbursementChoice === CONST.POLICY.REIMBURSEMENT_CHOICES.REIMBURSEMENT_YES ? false : ReportUtils.canBeAutoReimbursed(iouReport, policy); - let shouldBeApproved = false; - if (iouReport.statusNum === CONST.REPORT.STATUS_NUM.SUBMITTED || iouReport.stateNum === CONST.REPORT.STATE_NUM.SUBMITTED) { - shouldBeApproved = true; - } + const shouldBeApproved = canApproveIOU(iouReport, chatReport, policy); return isPayer && !isOpenExpenseReport && !iouSettled && !iouReport?.isWaitingOnBankAccount && reimbursableSpend !== 0 && !iouCanceled && !isAutoReimbursable && !shouldBeApproved; } -function canApproveIOU(iouReport: OnyxEntry | EmptyObject, chatReport: OnyxEntry | EmptyObject, policy: OnyxEntry | EmptyObject) { - if (isEmptyObject(chatReport)) { - return false; - } - const isPaidGroupPolicy = ReportUtils.isPaidGroupPolicyExpenseChat(chatReport); - if (!isPaidGroupPolicy) { - return false; - } - - const isOnInstantSubmitPolicy = PolicyUtils.isInstantSubmitEnabled(policy); - const isOnSubmitAndClosePolicy = PolicyUtils.isSubmitAndClose(policy); - if (isOnInstantSubmitPolicy && isOnSubmitAndClosePolicy) { - return false; - } - - const managerID = iouReport?.managerID ?? 0; - const isCurrentUserManager = managerID === userAccountID; - const isPolicyExpenseChat = ReportUtils.isPolicyExpenseChat(chatReport); - - const isOpenExpenseReport = isPolicyExpenseChat && ReportUtils.isOpenExpenseReport(iouReport); - const isApproved = ReportUtils.isReportApproved(iouReport); - const iouSettled = ReportUtils.isSettled(iouReport?.reportID); - - return isCurrentUserManager && !isOpenExpenseReport && !isApproved && !iouSettled; -} - function hasIOUToApproveOrPay(chatReport: OnyxEntry | EmptyObject, excludedIOUReportID: string): boolean { const chatReportActions = ReportActionsUtils.getAllReportActions(chatReport?.reportID ?? ''); From 0047ad2cc9005042b064bfd2fb5b8c6d21055d66 Mon Sep 17 00:00:00 2001 From: Carlos Martins Date: Fri, 22 Mar 2024 16:38:34 -0600 Subject: [PATCH 23/29] fix conditional --- src/components/SettlementButton.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/components/SettlementButton.tsx b/src/components/SettlementButton.tsx index 16c0b2ecaea5..690a9485f099 100644 --- a/src/components/SettlementButton.tsx +++ b/src/components/SettlementButton.tsx @@ -144,6 +144,7 @@ function SettlementButton({ const chatReport = ReportUtils.getReport(chatReportID); const isPaidGroupPolicy = ReportUtils.isPaidGroupPolicyExpenseChat(chatReport as OnyxEntry); const shouldShowPaywithExpensifyOption = !isPaidGroupPolicy || (!shouldHidePaymentOptions && ReportUtils.isPayer(session, iouReport as OnyxEntry)); + const shouldShowPayElsewhereOption = !isPaidGroupPolicy || policy?.reimbursementChoice === CONST.POLICY.REIMBURSEMENT_CHOICES.REIMBURSEMENT_MANUAL; const paymentButtonOptions = useMemo(() => { const buttonOptions = []; const isExpenseReport = ReportUtils.isExpenseReport(iouReport); @@ -187,7 +188,7 @@ function SettlementButton({ if (isExpenseReport && shouldShowPaywithExpensifyOption) { buttonOptions.push(paymentMethods[CONST.IOU.PAYMENT_TYPE.VBBA]); } - if (isExpenseReport && policy?.reimbursementChoice === CONST.POLICY.REIMBURSEMENT_CHOICES.REIMBURSEMENT_MANUAL) { + if (shouldShowPayElsewhereOption) { buttonOptions.push(paymentMethods[CONST.IOU.PAYMENT_TYPE.ELSEWHERE]); } From 507d697e1f01fd51eb6d822fd148d1dda817cb2b Mon Sep 17 00:00:00 2001 From: rory Date: Sat, 23 Mar 2024 02:13:10 -0700 Subject: [PATCH 24/29] Don't show 404 on ReportScreen if isLoading is true --- src/pages/home/ReportScreen.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/pages/home/ReportScreen.tsx b/src/pages/home/ReportScreen.tsx index aa03714394b1..2f9029e1e251 100644 --- a/src/pages/home/ReportScreen.tsx +++ b/src/pages/home/ReportScreen.tsx @@ -531,15 +531,15 @@ function ReportScreen({ // eslint-disable-next-line rulesdir/no-negated-variables const shouldShowNotFoundPage = useMemo( (): boolean => - (!wasReportAccessibleRef.current && + !isLoading && + ((!wasReportAccessibleRef.current && !firstRenderRef.current && !report.reportID && !isOptimisticDelete && !reportMetadata?.isLoadingInitialReportActions && - !isLoading && !userLeavingStatus) || - shouldHideReport || - (!!reportIDFromRoute && !ReportUtils.isValidReportIDFromPath(reportIDFromRoute)), + shouldHideReport || + (!!reportIDFromRoute && !ReportUtils.isValidReportIDFromPath(reportIDFromRoute))), [report, reportMetadata, isLoading, shouldHideReport, isOptimisticDelete, userLeavingStatus, reportIDFromRoute], ); From 3e9c90ba5d5730ad652709cfd296d9c00dd32943 Mon Sep 17 00:00:00 2001 From: Rory Abraham <47436092+roryabraham@users.noreply.github.com> Date: Sat, 23 Mar 2024 02:40:34 -0700 Subject: [PATCH 25/29] Revert "[No QA][TS migration] Migrate workflow_tests, adjust utils migration" --- src/types/modules/act.d.ts | 14 ------- ...rsion.test.ts => createNewVersion.test.js} | 31 ++++++++-------- .../{deploy.test.ts => deploy.test.js} | 27 +++++++------- ...yBlocker.test.ts => deployBlocker.test.js} | 26 ++++++------- ...cle.test.ts => finishReleaseCycle.test.js} | 29 +++++++-------- workflow_tests/{lint.test.ts => lint.test.js} | 37 ++++++++----------- workflow_tests/utils/JobMocker.ts | 11 +++--- workflow_tests/utils/preGenerateTest.ts | 5 +-- workflow_tests/utils/utils.ts | 9 +++-- 9 files changed, 82 insertions(+), 107 deletions(-) delete mode 100644 src/types/modules/act.d.ts rename workflow_tests/{createNewVersion.test.ts => createNewVersion.test.js} (93%) rename workflow_tests/{deploy.test.ts => deploy.test.js} (93%) rename workflow_tests/{deployBlocker.test.ts => deployBlocker.test.js} (92%) rename workflow_tests/{finishReleaseCycle.test.ts => finishReleaseCycle.test.js} (94%) rename workflow_tests/{lint.test.ts => lint.test.js} (91%) diff --git a/src/types/modules/act.d.ts b/src/types/modules/act.d.ts deleted file mode 100644 index 5fe00ec479cf..000000000000 --- a/src/types/modules/act.d.ts +++ /dev/null @@ -1,14 +0,0 @@ -import type {StepIdentifier as ActStepIdentifier} from '@kie/act-js'; - -declare module '@kie/act-js' { - // eslint-disable-next-line rulesdir/no-inline-named-export - export declare type StepIdentifier = { - id?: string; - name: string; - run?: string; - mockWith?: string; - with?: string; - envs?: string[]; - inputs?: string[]; - } & Omit; -} diff --git a/workflow_tests/createNewVersion.test.ts b/workflow_tests/createNewVersion.test.js similarity index 93% rename from workflow_tests/createNewVersion.test.ts rename to workflow_tests/createNewVersion.test.js index 05dcc2b10073..08ac63ba9948 100644 --- a/workflow_tests/createNewVersion.test.ts +++ b/workflow_tests/createNewVersion.test.js @@ -1,13 +1,12 @@ -import {MockGithub} from '@kie/mock-github'; -import path from 'path'; -import assertions from './assertions/createNewVersionAssertions'; -import mocks from './mocks/createNewVersionMocks'; -import ExtendedAct from './utils/ExtendedAct'; -import * as utils from './utils/utils'; +const path = require('path'); +const kieMockGithub = require('@kie/mock-github'); +const utils = require('./utils/utils'); +const assertions = require('./assertions/createNewVersionAssertions'); +const mocks = require('./mocks/createNewVersionMocks'); +const ExtendedAct = require('./utils/ExtendedAct').default; jest.setTimeout(90 * 1000); // 90 sec -let mockGithub: MockGithub; - +let mockGithub; const FILES_TO_COPY_INTO_TEST_REPO = [ ...utils.deepCopy(utils.FILES_TO_COPY_INTO_TEST_REPO), { @@ -17,7 +16,7 @@ const FILES_TO_COPY_INTO_TEST_REPO = [ ]; describe('test workflow createNewVersion', () => { - beforeAll(() => { + beforeAll(async () => { // in case of the tests being interrupted without cleanup the mock repo directory may be left behind // which breaks the next test run, this removes any possible leftovers utils.removeMockRepoDir(); @@ -25,7 +24,7 @@ describe('test workflow createNewVersion', () => { beforeEach(async () => { // create a local repository and copy required files - mockGithub = new MockGithub({ + mockGithub = new kieMockGithub.MockGithub({ repo: { testCreateNewVersionWorkflowRepo: { files: FILES_TO_COPY_INTO_TEST_REPO, @@ -57,7 +56,7 @@ describe('test workflow createNewVersion', () => { describe('actor is admin', () => { const validateActorMockSteps = mocks.CREATENEWVERSION__VALIDATEACTOR__ADMIN__STEP_MOCKS; it('executes full workflow', async () => { - const repoPath = mockGithub.repo.getPath('testCreateNewVersionWorkflowRepo') ?? ''; + const repoPath = mockGithub.repo.getPath('testCreateNewVersionWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'createNewVersion.yml'); let act = new ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams(act, event, {}, secrets, githubToken, {}, inputs); @@ -80,7 +79,7 @@ describe('test workflow createNewVersion', () => { describe('actor is writer', () => { const validateActorMockSteps = mocks.CREATENEWVERSION__VALIDATEACTOR__WRITER__STEP_MOCKS; it('executes full workflow', async () => { - const repoPath = mockGithub.repo.getPath('testCreateNewVersionWorkflowRepo') ?? ''; + const repoPath = mockGithub.repo.getPath('testCreateNewVersionWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'createNewVersion.yml'); let act = new ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams(act, event, {}, secrets, githubToken, {}, inputs); @@ -103,7 +102,7 @@ describe('test workflow createNewVersion', () => { describe('actor is reader', () => { const validateActorMockSteps = mocks.CREATENEWVERSION__VALIDATEACTOR__NO_PERMISSION__STEP_MOCKS; it('stops after validation', async () => { - const repoPath = mockGithub.repo.getPath('testCreateNewVersionWorkflowRepo') ?? ''; + const repoPath = mockGithub.repo.getPath('testCreateNewVersionWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'createNewVersion.yml'); let act = new ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams(act, event, {}, secrets, githubToken, {}, inputs); @@ -125,7 +124,7 @@ describe('test workflow createNewVersion', () => { describe('one step fails', () => { it('announces failure on Slack', async () => { - const repoPath = mockGithub.repo.getPath('testCreateNewVersionWorkflowRepo') ?? ''; + const repoPath = mockGithub.repo.getPath('testCreateNewVersionWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'createNewVersion.yml'); let act = new ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams(act, event, {}, secrets, githubToken, {}, inputs); @@ -134,7 +133,7 @@ describe('test workflow createNewVersion', () => { validateActor: mocks.CREATENEWVERSION__VALIDATEACTOR__ADMIN__STEP_MOCKS, createNewVersion: utils.deepCopy(mocks.CREATENEWVERSION__CREATENEWVERSION__STEP_MOCKS), }; - testMockSteps.createNewVersion[5] = utils.createMockStep('Commit new version', 'Commit new version', 'CREATENEWVERSION', [], [], {}, {}, false); + testMockSteps.createNewVersion[5] = utils.createMockStep('Commit new version', 'Commit new version', 'CREATENEWVERSION', [], [], [], [], false); const result = await act.runEvent(event, { workflowFile: path.join(repoPath, '.github', 'workflows', 'createNewVersion.yml'), mockSteps: testMockSteps, @@ -147,7 +146,7 @@ describe('test workflow createNewVersion', () => { }); it('chooses source branch depending on the SEMVER_LEVEL', async () => { - const repoPath = mockGithub.repo.getPath('testCreateNewVersionWorkflowRepo') ?? ''; + const repoPath = mockGithub.repo.getPath('testCreateNewVersionWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'createNewVersion.yml'); let act = new ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams(act, event, {}, secrets, githubToken, {}, {SEMVER_LEVEL: 'MAJOR'}); diff --git a/workflow_tests/deploy.test.ts b/workflow_tests/deploy.test.js similarity index 93% rename from workflow_tests/deploy.test.ts rename to workflow_tests/deploy.test.js index 4edb3b252d38..cf5b658d3ffb 100644 --- a/workflow_tests/deploy.test.ts +++ b/workflow_tests/deploy.test.js @@ -1,13 +1,12 @@ -import {MockGithub} from '@kie/mock-github'; -import path from 'path'; -import assertions from './assertions/deployAssertions'; -import mocks from './mocks/deployMocks'; -import ExtendedAct from './utils/ExtendedAct'; -import * as utils from './utils/utils'; +const path = require('path'); +const kieMockGithub = require('@kie/mock-github'); +const utils = require('./utils/utils'); +const assertions = require('./assertions/deployAssertions'); +const mocks = require('./mocks/deployMocks'); +const ExtendedAct = require('./utils/ExtendedAct').default; jest.setTimeout(90 * 1000); -let mockGithub: MockGithub; - +let mockGithub; const FILES_TO_COPY_INTO_TEST_REPO = [ ...utils.deepCopy(utils.FILES_TO_COPY_INTO_TEST_REPO), { @@ -17,7 +16,7 @@ const FILES_TO_COPY_INTO_TEST_REPO = [ ]; describe('test workflow deploy', () => { - beforeAll(() => { + beforeAll(async () => { // in case of the tests being interrupted without cleanup the mock repo directory may be left behind // which breaks the next test run, this removes any possible leftovers utils.removeMockRepoDir(); @@ -25,7 +24,7 @@ describe('test workflow deploy', () => { beforeEach(async () => { // create a local repository and copy required files - mockGithub = new MockGithub({ + mockGithub = new kieMockGithub.MockGithub({ repo: { testDeployWorkflowRepo: { files: FILES_TO_COPY_INTO_TEST_REPO, @@ -49,7 +48,7 @@ describe('test workflow deploy', () => { }; describe('push', () => { it('to main - nothing triggered', async () => { - const repoPath = mockGithub.repo.getPath('testDeployWorkflowRepo') ?? ''; + const repoPath = mockGithub.repo.getPath('testDeployWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'deploy.yml'); let act = new ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams( @@ -76,7 +75,7 @@ describe('test workflow deploy', () => { }); it('to staging - deployStaging triggered', async () => { - const repoPath = mockGithub.repo.getPath('testDeployWorkflowRepo') ?? ''; + const repoPath = mockGithub.repo.getPath('testDeployWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'deploy.yml'); let act = new ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams( @@ -103,7 +102,7 @@ describe('test workflow deploy', () => { }); it('to production - deployProduction triggered', async () => { - const repoPath = mockGithub.repo.getPath('testDeployWorkflowRepo') ?? ''; + const repoPath = mockGithub.repo.getPath('testDeployWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'deploy.yml'); let act = new ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams( @@ -131,7 +130,7 @@ describe('test workflow deploy', () => { }); it('different event than push - workflow does not execute', async () => { - const repoPath = mockGithub.repo.getPath('testDeployWorkflowRepo') ?? ''; + const repoPath = mockGithub.repo.getPath('testDeployWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'deploy.yml'); let act = new ExtendedAct(repoPath, workflowPath); const testMockSteps = { diff --git a/workflow_tests/deployBlocker.test.ts b/workflow_tests/deployBlocker.test.js similarity index 92% rename from workflow_tests/deployBlocker.test.ts rename to workflow_tests/deployBlocker.test.js index d6ee67f97f2c..42c4f9e741f7 100644 --- a/workflow_tests/deployBlocker.test.ts +++ b/workflow_tests/deployBlocker.test.js @@ -1,13 +1,12 @@ -import {MockGithub} from '@kie/mock-github'; -import path from 'path'; -import assertions from './assertions/deployBlockerAssertions'; -import mocks from './mocks/deployBlockerMocks'; -import ExtendedAct from './utils/ExtendedAct'; -import * as utils from './utils/utils'; +const path = require('path'); +const kieMockGithub = require('@kie/mock-github'); +const utils = require('./utils/utils'); +const assertions = require('./assertions/deployBlockerAssertions'); +const mocks = require('./mocks/deployBlockerMocks'); +const ExtendedAct = require('./utils/ExtendedAct').default; jest.setTimeout(90 * 1000); -let mockGithub: MockGithub; - +let mockGithub; const FILES_TO_COPY_INTO_TEST_REPO = [ ...utils.deepCopy(utils.FILES_TO_COPY_INTO_TEST_REPO), { @@ -24,7 +23,7 @@ describe('test workflow deployBlocker', () => { SLACK_WEBHOOK: 'dummy_slack_webhook', }; - beforeAll(() => { + beforeAll(async () => { // in case of the tests being interrupted without cleanup the mock repo directory may be left behind // which breaks the next test run, this removes any possible leftovers utils.removeMockRepoDir(); @@ -32,7 +31,7 @@ describe('test workflow deployBlocker', () => { beforeEach(async () => { // create a local repository and copy required files - mockGithub = new MockGithub({ + mockGithub = new kieMockGithub.MockGithub({ repo: { testDeployBlockerWorkflowRepo: { files: FILES_TO_COPY_INTO_TEST_REPO, @@ -58,7 +57,6 @@ describe('test workflow deployBlocker', () => { issue: { title: 'Labeled issue title', number: '1234', - // eslint-disable-next-line @typescript-eslint/naming-convention html_url: 'http://issue.html.url', }, }; @@ -66,7 +64,7 @@ describe('test workflow deployBlocker', () => { const testEventOptions = utils.deepCopy(eventOptions); testEventOptions.label = {name: 'DeployBlockerCash'}; it('runs the workflow and announces success on Slack', async () => { - const repoPath = mockGithub.repo.getPath('testDeployBlockerWorkflowRepo') ?? ''; + const repoPath = mockGithub.repo.getPath('testDeployBlockerWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'deployBlocker.yml'); let act = new ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams(act, event, testEventOptions, secrets, githubToken, {}, {}); @@ -92,7 +90,7 @@ describe('test workflow deployBlocker', () => { }); describe('one step fails', () => { it('announces failure on Slack', async () => { - const repoPath = mockGithub.repo.getPath('testDeployBlockerWorkflowRepo') ?? ''; + const repoPath = mockGithub.repo.getPath('testDeployBlockerWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'deployBlocker.yml'); let act = new ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams(act, event, testEventOptions, secrets, githubToken, {}, {}); @@ -132,7 +130,7 @@ describe('test workflow deployBlocker', () => { const testEventOptions = utils.deepCopy(eventOptions); testEventOptions.label = {name: 'Different Label'}; it('does not run workflow', async () => { - const repoPath = mockGithub.repo.getPath('testDeployBlockerWorkflowRepo') ?? ''; + const repoPath = mockGithub.repo.getPath('testDeployBlockerWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'deployBlocker.yml'); let act = new ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams(act, event, testEventOptions, secrets, githubToken, {}, {}); diff --git a/workflow_tests/finishReleaseCycle.test.ts b/workflow_tests/finishReleaseCycle.test.js similarity index 94% rename from workflow_tests/finishReleaseCycle.test.ts rename to workflow_tests/finishReleaseCycle.test.js index 44f9c57ab9da..20ab66471d91 100644 --- a/workflow_tests/finishReleaseCycle.test.ts +++ b/workflow_tests/finishReleaseCycle.test.js @@ -1,13 +1,12 @@ -import {MockGithub} from '@kie/mock-github'; -import path from 'path'; -import assertions from './assertions/finishReleaseCycleAssertions'; -import mocks from './mocks/finishReleaseCycleMocks'; -import ExtendedAct from './utils/ExtendedAct'; -import type {MockJobs} from './utils/JobMocker'; -import * as utils from './utils/utils'; +const path = require('path'); +const kieMockGithub = require('@kie/mock-github'); +const utils = require('./utils/utils'); +const assertions = require('./assertions/finishReleaseCycleAssertions'); +const mocks = require('./mocks/finishReleaseCycleMocks'); +const ExtendedAct = require('./utils/ExtendedAct').default; jest.setTimeout(90 * 1000); -let mockGithub: MockGithub; +let mockGithub; const FILES_TO_COPY_INTO_TEST_REPO = [ ...utils.deepCopy(utils.FILES_TO_COPY_INTO_TEST_REPO), { @@ -17,7 +16,7 @@ const FILES_TO_COPY_INTO_TEST_REPO = [ ]; describe('test workflow finishReleaseCycle', () => { - beforeAll(() => { + beforeAll(async () => { // in case of the tests being interrupted without cleanup the mock repo directory may be left behind // which breaks the next test run, this removes any possible leftovers utils.removeMockRepoDir(); @@ -25,7 +24,7 @@ describe('test workflow finishReleaseCycle', () => { beforeEach(async () => { // create a local repository and copy required files - mockGithub = new MockGithub({ + mockGithub = new kieMockGithub.MockGithub({ repo: { testFinishReleaseCycleWorkflowRepo: { files: FILES_TO_COPY_INTO_TEST_REPO, @@ -51,7 +50,7 @@ describe('test workflow finishReleaseCycle', () => { describe('actor is a team member', () => { describe('no deploy blockers', () => { it('production updated, new version created', async () => { - const repoPath = mockGithub.repo.getPath('testFinishReleaseCycleWorkflowRepo') ?? ''; + const repoPath = mockGithub.repo.getPath('testFinishReleaseCycleWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'finishReleaseCycle.yml'); let act = new ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams( @@ -72,7 +71,7 @@ describe('test workflow finishReleaseCycle', () => { updateProduction: mocks.FINISHRELEASECYCLE__UPDATEPRODUCTION__STEP_MOCKS, updateStaging: mocks.FINISHRELEASECYCLE__UPDATESTAGING__STEP_MOCKS, }; - const testMockJobs: MockJobs = { + const testMockJobs = { createNewPatchVersion: { steps: mocks.FINISHRELEASECYCLE__CREATENEWPATCHVERSION__STEP_MOCKS, outputs: { @@ -97,7 +96,7 @@ describe('test workflow finishReleaseCycle', () => { }); describe('deploy blockers', () => { it('production not updated, new version not created, issue reopened', async () => { - const repoPath = mockGithub.repo.getPath('testFinishReleaseCycleWorkflowRepo') ?? ''; + const repoPath = mockGithub.repo.getPath('testFinishReleaseCycleWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'finishReleaseCycle.yml'); let act = new ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams( @@ -144,7 +143,7 @@ describe('test workflow finishReleaseCycle', () => { }); describe('actor is not a team member', () => { it('production not updated, new version not created, issue reopened', async () => { - const repoPath = mockGithub.repo.getPath('testFinishReleaseCycleWorkflowRepo') ?? ''; + const repoPath = mockGithub.repo.getPath('testFinishReleaseCycleWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'finishReleaseCycle.yml'); let act = new ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams( @@ -191,7 +190,7 @@ describe('test workflow finishReleaseCycle', () => { }); describe('issue does not have StagingDeployCash', () => { it('validate job not run', async () => { - const repoPath = mockGithub.repo.getPath('testFinishReleaseCycleWorkflowRepo') ?? ''; + const repoPath = mockGithub.repo.getPath('testFinishReleaseCycleWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'finishReleaseCycle.yml'); let act = new ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams( diff --git a/workflow_tests/lint.test.ts b/workflow_tests/lint.test.js similarity index 91% rename from workflow_tests/lint.test.ts rename to workflow_tests/lint.test.js index f6ede86c5fd3..b13b4c1c3564 100644 --- a/workflow_tests/lint.test.ts +++ b/workflow_tests/lint.test.js @@ -1,14 +1,12 @@ -import type {MockStep} from '@kie/act-js/build/src/step-mocker/step-mocker.types'; -import {MockGithub} from '@kie/mock-github'; -import path from 'path'; -import assertions from './assertions/lintAssertions'; -import mocks from './mocks/lintMocks'; -import ExtendedAct from './utils/ExtendedAct'; -import * as utils from './utils/utils'; +const path = require('path'); +const kieMockGithub = require('@kie/mock-github'); +const utils = require('./utils/utils'); +const assertions = require('./assertions/lintAssertions'); +const mocks = require('./mocks/lintMocks'); +const ExtendedAct = require('./utils/ExtendedAct').default; jest.setTimeout(90 * 1000); -let mockGithub: MockGithub; - +let mockGithub; const FILES_TO_COPY_INTO_TEST_REPO = [ ...utils.deepCopy(utils.FILES_TO_COPY_INTO_TEST_REPO), { @@ -21,7 +19,7 @@ describe('test workflow lint', () => { const githubToken = 'dummy_github_token'; const actor = 'Dummy Actor'; - beforeAll(() => { + beforeAll(async () => { // in case of the tests being interrupted without cleanup the mock repo directory may be left behind // which breaks the next test run, this removes any possible leftovers utils.removeMockRepoDir(); @@ -29,7 +27,7 @@ describe('test workflow lint', () => { beforeEach(async () => { // create a local repository and copy required files - mockGithub = new MockGithub({ + mockGithub = new kieMockGithub.MockGithub({ repo: { testLintWorkflowRepo: { files: FILES_TO_COPY_INTO_TEST_REPO, @@ -49,14 +47,13 @@ describe('test workflow lint', () => { const event = 'workflow_call'; const eventOptions = {}; it('runs the lint', async () => { - const repoPath = mockGithub.repo.getPath('testLintWorkflowRepo') ?? ''; + const repoPath = mockGithub.repo.getPath('testLintWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'lint.yml'); let act = new ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams(act, event, eventOptions, {}, githubToken); - const testMockSteps: MockStep = { + const testMockSteps = { lint: mocks.LINT__LINT__STEP_MOCKS, }; - const result = await act.runEvent(event, { workflowFile: path.join(repoPath, '.github', 'workflows', 'lint.yml'), mockSteps: testMockSteps, @@ -69,14 +66,13 @@ describe('test workflow lint', () => { describe('actor is OSBotify', () => { const testActor = 'OSBotify'; it('runs the lint', async () => { - const repoPath = mockGithub.repo.getPath('testLintWorkflowRepo') ?? ''; + const repoPath = mockGithub.repo.getPath('testLintWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'lint.yml'); let act = new ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams(act, event, eventOptions, {}, githubToken); const testMockSteps = { lint: mocks.LINT__LINT__STEP_MOCKS, }; - const result = await act.runEvent(event, { workflowFile: path.join(repoPath, '.github', 'workflows', 'lint.yml'), mockSteps: testMockSteps, @@ -95,14 +91,13 @@ describe('test workflow lint', () => { action: 'opened', }; it('runs the lint', async () => { - const repoPath = mockGithub.repo.getPath('testLintWorkflowRepo') ?? ''; + const repoPath = mockGithub.repo.getPath('testLintWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'lint.yml'); let act = new ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams(act, event, eventOptions, {}, githubToken); const testMockSteps = { lint: mocks.LINT__LINT__STEP_MOCKS, }; - const result = await act.runEvent(event, { workflowFile: path.join(repoPath, '.github', 'workflows', 'lint.yml'), mockSteps: testMockSteps, @@ -115,14 +110,13 @@ describe('test workflow lint', () => { describe('actor is OSBotify', () => { const testActor = 'OSBotify'; it('does not run the lint', async () => { - const repoPath = mockGithub.repo.getPath('testLintWorkflowRepo') ?? ''; + const repoPath = mockGithub.repo.getPath('testLintWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'lint.yml'); let act = new ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams(act, event, eventOptions, {}, githubToken); const testMockSteps = { lint: mocks.LINT__LINT__STEP_MOCKS, }; - const result = await act.runEvent(event, { workflowFile: path.join(repoPath, '.github', 'workflows', 'lint.yml'), mockSteps: testMockSteps, @@ -139,14 +133,13 @@ describe('test workflow lint', () => { action: 'synchronize', }; it('runs the lint', async () => { - const repoPath = mockGithub.repo.getPath('testLintWorkflowRepo') ?? ''; + const repoPath = mockGithub.repo.getPath('testLintWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'lint.yml'); let act = new ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams(act, event, eventOptions, {}, githubToken); const testMockSteps = { lint: mocks.LINT__LINT__STEP_MOCKS, }; - const result = await act.runEvent(event, { workflowFile: path.join(repoPath, '.github', 'workflows', 'lint.yml'), mockSteps: testMockSteps, diff --git a/workflow_tests/utils/JobMocker.ts b/workflow_tests/utils/JobMocker.ts index 171d625b2fe1..b6dc99771dd2 100644 --- a/workflow_tests/utils/JobMocker.ts +++ b/workflow_tests/utils/JobMocker.ts @@ -1,4 +1,3 @@ -import type {StepIdentifier} from '@kie/act-js'; import type {PathOrFileDescriptor} from 'fs'; import fs from 'fs'; import path from 'path'; @@ -12,12 +11,12 @@ type YamlWorkflow = { }; type MockJob = { - steps: StepIdentifier[]; + steps: MockJobStep[]; uses?: string; secrets?: string[]; with?: string; - outputs?: Record; - runsOn: string; + outputs?: string[]; + runsOn?: string; }; type MockJobs = Record; @@ -60,8 +59,8 @@ class JobMocker { jobWith = job.with; delete job.with; } - job.steps = mockJob.steps.map((step): StepIdentifier => { - const mockStep: StepIdentifier = { + job.steps = mockJob.steps.map((step) => { + const mockStep: MockJobStep = { name: step.name, run: step.mockWith, }; diff --git a/workflow_tests/utils/preGenerateTest.ts b/workflow_tests/utils/preGenerateTest.ts index c5e54d9a11c0..7698e618432d 100644 --- a/workflow_tests/utils/preGenerateTest.ts +++ b/workflow_tests/utils/preGenerateTest.ts @@ -1,11 +1,10 @@ /* eslint no-console: ["error", { allow: ["warn", "log"] }] */ -import type {StepIdentifier} from '@kie/act-js'; import type {PathLike} from 'fs'; import fs from 'fs'; import path from 'path'; import {exit} from 'process'; import yaml from 'yaml'; -import type {YamlMockJob, YamlWorkflow} from './JobMocker'; +import type {MockJobStep, YamlMockJob, YamlWorkflow} from './JobMocker'; const workflowsDirectory = path.resolve(__dirname, '..', '..', '.github', 'workflows'); const workflowTestsDirectory = path.resolve(__dirname, '..'); @@ -98,7 +97,7 @@ describe('test workflow ${workflowName}', () => { }); `; -const mockStepTemplate = (stepMockName: string, step: StepIdentifier, jobId: string | undefined) => ` +const mockStepTemplate = (stepMockName: string, step: MockJobStep, jobId: string | undefined) => ` const ${stepMockName} = utils.createMockStep( '${step.name ?? ''}', '${step.name ?? ''}', diff --git a/workflow_tests/utils/utils.ts b/workflow_tests/utils/utils.ts index 2b4036c8b826..df4cc0468963 100644 --- a/workflow_tests/utils/utils.ts +++ b/workflow_tests/utils/utils.ts @@ -1,10 +1,13 @@ -import type {StepIdentifier} from '@kie/act-js'; -import type {EventJSON} from '@kie/act-js/build/src/action-event/action-event.types'; +import type {StepIdentifier} from '@kie/act-js/build/src/step-mocker/step-mocker.types'; import fs from 'fs'; import path from 'path'; import yaml from 'yaml'; import type ExtendedAct from './ExtendedAct'; +type EventOptions = { + action?: string; +}; + type StepAssertionInputEntry = {key: string; value: string}; type StepAssertion = { @@ -16,7 +19,7 @@ type StepAssertion = { function setUpActParams( act: ExtendedAct, event: string | null = null, - eventOptions: EventJSON | null = null, + eventOptions: EventOptions | null = null, secrets: Record | null = null, githubToken: string | null = null, envVars: Record | null = null, From 9449e9f546ecf33d32e47e812faeb0ead152d743 Mon Sep 17 00:00:00 2001 From: rory Date: Sun, 24 Mar 2024 18:00:23 -0700 Subject: [PATCH 26/29] Check isValidReportIDFromPath in isLoading --- src/pages/home/ReportScreen.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/home/ReportScreen.tsx b/src/pages/home/ReportScreen.tsx index 2f9029e1e251..fe475d8d2037 100644 --- a/src/pages/home/ReportScreen.tsx +++ b/src/pages/home/ReportScreen.tsx @@ -269,7 +269,6 @@ function ReportScreen({ const hasHelpfulErrors = Object.keys(report?.errorFields ?? {}).some((key) => key !== 'notFound'); const shouldHideReport = !hasHelpfulErrors && !ReportUtils.canAccessReport(report, policies, betas); - const isLoading = !reportIDFromRoute || !isSidebarLoaded || PersonalDetailsUtils.isPersonalDetailsEmpty(); const lastReportAction: OnyxEntry = useMemo( () => reportActions.length @@ -331,6 +330,7 @@ function ReportScreen({ return reportIDFromRoute !== '' && !!report.reportID && !isTransitioning; }, [report, reportIDFromRoute]); + const isLoading = !ReportUtils.isValidReportIDFromPath(reportIDFromRoute) || !isSidebarLoaded || PersonalDetailsUtils.isPersonalDetailsEmpty(); const shouldShowSkeleton = isLinkingToMessage || !isCurrentReportLoadedFromOnyx || From e55b82da5bb4afb042d8025b756909a710666f84 Mon Sep 17 00:00:00 2001 From: rory Date: Sun, 24 Mar 2024 18:01:20 -0700 Subject: [PATCH 27/29] Move shouldShowNotFoundPage --- src/pages/home/ReportScreen.tsx | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/src/pages/home/ReportScreen.tsx b/src/pages/home/ReportScreen.tsx index fe475d8d2037..ccd32e0fe1f9 100644 --- a/src/pages/home/ReportScreen.tsx +++ b/src/pages/home/ReportScreen.tsx @@ -337,8 +337,21 @@ function ReportScreen({ (reportActions.length === 0 && !!reportMetadata?.isLoadingInitialReportActions) || isLoading || (!!reportActionIDFromRoute && reportMetadata?.isLoadingInitialReportActions); - const shouldShowReportActionList = isCurrentReportLoadedFromOnyx && !isLoading; + // eslint-disable-next-line rulesdir/no-negated-variables + const shouldShowNotFoundPage = useMemo( + (): boolean => + !isLoading && + ((!wasReportAccessibleRef.current && + !firstRenderRef.current && + !report.reportID && + !isOptimisticDelete && + !reportMetadata?.isLoadingInitialReportActions && + !userLeavingStatus) || + shouldHideReport || + (!!reportIDFromRoute && !ReportUtils.isValidReportIDFromPath(reportIDFromRoute))), + [report, reportMetadata, isLoading, shouldHideReport, isOptimisticDelete, userLeavingStatus, reportIDFromRoute], + ); const fetchReport = useCallback(() => { Report.openReport(reportIDFromRoute, reportActionIDFromRoute); @@ -528,21 +541,6 @@ function ReportScreen({ // eslint-disable-next-line react-hooks/exhaustive-deps }, []); - // eslint-disable-next-line rulesdir/no-negated-variables - const shouldShowNotFoundPage = useMemo( - (): boolean => - !isLoading && - ((!wasReportAccessibleRef.current && - !firstRenderRef.current && - !report.reportID && - !isOptimisticDelete && - !reportMetadata?.isLoadingInitialReportActions && - !userLeavingStatus) || - shouldHideReport || - (!!reportIDFromRoute && !ReportUtils.isValidReportIDFromPath(reportIDFromRoute))), - [report, reportMetadata, isLoading, shouldHideReport, isOptimisticDelete, userLeavingStatus, reportIDFromRoute], - ); - const actionListValue = useMemo((): ActionListContextType => ({flatListRef, scrollPosition, setScrollPosition}), [flatListRef, scrollPosition, setScrollPosition]); // This helps in tracking from the moment 'route' triggers useMemo until isLoadingInitialReportActions becomes true. It prevents blinking when loading reportActions from cache. From 6873f240a5d9e3dbe3f02c085958b9420dc7fb4a Mon Sep 17 00:00:00 2001 From: rory Date: Sun, 24 Mar 2024 18:06:02 -0700 Subject: [PATCH 28/29] Replace isLoading with shouldShowSkeleton in shouldShowNotFoundPage --- src/pages/home/ReportScreen.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/home/ReportScreen.tsx b/src/pages/home/ReportScreen.tsx index ccd32e0fe1f9..9bc0c4c3a4a8 100644 --- a/src/pages/home/ReportScreen.tsx +++ b/src/pages/home/ReportScreen.tsx @@ -341,7 +341,7 @@ function ReportScreen({ // eslint-disable-next-line rulesdir/no-negated-variables const shouldShowNotFoundPage = useMemo( (): boolean => - !isLoading && + !shouldShowSkeleton && ((!wasReportAccessibleRef.current && !firstRenderRef.current && !report.reportID && @@ -350,7 +350,7 @@ function ReportScreen({ !userLeavingStatus) || shouldHideReport || (!!reportIDFromRoute && !ReportUtils.isValidReportIDFromPath(reportIDFromRoute))), - [report, reportMetadata, isLoading, shouldHideReport, isOptimisticDelete, userLeavingStatus, reportIDFromRoute], + [shouldShowSkeleton, report.reportID, isOptimisticDelete, reportMetadata?.isLoadingInitialReportActions, userLeavingStatus, shouldHideReport, reportIDFromRoute], ); const fetchReport = useCallback(() => { From 18ec4fcbdae94d4a9e8cb8ae16873923c214b496 Mon Sep 17 00:00:00 2001 From: OSBotify Date: Mon, 25 Mar 2024 01:42:30 +0000 Subject: [PATCH 29/29] Update version to 1.4.56-2 --- android/app/build.gradle | 4 ++-- ios/NewExpensify/Info.plist | 2 +- ios/NewExpensifyTests/Info.plist | 2 +- ios/NotificationServiceExtension/Info.plist | 2 +- package-lock.json | 4 ++-- package.json | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/android/app/build.gradle b/android/app/build.gradle index 51f7ffc466b6..62e30858e73c 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -98,8 +98,8 @@ android { minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion multiDexEnabled rootProject.ext.multiDexEnabled - versionCode 1001045601 - versionName "1.4.56-1" + versionCode 1001045602 + versionName "1.4.56-2" } flavorDimensions "default" diff --git a/ios/NewExpensify/Info.plist b/ios/NewExpensify/Info.plist index e8f3bc7c38e2..a962c69f0bc6 100644 --- a/ios/NewExpensify/Info.plist +++ b/ios/NewExpensify/Info.plist @@ -40,7 +40,7 @@ CFBundleVersion - 1.4.56.1 + 1.4.56.2 ITSAppUsesNonExemptEncryption LSApplicationQueriesSchemes diff --git a/ios/NewExpensifyTests/Info.plist b/ios/NewExpensifyTests/Info.plist index fec078bdb26c..9f20eb574abc 100644 --- a/ios/NewExpensifyTests/Info.plist +++ b/ios/NewExpensifyTests/Info.plist @@ -19,6 +19,6 @@ CFBundleSignature ???? CFBundleVersion - 1.4.56.1 + 1.4.56.2 diff --git a/ios/NotificationServiceExtension/Info.plist b/ios/NotificationServiceExtension/Info.plist index 3fce69f13cdc..2319ff879a03 100644 --- a/ios/NotificationServiceExtension/Info.plist +++ b/ios/NotificationServiceExtension/Info.plist @@ -13,7 +13,7 @@ CFBundleShortVersionString 1.4.56 CFBundleVersion - 1.4.56.1 + 1.4.56.2 NSExtension NSExtensionPointIdentifier diff --git a/package-lock.json b/package-lock.json index 9f0916546172..fcebc3cd46dd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "new.expensify", - "version": "1.4.56-1", + "version": "1.4.56-2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "new.expensify", - "version": "1.4.56-1", + "version": "1.4.56-2", "hasInstallScript": true, "license": "MIT", "dependencies": { diff --git a/package.json b/package.json index e6531ae5e7e7..ab1a3ecc7d64 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "new.expensify", - "version": "1.4.56-1", + "version": "1.4.56-2", "author": "Expensify, Inc.", "homepage": "https://new.expensify.com", "description": "New Expensify is the next generation of Expensify: a reimagination of payments based atop a foundation of chat.",