From b27ccb8ef17ee199a4003931084416dcfbdb5d7a Mon Sep 17 00:00:00 2001 From: Rory Abraham Date: Tue, 29 Jun 2021 16:28:51 -0700 Subject: [PATCH 1/7] Add log line for npm_version in createOrUpdateStagingDeploy --- .github/actions/checkDeployBlockers/index.js | 4 ++-- .../createOrUpdateStagingDeploy.js | 1 + .github/actions/createOrUpdateStagingDeploy/index.js | 5 +++-- .github/actions/getMergeCommitForPullRequest/index.js | 4 ++-- .github/actions/getReleaseBody/index.js | 4 ++-- .github/actions/isPullRequestMergeable/index.js | 4 ++-- .github/actions/isStagingDeployLocked/index.js | 4 ++-- .github/actions/markPullRequestsAsDeployed/index.js | 4 ++-- .github/actions/reopenIssueWithComment/index.js | 4 ++-- .github/actions/triggerWorkflowAndWait/index.js | 4 ++-- .github/libs/GithubUtils.js | 4 ++-- 11 files changed, 22 insertions(+), 20 deletions(-) diff --git a/.github/actions/checkDeployBlockers/index.js b/.github/actions/checkDeployBlockers/index.js index 11405091beb1..ddf71c86f4f5 100644 --- a/.github/actions/checkDeployBlockers/index.js +++ b/.github/actions/checkDeployBlockers/index.js @@ -288,6 +288,8 @@ class GithubUtils { deployBlockers = [], resolvedDeployBlockers = [], ) { + // PRList is reverse-chronologically ordered + const oldestMergedPR = _.last(PRList); return this.octokit.paginate(this.octokit.pulls.list, { owner: GITHUB_OWNER, repo: EXPENSIFY_CASH_REPO, @@ -296,8 +298,6 @@ class GithubUtils { direction: 'desc', per_page: 100, }, ({data}, done) => { - // PRList is reverse-chronologically ordered - const oldestMergedPR = _.last(PRList); if (_.find(data, pr => pr.html_url === oldestMergedPR)) { done(); } diff --git a/.github/actions/createOrUpdateStagingDeploy/createOrUpdateStagingDeploy.js b/.github/actions/createOrUpdateStagingDeploy/createOrUpdateStagingDeploy.js index 9ea8c688b53d..0272f95f44b2 100644 --- a/.github/actions/createOrUpdateStagingDeploy/createOrUpdateStagingDeploy.js +++ b/.github/actions/createOrUpdateStagingDeploy/createOrUpdateStagingDeploy.js @@ -6,6 +6,7 @@ const GitUtils = require('../../libs/GitUtils'); const run = function () { const newVersion = core.getInput('NPM_VERSION'); + console.log('New version found from action input:', newVersion); let shouldCreateNewStagingDeployCash = false; let currentStagingDeployCashIssueNumber = null; diff --git a/.github/actions/createOrUpdateStagingDeploy/index.js b/.github/actions/createOrUpdateStagingDeploy/index.js index c05fb122d12f..eae3e2725510 100644 --- a/.github/actions/createOrUpdateStagingDeploy/index.js +++ b/.github/actions/createOrUpdateStagingDeploy/index.js @@ -16,6 +16,7 @@ const GitUtils = __nccwpck_require__(669); const run = function () { const newVersion = core.getInput('NPM_VERSION'); + console.log('New version found from action input:', newVersion); let shouldCreateNewStagingDeployCash = false; let currentStagingDeployCashIssueNumber = null; @@ -410,6 +411,8 @@ class GithubUtils { deployBlockers = [], resolvedDeployBlockers = [], ) { + // PRList is reverse-chronologically ordered + const oldestMergedPR = _.last(PRList); return this.octokit.paginate(this.octokit.pulls.list, { owner: GITHUB_OWNER, repo: EXPENSIFY_CASH_REPO, @@ -418,8 +421,6 @@ class GithubUtils { direction: 'desc', per_page: 100, }, ({data}, done) => { - // PRList is reverse-chronologically ordered - const oldestMergedPR = _.last(PRList); if (_.find(data, pr => pr.html_url === oldestMergedPR)) { done(); } diff --git a/.github/actions/getMergeCommitForPullRequest/index.js b/.github/actions/getMergeCommitForPullRequest/index.js index 0d8ff72c505f..9166613132a1 100644 --- a/.github/actions/getMergeCommitForPullRequest/index.js +++ b/.github/actions/getMergeCommitForPullRequest/index.js @@ -316,6 +316,8 @@ class GithubUtils { deployBlockers = [], resolvedDeployBlockers = [], ) { + // PRList is reverse-chronologically ordered + const oldestMergedPR = _.last(PRList); return this.octokit.paginate(this.octokit.pulls.list, { owner: GITHUB_OWNER, repo: EXPENSIFY_CASH_REPO, @@ -324,8 +326,6 @@ class GithubUtils { direction: 'desc', per_page: 100, }, ({data}, done) => { - // PRList is reverse-chronologically ordered - const oldestMergedPR = _.last(PRList); if (_.find(data, pr => pr.html_url === oldestMergedPR)) { done(); } diff --git a/.github/actions/getReleaseBody/index.js b/.github/actions/getReleaseBody/index.js index c7a31a97d88e..39d578328648 100644 --- a/.github/actions/getReleaseBody/index.js +++ b/.github/actions/getReleaseBody/index.js @@ -259,6 +259,8 @@ class GithubUtils { deployBlockers = [], resolvedDeployBlockers = [], ) { + // PRList is reverse-chronologically ordered + const oldestMergedPR = _.last(PRList); return this.octokit.paginate(this.octokit.pulls.list, { owner: GITHUB_OWNER, repo: EXPENSIFY_CASH_REPO, @@ -267,8 +269,6 @@ class GithubUtils { direction: 'desc', per_page: 100, }, ({data}, done) => { - // PRList is reverse-chronologically ordered - const oldestMergedPR = _.last(PRList); if (_.find(data, pr => pr.html_url === oldestMergedPR)) { done(); } diff --git a/.github/actions/isPullRequestMergeable/index.js b/.github/actions/isPullRequestMergeable/index.js index 708d87e20448..7b0eadf1763c 100644 --- a/.github/actions/isPullRequestMergeable/index.js +++ b/.github/actions/isPullRequestMergeable/index.js @@ -262,6 +262,8 @@ class GithubUtils { deployBlockers = [], resolvedDeployBlockers = [], ) { + // PRList is reverse-chronologically ordered + const oldestMergedPR = _.last(PRList); return this.octokit.paginate(this.octokit.pulls.list, { owner: GITHUB_OWNER, repo: EXPENSIFY_CASH_REPO, @@ -270,8 +272,6 @@ class GithubUtils { direction: 'desc', per_page: 100, }, ({data}, done) => { - // PRList is reverse-chronologically ordered - const oldestMergedPR = _.last(PRList); if (_.find(data, pr => pr.html_url === oldestMergedPR)) { done(); } diff --git a/.github/actions/isStagingDeployLocked/index.js b/.github/actions/isStagingDeployLocked/index.js index 8af14b146596..38968fef7dc3 100644 --- a/.github/actions/isStagingDeployLocked/index.js +++ b/.github/actions/isStagingDeployLocked/index.js @@ -238,6 +238,8 @@ class GithubUtils { deployBlockers = [], resolvedDeployBlockers = [], ) { + // PRList is reverse-chronologically ordered + const oldestMergedPR = _.last(PRList); return this.octokit.paginate(this.octokit.pulls.list, { owner: GITHUB_OWNER, repo: EXPENSIFY_CASH_REPO, @@ -246,8 +248,6 @@ class GithubUtils { direction: 'desc', per_page: 100, }, ({data}, done) => { - // PRList is reverse-chronologically ordered - const oldestMergedPR = _.last(PRList); if (_.find(data, pr => pr.html_url === oldestMergedPR)) { done(); } diff --git a/.github/actions/markPullRequestsAsDeployed/index.js b/.github/actions/markPullRequestsAsDeployed/index.js index 73c53802d172..519d3ef520b6 100644 --- a/.github/actions/markPullRequestsAsDeployed/index.js +++ b/.github/actions/markPullRequestsAsDeployed/index.js @@ -312,6 +312,8 @@ class GithubUtils { deployBlockers = [], resolvedDeployBlockers = [], ) { + // PRList is reverse-chronologically ordered + const oldestMergedPR = _.last(PRList); return this.octokit.paginate(this.octokit.pulls.list, { owner: GITHUB_OWNER, repo: EXPENSIFY_CASH_REPO, @@ -320,8 +322,6 @@ class GithubUtils { direction: 'desc', per_page: 100, }, ({data}, done) => { - // PRList is reverse-chronologically ordered - const oldestMergedPR = _.last(PRList); if (_.find(data, pr => pr.html_url === oldestMergedPR)) { done(); } diff --git a/.github/actions/reopenIssueWithComment/index.js b/.github/actions/reopenIssueWithComment/index.js index 63d616bdd1d0..69edc7d42bad 100644 --- a/.github/actions/reopenIssueWithComment/index.js +++ b/.github/actions/reopenIssueWithComment/index.js @@ -251,6 +251,8 @@ class GithubUtils { deployBlockers = [], resolvedDeployBlockers = [], ) { + // PRList is reverse-chronologically ordered + const oldestMergedPR = _.last(PRList); return this.octokit.paginate(this.octokit.pulls.list, { owner: GITHUB_OWNER, repo: EXPENSIFY_CASH_REPO, @@ -259,8 +261,6 @@ class GithubUtils { direction: 'desc', per_page: 100, }, ({data}, done) => { - // PRList is reverse-chronologically ordered - const oldestMergedPR = _.last(PRList); if (_.find(data, pr => pr.html_url === oldestMergedPR)) { done(); } diff --git a/.github/actions/triggerWorkflowAndWait/index.js b/.github/actions/triggerWorkflowAndWait/index.js index df46a30134df..55779d3e2935 100644 --- a/.github/actions/triggerWorkflowAndWait/index.js +++ b/.github/actions/triggerWorkflowAndWait/index.js @@ -402,6 +402,8 @@ class GithubUtils { deployBlockers = [], resolvedDeployBlockers = [], ) { + // PRList is reverse-chronologically ordered + const oldestMergedPR = _.last(PRList); return this.octokit.paginate(this.octokit.pulls.list, { owner: GITHUB_OWNER, repo: EXPENSIFY_CASH_REPO, @@ -410,8 +412,6 @@ class GithubUtils { direction: 'desc', per_page: 100, }, ({data}, done) => { - // PRList is reverse-chronologically ordered - const oldestMergedPR = _.last(PRList); if (_.find(data, pr => pr.html_url === oldestMergedPR)) { done(); } diff --git a/.github/libs/GithubUtils.js b/.github/libs/GithubUtils.js index f4989e32a8c8..1724d5f186e4 100644 --- a/.github/libs/GithubUtils.js +++ b/.github/libs/GithubUtils.js @@ -200,6 +200,8 @@ class GithubUtils { deployBlockers = [], resolvedDeployBlockers = [], ) { + // PRList is reverse-chronologically ordered + const oldestMergedPR = _.last(PRList); return this.octokit.paginate(this.octokit.pulls.list, { owner: GITHUB_OWNER, repo: EXPENSIFY_CASH_REPO, @@ -208,8 +210,6 @@ class GithubUtils { direction: 'desc', per_page: 100, }, ({data}, done) => { - // PRList is reverse-chronologically ordered - const oldestMergedPR = _.last(PRList); if (_.find(data, pr => pr.html_url === oldestMergedPR)) { done(); } From 63cca4ea60489c1c76c60d46b4c485431b958551 Mon Sep 17 00:00:00 2001 From: Rory Abraham Date: Tue, 29 Jun 2021 16:36:24 -0700 Subject: [PATCH 2/7] Make sure we use a reasonable PR list even for adding deploy blockers --- .../createOrUpdateStagingDeploy.js | 22 ++++++++++++------- .../createOrUpdateStagingDeploy/index.js | 22 ++++++++++++------- 2 files changed, 28 insertions(+), 16 deletions(-) diff --git a/.github/actions/createOrUpdateStagingDeploy/createOrUpdateStagingDeploy.js b/.github/actions/createOrUpdateStagingDeploy/createOrUpdateStagingDeploy.js index 0272f95f44b2..be55ac0c1b31 100644 --- a/.github/actions/createOrUpdateStagingDeploy/createOrUpdateStagingDeploy.js +++ b/.github/actions/createOrUpdateStagingDeploy/createOrUpdateStagingDeploy.js @@ -59,15 +59,14 @@ const run = function () { console.log('Found tag of previous StagingDeployCash:', previousStagingDeployCashData.tag); - // Find the list of PRs merged between the last StagingDeployCash and the new version - const mergedPRs = GitUtils.getPullRequestsMergedBetween(previousStagingDeployCashData.tag, newVersion); - console.log( - 'The following PRs have been merged between the previous StagingDeployCash and new version:', - mergedPRs, - ); - if (shouldCreateNewStagingDeployCash) { - // We're in the create flow, not update + // Find the list of PRs merged between the last StagingDeployCash and the new version + const mergedPRs = GitUtils.getPullRequestsMergedBetween(previousStagingDeployCashData.tag, newVersion); + console.log( + 'The following PRs have been merged between the previous StagingDeployCash and new version:', + mergedPRs, + ); + // TODO: if there are open DeployBlockers and we are opening a new checklist, // then we should close / remove the DeployBlockerCash label from those return GithubUtils.generateStagingDeployCashBody( @@ -90,6 +89,13 @@ const run = function () { // If we aren't sent a tag, then use the existing tag const tag = newVersion || currentStagingDeployCashData.tag; + // Find the list of PRs merged between the last StagingDeployCash and the new version + const mergedPRs = GitUtils.getPullRequestsMergedBetween(previousStagingDeployCashData.tag, newVersion); + console.log( + 'The following PRs have been merged between the previous StagingDeployCash and new version:', + mergedPRs, + ); + // Generate the PR list, preserving the previous state of `isVerified` for existing PRs const PRList = _.sortBy( _.unique( diff --git a/.github/actions/createOrUpdateStagingDeploy/index.js b/.github/actions/createOrUpdateStagingDeploy/index.js index eae3e2725510..992bb40b90df 100644 --- a/.github/actions/createOrUpdateStagingDeploy/index.js +++ b/.github/actions/createOrUpdateStagingDeploy/index.js @@ -69,15 +69,14 @@ const run = function () { console.log('Found tag of previous StagingDeployCash:', previousStagingDeployCashData.tag); - // Find the list of PRs merged between the last StagingDeployCash and the new version - const mergedPRs = GitUtils.getPullRequestsMergedBetween(previousStagingDeployCashData.tag, newVersion); - console.log( - 'The following PRs have been merged between the previous StagingDeployCash and new version:', - mergedPRs, - ); - if (shouldCreateNewStagingDeployCash) { - // We're in the create flow, not update + // Find the list of PRs merged between the last StagingDeployCash and the new version + const mergedPRs = GitUtils.getPullRequestsMergedBetween(previousStagingDeployCashData.tag, newVersion); + console.log( + 'The following PRs have been merged between the previous StagingDeployCash and new version:', + mergedPRs, + ); + // TODO: if there are open DeployBlockers and we are opening a new checklist, // then we should close / remove the DeployBlockerCash label from those return GithubUtils.generateStagingDeployCashBody( @@ -100,6 +99,13 @@ const run = function () { // If we aren't sent a tag, then use the existing tag const tag = newVersion || currentStagingDeployCashData.tag; + // Find the list of PRs merged between the last StagingDeployCash and the new version + const mergedPRs = GitUtils.getPullRequestsMergedBetween(previousStagingDeployCashData.tag, newVersion); + console.log( + 'The following PRs have been merged between the previous StagingDeployCash and new version:', + mergedPRs, + ); + // Generate the PR list, preserving the previous state of `isVerified` for existing PRs const PRList = _.sortBy( _.unique( From 8acfa62f6b264273b0e9bf5988d55af7be49a5cd Mon Sep 17 00:00:00 2001 From: Rory Abraham Date: Tue, 29 Jun 2021 16:41:10 -0700 Subject: [PATCH 3/7] pass adjusted tag instead of newVersion --- .../createOrUpdateStagingDeploy/createOrUpdateStagingDeploy.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/createOrUpdateStagingDeploy/createOrUpdateStagingDeploy.js b/.github/actions/createOrUpdateStagingDeploy/createOrUpdateStagingDeploy.js index be55ac0c1b31..72e07890bb85 100644 --- a/.github/actions/createOrUpdateStagingDeploy/createOrUpdateStagingDeploy.js +++ b/.github/actions/createOrUpdateStagingDeploy/createOrUpdateStagingDeploy.js @@ -90,7 +90,7 @@ const run = function () { const tag = newVersion || currentStagingDeployCashData.tag; // Find the list of PRs merged between the last StagingDeployCash and the new version - const mergedPRs = GitUtils.getPullRequestsMergedBetween(previousStagingDeployCashData.tag, newVersion); + const mergedPRs = GitUtils.getPullRequestsMergedBetween(previousStagingDeployCashData.tag, tag); console.log( 'The following PRs have been merged between the previous StagingDeployCash and new version:', mergedPRs, From 1a40a38b078d79778c1d93e14a76930761f11bf4 Mon Sep 17 00:00:00 2001 From: Rory Abraham Date: Tue, 29 Jun 2021 16:41:58 -0700 Subject: [PATCH 4/7] Rebuild GH actions --- .github/actions/createOrUpdateStagingDeploy/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/createOrUpdateStagingDeploy/index.js b/.github/actions/createOrUpdateStagingDeploy/index.js index 992bb40b90df..015ebfd880ae 100644 --- a/.github/actions/createOrUpdateStagingDeploy/index.js +++ b/.github/actions/createOrUpdateStagingDeploy/index.js @@ -100,7 +100,7 @@ const run = function () { const tag = newVersion || currentStagingDeployCashData.tag; // Find the list of PRs merged between the last StagingDeployCash and the new version - const mergedPRs = GitUtils.getPullRequestsMergedBetween(previousStagingDeployCashData.tag, newVersion); + const mergedPRs = GitUtils.getPullRequestsMergedBetween(previousStagingDeployCashData.tag, tag); console.log( 'The following PRs have been merged between the previous StagingDeployCash and new version:', mergedPRs, From c8e0d09696d85caabbde1b9c9c60d9e513030215 Mon Sep 17 00:00:00 2001 From: Rory Abraham Date: Wed, 30 Jun 2021 10:40:25 -0700 Subject: [PATCH 5/7] Create separate function for fetchAllPullRequests --- .github/actions/checkDeployBlockers/index.js | 40 ++++++++++------- .../createOrUpdateStagingDeploy.js | 3 +- .../createOrUpdateStagingDeploy/index.js | 43 +++++++++++-------- .../getMergeCommitForPullRequest/index.js | 40 ++++++++++------- .github/actions/getReleaseBody/index.js | 40 ++++++++++------- .../actions/isPullRequestMergeable/index.js | 40 ++++++++++------- .../actions/isStagingDeployLocked/index.js | 40 ++++++++++------- .../markPullRequestsAsDeployed/index.js | 40 ++++++++++------- .../actions/reopenIssueWithComment/index.js | 40 ++++++++++------- .../actions/triggerWorkflowAndWait/index.js | 40 ++++++++++------- .github/libs/GithubUtils.js | 40 ++++++++++------- 11 files changed, 252 insertions(+), 154 deletions(-) diff --git a/.github/actions/checkDeployBlockers/index.js b/.github/actions/checkDeployBlockers/index.js index ddf71c86f4f5..11ae9a173fd0 100644 --- a/.github/actions/checkDeployBlockers/index.js +++ b/.github/actions/checkDeployBlockers/index.js @@ -288,21 +288,7 @@ class GithubUtils { deployBlockers = [], resolvedDeployBlockers = [], ) { - // PRList is reverse-chronologically ordered - const oldestMergedPR = _.last(PRList); - return this.octokit.paginate(this.octokit.pulls.list, { - owner: GITHUB_OWNER, - repo: EXPENSIFY_CASH_REPO, - state: 'all', - sort: 'created', - direction: 'desc', - per_page: 100, - }, ({data}, done) => { - if (_.find(data, pr => pr.html_url === oldestMergedPR)) { - done(); - } - return data; - }) + return this.fetchAllPullRequests(_.map(PRList, this.getPullRequestNumberFromURL)) .then((data) => { const automatedPRs = _.pluck( _.filter(data, GithubUtils.isAutomatedPullRequest), @@ -461,6 +447,30 @@ class GithubUtils { static isAutomatedPullRequest(pullRequest) { return _.isEqual(lodashGet(pullRequest, 'user.login', ''), 'OSBotify'); } + + /** + * Fetch all pull requests given a list of PR numbers. + * + * @param {Array} pullRequestNumbers + * @returns {Promise} + */ + static fetchAllPullRequests(pullRequestNumbers) { + const oldestPR = _.first(_.sortBy(pullRequestNumbers)); + return this.octokit.paginate(this.octokit.pulls.list, { + owner: GITHUB_OWNER, + repo: EXPENSIFY_CASH_REPO, + state: 'all', + sort: 'created', + direction: 'desc', + per_page: 100, + }, ({data}, done) => { + if (_.find(data, pr => pr.number === oldestPR)) { + done(); + } + return data; + }) + .then(prList => _.filter(prList, pr => _.contains(pullRequestNumbers, pr.number))); + } } module.exports = GithubUtils; diff --git a/.github/actions/createOrUpdateStagingDeploy/createOrUpdateStagingDeploy.js b/.github/actions/createOrUpdateStagingDeploy/createOrUpdateStagingDeploy.js index 72e07890bb85..9769807e3fd2 100644 --- a/.github/actions/createOrUpdateStagingDeploy/createOrUpdateStagingDeploy.js +++ b/.github/actions/createOrUpdateStagingDeploy/createOrUpdateStagingDeploy.js @@ -27,8 +27,7 @@ const run = function () { labels: GithubUtils.DEPLOY_BLOCKER_CASH_LABEL, }), ]) - .then((results) => { - const [stagingDeployResponse, deployBlockerResponse] = results; + .then(([stagingDeployResponse, deployBlockerResponse]) => { if (!stagingDeployResponse || !stagingDeployResponse.data || _.isEmpty(stagingDeployResponse.data)) { console.error('Failed fetching StagingDeployCash issues from Github!', stagingDeployResponse); throw new Error('Failed fetching StagingDeployCash issues from Github'); diff --git a/.github/actions/createOrUpdateStagingDeploy/index.js b/.github/actions/createOrUpdateStagingDeploy/index.js index 015ebfd880ae..f00f79e8a0af 100644 --- a/.github/actions/createOrUpdateStagingDeploy/index.js +++ b/.github/actions/createOrUpdateStagingDeploy/index.js @@ -37,8 +37,7 @@ const run = function () { labels: GithubUtils.DEPLOY_BLOCKER_CASH_LABEL, }), ]) - .then((results) => { - const [stagingDeployResponse, deployBlockerResponse] = results; + .then(([stagingDeployResponse, deployBlockerResponse]) => { if (!stagingDeployResponse || !stagingDeployResponse.data || _.isEmpty(stagingDeployResponse.data)) { console.error('Failed fetching StagingDeployCash issues from Github!', stagingDeployResponse); throw new Error('Failed fetching StagingDeployCash issues from Github'); @@ -417,21 +416,7 @@ class GithubUtils { deployBlockers = [], resolvedDeployBlockers = [], ) { - // PRList is reverse-chronologically ordered - const oldestMergedPR = _.last(PRList); - return this.octokit.paginate(this.octokit.pulls.list, { - owner: GITHUB_OWNER, - repo: EXPENSIFY_CASH_REPO, - state: 'all', - sort: 'created', - direction: 'desc', - per_page: 100, - }, ({data}, done) => { - if (_.find(data, pr => pr.html_url === oldestMergedPR)) { - done(); - } - return data; - }) + return this.fetchAllPullRequests(_.map(PRList, this.getPullRequestNumberFromURL)) .then((data) => { const automatedPRs = _.pluck( _.filter(data, GithubUtils.isAutomatedPullRequest), @@ -590,6 +575,30 @@ class GithubUtils { static isAutomatedPullRequest(pullRequest) { return _.isEqual(lodashGet(pullRequest, 'user.login', ''), 'OSBotify'); } + + /** + * Fetch all pull requests given a list of PR numbers. + * + * @param {Array} pullRequestNumbers + * @returns {Promise} + */ + static fetchAllPullRequests(pullRequestNumbers) { + const oldestPR = _.first(_.sortBy(pullRequestNumbers)); + return this.octokit.paginate(this.octokit.pulls.list, { + owner: GITHUB_OWNER, + repo: EXPENSIFY_CASH_REPO, + state: 'all', + sort: 'created', + direction: 'desc', + per_page: 100, + }, ({data}, done) => { + if (_.find(data, pr => pr.number === oldestPR)) { + done(); + } + return data; + }) + .then(prList => _.filter(prList, pr => _.contains(pullRequestNumbers, pr.number))); + } } module.exports = GithubUtils; diff --git a/.github/actions/getMergeCommitForPullRequest/index.js b/.github/actions/getMergeCommitForPullRequest/index.js index 9166613132a1..181b1db08136 100644 --- a/.github/actions/getMergeCommitForPullRequest/index.js +++ b/.github/actions/getMergeCommitForPullRequest/index.js @@ -316,21 +316,7 @@ class GithubUtils { deployBlockers = [], resolvedDeployBlockers = [], ) { - // PRList is reverse-chronologically ordered - const oldestMergedPR = _.last(PRList); - return this.octokit.paginate(this.octokit.pulls.list, { - owner: GITHUB_OWNER, - repo: EXPENSIFY_CASH_REPO, - state: 'all', - sort: 'created', - direction: 'desc', - per_page: 100, - }, ({data}, done) => { - if (_.find(data, pr => pr.html_url === oldestMergedPR)) { - done(); - } - return data; - }) + return this.fetchAllPullRequests(_.map(PRList, this.getPullRequestNumberFromURL)) .then((data) => { const automatedPRs = _.pluck( _.filter(data, GithubUtils.isAutomatedPullRequest), @@ -489,6 +475,30 @@ class GithubUtils { static isAutomatedPullRequest(pullRequest) { return _.isEqual(lodashGet(pullRequest, 'user.login', ''), 'OSBotify'); } + + /** + * Fetch all pull requests given a list of PR numbers. + * + * @param {Array} pullRequestNumbers + * @returns {Promise} + */ + static fetchAllPullRequests(pullRequestNumbers) { + const oldestPR = _.first(_.sortBy(pullRequestNumbers)); + return this.octokit.paginate(this.octokit.pulls.list, { + owner: GITHUB_OWNER, + repo: EXPENSIFY_CASH_REPO, + state: 'all', + sort: 'created', + direction: 'desc', + per_page: 100, + }, ({data}, done) => { + if (_.find(data, pr => pr.number === oldestPR)) { + done(); + } + return data; + }) + .then(prList => _.filter(prList, pr => _.contains(pullRequestNumbers, pr.number))); + } } module.exports = GithubUtils; diff --git a/.github/actions/getReleaseBody/index.js b/.github/actions/getReleaseBody/index.js index 39d578328648..5470394b807c 100644 --- a/.github/actions/getReleaseBody/index.js +++ b/.github/actions/getReleaseBody/index.js @@ -259,21 +259,7 @@ class GithubUtils { deployBlockers = [], resolvedDeployBlockers = [], ) { - // PRList is reverse-chronologically ordered - const oldestMergedPR = _.last(PRList); - return this.octokit.paginate(this.octokit.pulls.list, { - owner: GITHUB_OWNER, - repo: EXPENSIFY_CASH_REPO, - state: 'all', - sort: 'created', - direction: 'desc', - per_page: 100, - }, ({data}, done) => { - if (_.find(data, pr => pr.html_url === oldestMergedPR)) { - done(); - } - return data; - }) + return this.fetchAllPullRequests(_.map(PRList, this.getPullRequestNumberFromURL)) .then((data) => { const automatedPRs = _.pluck( _.filter(data, GithubUtils.isAutomatedPullRequest), @@ -432,6 +418,30 @@ class GithubUtils { static isAutomatedPullRequest(pullRequest) { return _.isEqual(lodashGet(pullRequest, 'user.login', ''), 'OSBotify'); } + + /** + * Fetch all pull requests given a list of PR numbers. + * + * @param {Array} pullRequestNumbers + * @returns {Promise} + */ + static fetchAllPullRequests(pullRequestNumbers) { + const oldestPR = _.first(_.sortBy(pullRequestNumbers)); + return this.octokit.paginate(this.octokit.pulls.list, { + owner: GITHUB_OWNER, + repo: EXPENSIFY_CASH_REPO, + state: 'all', + sort: 'created', + direction: 'desc', + per_page: 100, + }, ({data}, done) => { + if (_.find(data, pr => pr.number === oldestPR)) { + done(); + } + return data; + }) + .then(prList => _.filter(prList, pr => _.contains(pullRequestNumbers, pr.number))); + } } module.exports = GithubUtils; diff --git a/.github/actions/isPullRequestMergeable/index.js b/.github/actions/isPullRequestMergeable/index.js index 7b0eadf1763c..d03f5d5d8e9f 100644 --- a/.github/actions/isPullRequestMergeable/index.js +++ b/.github/actions/isPullRequestMergeable/index.js @@ -262,21 +262,7 @@ class GithubUtils { deployBlockers = [], resolvedDeployBlockers = [], ) { - // PRList is reverse-chronologically ordered - const oldestMergedPR = _.last(PRList); - return this.octokit.paginate(this.octokit.pulls.list, { - owner: GITHUB_OWNER, - repo: EXPENSIFY_CASH_REPO, - state: 'all', - sort: 'created', - direction: 'desc', - per_page: 100, - }, ({data}, done) => { - if (_.find(data, pr => pr.html_url === oldestMergedPR)) { - done(); - } - return data; - }) + return this.fetchAllPullRequests(_.map(PRList, this.getPullRequestNumberFromURL)) .then((data) => { const automatedPRs = _.pluck( _.filter(data, GithubUtils.isAutomatedPullRequest), @@ -435,6 +421,30 @@ class GithubUtils { static isAutomatedPullRequest(pullRequest) { return _.isEqual(lodashGet(pullRequest, 'user.login', ''), 'OSBotify'); } + + /** + * Fetch all pull requests given a list of PR numbers. + * + * @param {Array} pullRequestNumbers + * @returns {Promise} + */ + static fetchAllPullRequests(pullRequestNumbers) { + const oldestPR = _.first(_.sortBy(pullRequestNumbers)); + return this.octokit.paginate(this.octokit.pulls.list, { + owner: GITHUB_OWNER, + repo: EXPENSIFY_CASH_REPO, + state: 'all', + sort: 'created', + direction: 'desc', + per_page: 100, + }, ({data}, done) => { + if (_.find(data, pr => pr.number === oldestPR)) { + done(); + } + return data; + }) + .then(prList => _.filter(prList, pr => _.contains(pullRequestNumbers, pr.number))); + } } module.exports = GithubUtils; diff --git a/.github/actions/isStagingDeployLocked/index.js b/.github/actions/isStagingDeployLocked/index.js index 38968fef7dc3..6d22dc1b1030 100644 --- a/.github/actions/isStagingDeployLocked/index.js +++ b/.github/actions/isStagingDeployLocked/index.js @@ -238,21 +238,7 @@ class GithubUtils { deployBlockers = [], resolvedDeployBlockers = [], ) { - // PRList is reverse-chronologically ordered - const oldestMergedPR = _.last(PRList); - return this.octokit.paginate(this.octokit.pulls.list, { - owner: GITHUB_OWNER, - repo: EXPENSIFY_CASH_REPO, - state: 'all', - sort: 'created', - direction: 'desc', - per_page: 100, - }, ({data}, done) => { - if (_.find(data, pr => pr.html_url === oldestMergedPR)) { - done(); - } - return data; - }) + return this.fetchAllPullRequests(_.map(PRList, this.getPullRequestNumberFromURL)) .then((data) => { const automatedPRs = _.pluck( _.filter(data, GithubUtils.isAutomatedPullRequest), @@ -411,6 +397,30 @@ class GithubUtils { static isAutomatedPullRequest(pullRequest) { return _.isEqual(lodashGet(pullRequest, 'user.login', ''), 'OSBotify'); } + + /** + * Fetch all pull requests given a list of PR numbers. + * + * @param {Array} pullRequestNumbers + * @returns {Promise} + */ + static fetchAllPullRequests(pullRequestNumbers) { + const oldestPR = _.first(_.sortBy(pullRequestNumbers)); + return this.octokit.paginate(this.octokit.pulls.list, { + owner: GITHUB_OWNER, + repo: EXPENSIFY_CASH_REPO, + state: 'all', + sort: 'created', + direction: 'desc', + per_page: 100, + }, ({data}, done) => { + if (_.find(data, pr => pr.number === oldestPR)) { + done(); + } + return data; + }) + .then(prList => _.filter(prList, pr => _.contains(pullRequestNumbers, pr.number))); + } } module.exports = GithubUtils; diff --git a/.github/actions/markPullRequestsAsDeployed/index.js b/.github/actions/markPullRequestsAsDeployed/index.js index 519d3ef520b6..5e05cf14583b 100644 --- a/.github/actions/markPullRequestsAsDeployed/index.js +++ b/.github/actions/markPullRequestsAsDeployed/index.js @@ -312,21 +312,7 @@ class GithubUtils { deployBlockers = [], resolvedDeployBlockers = [], ) { - // PRList is reverse-chronologically ordered - const oldestMergedPR = _.last(PRList); - return this.octokit.paginate(this.octokit.pulls.list, { - owner: GITHUB_OWNER, - repo: EXPENSIFY_CASH_REPO, - state: 'all', - sort: 'created', - direction: 'desc', - per_page: 100, - }, ({data}, done) => { - if (_.find(data, pr => pr.html_url === oldestMergedPR)) { - done(); - } - return data; - }) + return this.fetchAllPullRequests(_.map(PRList, this.getPullRequestNumberFromURL)) .then((data) => { const automatedPRs = _.pluck( _.filter(data, GithubUtils.isAutomatedPullRequest), @@ -485,6 +471,30 @@ class GithubUtils { static isAutomatedPullRequest(pullRequest) { return _.isEqual(lodashGet(pullRequest, 'user.login', ''), 'OSBotify'); } + + /** + * Fetch all pull requests given a list of PR numbers. + * + * @param {Array} pullRequestNumbers + * @returns {Promise} + */ + static fetchAllPullRequests(pullRequestNumbers) { + const oldestPR = _.first(_.sortBy(pullRequestNumbers)); + return this.octokit.paginate(this.octokit.pulls.list, { + owner: GITHUB_OWNER, + repo: EXPENSIFY_CASH_REPO, + state: 'all', + sort: 'created', + direction: 'desc', + per_page: 100, + }, ({data}, done) => { + if (_.find(data, pr => pr.number === oldestPR)) { + done(); + } + return data; + }) + .then(prList => _.filter(prList, pr => _.contains(pullRequestNumbers, pr.number))); + } } module.exports = GithubUtils; diff --git a/.github/actions/reopenIssueWithComment/index.js b/.github/actions/reopenIssueWithComment/index.js index 69edc7d42bad..05d9a4448987 100644 --- a/.github/actions/reopenIssueWithComment/index.js +++ b/.github/actions/reopenIssueWithComment/index.js @@ -251,21 +251,7 @@ class GithubUtils { deployBlockers = [], resolvedDeployBlockers = [], ) { - // PRList is reverse-chronologically ordered - const oldestMergedPR = _.last(PRList); - return this.octokit.paginate(this.octokit.pulls.list, { - owner: GITHUB_OWNER, - repo: EXPENSIFY_CASH_REPO, - state: 'all', - sort: 'created', - direction: 'desc', - per_page: 100, - }, ({data}, done) => { - if (_.find(data, pr => pr.html_url === oldestMergedPR)) { - done(); - } - return data; - }) + return this.fetchAllPullRequests(_.map(PRList, this.getPullRequestNumberFromURL)) .then((data) => { const automatedPRs = _.pluck( _.filter(data, GithubUtils.isAutomatedPullRequest), @@ -424,6 +410,30 @@ class GithubUtils { static isAutomatedPullRequest(pullRequest) { return _.isEqual(lodashGet(pullRequest, 'user.login', ''), 'OSBotify'); } + + /** + * Fetch all pull requests given a list of PR numbers. + * + * @param {Array} pullRequestNumbers + * @returns {Promise} + */ + static fetchAllPullRequests(pullRequestNumbers) { + const oldestPR = _.first(_.sortBy(pullRequestNumbers)); + return this.octokit.paginate(this.octokit.pulls.list, { + owner: GITHUB_OWNER, + repo: EXPENSIFY_CASH_REPO, + state: 'all', + sort: 'created', + direction: 'desc', + per_page: 100, + }, ({data}, done) => { + if (_.find(data, pr => pr.number === oldestPR)) { + done(); + } + return data; + }) + .then(prList => _.filter(prList, pr => _.contains(pullRequestNumbers, pr.number))); + } } module.exports = GithubUtils; diff --git a/.github/actions/triggerWorkflowAndWait/index.js b/.github/actions/triggerWorkflowAndWait/index.js index 55779d3e2935..6dc2bb04bef5 100644 --- a/.github/actions/triggerWorkflowAndWait/index.js +++ b/.github/actions/triggerWorkflowAndWait/index.js @@ -402,21 +402,7 @@ class GithubUtils { deployBlockers = [], resolvedDeployBlockers = [], ) { - // PRList is reverse-chronologically ordered - const oldestMergedPR = _.last(PRList); - return this.octokit.paginate(this.octokit.pulls.list, { - owner: GITHUB_OWNER, - repo: EXPENSIFY_CASH_REPO, - state: 'all', - sort: 'created', - direction: 'desc', - per_page: 100, - }, ({data}, done) => { - if (_.find(data, pr => pr.html_url === oldestMergedPR)) { - done(); - } - return data; - }) + return this.fetchAllPullRequests(_.map(PRList, this.getPullRequestNumberFromURL)) .then((data) => { const automatedPRs = _.pluck( _.filter(data, GithubUtils.isAutomatedPullRequest), @@ -575,6 +561,30 @@ class GithubUtils { static isAutomatedPullRequest(pullRequest) { return _.isEqual(lodashGet(pullRequest, 'user.login', ''), 'OSBotify'); } + + /** + * Fetch all pull requests given a list of PR numbers. + * + * @param {Array} pullRequestNumbers + * @returns {Promise} + */ + static fetchAllPullRequests(pullRequestNumbers) { + const oldestPR = _.first(_.sortBy(pullRequestNumbers)); + return this.octokit.paginate(this.octokit.pulls.list, { + owner: GITHUB_OWNER, + repo: EXPENSIFY_CASH_REPO, + state: 'all', + sort: 'created', + direction: 'desc', + per_page: 100, + }, ({data}, done) => { + if (_.find(data, pr => pr.number === oldestPR)) { + done(); + } + return data; + }) + .then(prList => _.filter(prList, pr => _.contains(pullRequestNumbers, pr.number))); + } } module.exports = GithubUtils; diff --git a/.github/libs/GithubUtils.js b/.github/libs/GithubUtils.js index 1724d5f186e4..3438967f761a 100644 --- a/.github/libs/GithubUtils.js +++ b/.github/libs/GithubUtils.js @@ -200,21 +200,7 @@ class GithubUtils { deployBlockers = [], resolvedDeployBlockers = [], ) { - // PRList is reverse-chronologically ordered - const oldestMergedPR = _.last(PRList); - return this.octokit.paginate(this.octokit.pulls.list, { - owner: GITHUB_OWNER, - repo: EXPENSIFY_CASH_REPO, - state: 'all', - sort: 'created', - direction: 'desc', - per_page: 100, - }, ({data}, done) => { - if (_.find(data, pr => pr.html_url === oldestMergedPR)) { - done(); - } - return data; - }) + return this.fetchAllPullRequests(_.map(PRList, this.getPullRequestNumberFromURL)) .then((data) => { const automatedPRs = _.pluck( _.filter(data, GithubUtils.isAutomatedPullRequest), @@ -373,6 +359,30 @@ class GithubUtils { static isAutomatedPullRequest(pullRequest) { return _.isEqual(lodashGet(pullRequest, 'user.login', ''), 'OSBotify'); } + + /** + * Fetch all pull requests given a list of PR numbers. + * + * @param {Array} pullRequestNumbers + * @returns {Promise} + */ + static fetchAllPullRequests(pullRequestNumbers) { + const oldestPR = _.first(_.sortBy(pullRequestNumbers)); + return this.octokit.paginate(this.octokit.pulls.list, { + owner: GITHUB_OWNER, + repo: EXPENSIFY_CASH_REPO, + state: 'all', + sort: 'created', + direction: 'desc', + per_page: 100, + }, ({data}, done) => { + if (_.find(data, pr => pr.number === oldestPR)) { + done(); + } + return data; + }) + .then(prList => _.filter(prList, pr => _.contains(pullRequestNumbers, pr.number))); + } } module.exports = GithubUtils; From 29d7ec7e3819c842519971277ab22db5374e4444 Mon Sep 17 00:00:00 2001 From: Rory Abraham Date: Wed, 30 Jun 2021 10:42:09 -0700 Subject: [PATCH 6/7] Add log line for automated pull requests --- .github/actions/checkDeployBlockers/index.js | 1 + .github/actions/createOrUpdateStagingDeploy/index.js | 1 + .github/actions/getMergeCommitForPullRequest/index.js | 1 + .github/actions/getReleaseBody/index.js | 1 + .github/actions/isPullRequestMergeable/index.js | 1 + .github/actions/isStagingDeployLocked/index.js | 1 + .github/actions/markPullRequestsAsDeployed/index.js | 1 + .github/actions/reopenIssueWithComment/index.js | 1 + .github/actions/triggerWorkflowAndWait/index.js | 1 + .github/libs/GithubUtils.js | 1 + 10 files changed, 10 insertions(+) diff --git a/.github/actions/checkDeployBlockers/index.js b/.github/actions/checkDeployBlockers/index.js index 11ae9a173fd0..61eb964bbead 100644 --- a/.github/actions/checkDeployBlockers/index.js +++ b/.github/actions/checkDeployBlockers/index.js @@ -294,6 +294,7 @@ class GithubUtils { _.filter(data, GithubUtils.isAutomatedPullRequest), 'html_url', ); + console.log('Filtering out the following automated pull requests:', automatedPRs); const sortedPRList = _.chain(PRList) .difference(automatedPRs) .unique() diff --git a/.github/actions/createOrUpdateStagingDeploy/index.js b/.github/actions/createOrUpdateStagingDeploy/index.js index f00f79e8a0af..b0b5f8fe600d 100644 --- a/.github/actions/createOrUpdateStagingDeploy/index.js +++ b/.github/actions/createOrUpdateStagingDeploy/index.js @@ -422,6 +422,7 @@ class GithubUtils { _.filter(data, GithubUtils.isAutomatedPullRequest), 'html_url', ); + console.log('Filtering out the following automated pull requests:', automatedPRs); const sortedPRList = _.chain(PRList) .difference(automatedPRs) .unique() diff --git a/.github/actions/getMergeCommitForPullRequest/index.js b/.github/actions/getMergeCommitForPullRequest/index.js index 181b1db08136..12cdd12c9bac 100644 --- a/.github/actions/getMergeCommitForPullRequest/index.js +++ b/.github/actions/getMergeCommitForPullRequest/index.js @@ -322,6 +322,7 @@ class GithubUtils { _.filter(data, GithubUtils.isAutomatedPullRequest), 'html_url', ); + console.log('Filtering out the following automated pull requests:', automatedPRs); const sortedPRList = _.chain(PRList) .difference(automatedPRs) .unique() diff --git a/.github/actions/getReleaseBody/index.js b/.github/actions/getReleaseBody/index.js index 5470394b807c..0a896b8664af 100644 --- a/.github/actions/getReleaseBody/index.js +++ b/.github/actions/getReleaseBody/index.js @@ -265,6 +265,7 @@ class GithubUtils { _.filter(data, GithubUtils.isAutomatedPullRequest), 'html_url', ); + console.log('Filtering out the following automated pull requests:', automatedPRs); const sortedPRList = _.chain(PRList) .difference(automatedPRs) .unique() diff --git a/.github/actions/isPullRequestMergeable/index.js b/.github/actions/isPullRequestMergeable/index.js index d03f5d5d8e9f..8e412bce84f8 100644 --- a/.github/actions/isPullRequestMergeable/index.js +++ b/.github/actions/isPullRequestMergeable/index.js @@ -268,6 +268,7 @@ class GithubUtils { _.filter(data, GithubUtils.isAutomatedPullRequest), 'html_url', ); + console.log('Filtering out the following automated pull requests:', automatedPRs); const sortedPRList = _.chain(PRList) .difference(automatedPRs) .unique() diff --git a/.github/actions/isStagingDeployLocked/index.js b/.github/actions/isStagingDeployLocked/index.js index 6d22dc1b1030..168439eb409d 100644 --- a/.github/actions/isStagingDeployLocked/index.js +++ b/.github/actions/isStagingDeployLocked/index.js @@ -244,6 +244,7 @@ class GithubUtils { _.filter(data, GithubUtils.isAutomatedPullRequest), 'html_url', ); + console.log('Filtering out the following automated pull requests:', automatedPRs); const sortedPRList = _.chain(PRList) .difference(automatedPRs) .unique() diff --git a/.github/actions/markPullRequestsAsDeployed/index.js b/.github/actions/markPullRequestsAsDeployed/index.js index 5e05cf14583b..e9623971ff80 100644 --- a/.github/actions/markPullRequestsAsDeployed/index.js +++ b/.github/actions/markPullRequestsAsDeployed/index.js @@ -318,6 +318,7 @@ class GithubUtils { _.filter(data, GithubUtils.isAutomatedPullRequest), 'html_url', ); + console.log('Filtering out the following automated pull requests:', automatedPRs); const sortedPRList = _.chain(PRList) .difference(automatedPRs) .unique() diff --git a/.github/actions/reopenIssueWithComment/index.js b/.github/actions/reopenIssueWithComment/index.js index 05d9a4448987..73f3b982244e 100644 --- a/.github/actions/reopenIssueWithComment/index.js +++ b/.github/actions/reopenIssueWithComment/index.js @@ -257,6 +257,7 @@ class GithubUtils { _.filter(data, GithubUtils.isAutomatedPullRequest), 'html_url', ); + console.log('Filtering out the following automated pull requests:', automatedPRs); const sortedPRList = _.chain(PRList) .difference(automatedPRs) .unique() diff --git a/.github/actions/triggerWorkflowAndWait/index.js b/.github/actions/triggerWorkflowAndWait/index.js index 6dc2bb04bef5..f7da63116d4a 100644 --- a/.github/actions/triggerWorkflowAndWait/index.js +++ b/.github/actions/triggerWorkflowAndWait/index.js @@ -408,6 +408,7 @@ class GithubUtils { _.filter(data, GithubUtils.isAutomatedPullRequest), 'html_url', ); + console.log('Filtering out the following automated pull requests:', automatedPRs); const sortedPRList = _.chain(PRList) .difference(automatedPRs) .unique() diff --git a/.github/libs/GithubUtils.js b/.github/libs/GithubUtils.js index 3438967f761a..366cb02e9503 100644 --- a/.github/libs/GithubUtils.js +++ b/.github/libs/GithubUtils.js @@ -206,6 +206,7 @@ class GithubUtils { _.filter(data, GithubUtils.isAutomatedPullRequest), 'html_url', ); + console.log('Filtering out the following automated pull requests:', automatedPRs); const sortedPRList = _.chain(PRList) .difference(automatedPRs) .unique() From 338788fe16826c17c1d321c3933236c0d23c2db0 Mon Sep 17 00:00:00 2001 From: Rory Abraham Date: Fri, 2 Jul 2021 09:51:35 -0700 Subject: [PATCH 7/7] Remove duplicate function --- .github/actions/checkDeployBlockers/index.js | 24 ------------------- .../createOrUpdateStagingDeploy/index.js | 24 ------------------- .../getMergeCommitForPullRequest/index.js | 24 ------------------- .github/actions/getReleaseBody/index.js | 24 ------------------- .../actions/isPullRequestMergeable/index.js | 24 ------------------- .../actions/isStagingDeployLocked/index.js | 24 ------------------- .../markPullRequestsAsDeployed/index.js | 24 ------------------- .../actions/reopenIssueWithComment/index.js | 24 ------------------- .../actions/triggerWorkflowAndWait/index.js | 24 ------------------- .github/libs/GithubUtils.js | 24 ------------------- 10 files changed, 240 deletions(-) diff --git a/.github/actions/checkDeployBlockers/index.js b/.github/actions/checkDeployBlockers/index.js index 1ca01f9b8bad..94ad93b1bd6a 100644 --- a/.github/actions/checkDeployBlockers/index.js +++ b/.github/actions/checkDeployBlockers/index.js @@ -472,30 +472,6 @@ class GithubUtils { static isAutomatedPullRequest(pullRequest) { return _.isEqual(lodashGet(pullRequest, 'user.login', ''), 'OSBotify'); } - - /** - * Fetch all pull requests given a list of PR numbers. - * - * @param {Array} pullRequestNumbers - * @returns {Promise} - */ - static fetchAllPullRequests(pullRequestNumbers) { - const oldestPR = _.first(_.sortBy(pullRequestNumbers)); - return this.octokit.paginate(this.octokit.pulls.list, { - owner: GITHUB_OWNER, - repo: EXPENSIFY_CASH_REPO, - state: 'all', - sort: 'created', - direction: 'desc', - per_page: 100, - }, ({data}, done) => { - if (_.find(data, pr => pr.number === oldestPR)) { - done(); - } - return data; - }) - .then(prList => _.filter(prList, pr => _.contains(pullRequestNumbers, pr.number))); - } } module.exports = GithubUtils; diff --git a/.github/actions/createOrUpdateStagingDeploy/index.js b/.github/actions/createOrUpdateStagingDeploy/index.js index 1421380a300e..e9338f06925a 100644 --- a/.github/actions/createOrUpdateStagingDeploy/index.js +++ b/.github/actions/createOrUpdateStagingDeploy/index.js @@ -600,30 +600,6 @@ class GithubUtils { static isAutomatedPullRequest(pullRequest) { return _.isEqual(lodashGet(pullRequest, 'user.login', ''), 'OSBotify'); } - - /** - * Fetch all pull requests given a list of PR numbers. - * - * @param {Array} pullRequestNumbers - * @returns {Promise} - */ - static fetchAllPullRequests(pullRequestNumbers) { - const oldestPR = _.first(_.sortBy(pullRequestNumbers)); - return this.octokit.paginate(this.octokit.pulls.list, { - owner: GITHUB_OWNER, - repo: EXPENSIFY_CASH_REPO, - state: 'all', - sort: 'created', - direction: 'desc', - per_page: 100, - }, ({data}, done) => { - if (_.find(data, pr => pr.number === oldestPR)) { - done(); - } - return data; - }) - .then(prList => _.filter(prList, pr => _.contains(pullRequestNumbers, pr.number))); - } } module.exports = GithubUtils; diff --git a/.github/actions/getMergeCommitForPullRequest/index.js b/.github/actions/getMergeCommitForPullRequest/index.js index ceb5de68cac0..5f4d6bc8038a 100644 --- a/.github/actions/getMergeCommitForPullRequest/index.js +++ b/.github/actions/getMergeCommitForPullRequest/index.js @@ -500,30 +500,6 @@ class GithubUtils { static isAutomatedPullRequest(pullRequest) { return _.isEqual(lodashGet(pullRequest, 'user.login', ''), 'OSBotify'); } - - /** - * Fetch all pull requests given a list of PR numbers. - * - * @param {Array} pullRequestNumbers - * @returns {Promise} - */ - static fetchAllPullRequests(pullRequestNumbers) { - const oldestPR = _.first(_.sortBy(pullRequestNumbers)); - return this.octokit.paginate(this.octokit.pulls.list, { - owner: GITHUB_OWNER, - repo: EXPENSIFY_CASH_REPO, - state: 'all', - sort: 'created', - direction: 'desc', - per_page: 100, - }, ({data}, done) => { - if (_.find(data, pr => pr.number === oldestPR)) { - done(); - } - return data; - }) - .then(prList => _.filter(prList, pr => _.contains(pullRequestNumbers, pr.number))); - } } module.exports = GithubUtils; diff --git a/.github/actions/getReleaseBody/index.js b/.github/actions/getReleaseBody/index.js index 64ee38190878..1db39d187031 100644 --- a/.github/actions/getReleaseBody/index.js +++ b/.github/actions/getReleaseBody/index.js @@ -443,30 +443,6 @@ class GithubUtils { static isAutomatedPullRequest(pullRequest) { return _.isEqual(lodashGet(pullRequest, 'user.login', ''), 'OSBotify'); } - - /** - * Fetch all pull requests given a list of PR numbers. - * - * @param {Array} pullRequestNumbers - * @returns {Promise} - */ - static fetchAllPullRequests(pullRequestNumbers) { - const oldestPR = _.first(_.sortBy(pullRequestNumbers)); - return this.octokit.paginate(this.octokit.pulls.list, { - owner: GITHUB_OWNER, - repo: EXPENSIFY_CASH_REPO, - state: 'all', - sort: 'created', - direction: 'desc', - per_page: 100, - }, ({data}, done) => { - if (_.find(data, pr => pr.number === oldestPR)) { - done(); - } - return data; - }) - .then(prList => _.filter(prList, pr => _.contains(pullRequestNumbers, pr.number))); - } } module.exports = GithubUtils; diff --git a/.github/actions/isPullRequestMergeable/index.js b/.github/actions/isPullRequestMergeable/index.js index 9f40a3439c92..eb5430b21526 100644 --- a/.github/actions/isPullRequestMergeable/index.js +++ b/.github/actions/isPullRequestMergeable/index.js @@ -446,30 +446,6 @@ class GithubUtils { static isAutomatedPullRequest(pullRequest) { return _.isEqual(lodashGet(pullRequest, 'user.login', ''), 'OSBotify'); } - - /** - * Fetch all pull requests given a list of PR numbers. - * - * @param {Array} pullRequestNumbers - * @returns {Promise} - */ - static fetchAllPullRequests(pullRequestNumbers) { - const oldestPR = _.first(_.sortBy(pullRequestNumbers)); - return this.octokit.paginate(this.octokit.pulls.list, { - owner: GITHUB_OWNER, - repo: EXPENSIFY_CASH_REPO, - state: 'all', - sort: 'created', - direction: 'desc', - per_page: 100, - }, ({data}, done) => { - if (_.find(data, pr => pr.number === oldestPR)) { - done(); - } - return data; - }) - .then(prList => _.filter(prList, pr => _.contains(pullRequestNumbers, pr.number))); - } } module.exports = GithubUtils; diff --git a/.github/actions/isStagingDeployLocked/index.js b/.github/actions/isStagingDeployLocked/index.js index ef73e75a2bb0..0451d13d7fb5 100644 --- a/.github/actions/isStagingDeployLocked/index.js +++ b/.github/actions/isStagingDeployLocked/index.js @@ -424,30 +424,6 @@ class GithubUtils { static isAutomatedPullRequest(pullRequest) { return _.isEqual(lodashGet(pullRequest, 'user.login', ''), 'OSBotify'); } - - /** - * Fetch all pull requests given a list of PR numbers. - * - * @param {Array} pullRequestNumbers - * @returns {Promise} - */ - static fetchAllPullRequests(pullRequestNumbers) { - const oldestPR = _.first(_.sortBy(pullRequestNumbers)); - return this.octokit.paginate(this.octokit.pulls.list, { - owner: GITHUB_OWNER, - repo: EXPENSIFY_CASH_REPO, - state: 'all', - sort: 'created', - direction: 'desc', - per_page: 100, - }, ({data}, done) => { - if (_.find(data, pr => pr.number === oldestPR)) { - done(); - } - return data; - }) - .then(prList => _.filter(prList, pr => _.contains(pullRequestNumbers, pr.number))); - } } module.exports = GithubUtils; diff --git a/.github/actions/markPullRequestsAsDeployed/index.js b/.github/actions/markPullRequestsAsDeployed/index.js index bbf83b7fd591..73f966a01395 100644 --- a/.github/actions/markPullRequestsAsDeployed/index.js +++ b/.github/actions/markPullRequestsAsDeployed/index.js @@ -576,30 +576,6 @@ class GithubUtils { static isAutomatedPullRequest(pullRequest) { return _.isEqual(lodashGet(pullRequest, 'user.login', ''), 'OSBotify'); } - - /** - * Fetch all pull requests given a list of PR numbers. - * - * @param {Array} pullRequestNumbers - * @returns {Promise} - */ - static fetchAllPullRequests(pullRequestNumbers) { - const oldestPR = _.first(_.sortBy(pullRequestNumbers)); - return this.octokit.paginate(this.octokit.pulls.list, { - owner: GITHUB_OWNER, - repo: EXPENSIFY_CASH_REPO, - state: 'all', - sort: 'created', - direction: 'desc', - per_page: 100, - }, ({data}, done) => { - if (_.find(data, pr => pr.number === oldestPR)) { - done(); - } - return data; - }) - .then(prList => _.filter(prList, pr => _.contains(pullRequestNumbers, pr.number))); - } } module.exports = GithubUtils; diff --git a/.github/actions/reopenIssueWithComment/index.js b/.github/actions/reopenIssueWithComment/index.js index d9135ed48412..f6fb5e345902 100644 --- a/.github/actions/reopenIssueWithComment/index.js +++ b/.github/actions/reopenIssueWithComment/index.js @@ -435,30 +435,6 @@ class GithubUtils { static isAutomatedPullRequest(pullRequest) { return _.isEqual(lodashGet(pullRequest, 'user.login', ''), 'OSBotify'); } - - /** - * Fetch all pull requests given a list of PR numbers. - * - * @param {Array} pullRequestNumbers - * @returns {Promise} - */ - static fetchAllPullRequests(pullRequestNumbers) { - const oldestPR = _.first(_.sortBy(pullRequestNumbers)); - return this.octokit.paginate(this.octokit.pulls.list, { - owner: GITHUB_OWNER, - repo: EXPENSIFY_CASH_REPO, - state: 'all', - sort: 'created', - direction: 'desc', - per_page: 100, - }, ({data}, done) => { - if (_.find(data, pr => pr.number === oldestPR)) { - done(); - } - return data; - }) - .then(prList => _.filter(prList, pr => _.contains(pullRequestNumbers, pr.number))); - } } module.exports = GithubUtils; diff --git a/.github/actions/triggerWorkflowAndWait/index.js b/.github/actions/triggerWorkflowAndWait/index.js index b985e26c28c8..ceb5b74309a9 100644 --- a/.github/actions/triggerWorkflowAndWait/index.js +++ b/.github/actions/triggerWorkflowAndWait/index.js @@ -586,30 +586,6 @@ class GithubUtils { static isAutomatedPullRequest(pullRequest) { return _.isEqual(lodashGet(pullRequest, 'user.login', ''), 'OSBotify'); } - - /** - * Fetch all pull requests given a list of PR numbers. - * - * @param {Array} pullRequestNumbers - * @returns {Promise} - */ - static fetchAllPullRequests(pullRequestNumbers) { - const oldestPR = _.first(_.sortBy(pullRequestNumbers)); - return this.octokit.paginate(this.octokit.pulls.list, { - owner: GITHUB_OWNER, - repo: EXPENSIFY_CASH_REPO, - state: 'all', - sort: 'created', - direction: 'desc', - per_page: 100, - }, ({data}, done) => { - if (_.find(data, pr => pr.number === oldestPR)) { - done(); - } - return data; - }) - .then(prList => _.filter(prList, pr => _.contains(pullRequestNumbers, pr.number))); - } } module.exports = GithubUtils; diff --git a/.github/libs/GithubUtils.js b/.github/libs/GithubUtils.js index 69ccbd56907b..59263891fc6c 100644 --- a/.github/libs/GithubUtils.js +++ b/.github/libs/GithubUtils.js @@ -384,30 +384,6 @@ class GithubUtils { static isAutomatedPullRequest(pullRequest) { return _.isEqual(lodashGet(pullRequest, 'user.login', ''), 'OSBotify'); } - - /** - * Fetch all pull requests given a list of PR numbers. - * - * @param {Array} pullRequestNumbers - * @returns {Promise} - */ - static fetchAllPullRequests(pullRequestNumbers) { - const oldestPR = _.first(_.sortBy(pullRequestNumbers)); - return this.octokit.paginate(this.octokit.pulls.list, { - owner: GITHUB_OWNER, - repo: EXPENSIFY_CASH_REPO, - state: 'all', - sort: 'created', - direction: 'desc', - per_page: 100, - }, ({data}, done) => { - if (_.find(data, pr => pr.number === oldestPR)) { - done(); - } - return data; - }) - .then(prList => _.filter(prList, pr => _.contains(pullRequestNumbers, pr.number))); - } } module.exports = GithubUtils;