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

Add production/staging deploy comment #2444

Merged
merged 8 commits into from
Apr 19, 2021
Merged

Conversation

AndrewGable
Copy link
Contributor

Details

Adds a production or staging deploy comment when the deploy is over with a table of what platforms deployed successfully and which did not.

Fixed Issues

Fixes https://github.com/Expensify/Expensify/issues/157261

Tests (No QA)

  1. Merge this PR
  2. Wait until QA is done with their checklist
  3. Verify after we deploy this PR to staging, there is a comment that is left something like this:

🚀 Deployed 🚀 to staging

platform result
android success ✅
iOS success ✅
web success ✅
desktop success ✅

@AndrewGable AndrewGable requested a review from roryabraham April 16, 2021 23:13
@AndrewGable AndrewGable self-assigned this Apr 16, 2021
@AndrewGable AndrewGable requested a review from a team as a code owner April 16, 2021 23:13
@MelvinBot MelvinBot requested review from MariaHCD and removed request for a team April 16, 2021 23:13
Copy link
Contributor

@MariaHCD MariaHCD left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks pretty cool!

Comment on lines 25 to 43
function getDeployTableMessage(platformResult) {
const emoji = platformResult === 'success' ? '✅' : '❌';
return platformResult + emoji;
}

const androidResult = getDeployTableMessage(core.getInput('ANDROID', {required: true}));
const desktopResult = getDeployTableMessage(core.getInput('DESKTOP', {required: true}));
const iOSResult = getDeployTableMessage(core.getInput('IOS', {required: true}));
const webResult = getDeployTableMessage(core.getInput('WEB', {required: true}));

const workflowURL = `${process.env.GITHUB_SERVER_URL}/${process.env.GITHUB_REPOSITORY}
/actions/runs/${process.env.GITHUB_RUN_ID}`;

let message = `🚀 [Deployed](${workflowURL}) 🚀 to
${isProd ? 'production' : 'staging'} on ${date.toDateString()} at ${date.toTimeString()}`;

message += `\n\n platform | result \n ---|--- \n android|${androidResult} \n desktop|${desktopResult}`;
message += `\n iOS|${iOSResult} \n web|${webResult}`;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NAB: Curious if it's possible/worth DRY-ing up these blocks of code?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which lines specifically did you have in mind? The four instances of getDeployTableMessage? I could loop through them and store them in a map? Did you have any other ideas?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe there's something I'm missing but looks to me that these lines are the same in the markPullRequestsAsDeployed.js, just wondering if we could have this logic in some sort of helper function?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe there's something I'm missing but looks to me that these lines are the same in the markPullRequestsAsDeployed.js, just wondering if we could have this logic in some sort of helper function?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh - Sorry this is confusing, but index.js is just a compiled JS version for GitHub actions with all the libraries, etc needed to run. So yes it will be identical to the source code (which is not index.js). So you can just ignore all the code in index.js as it was compiled via npm run gh-actions-build

Copy link
Contributor

@roryabraham roryabraham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks pretty 🔥, just a few NAB comments.


const octokit = github.getOctokit(token);
const githubUtils = new GithubUtils(octokit);

function getDeployTableMessage(platformResult) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NAB could do this instead:

function getDeployTableMessage(platformResult) {
    switch (platformResult) {
        case 'success':
            return `${platformResult} ✅`;
        case 'cancelled':
            return `${platformResult} 🔪`;
        case 'skipped':
            return `${platformResult} 🚫`;
        case 'failure':
        default:
            return `${platformResult} ❌`;
    }
}

Also, you're missing a method doc comment.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah we could, I was thinking anything but a success is a ✅ - But more emojis the better, so let's do it

AndrewGable and others added 2 commits April 19, 2021 11:42
Co-authored-by: Rory Abraham <47436092+roryabraham@users.noreply.github.com>
@AndrewGable AndrewGable requested a review from roryabraham April 19, 2021 17:46
Copy link
Contributor

@roryabraham roryabraham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@AndrewGable
Copy link
Contributor Author

In order to test this before QA starts I am going to merge this now. E2E is not done, but this does not change any of that code.

@AndrewGable AndrewGable merged commit 0d92759 into main Apr 19, 2021
@AndrewGable AndrewGable deleted the andrew-deploy-comment branch April 19, 2021 17:55
@OSBotify
Copy link
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@OSBotify
Copy link
Contributor

🚀 [Deployed](https://github.com/Expensify/Expensify.cash
/actions/runs/765130740) 🚀 to
staging on Mon Apr 19 2021 at 22:41:56 GMT+0000 (Coordinated Universal Time)

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants