Skip to content

Commit

Permalink
Merge branch 'main' into Rory-FixFonts
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/components/PopoverMenu/BasePopoverMenu.js
#	src/pages/home/HeaderView.js
#	src/pages/home/report/EmojiPickerMenu/index.native.js
#	src/pages/home/report/ReportActionCompose.js
#	src/pages/settings/Payments/AddPayPalMePage.js
  • Loading branch information
roryabraham committed Jul 8, 2021
2 parents 3155e1c + ac0f038 commit 429e7bb
Show file tree
Hide file tree
Showing 101 changed files with 8,539 additions and 768 deletions.
41 changes: 26 additions & 15 deletions .github/actions/checkDeployBlockers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -288,26 +288,13 @@ class GithubUtils {
deployBlockers = [],
resolvedDeployBlockers = [],
) {
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) => {
// PRList is reverse-chronologically ordered
const oldestMergedPR = _.last(PRList);
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),
'html_url',
);
console.log('Filtering out the following automated pull requests:', automatedPRs);
const sortedPRList = _.chain(PRList)
.difference(automatedPRs)
.unique()
Expand Down Expand Up @@ -350,6 +337,30 @@ class GithubUtils {
));
}

/**
* Fetch all pull requests given a list of PR numbers.
*
* @param {Array<Number>} 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)));
}

/**
* Create comment on pull request
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -26,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');
Expand Down Expand Up @@ -58,15 +58,12 @@ 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);
// eslint-disable-next-line max-len
console.log(`The following PRs have been merged between the previous StagingDeployCash (${previousStagingDeployCashData.tag}) and new version (${newVersion}):`, 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(
Expand All @@ -89,6 +86,11 @@ 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, tag);
// eslint-disable-next-line max-len
console.log(`The following PRs have been merged between the previous StagingDeployCash (${previousStagingDeployCashData.tag}) and new version (${tag}):`, mergedPRs);

// Generate the PR list, preserving the previous state of `isVerified` for existing PRs
const PRList = _.sortBy(
_.unique(
Expand Down
64 changes: 39 additions & 25 deletions .github/actions/createOrUpdateStagingDeploy/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -36,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');
Expand Down Expand Up @@ -68,15 +68,12 @@ 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);
// eslint-disable-next-line max-len
console.log(`The following PRs have been merged between the previous StagingDeployCash (${previousStagingDeployCashData.tag}) and new version (${newVersion}):`, 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(
Expand All @@ -99,6 +96,11 @@ 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, tag);
// eslint-disable-next-line max-len
console.log(`The following PRs have been merged between the previous StagingDeployCash (${previousStagingDeployCashData.tag}) and new version (${tag}):`, mergedPRs);

// Generate the PR list, preserving the previous state of `isVerified` for existing PRs
const PRList = _.sortBy(
_.unique(
Expand Down Expand Up @@ -191,6 +193,7 @@ const {execSync} = __nccwpck_require__(3129);
* @returns {Array}
*/
function getPullRequestsMergedBetween(fromRef, toRef) {
console.log('Getting pull requests merged between the following refs:', fromRef, toRef);
const localGitLogs = execSync(`git log --format="%s" ${fromRef}...${toRef}`).toString();
return _.map(
[...localGitLogs.matchAll(/Merge pull request #(\d{1,6}) from (?!Expensify\/(?:master|main|version-))/g)],
Expand Down Expand Up @@ -410,26 +413,13 @@ class GithubUtils {
deployBlockers = [],
resolvedDeployBlockers = [],
) {
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) => {
// PRList is reverse-chronologically ordered
const oldestMergedPR = _.last(PRList);
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),
'html_url',
);
console.log('Filtering out the following automated pull requests:', automatedPRs);
const sortedPRList = _.chain(PRList)
.difference(automatedPRs)
.unique()
Expand Down Expand Up @@ -472,6 +462,30 @@ class GithubUtils {
));
}

/**
* Fetch all pull requests given a list of PR numbers.
*
* @param {Array<Number>} 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)));
}

/**
* Create comment on pull request
*
Expand Down
1 change: 1 addition & 0 deletions .github/actions/getDeployPullRequestList/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ const {execSync} = __nccwpck_require__(3129);
* @returns {Array}
*/
function getPullRequestsMergedBetween(fromRef, toRef) {
console.log('Getting pull requests merged between the following refs:', fromRef, toRef);
const localGitLogs = execSync(`git log --format="%s" ${fromRef}...${toRef}`).toString();
return _.map(
[...localGitLogs.matchAll(/Merge pull request #(\d{1,6}) from (?!Expensify\/(?:master|main|version-))/g)],
Expand Down
41 changes: 26 additions & 15 deletions .github/actions/getMergeCommitForPullRequest/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -316,26 +316,13 @@ class GithubUtils {
deployBlockers = [],
resolvedDeployBlockers = [],
) {
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) => {
// PRList is reverse-chronologically ordered
const oldestMergedPR = _.last(PRList);
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),
'html_url',
);
console.log('Filtering out the following automated pull requests:', automatedPRs);
const sortedPRList = _.chain(PRList)
.difference(automatedPRs)
.unique()
Expand Down Expand Up @@ -378,6 +365,30 @@ class GithubUtils {
));
}

/**
* Fetch all pull requests given a list of PR numbers.
*
* @param {Array<Number>} 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)));
}

/**
* Create comment on pull request
*
Expand Down
41 changes: 26 additions & 15 deletions .github/actions/getReleaseBody/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,26 +259,13 @@ class GithubUtils {
deployBlockers = [],
resolvedDeployBlockers = [],
) {
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) => {
// PRList is reverse-chronologically ordered
const oldestMergedPR = _.last(PRList);
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),
'html_url',
);
console.log('Filtering out the following automated pull requests:', automatedPRs);
const sortedPRList = _.chain(PRList)
.difference(automatedPRs)
.unique()
Expand Down Expand Up @@ -321,6 +308,30 @@ class GithubUtils {
));
}

/**
* Fetch all pull requests given a list of PR numbers.
*
* @param {Array<Number>} 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)));
}

/**
* Create comment on pull request
*
Expand Down
Loading

0 comments on commit 429e7bb

Please sign in to comment.