Skip to content

Commit

Permalink
Merge branch 'main' into Rory-PushNotificationOptInStatus
Browse files Browse the repository at this point in the history
# Conflicts:
#	tests/unit/NetworkTest.js
  • Loading branch information
roryabraham committed Feb 9, 2023
2 parents 8fe9141 + 49002ef commit 99d799d
Show file tree
Hide file tree
Showing 85 changed files with 9,685 additions and 4,629 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ inputs:
runs:
using: composite
steps:
- uses: 8398a7/action-slack@v2780b654eb23ee546e54052f0d2b0ed66ea30eaa
- uses: 8398a7/action-slack@v3
name: Job failed Slack notification
with:
status: custom
Expand Down
9 changes: 9 additions & 0 deletions .github/scripts/verifyPodfile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@ title "Verifying that Podfile.lock is synced with the project"

declare EXIT_CODE=0

# Check Provisioning Style. If automatic signing is enabled, iOS builds will fail, so ensure we always have the proper profile specified
info "Verifying that automatic signing is not enabled"
if grep -q 'PROVISIONING_PROFILE_SPECIFIER = chat_expensify_appstore' ios/NewExpensify.xcodeproj/project.pbxproj; then
success "Automatic signing not enabled"
else
error "Error: Automatic provisioning style is not allowed!"
EXIT_CODE=1
fi

PODFILE_SHA=$(openssl sha1 ios/Podfile | awk '{print $2}')
PODFILE_LOCK_SHA=$(awk '/PODFILE CHECKSUM: /{print $3}' ios/Podfile.lock)

Expand Down
65 changes: 20 additions & 45 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,69 +6,44 @@ on:
types: [opened, synchronize]
branches-ignore: [staging, production]

env:
# Number of parallel jobs for jest tests
CHUNKS: 3
jobs:
config:
runs-on: ubuntu-latest
name: Define matrix parameters
outputs:
MATRIX: ${{ steps.set-matrix.outputs.MATRIX }}
JEST_CHUNKS: ${{ steps.set-matrix.outputs.JEST_CHUNKS }}
steps:
- name: Set Matrix
id: set-matrix
uses: actions/github-script@v6
with:
# Generate matrix array i.e. [0, 1, 2, ...., CHUNKS - 1] for test job
script: |
core.setOutput('MATRIX', Array.from({ length: Number(process.env.CHUNKS) }, (v, i) => i + 1));
core.setOutput('JEST_CHUNKS', Number(process.env.CHUNKS) - 1);
test:
needs: config
jest:
if: ${{ github.actor != 'OSBotify' || github.event_name == 'workflow_call' }}
runs-on: ubuntu-latest
name: test (job ${{ fromJSON(matrix.chunk) }})
env:
CI: true
strategy:
fail-fast: false
matrix:
chunk: ${{fromJson(needs.config.outputs.MATRIX)}}

chunk: [ 1, 2, 3 ]
name: test (job ${{ fromJSON(matrix.chunk) }})
steps:
# This action checks-out the repository, so the workflow can access it.
- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8
with:
fetch-depth: 0
- uses: actions/checkout@885641592076c27bfb56c028cd5612cdad63e16d

- uses: Expensify/App/.github/actions/composite/setupNode@main

# If automatic signing is enabled, iOS builds will fail, so ensure we always have the proper profile specified
- name: Check Provisioning Style
run: |
if grep -q 'PROVISIONING_PROFILE_SPECIFIER = chat_expensify_appstore' ios/NewExpensify.xcodeproj/project.pbxproj; then
exit 0
else
echo "Error: Automatic provisioning style is not allowed!"
exit 1
fi
- name: Get number of CPU cores
id: cpu-cores
uses: SimenB/github-actions-cpu-cores@31e91de0f8654375a21e8e83078be625380e2b18

- name: Cache Jest cache
id: cache-jest-cache
uses: actions/cache@v1
uses: actions/cache@ac25611caef967612169ab7e95533cf932c32270
with:
path: .jest-cache
key: ${{ runner.os }}-jest

- name: All Unit Tests
if: ${{ fromJSON(matrix.chunk) < fromJSON(env.CHUNKS) }}
# Split the jest based test files in multiple chunks/groups and then execute them in parallel in different jobs/runners.
run: npx jest --listTests --json | jq -cM '[_nwise(length / ${{ fromJSON(needs.config.outputs.JEST_CHUNKS) }} | ceil)]' | jq '[[]] + .' | jq '.[${{ fromJSON(matrix.chunk) }}] | .[] | @text' | xargs npm test
- name: Jest tests
run: npx jest --shard=${{ fromJSON(matrix.chunk) }}/${{ strategy.job-total }} --max-workers ${{ steps.cpu-cores.outputs.count }}

shellTests:
if: ${{ github.actor != 'OSBotify' || github.event_name == 'workflow_call' }}
runs-on: ubuntu-latest
name: Shell tests
steps:
- uses: actions/checkout@885641592076c27bfb56c028cd5612cdad63e16d

- uses: Expensify/App/.github/actions/composite/setupNode@main

- name: Pull Request Tests
# Pull request related tests will be run in separate runner in parallel.
if: ${{ fromJSON(matrix.chunk) == fromJSON(env.CHUNKS) }}
- name: getPullRequestsMergedBetween
run: tests/unit/getPullRequestsMergedBetweenTest.sh
4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ android {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
multiDexEnabled rootProject.ext.multiDexEnabled
versionCode 1001026404
versionName "1.2.64-4"
versionCode 1001026800
versionName "1.2.68-0"
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()

if (isNewArchitectureEnabled()) {
Expand Down
9 changes: 9 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@ const metro = {
presets: [require('metro-react-native-babel-preset')],
plugins: [
'react-native-reanimated/plugin',

// This is needed due to a react-native bug: https://github.com/facebook/react-native/issues/29084#issuecomment-1030732709
// It is included in metro-react-native-babel-preset but needs to be before plugin-proposal-class-properties or FlatList will break
'@babel/plugin-transform-flow-strip-types',

['@babel/plugin-proposal-class-properties', {loose: true}],
['@babel/plugin-proposal-private-methods', {loose: true}],
['@babel/plugin-proposal-private-property-in-object', {loose: true}],
],
};

Expand Down Expand Up @@ -60,6 +68,7 @@ if (process.env.CAPTURE_METRICS === 'true') {
module.exports = ({caller}) => {
// For `react-native` (iOS/Android) caller will be "metro"
// For `webpack` (Web) caller will be "@babel-loader"
// For jest, it will be babel-jest
// For `storybook` there won't be any config at all so we must give default argument of an empty object
const runningIn = caller((args = {}) => args.name);
return ['metro', 'babel-jest'].includes(runningIn) ? metro : webpack;
Expand Down
18 changes: 8 additions & 10 deletions config/webpack/webpack.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const CopyPlugin = require('copy-webpack-plugin');
const dotenv = require('dotenv');
const {BundleAnalyzerPlugin} = require('webpack-bundle-analyzer');
const HtmlInlineScriptPlugin = require('html-inline-script-webpack-plugin');
const FontPreloadPlugin = require('webpack-font-preload-plugin');
const CustomVersionFilePlugin = require('./CustomVersionFilePlugin');

const includeModules = [
Expand Down Expand Up @@ -79,6 +80,9 @@ const webpackConfig = ({envFile = '.env', platform = 'web'}) => ({
new HtmlInlineScriptPlugin({
scriptMatchPattern: [/splash.+[.]js$/],
}),
new FontPreloadPlugin({
extensions: ['woff2'],
}),
new ProvidePlugin({
process: 'process/browser',
}),
Expand Down Expand Up @@ -152,22 +156,16 @@ const webpackConfig = ({envFile = '.env', platform = 'web'}) => ({
// Rule for react-native-web-webview
{
test: /postMock.html$/,
use: {
loader: 'file-loader',
options: {
name: '[name].[ext]',
},
type: 'asset',
generator: {
filename: '[name].[ext]',
},
},

// Gives the ability to load local images
{
test: /\.(png|jpe?g|gif)$/i,
use: [
{
loader: 'file-loader',
},
],
type: 'asset',
},

// Load svg images
Expand Down
15 changes: 11 additions & 4 deletions contributingGuides/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,18 @@ Additionally if you want to discuss an idea with the open source community witho
3. If you cannot reproduce the problem, pause on this step and add a comment to the issue explaining where you are stuck or that you don't think the issue can be reproduced.

#### Propose a solution for the job
4. After you reproduce the issue, make a proposal for your solution and post it as a comment in the corresponding GitHub issue (linked in the Upwork job). Your solution proposal should include a brief written technical explanation of the changes you will make. Include "Proposal" as the first word in your comment.
4. After you reproduce the issue, complete the [proposal template here](./PROPOSAL_TEMPLATE.md) and post it as a comment in the corresponding GitHub issue (linked in the Upwork job).
- Note: Before submitting a proposal on an issue, be sure to read any other existing proposals. Any new proposal should be substantively different from existing proposals.
5. Pause at this step until someone from the Contributor-Plus team and / or someone from Expensify provides feedback on your proposal (do not create a pull request yet).
6. If your solution proposal is accepted by the Expensify engineer assigned to the issue, Expensify will hire you on Upwork and assign the GitHub issue to you.
7. Once hired, post a comment in the Github issue stating when you expect to have your PR ready for review
5. Refrain from leaving additional comments until someone from the Contributor-Plus team and / or someone from Expensify provides feedback on your proposal (do not create a pull request yet).
- Do not leave more than one proposal.
- Do not make extensive changes to your current proposal until after it has been reviewed.
- If you want to make an entirely new proposal or update an existing proposal, please go back and edit your original proposal, then post a new comment to the issue in this format to alert everyone that it has been updated:
```
## Proposal
[Updated](link to proposal)
```
6. If your proposal is accepted by the Expensify engineer assigned to the issue, Expensify will hire you on Upwork and assign the GitHub issue to you.
7. Once hired, post a comment in the Github issue stating when you expect to have your PR ready for review.
#### Begin coding your solution in a pull request
7. When you are ready to start, fork the repository and create a new branch.
Expand Down
33 changes: 33 additions & 0 deletions contributingGuides/PROPOSAL_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
## Proposal

### Please re-state the problem that we are trying to solve in this issue.

### What is the root cause of that problem?

### What changes do you think we should make in order to solve the problem?
<!-- DO NOT POST CODE DIFFS -->

### What alternative solutions did you explore? (Optional)

**Reminder:** Please use plain English, be brief and avoid jargon. Feel free to use images, charts or pseudo-code if necessary. Do not post large multi-line diffs or write walls of text. Do not create PRs unless you have been hired for this job.

<!---
ATTN: Contributor+
You are the first line of defense in making sure every proposal has a clear and easily understood problem with a "root cause". Do not approve any proposals that lack a satisfying explanation to the first two prompts. It is CRITICALLY important that we understand the root cause at a minimum even if the solution doesn't directly address it. When we avoid this step we can end up solving the wrong problems entirely or just writing hacks and workarounds.
Instructions for how to review a proposal:
1. Address each contributor proposal one at a time and address each part of the question one at a time e.g. if a solution looks acceptable, but the stated problem is not clear then you should provide feedback and make suggestions to improve each prompt before moving on to the next. Avoid responding to all sections of a proposal at once. Move from one question to the next each time asking the contributor to "Please update your original proposal and tag me again when it's ready for review".
2. Limit excessive conversation and moderate issues to keep them on track. If someone is doing any of the following things please kindly and humbly course-correct them:
- Posting PRs.
- Posting large multi-line diffs (this is basically a PR).
- Skipping any of the required questions.
- Not using the proposal template at all.
- Suggesting that an existing issue is related to the current issue before a problem or root cause has been established.
- Excessively wordy explanations.
3. Choose the first proposal that has a reasonable answer to all the required questions.
-->
4 changes: 2 additions & 2 deletions ios/NewExpensify/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.2.64</string>
<string>1.2.68</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleURLTypes</key>
Expand All @@ -30,7 +30,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>1.2.64.4</string>
<string>1.2.68.0</string>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
<key>LSApplicationQueriesSchemes</key>
Expand Down
4 changes: 2 additions & 2 deletions ios/NewExpensifyTests/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>1.2.64</string>
<string>1.2.68</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.2.64.4</string>
<string>1.2.68.0</string>
</dict>
</plist>
36 changes: 36 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
const testFileExtension = '[jt]s?(x)';
module.exports = {
// TODO: change this back to preset: 'react-native' once we upgrade to React Native >= 0.71.2
preset: '@testing-library/react-native',
testMatch: [
`<rootDir>/tests/ui/**/*.${testFileExtension}`,
`<rootDir>/tests/unit/**/*.${testFileExtension}`,
`<rootDir>/tests/actions/**/*.${testFileExtension}`,
`<rootDir>/?(*.)+(spec|test).${testFileExtension}`,
],
transform: {
'^.+\\.jsx?$': 'babel-jest',
},
transformIgnorePatterns: [
'<rootDir>/node_modules/(?!react-native)/',
],
testPathIgnorePatterns: [
'<rootDir>/node_modules',
],
globals: {
__DEV__: true,
WebSocket: {},
},
fakeTimers: {
enableGlobally: true,
doNotFake: ['nextTick'],
},
testEnvironment: 'jsdom',
setupFiles: [
'<rootDir>/jest/setup.js',
],
setupFilesAfterEnv: [
'@testing-library/jest-native/extend-expect',
],
cacheDirectory: '<rootDir>/.jest-cache',
};
Loading

0 comments on commit 99d799d

Please sign in to comment.