Skip to content

Commit

Permalink
Merge branch 'main' into Rory-MoveVersionToItsOwnWorkflow
Browse files Browse the repository at this point in the history
  • Loading branch information
roryabraham committed May 11, 2021
2 parents 9c4287b + 20b0791 commit 2c3e041
Show file tree
Hide file tree
Showing 242 changed files with 5,683 additions and 1,979 deletions.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
EXPENSIFY_URL_CASH=https://expensify.cash/
EXPENSIFY_URL_SECURE=https://secure.expensify.com.dev/
EXPENSIFY_URL_COM=https://www.expensify.com.dev/
EXPENSIFY_PARTNER_NAME=chat-expensify-com
EXPENSIFY_PARTNER_PASSWORD=e21965746fd75f82bb66
Expand Down
2 changes: 2 additions & 0 deletions .env.production
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
EXPENSIFY_URL_CASH=https://expensify.cash/
EXPENSIFY_URL_SECURE=https://secure.expensify.com/
EXPENSIFY_URL_COM=https://www.expensify.com/
EXPENSIFY_PARTNER_NAME=chat-expensify-com
EXPENSIFY_PARTNER_PASSWORD=e21965746fd75f82bb66
PUSHER_APP_KEY=268df511a204fbb60884
USE_WEB_PROXY=false
ENVIRONMENT=PROD
2 changes: 2 additions & 0 deletions .env.staging
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
EXPENSIFY_URL_CASH=https://staging.expensify.cash/
EXPENSIFY_URL_SECURE=https://staging-secure.expensify.com/
EXPENSIFY_URL_COM=https://www.expensify.com/
EXPENSIFY_PARTNER_NAME=chat-expensify-com
EXPENSIFY_PARTNER_PASSWORD=e21965746fd75f82bb66
PUSHER_APP_KEY=268df511a204fbb60884
USE_WEB_PROXY=false
ENVIRONMENT=STG
2 changes: 2 additions & 0 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
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)
6 changes: 3 additions & 3 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<If necessary, assign reviewers that know the area or changes well. Feel free to tag any additional reviewers you see fit.>
<!-- If necessary, assign reviewers that know the area or changes well. Feel free to tag any additional reviewers you see fit. -->

### Details
<Explanation of the change or anything fishy that is going on>
<!-- Explanation of the change or anything fishy that is going on -->

### Fixed Issues
<Please replace GH_LINK with the link to the GitHub issue this Pull Request is fixing>
<!-- Please replace GH_LINK with the link to the GitHub issue this Pull Request is fixing -->
Fixes GH_LINK

### Tests
Expand Down
10 changes: 8 additions & 2 deletions .github/actions/checkDeployBlockers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,13 @@ class GithubUtils {
* @returns {Array<Object>} - [{url: String, number: Number, isVerified: Boolean}]
*/
getStagingDeployCashPRList(issue) {
const PRListSection = issue.body.match(/pull requests:\*\*\r\n((?:.*\r\n)+)\r\n/)[1];
let PRListSection = issue.body.match(/pull requests:\*\*\r?\n((?:.*\r?\n)+)\r?\n/) || [];
if (PRListSection.length !== 2) {
// No PRs, return an empty array
console.log('Hmmm...The open StagingDeployCash does not list any pull requests, continuing...');
return [];
}
PRListSection = PRListSection[1];
const unverifiedPRs = _.map(
[...PRListSection.matchAll(new RegExp(`- \\[ ] (${PULL_REQUEST_REGEX.source})`, 'g'))],
match => ({
Expand Down Expand Up @@ -204,7 +210,7 @@ class GithubUtils {
* @returns {Array<Object>} - [{URL: String, number: Number, isResolved: Boolean}]
*/
getStagingDeployCashDeployBlockers(issue) {
let deployBlockerSection = issue.body.match(/Deploy Blockers:\*\*\r\n((?:.*\r\n)+)/) || [];
let deployBlockerSection = issue.body.match(/Deploy Blockers:\*\*\r?\n((?:.*\r?\n)+)/) || [];
if (deployBlockerSection.length !== 2) {
return [];
}
Expand Down
12 changes: 9 additions & 3 deletions .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 Expand Up @@ -198,7 +198,13 @@ class GithubUtils {
* @returns {Array<Object>} - [{url: String, number: Number, isVerified: Boolean}]
*/
getStagingDeployCashPRList(issue) {
const PRListSection = issue.body.match(/pull requests:\*\*\r\n((?:.*\r\n)+)\r\n/)[1];
let PRListSection = issue.body.match(/pull requests:\*\*\r?\n((?:.*\r?\n)+)\r?\n/) || [];
if (PRListSection.length !== 2) {
// No PRs, return an empty array
console.log('Hmmm...The open StagingDeployCash does not list any pull requests, continuing...');
return [];
}
PRListSection = PRListSection[1];
const unverifiedPRs = _.map(
[...PRListSection.matchAll(new RegExp(`- \\[ ] (${PULL_REQUEST_REGEX.source})`, 'g'))],
match => ({
Expand Down Expand Up @@ -230,7 +236,7 @@ class GithubUtils {
* @returns {Array<Object>} - [{URL: String, number: Number, isResolved: Boolean}]
*/
getStagingDeployCashDeployBlockers(issue) {
let deployBlockerSection = issue.body.match(/Deploy Blockers:\*\*\r\n((?:.*\r\n)+)/) || [];
let deployBlockerSection = issue.body.match(/Deploy Blockers:\*\*\r?\n((?:.*\r?\n)+)/) || [];
if (deployBlockerSection.length !== 2) {
return [];
}
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);
/******/ })()
;
10 changes: 8 additions & 2 deletions .github/actions/getReleaseBody/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,13 @@ class GithubUtils {
* @returns {Array<Object>} - [{url: String, number: Number, isVerified: Boolean}]
*/
getStagingDeployCashPRList(issue) {
const PRListSection = issue.body.match(/pull requests:\*\*\r\n((?:.*\r\n)+)\r\n/)[1];
let PRListSection = issue.body.match(/pull requests:\*\*\r?\n((?:.*\r?\n)+)\r?\n/) || [];
if (PRListSection.length !== 2) {
// No PRs, return an empty array
console.log('Hmmm...The open StagingDeployCash does not list any pull requests, continuing...');
return [];
}
PRListSection = PRListSection[1];
const unverifiedPRs = _.map(
[...PRListSection.matchAll(new RegExp(`- \\[ ] (${PULL_REQUEST_REGEX.source})`, 'g'))],
match => ({
Expand Down Expand Up @@ -143,7 +149,7 @@ class GithubUtils {
* @returns {Array<Object>} - [{URL: String, number: Number, isResolved: Boolean}]
*/
getStagingDeployCashDeployBlockers(issue) {
let deployBlockerSection = issue.body.match(/Deploy Blockers:\*\*\r\n((?:.*\r\n)+)/) || [];
let deployBlockerSection = issue.body.match(/Deploy Blockers:\*\*\r?\n((?:.*\r?\n)+)/) || [];
if (deployBlockerSection.length !== 2) {
return [];
}
Expand Down

This file was deleted.

10 changes: 8 additions & 2 deletions .github/actions/isPullRequestMergeable/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,13 @@ class GithubUtils {
* @returns {Array<Object>} - [{url: String, number: Number, isVerified: Boolean}]
*/
getStagingDeployCashPRList(issue) {
const PRListSection = issue.body.match(/pull requests:\*\*\r\n((?:.*\r\n)+)\r\n/)[1];
let PRListSection = issue.body.match(/pull requests:\*\*\r?\n((?:.*\r?\n)+)\r?\n/) || [];
if (PRListSection.length !== 2) {
// No PRs, return an empty array
console.log('Hmmm...The open StagingDeployCash does not list any pull requests, continuing...');
return [];
}
PRListSection = PRListSection[1];
const unverifiedPRs = _.map(
[...PRListSection.matchAll(new RegExp(`- \\[ ] (${PULL_REQUEST_REGEX.source})`, 'g'))],
match => ({
Expand Down Expand Up @@ -178,7 +184,7 @@ class GithubUtils {
* @returns {Array<Object>} - [{URL: String, number: Number, isResolved: Boolean}]
*/
getStagingDeployCashDeployBlockers(issue) {
let deployBlockerSection = issue.body.match(/Deploy Blockers:\*\*\r\n((?:.*\r\n)+)/) || [];
let deployBlockerSection = issue.body.match(/Deploy Blockers:\*\*\r?\n((?:.*\r?\n)+)/) || [];
if (deployBlockerSection.length !== 2) {
return [];
}
Expand Down
10 changes: 8 additions & 2 deletions .github/actions/isStagingDeployLocked/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,13 @@ class GithubUtils {
* @returns {Array<Object>} - [{url: String, number: Number, isVerified: Boolean}]
*/
getStagingDeployCashPRList(issue) {
const PRListSection = issue.body.match(/pull requests:\*\*\r\n((?:.*\r\n)+)\r\n/)[1];
let PRListSection = issue.body.match(/pull requests:\*\*\r?\n((?:.*\r?\n)+)\r?\n/) || [];
if (PRListSection.length !== 2) {
// No PRs, return an empty array
console.log('Hmmm...The open StagingDeployCash does not list any pull requests, continuing...');
return [];
}
PRListSection = PRListSection[1];
const unverifiedPRs = _.map(
[...PRListSection.matchAll(new RegExp(`- \\[ ] (${PULL_REQUEST_REGEX.source})`, 'g'))],
match => ({
Expand Down Expand Up @@ -156,7 +162,7 @@ class GithubUtils {
* @returns {Array<Object>} - [{URL: String, number: Number, isResolved: Boolean}]
*/
getStagingDeployCashDeployBlockers(issue) {
let deployBlockerSection = issue.body.match(/Deploy Blockers:\*\*\r\n((?:.*\r\n)+)/) || [];
let deployBlockerSection = issue.body.match(/Deploy Blockers:\*\*\r?\n((?:.*\r?\n)+)/) || [];
if (deployBlockerSection.length !== 2) {
return [];
}
Expand Down
Loading

0 comments on commit 2c3e041

Please sign in to comment.