Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[No QA] Fix StagingDeployCash bug #3650

Merged
merged 4 commits into from
Jun 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/actions/checkDeployBlockers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ class GithubUtils {
let issueBody = `**Release Version:** \`${tag}\`\r\n**Compare Changes:** https://github.com/Expensify/Expensify.cash/compare/production...staging\r\n`;

// PR list
if (!_.isEmpty(PRList)) {
if (!_.isEmpty(sortedPRList)) {
issueBody += '\r\n**This release contains changes from the following pull requests:**\r\n';
_.each(sortedPRList, (URL) => {
issueBody += _.contains(verifiedPRList, URL) ? '- [x]' : '- [ ]';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,15 @@ const run = function () {
// We're in the create flow, not update
// 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(newVersion, mergedPRs);
return GithubUtils.generateStagingDeployCashBody(
newVersion,
_.map(mergedPRs, GithubUtils.getPullRequestURLFromNumber),
);
}

// There is an open StagingDeployCash, so we'll be updating it, not creating a new one
const currentStagingDeployCashData = GithubUtils.getStagingDeployCashData(stagingDeployResponse.data[0]);
console.log('Parsed the following data from the current StagingDeployCash:', currentStagingDeployCashData);
currentStagingDeployCashIssueNumber = currentStagingDeployCashData.number;

const newDeployBlockers = _.map(deployBlockerResponse.data, ({url}) => ({
Expand All @@ -88,9 +92,9 @@ const run = function () {
// Generate the PR list, preserving the previous state of `isVerified` for existing PRs
const PRList = _.sortBy(
_.unique(
_.union(currentStagingDeployCashData.PRList, _.map(mergedPRs, url => ({
url,
number: GithubUtils.getPullRequestNumberFromURL(url),
_.union(currentStagingDeployCashData.PRList, _.map(mergedPRs, number => ({
number,
url: GithubUtils.getPullRequestURLFromNumber(number),

// Since this is the second argument to _.union,
// it will appear later in the array than any duplicate.
Expand Down
14 changes: 9 additions & 5 deletions .github/actions/createOrUpdateStagingDeploy/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,15 @@ const run = function () {
// We're in the create flow, not update
// 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(newVersion, mergedPRs);
return GithubUtils.generateStagingDeployCashBody(
newVersion,
_.map(mergedPRs, GithubUtils.getPullRequestURLFromNumber),
);
}

// There is an open StagingDeployCash, so we'll be updating it, not creating a new one
const currentStagingDeployCashData = GithubUtils.getStagingDeployCashData(stagingDeployResponse.data[0]);
console.log('Parsed the following data from the current StagingDeployCash:', currentStagingDeployCashData);
currentStagingDeployCashIssueNumber = currentStagingDeployCashData.number;

const newDeployBlockers = _.map(deployBlockerResponse.data, ({url}) => ({
Expand All @@ -98,9 +102,9 @@ const run = function () {
// Generate the PR list, preserving the previous state of `isVerified` for existing PRs
const PRList = _.sortBy(
_.unique(
_.union(currentStagingDeployCashData.PRList, _.map(mergedPRs, url => ({
url,
number: GithubUtils.getPullRequestNumberFromURL(url),
_.union(currentStagingDeployCashData.PRList, _.map(mergedPRs, number => ({
number,
url: GithubUtils.getPullRequestURLFromNumber(number),

// Since this is the second argument to _.union,
// it will appear later in the array than any duplicate.
Expand Down Expand Up @@ -431,7 +435,7 @@ class GithubUtils {
let issueBody = `**Release Version:** \`${tag}\`\r\n**Compare Changes:** https://github.com/Expensify/Expensify.cash/compare/production...staging\r\n`;

// PR list
if (!_.isEmpty(PRList)) {
if (!_.isEmpty(sortedPRList)) {
issueBody += '\r\n**This release contains changes from the following pull requests:**\r\n';
_.each(sortedPRList, (URL) => {
issueBody += _.contains(verifiedPRList, URL) ? '- [x]' : '- [ ]';
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/getMergeCommitForPullRequest/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ class GithubUtils {
let issueBody = `**Release Version:** \`${tag}\`\r\n**Compare Changes:** https://github.com/Expensify/Expensify.cash/compare/production...staging\r\n`;

// PR list
if (!_.isEmpty(PRList)) {
if (!_.isEmpty(sortedPRList)) {
issueBody += '\r\n**This release contains changes from the following pull requests:**\r\n';
_.each(sortedPRList, (URL) => {
issueBody += _.contains(verifiedPRList, URL) ? '- [x]' : '- [ ]';
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/getReleaseBody/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ class GithubUtils {
let issueBody = `**Release Version:** \`${tag}\`\r\n**Compare Changes:** https://github.com/Expensify/Expensify.cash/compare/production...staging\r\n`;

// PR list
if (!_.isEmpty(PRList)) {
if (!_.isEmpty(sortedPRList)) {
issueBody += '\r\n**This release contains changes from the following pull requests:**\r\n';
_.each(sortedPRList, (URL) => {
issueBody += _.contains(verifiedPRList, URL) ? '- [x]' : '- [ ]';
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/isPullRequestMergeable/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ class GithubUtils {
let issueBody = `**Release Version:** \`${tag}\`\r\n**Compare Changes:** https://github.com/Expensify/Expensify.cash/compare/production...staging\r\n`;

// PR list
if (!_.isEmpty(PRList)) {
if (!_.isEmpty(sortedPRList)) {
issueBody += '\r\n**This release contains changes from the following pull requests:**\r\n';
_.each(sortedPRList, (URL) => {
issueBody += _.contains(verifiedPRList, URL) ? '- [x]' : '- [ ]';
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/isStagingDeployLocked/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ class GithubUtils {
let issueBody = `**Release Version:** \`${tag}\`\r\n**Compare Changes:** https://github.com/Expensify/Expensify.cash/compare/production...staging\r\n`;

// PR list
if (!_.isEmpty(PRList)) {
if (!_.isEmpty(sortedPRList)) {
issueBody += '\r\n**This release contains changes from the following pull requests:**\r\n';
_.each(sortedPRList, (URL) => {
issueBody += _.contains(verifiedPRList, URL) ? '- [x]' : '- [ ]';
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/markPullRequestsAsDeployed/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ class GithubUtils {
let issueBody = `**Release Version:** \`${tag}\`\r\n**Compare Changes:** https://github.com/Expensify/Expensify.cash/compare/production...staging\r\n`;

// PR list
if (!_.isEmpty(PRList)) {
if (!_.isEmpty(sortedPRList)) {
issueBody += '\r\n**This release contains changes from the following pull requests:**\r\n';
_.each(sortedPRList, (URL) => {
issueBody += _.contains(verifiedPRList, URL) ? '- [x]' : '- [ ]';
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/reopenIssueWithComment/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ class GithubUtils {
let issueBody = `**Release Version:** \`${tag}\`\r\n**Compare Changes:** https://github.com/Expensify/Expensify.cash/compare/production...staging\r\n`;

// PR list
if (!_.isEmpty(PRList)) {
if (!_.isEmpty(sortedPRList)) {
issueBody += '\r\n**This release contains changes from the following pull requests:**\r\n';
_.each(sortedPRList, (URL) => {
issueBody += _.contains(verifiedPRList, URL) ? '- [x]' : '- [ ]';
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/triggerWorkflowAndWait/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ class GithubUtils {
let issueBody = `**Release Version:** \`${tag}\`\r\n**Compare Changes:** https://github.com/Expensify/Expensify.cash/compare/production...staging\r\n`;

// PR list
if (!_.isEmpty(PRList)) {
if (!_.isEmpty(sortedPRList)) {
issueBody += '\r\n**This release contains changes from the following pull requests:**\r\n';
_.each(sortedPRList, (URL) => {
issueBody += _.contains(verifiedPRList, URL) ? '- [x]' : '- [ ]';
Expand Down
2 changes: 1 addition & 1 deletion .github/libs/GithubUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ class GithubUtils {
let issueBody = `**Release Version:** \`${tag}\`\r\n**Compare Changes:** https://github.com/Expensify/Expensify.cash/compare/production...staging\r\n`;

// PR list
if (!_.isEmpty(PRList)) {
if (!_.isEmpty(sortedPRList)) {
issueBody += '\r\n**This release contains changes from the following pull requests:**\r\n';
_.each(sortedPRList, (URL) => {
issueBody += _.contains(verifiedPRList, URL) ? '- [x]' : '- [ ]';
Expand Down
13 changes: 3 additions & 10 deletions tests/unit/createOrUpdateStagingDeployTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,7 @@ describe('createOrUpdateStagingDeployCash', () => {
state: 'closed',
};

const baseNewPullRequests = [
'https://github.com/Expensify/Expensify.cash/pull/6',
'https://github.com/Expensify/Expensify.cash/pull/7',
'https://github.com/Expensify/Expensify.cash/pull/8',
];
const baseNewPullRequests = ['6', '7', '8'];

test('creates new issue when there is none open', () => {
mockGetInput.mockImplementation((arg) => {
Expand Down Expand Up @@ -179,10 +175,7 @@ describe('createOrUpdateStagingDeployCash', () => {
});

// New pull requests to add to open StagingDeployCash
const newPullRequests = [
'https://github.com/Expensify/Expensify.cash/pull/9',
'https://github.com/Expensify/Expensify.cash/pull/10',
];
const newPullRequests = ['9', '10'];
mockGetPullRequestsMergedBetween.mockImplementation((fromRef, toRef) => {
if (fromRef === '1.0.1-0' && toRef === '1.0.2-2') {
return [
Expand Down Expand Up @@ -229,7 +222,7 @@ describe('createOrUpdateStagingDeployCash', () => {
// eslint-disable-next-line max-len
html_url: `https://github.com/Expensify/Expensify.cash/issues/${openStagingDeployCashBefore.number}`,
// eslint-disable-next-line max-len
body: `**Release Version:** \`1.0.2-2\`\r\n**Compare Changes:** https://github.com/Expensify/Expensify.cash/compare/production...staging\r\n\r\n**This release contains changes from the following pull requests:**\r\n- [ ] https://github.com/Expensify/Expensify.cash/pull/6\r\n- [x] https://github.com/Expensify/Expensify.cash/pull/7\r\n- [ ] https://github.com/Expensify/Expensify.cash/pull/8\r\n- [ ] ${newPullRequests[0]}\r\n- [ ] ${newPullRequests[1]}\r\n\r\n**Deploy Blockers:**\r\n- [ ] https://github.com/Expensify/Expensify.cash/pull/6\r\n- [ ] https://github.com/Expensify/Expensify.cash/issues/9\r\n- [x] https://github.com/Expensify/Expensify.cash/issues/10\r\n- [ ] https://github.com/Expensify/Expensify.cash/issues/11\r\n- [ ] https://github.com/Expensify/Expensify.cash/issues/12\r\n\r\ncc @Expensify/applauseleads\r\n`,
body: `**Release Version:** \`1.0.2-2\`\r\n**Compare Changes:** https://github.com/Expensify/Expensify.cash/compare/production...staging\r\n\r\n**This release contains changes from the following pull requests:**\r\n- [ ] https://github.com/Expensify/Expensify.cash/pull/6\r\n- [x] https://github.com/Expensify/Expensify.cash/pull/7\r\n- [ ] https://github.com/Expensify/Expensify.cash/pull/8\r\n- [ ] https://github.com/Expensify/Expensify.cash/pull/${newPullRequests[0]}\r\n- [ ] https://github.com/Expensify/Expensify.cash/pull/${newPullRequests[1]}\r\n\r\n**Deploy Blockers:**\r\n- [ ] https://github.com/Expensify/Expensify.cash/pull/6\r\n- [ ] https://github.com/Expensify/Expensify.cash/issues/9\r\n- [x] https://github.com/Expensify/Expensify.cash/issues/10\r\n- [ ] https://github.com/Expensify/Expensify.cash/issues/11\r\n- [ ] https://github.com/Expensify/Expensify.cash/issues/12\r\n\r\ncc @Expensify/applauseleads\r\n`,
});
});
});
Expand Down