Skip to content

Commit

Permalink
Merge pull request #17 from Expensify/main
Browse files Browse the repository at this point in the history
Merge
  • Loading branch information
tugbadogan authored Apr 21, 2021
2 parents 195b424 + af19f63 commit bada5ba
Show file tree
Hide file tree
Showing 63 changed files with 1,097 additions and 354 deletions.
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.

10 changes: 3 additions & 7 deletions .github/actions/markPullRequestsAsDeployed/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ const isProd = JSON.parse(
core.getInput('IS_PRODUCTION_DEPLOY', {required: true}),
);
const token = core.getInput('GITHUB_TOKEN', {required: true});
const date = new Date();

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

Expand Down Expand Up @@ -47,12 +45,10 @@ const desktopResult = getDeployTableMessage(core.getInput('DESKTOP', {required:
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()}`;
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}`;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ const isProd = JSON.parse(
core.getInput('IS_PRODUCTION_DEPLOY', {required: true}),
);
const token = core.getInput('GITHUB_TOKEN', {required: true});
const date = new Date();

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

Expand Down Expand Up @@ -37,12 +35,10 @@ const desktopResult = getDeployTableMessage(core.getInput('DESKTOP', {required:
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()}`;
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}`;

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
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:

- name: Get Release Pull Request List
id: getReleasePRList
uses: Expensify/Expensify.cash/.github/actions/getReleasePullRequestList@main
uses: Expensify/Expensify.cash/.github/actions/getDeployPullRequestList@main
with:
TAG: ${{ env.PRODUCTION_VERSION }}
GITHUB_TOKEN: ${{ secrets.OS_BOTIFY_TOKEN }}
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/platformDeploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -281,10 +281,11 @@ jobs:

- name: Get Release Pull Request List
id: getReleasePRList
uses: Expensify/Expensify.cash/.github/actions/getReleasePullRequestList@main
uses: Expensify/Expensify.cash/.github/actions/getDeployPullRequestList@main
with:
TAG: ${{ env.VERSION }}
GITHUB_TOKEN: ${{ secrets.OS_BOTIFY_TOKEN }}
IS_PRODUCTION_DEPLOY: ${{ env.SHOULD_DEPLOY_PRODUCTION == 'true' }}

- name: Comment on issues
uses: Expensify/Expensify.cash/.github/actions/markPullRequestsAsDeployed@main
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ In this scenario, it’s possible that you found a bug or enhancement that we ha
5. Pause at this step until Expensify provides feedback on your proposal (do not begin coding or creating a pull request yet).
6. If your solution proposal is accepted, Expensify will hire you on Upwork and assign the GitHub issue to you.

#### Begin coding your solution in a pull reuqest
#### Begin coding your solution in a pull request
7. When you are ready to start, fork the repository and create a new branch.
8. Before you begin writing any code, please be aware that we require all commits to be [signed](https://docs.github.com/en/github/authenticating-to-github/signing-commits). The easiest way to do that is to [generate a new GPG key](https://docs.github.com/en/github/authenticating-to-github/generating-a-new-gpg-key) and [add it to your Github account](https://docs.github.com/en/github/authenticating-to-github/adding-a-new-gpg-key-to-your-github-account). Once you've done that, you can automatically sign all your commits by adding the following to your `.gitconfig`:
```
Expand Down
5 changes: 5 additions & 0 deletions __mocks__/react-native-bootsplash.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export default {
hide: jest.fn().mockResolvedValueOnce(),
show: jest.fn().mockResolvedValueOnce(),
getVisibilityStatus: jest.fn().mockResolvedValue('hidden'),
};
4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@ android {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
multiDexEnabled rootProject.ext.multiDexEnabled
versionCode 1001002604
versionName "1.0.26-4"
versionCode 1001002702
versionName "1.0.27-2"
}
splits {
abi {
Expand Down
6 changes: 6 additions & 0 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,13 @@
android:label="@string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"
android:launchMode="singleTask"
android:exported="true"
android:windowSoftInputMode="adjustResize">
</activity>
<activity
android:name="com.zoontek.rnbootsplash.RNBootSplashActivity"
android:theme="@style/BootTheme"
android:launchMode="singleTask">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.expensify.chat;

import android.os.Bundle;
import com.facebook.react.ReactActivity;
import com.zoontek.rnbootsplash.RNBootSplash;

public class MainActivity extends ReactActivity {

Expand All @@ -12,4 +14,10 @@ public class MainActivity extends ReactActivity {
protected String getMainComponentName() {
return "ExpensifyCash";
}

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
RNBootSplash.init(R.drawable.bootsplash, MainActivity.this); // <- display the generated bootsplash.xml drawable over our MainActivity
}
}
9 changes: 9 additions & 0 deletions android/app/src/main/res/drawable/bootsplash.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>

<layer-list xmlns:android="http://schemas.android.com/apk/res/android" android:opacity="opaque">
<item android:drawable="@color/bootsplash_background" />

<item>
<bitmap android:src="@mipmap/bootsplash_logo" android:gravity="center" />
</item>
</layer-list>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions android/app/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<resources>
<color name="bootsplash_background">#FFFFFF</color>
</resources>
5 changes: 5 additions & 0 deletions android/app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,9 @@
<item name="android:textColor">#000000</item>
</style>

<style name="BootTheme" parent="AppTheme">
<!-- set the generated bootsplash.xml drawable as activity background -->
<item name="android:background">@drawable/bootsplash</item>
</style>

</resources>
Loading

0 comments on commit bada5ba

Please sign in to comment.