Skip to content

Commit

Permalink
Merge branch 'main' of github.com:Expensify/Expensify.cash into paras…
Browse files Browse the repository at this point in the history
…harrajat/quotedText
  • Loading branch information
parasharrajat committed Apr 20, 2021
2 parents 80f3219 + dd5adba commit 92ddc5a
Show file tree
Hide file tree
Showing 171 changed files with 15,987 additions and 1,407 deletions.
4 changes: 3 additions & 1 deletion .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
If you haven’t already, check out our [contributing guidelines](https://github.com/Expensify/ReactNativeChat/blob/master/CONTRIBUTING.md) for onboarding and email [email protected] to request to join our Slack channel!
If you haven’t already, check out our [contributing guidelines](https://github.com/Expensify/ReactNativeChat/blob/main/CONTRIBUTING.md) for onboarding and email [email protected] to request to join our Slack channel!
___

## Expected Result:
Expand Down Expand Up @@ -26,3 +26,5 @@ Where is this issue occurring?
**Logs:** https://stackoverflow.com/c/expensify/questions/4856
**Notes/Photos/Videos:** Any additional supporting documentation
**Expensify/Expensify Issue URL:**

[View all open jobs on Upwork](https://www.upwork.com/ab/jobs/search/?q=Expensify%20React%20Native&sort=recency&user_location_match=2)
2 changes: 1 addition & 1 deletion .github/actions/createOrUpdateStagingDeploy/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ const exec = promisify(__nccwpck_require__(3129).exec);
function getPullRequestsMergedBetween(fromRef, toRef) {
return exec(`git log --format="%s" ${fromRef}...${toRef}`)
.then(({stdout}) => (
[...stdout.matchAll(/Merge pull request #(\d{1,6})/g)]
[...stdout.matchAll(/Merge pull request #(\d{1,6}) from (?!Expensify\/(?:master|main|version-))/g)]
.map(match => match[1])
));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@ inputs:
GITHUB_TOKEN:
description: "Github token for authentication"
required: true
IS_PRODUCTION_DEPLOY:
description: "True if we are deploying to production"
required: false
outputs:
PR_LIST:
description: Array of released pull request numbers
description: Array of pull request numbers
runs:
using: 'node12'
main: './index.js'
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
const _ = require('underscore');
const core = require('@actions/core');
const github = require('@actions/github');
const GitUtils = require('../../libs/GitUtils');

const octokit = github.getOctokit(core.getInput('GITHUB_TOKEN', {required: true}));
const inputTag = core.getInput('TAG', {required: true});

const isProductionDeploy = JSON.parse(core.getInput('IS_PRODUCTION_DEPLOY', {required: false}));
const itemToFetch = isProductionDeploy ? 'release' : 'tag';

/**
* Gets either releases or tags for a GitHub repo
*
* @param {boolean} fetchReleases
* @returns {*}
*/
function getTagsOrReleases(fetchReleases) {
if (fetchReleases) {
return octokit.repos.listReleases({
owner: github.context.repo.owner,
repo: github.context.repo.repo,
});
}

return octokit.repos.listTags({
owner: github.context.repo.owner,
repo: github.context.repo.repo,
});
}

console.log(`Fetching ${itemToFetch} list from github...`);
getTagsOrReleases(isProductionDeploy)
.catch(githubError => core.setFailed(githubError))
.then(({data}) => {
const keyToPluck = isProductionDeploy ? 'tag_name' : 'name';
const tags = _.pluck(data, keyToPluck);
const priorTagIndex = _.indexOf(tags, inputTag) + 1;

if (priorTagIndex === 0) {
console.log(`No ${itemToFetch} was found for input tag ${inputTag}.`
+ `Comparing it to latest ${itemToFetch} ${tags[0]}`);
}

if (priorTagIndex === tags.length) {
const err = new Error('Somehow, the input tag was at the end of the paginated result, '
+ 'so we don\'t have the prior tag');
console.error(err.message);
core.setFailed(err);
return;
}

const priorTag = tags[priorTagIndex];
console.log(`Given ${itemToFetch}: ${inputTag}`);
console.log(`Prior ${itemToFetch}: ${priorTag}`);

return GitUtils.getPullRequestsMergedBetween(priorTag, inputTag);
})
.then((pullRequestList) => {
console.log(`Found the pull request list: ${pullRequestList}`);
return core.setOutput('PR_LIST', pullRequestList);
})
.catch(error => core.setFailed(error));
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module.exports =
/******/ (() => { // webpackBootstrap
/******/ var __webpack_modules__ = ({

/***/ 4365:
/***/ 6062:
/***/ ((__unused_webpack_module, __unused_webpack_exports, __nccwpck_require__) => {

const _ = __nccwpck_require__(4987);
Expand All @@ -16,35 +16,60 @@ const GitUtils = __nccwpck_require__(669);
const octokit = github.getOctokit(core.getInput('GITHUB_TOKEN', {required: true}));
const inputTag = core.getInput('TAG', {required: true});

console.log('Fetching release list from github...');
octokit.repos.listReleases({
owner: github.context.repo.owner,
repo: github.context.repo.repo,
})
const isProductionDeploy = JSON.parse(core.getInput('IS_PRODUCTION_DEPLOY', {required: false}));
const itemToFetch = isProductionDeploy ? 'release' : 'tag';

/**
* Gets either releases or tags for a GitHub repo
*
* @param {boolean} fetchReleases
* @returns {*}
*/
function getTagsOrReleases(fetchReleases) {
if (fetchReleases) {
return octokit.repos.listReleases({
owner: github.context.repo.owner,
repo: github.context.repo.repo,
});
}

return octokit.repos.listTags({
owner: github.context.repo.owner,
repo: github.context.repo.repo,
});
}

console.log(`Fetching ${itemToFetch} list from github...`);
getTagsOrReleases(isProductionDeploy)
.catch(githubError => core.setFailed(githubError))
.then(({data}) => {
const tags = _.pluck(data, 'tag_name');
const keyToPluck = isProductionDeploy ? 'tag_name' : 'name';
const tags = _.pluck(data, keyToPluck);
const priorTagIndex = _.indexOf(tags, inputTag) + 1;

if (priorTagIndex === 0) {
console.log(`No release was found for input tag ${inputTag}. Comparing it to latest release ${tags[0]}`);
console.log(`No ${itemToFetch} was found for input tag ${inputTag}.`
+ `Comparing it to latest ${itemToFetch} ${tags[0]}`);
}

if (priorTagIndex === tags.length) {
const err = new Error('Somehow, the input tag was at the end of the paginated result, '
+ "so we don't have the prior tag.");
+ 'so we don\'t have the prior tag');
console.error(err.message);
core.setFailed(err);
return;
}

const priorTag = tags[priorTagIndex];
console.log(`Given Release Tag: ${inputTag}`);
console.log(`Prior Release Tag: ${priorTag}`);
console.log(`Given ${itemToFetch}: ${inputTag}`);
console.log(`Prior ${itemToFetch}: ${priorTag}`);

return GitUtils.getPullRequestsMergedBetween(priorTag, inputTag);
})
.then(pullRequestList => core.setOutput('PR_LIST', pullRequestList))
.then((pullRequestList) => {
console.log(`Found the pull request list: ${pullRequestList}`);
return core.setOutput('PR_LIST', pullRequestList);
})
.catch(error => core.setFailed(error));


Expand All @@ -66,7 +91,7 @@ const exec = promisify(__nccwpck_require__(3129).exec);
function getPullRequestsMergedBetween(fromRef, toRef) {
return exec(`git log --format="%s" ${fromRef}...${toRef}`)
.then(({stdout}) => (
[...stdout.matchAll(/Merge pull request #(\d{1,6})/g)]
[...stdout.matchAll(/Merge pull request #(\d{1,6}) from (?!Expensify\/(?:master|main|version-))/g)]
.map(match => match[1])
));
}
Expand Down Expand Up @@ -11224,6 +11249,6 @@ module.exports = require("zlib");;
/******/ // module exports must be returned from runtime so entry inlining is disabled
/******/ // startup
/******/ // Load entry module and return exports
/******/ return __nccwpck_require__(4365);
/******/ return __nccwpck_require__(6062);
/******/ })()
;

This file was deleted.

12 changes: 12 additions & 0 deletions .github/actions/markPullRequestsAsDeployed/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,18 @@ inputs:
description: "Github token for authentication"
required: true
default: "${{ github.token }}"
ANDROID:
description: "Android job result ('success', 'failure', 'cancelled', or 'skipped')"
required: true
DESKTOP:
description: "Desktop job result ('success', 'failure', 'cancelled', or 'skipped')"
required: true
IOS:
description: "iOS job result ('success', 'failure', 'cancelled', or 'skipped')"
required: true
WEB:
description: "Web job result ('success', 'failure', 'cancelled', or 'skipped')"
required: true
runs:
using: "node12"
main: "./index.js"
37 changes: 32 additions & 5 deletions .github/actions/markPullRequestsAsDeployed/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,41 @@ const isProd = JSON.parse(
core.getInput('IS_PRODUCTION_DEPLOY', {required: true}),
);
const token = core.getInput('GITHUB_TOKEN', {required: true});
const date = new Date();
const message = `🚀 Deployed 🚀 to ${
isProd ? 'production' : 'staging'
} on ${date.toDateString()} at ${date.toTimeString()}`;

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

/**
* Return a nicely formatted message for the table based on the result of the GitHub action job
*
* @param {string} platformResult
* @returns {string}
*/
function getDeployTableMessage(platformResult) {
switch (platformResult) {
case 'success':
return `${platformResult} ✅`;
case 'cancelled':
return `${platformResult} 🔪`;
case 'skipped':
return `${platformResult} 🚫`;
case 'failure':
default:
return `${platformResult} ❌`;
}
}

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'} 🚀`;
message += `\n\n platform | result \n ---|--- \n🤖 android 🤖|${androidResult} \n🖥 desktop 🖥|${desktopResult}`;
message += `\n🍎 iOS 🍎|${iOSResult} \n🕸 web 🕸|${webResult}`;

/**
* Create comment on each pull request
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,41 @@ const isProd = JSON.parse(
core.getInput('IS_PRODUCTION_DEPLOY', {required: true}),
);
const token = core.getInput('GITHUB_TOKEN', {required: true});
const date = new Date();
const message = `🚀 Deployed 🚀 to ${
isProd ? 'production' : 'staging'
} on ${date.toDateString()} at ${date.toTimeString()}`;

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

/**
* Return a nicely formatted message for the table based on the result of the GitHub action job
*
* @param {string} platformResult
* @returns {string}
*/
function getDeployTableMessage(platformResult) {
switch (platformResult) {
case 'success':
return `${platformResult} ✅`;
case 'cancelled':
return `${platformResult} 🔪`;
case 'skipped':
return `${platformResult} 🚫`;
case 'failure':
default:
return `${platformResult} ❌`;
}
}

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'} 🚀`;
message += `\n\n platform | result \n ---|--- \n🤖 android 🤖|${androidResult} \n🖥 desktop 🖥|${desktopResult}`;
message += `\n🍎 iOS 🍎|${iOSResult} \n🕸 web 🕸|${webResult}`;

/**
* Create comment on each pull request
*/
Expand Down
2 changes: 1 addition & 1 deletion .github/libs/GitUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const exec = promisify(require('child_process').exec);
function getPullRequestsMergedBetween(fromRef, toRef) {
return exec(`git log --format="%s" ${fromRef}...${toRef}`)
.then(({stdout}) => (
[...stdout.matchAll(/Merge pull request #(\d{1,6})/g)]
[...stdout.matchAll(/Merge pull request #(\d{1,6}) from (?!Expensify\/(?:master|main|version-))/g)]
.map(match => match[1])
));
}
Expand Down
2 changes: 1 addition & 1 deletion .github/scripts/buildActions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ declare -r GITHUB_ACTIONS=(
"$ACTIONS_DIR/checkDeployBlockers/checkDeployBlockers.js"
"$ACTIONS_DIR/createOrUpdateStagingDeploy/createOrUpdateStagingDeploy.js"
"$ACTIONS_DIR/getReleaseBody/getReleaseBody.js"
"$ACTIONS_DIR/getReleasePullRequestList/getReleasePullRequestList.js"
"$ACTIONS_DIR/getDeployPullRequestList/getDeployPullRequestList.js"
"$ACTIONS_DIR/isPullRequestMergeable/isPullRequestMergeable.js"
"$ACTIONS_DIR/isStagingDeployLocked/isStagingDeployLocked.js"
"$ACTIONS_DIR/markPullRequestsAsDeployed/markPullRequestsAsDeployed.js"
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ The GitHub workflows require a large list of secrets to deploy, notify and test

All these _workflows_ are comprised of atomic _actions_. Most of the time, we can use pre-made and independently maintained actions to create powerful workflows that meet our needs. However, when we want to do something very specific or have a more complex or robust action in mind, we can create our own _actions_.

All our actions are stored in the neighboring directory [`.github/actions`](https://github.com/Expensify/Expensify.cash/tree/master/.github/actions). Each action is a module comprised of three parts:
All our actions are stored in the neighboring directory [`.github/actions`](https://github.com/Expensify/Expensify.cash/tree/main/.github/actions). Each action is a module comprised of three parts:

1) An [action metadata file](https://docs.github.com/en/free-pro-team@latest/actions/creating-actions/creating-a-javascript-action#creating-an-action-metadata-file) called `action.yml`. This describes the action, gives it a name, and defines its inputs and outputs.
2) A Node.js script, whose name matches the module. This is where you can implement the custom logic for your action.
Expand All @@ -67,7 +67,7 @@ In order to bundle actions with their dependencies into a single Node.js executa
- Use the absolute path of the action in GitHub, including the repo name, path, and branch ref, like so:
```yaml
- name: Generate Version
uses: Expensify/Expensify.cash/.github/actions/bumpVersion@master
uses: Expensify/Expensify.cash/.github/actions/bumpVersion@main
```
Do not try to use a relative path.
- Confusingly, paths in action metadata files (`action.yml`) _must_ use relative paths.
Expand Down
Loading

0 comments on commit 92ddc5a

Please sign in to comment.