Skip to content

Commit

Permalink
chore: bye bye monorepo (#2435)
Browse files Browse the repository at this point in the history
### Description

This fully removes the monorepo structure 🚝 💣 💥 

Here's what was done:
- move everything from `packages/mobile` to the repository root
- file/folder names that were the same between these 2 folders, were merged (`package.json`, `scripts`,  `jest.config.js`, etc)
- adjust all paths accordingly (GitHub workflows, jest, metro, TS, Xcode, Android gradle files, etc)
- remove lerna
- remove some old unused scripts

The app behavior should remain the same, since only paths were adjusted.

For developers, the impact should be minimal, the main thing that changes is the working directory. No need to work in `packages/mobile` anymore.
All scripts we had remain.

### Follow up

While working on this, I came across 2 surprising issues:
- `yarn install` [started failing on GH actions](https://github.com/valora-inc/wallet/runs/6351393671?check_suite_focus=true), while working locally, this is not the first time I see this and is caused by prepare steps of some dependencies which trigger `yarn install` multiple times while the initial `yarn install` is still running, yarnpkg/yarn#6312. As a workaround `yarn install` is retried to avoid this issue. We should see if newer versions of yarn handle this better.
- The final app bundle size changed. It is caused by packages hoisting happening differently without the monorepo structure. It bundles multiple versions of the same package, because the ordering is different. It's mostly happening with `@celo/` packages + `bn.js`. The bundle size was initially 1.1 MB bigger, but I managed to decrease it by setting a yarn resolution for `bn.js`. We should take a further look at this next time we upgrade `@celo/` packages to avoid making the app bundle bigger than necessary.

### Tested

- CI passes
- Locally:
  - `yarn dev:ios`
  - `yarn dev:android`

### How others should test

The wallet works as before.

### Related issues

- Discussed on [Slack](https://valora-app.slack.com/archives/C025V1D6F3J/p1651251065521769).

### Backwards compatibility

Yes
  • Loading branch information
jeanregisser authored May 10, 2022
1 parent ee94ebe commit 2b28b69
Show file tree
Hide file tree
Showing 1,461 changed files with 964 additions and 5,211 deletions.
3 changes: 0 additions & 3 deletions .babelrc

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
5 changes: 2 additions & 3 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
# For details on acceptable file patterns, please refer to the [Github Documentation](https://help.github.com/articles/about-codeowners/)

# default owners, overridden by package specific owners below
* @celo-org/wallet
* @valora-inc/wallet

# directory and file-level owners. Feel free to add to this!
/packages/moonpay-auth/ @tarikbellamine
/packages/komencikit/ @celo-org/cap

4 changes: 2 additions & 2 deletions .github/scripts/automergeCrowdinPr.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ const CROWDIN_BRANCH = 'l10n/main'
const CROWDIN_PR_USER = 'valora-bot-crowdin'
const AUTOMERGE_LABEL = 'automerge'

const ALLOWED_UPDATED_FILE_MATCHER = `packages\/mobile\/locales\/.*\/translation\.json`
const DISALLOWED_UPDATED_FILE = 'packages/mobile/locales/base/translation.json'
const ALLOWED_UPDATED_FILE_MATCHER = `locales\/.*\/translation\.json`
const DISALLOWED_UPDATED_FILE = 'locales/base/translation.json'

/**
* @param {Object} obj - An object.
Expand Down
2 changes: 1 addition & 1 deletion .github/scripts/automergeTranslationPrs.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

const AUTOMERGE_LABEL = 'automerge'
const TRANSLATION_USERS = ['mpgaarciaa', 'lukasawagner']
const BASE_TRANSLATION_FILENAME = 'packages/mobile/locales/base/translation.json'
const BASE_TRANSLATION_FILENAME = 'locales/base/translation.json'

/**
* @param {Object} obj - An object.
Expand Down
2 changes: 0 additions & 2 deletions .github/scripts/createLicenseDisclaimerPr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ config.fatal = true

const branchName = new ShellString(env.BRANCH_NAME)

cd('packages/mobile')

// ensure that we are using ssh
exec('git remote set-url origin [email protected]:valora-inc/wallet.git')

Expand Down
2 changes: 0 additions & 2 deletions .github/scripts/create_app_version_pr.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#!/usr/bin/env bash
set -euo pipefail

cd packages/mobile

# ensure that we are using ssh
git remote set-url origin [email protected]:valora-inc/wallet.git

Expand Down
2 changes: 0 additions & 2 deletions .github/scripts/uploadE2eBuildToEmerge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@ function getGitHubInfo() {
}
}

$.cd('packages/mobile')

const { sha, baseSha, repoName, prNumber, branchName } = getGitHubInfo()

const packageJson = JSON.parse(fs.readFileSync('package.json', { encoding: 'utf8' }))
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/bump-app-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,18 @@ jobs:
- uses: actions/checkout@v2
with:
ref: main
- run: yarn
- run: yarn || yarn
- run: .github/scripts/create_app_version_pr.sh
env:
VALORA_BOT_TOKEN: ${{ steps.google-secrets.outputs.VALORA_BOT_TOKEN }}
- uses: actions/github-script@v5
with:
script: |
const allowedUpdatedFiles = [
'packages/mobile/android/app/build.gradle',
'packages/mobile/android/gradle.properties',
'packages/mobile/ios/celo.xcodeproj/project.pbxproj',
'packages/mobile/package.json'
'android/app/build.gradle',
'android/gradle.properties',
'ios/celo.xcodeproj/project.pbxproj',
'package.json'
]
const script = require('.github/scripts/automergePR.js')
await script({github, context, core, allowedUpdatedFiles})
7 changes: 3 additions & 4 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ jobs:
node_modules
*/*/node_modules
key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}
- run: yarn
- run: yarn build --ignore docs
- run: yarn || yarn
- run: ./scripts/ci_check_vulnerabilities.sh
lint:
name: Lint
Expand All @@ -49,7 +48,7 @@ jobs:
node_modules
*/*/node_modules
key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}
- run: yarn
- run: yarn || yarn
- run: yarn run prettify:diff
- run: yarn run lint
- run: yarn tsc -p .github/scripts
Expand All @@ -69,5 +68,5 @@ jobs:
node_modules
*/*/node_modules
key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}
- run: yarn
- run: yarn || yarn
- run: git diff --exit-code
34 changes: 9 additions & 25 deletions .github/workflows/e2e-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ concurrency:

jobs:
android:
env:
working-directory: ./packages/mobile
name: Android
runs-on: android-e2e-group
steps:
Expand All @@ -37,23 +35,17 @@ jobs:
node-version: '12'
check-latest: true
- name: Install package dependencies
run: yarn
run: yarn || yarn
- name: Fail if someone forgot to commit "yarn.lock"
run: git diff --exit-code
- name: Make jest available
working-directory: ${{env.working-directory}}
run: cp ../../node_modules/.bin/jest node_modules/.bin/
- name: Check E2E wallet balance
working-directory: ${{env.working-directory}}
run: NODE_OPTIONS='--unhandled-rejections=strict' yarn ts-node ./e2e/scripts/check-e2e-wallet-balance.ts
- name: Create Detox Build
working-directory: ${{env.working-directory}}
run: |
export CELO_TEST_CONFIG=e2e
export ANDROID_SDK_ROOT=$HOME/android-tools
yarn detox build -c android.release
- name: Run Detox
working-directory: ${{env.working-directory}}
run: >
export ANDROID_SDK_ROOT=$HOME/android-tools &&
export PATH=$ANDROID_SDK_ROOT/platform-tools:$PATH &&
Expand All @@ -75,22 +67,21 @@ jobs:
uses: mikepenz/action-junit-report@v2
with:
check_name: Android e2e Test Report
report_paths: 'packages/mobile/e2e/test-results/junit.xml'
report_paths: 'e2e/test-results/junit.xml'
- name: 'Upload Android E2E Artifacts'
if: failure()
uses: actions/upload-artifact@v2
with:
name: android-e2e-artifact
path: packages/mobile/e2e/artifacts
path: e2e/artifacts
- name: 'Upload Android E2E HTML Report'
if: always()
uses: actions/upload-artifact@v2
with:
name: android-e2e-test-report
path: packages/mobile/e2e/test-results
path: e2e/test-results
ios:
env:
working-directory: ./packages/mobile
# `if` conditions can't directly access secrets, so we use a workaround
# See https://docs.github.com/en/actions/security-guides/encrypted-secrets#using-encrypted-secrets-in-a-workflow
SECRETS_AVAILABLE: ${{ secrets.SECRETS_AVAILABLE }}
Expand All @@ -111,27 +102,21 @@ jobs:
node-version: '12'
check-latest: true
- name: Install package dependencies
run: yarn
run: yarn || yarn
- name: Fail if someone forgot to commit "yarn.lock"
run: git diff --exit-code
- name: Install Ruby dependencies
working-directory: ${{env.working-directory}}
run: bundle install --path vendor/bundle
- name: Fail if someone forgot to commit "Gemfile.lock"
run: git diff --exit-code
- name: Install CocoaPods dependencies
working-directory: ${{env.working-directory}}/ios
working-directory: ios
run: bundle exec pod install || bundle exec pod install --repo-update
- name: Fail if someone forgot to commit "Podfile.lock"
run: git diff --exit-code
- name: Make jest available
working-directory: ${{env.working-directory}}
run: cp ../../node_modules/.bin/jest node_modules/.bin/
- name: Check E2E wallet balance
working-directory: ${{env.working-directory}}
run: NODE_OPTIONS='--unhandled-rejections=strict' yarn ts-node ./e2e/scripts/check-e2e-wallet-balance.ts
- name: Create Detox Build
working-directory: ${{env.working-directory}}
run: |
export CELO_TEST_CONFIG=e2e
yarn detox build -c ios.release
Expand All @@ -144,7 +129,6 @@ jobs:
EMERGE_API_TOKEN: ${{ steps.google-secrets.outputs.EMERGE_API_TOKEN }}
DETOX_CONFIG: ios.release
- name: Run Detox
working-directory: ${{env.working-directory}}
run: >
yarn detox test
--configuration ios.release
Expand All @@ -162,16 +146,16 @@ jobs:
uses: mikepenz/action-junit-report@v2
with:
check_name: iOS e2e Test Report
report_paths: 'packages/mobile/e2e/test-results/junit.xml'
report_paths: 'e2e/test-results/junit.xml'
- name: 'Upload iOS E2E Artifacts'
if: failure()
uses: actions/upload-artifact@v2
with:
name: ios-e2e-artifact
path: packages/mobile/e2e/artifacts
path: e2e/artifacts
- name: 'Upload iOS E2E HTML Report'
if: always()
uses: actions/upload-artifact@v2
with:
name: ios-e2e-test-report
path: packages/mobile/e2e/test-results
path: e2e/test-results
7 changes: 2 additions & 5 deletions .github/workflows/e2e-faucet-balance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ on:

jobs:
balance-and-fund:
env:
working-directory: ./packages/mobile
name: balance-and-fund
runs-on: ubuntu-latest
steps:
Expand All @@ -25,12 +23,11 @@ jobs:
node-version: '12'
check-latest: true
- name: Install package dependencies
run: yarn
run: yarn || yarn
- name: Create E2E Fund .env File
env:
TEST_FAUCET_SECRET: ${{ secrets.TEST_FAUCET_SECRET }}
working-directory: ${{env.working-directory}}/e2e
working-directory: e2e
run: echo TEST_FAUCET_SECRET=$TEST_FAUCET_SECRET >> .env
- name: Run Balance and Fund
working-directory: ${{env.working-directory}}
run: NODE_OPTIONS='--unhandled-rejections=strict' yarn ts-node ./e2e/scripts/fund-e2e-accounts.ts
12 changes: 6 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,21 @@ jobs:
*/*/node_modules
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
- name: Install Yarn dependencies
run: yarn
- name: Build Yarn packages
run: yarn build --ignore docs
run: yarn || yarn
- name: Build
run: yarn build
- name: Update RootStateSchema if necessary
run: yarn --cwd packages/mobile test:update-root-state-schema
run: yarn test:update-root-state-schema
- name: Fail if someone forgot to commit "RootStateSchema.json"
run: git diff --exit-code
- name: Run mobile tests
run: |
mkdir -p test-results/jest
yarn --cwd packages/mobile test:ci
yarn test:ci
- name: Upload Coverage Report
uses: actions/upload-artifact@v2
with:
path: packages/mobile/coverage/lcov-report
path: coverage/lcov-report
- name: 'Upload to Codecov'
uses: codecov/codecov-action@v2
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/update-licenses-disclaimer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ jobs:
with:
ssh-private-key: ${{ steps.google-secrets.outputs.BOT_SSH_KEY }}
- uses: actions/checkout@v2
- run: yarn
- run: yarn || yarn
- run: yarn ts-node .github/scripts/createLicenseDisclaimerPr.ts
env:
VALORA_BOT_TOKEN: ${{ steps.google-secrets.outputs.VALORA_BOT_TOKEN }}
- uses: actions/github-script@v5
with:
script: |
const script = require('.github/scripts/automergePR.js')
const allowedUpdatedFiles = ['packages/mobile/src/account/LicenseDisclaimer.txt']
const allowedUpdatedFiles = ['src/account/LicenseDisclaimer.txt']
await script({github, context, core, allowedUpdatedFiles})
62 changes: 52 additions & 10 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

# Xcode
#
build/
*.pbxuser
!default.pbxuser
*.mode1v3
Expand All @@ -34,10 +35,10 @@ DerivedData
*.hmap
*.ipa
*.xcuserstate
project.xcworkspace

# Android/IntelliJ
#
build/
.idea
.gradle
local.properties
Expand All @@ -53,6 +54,7 @@ yarn-error.log
buck-out/
\.buckd/
*.keystore
!debug.keystore

# fastlane
#
Expand Down Expand Up @@ -85,15 +87,55 @@ tsconfig.tsbuildinfo
# git mergetool
*.orig

packages/docs/_book/

*/.next/*
.env.local

packages/provider-url-service/*
packages/moonpay-auth/*
packages/komencikit/*
packages/indexer/*
packages/blockchain-api/*
packages/notification-service/*
packages/cloud-functions/*
# Packages from old monorepo structure
packages/

# Ruby gem artifacts
.bundle
vendor/

# Bundle artifact
*.jsbundle

fastlane/google-play-service-account.json

test-report.xml
coverage/

android/keystore.properties
android/app/celo-release-key.keystore
android/app/.settings
android/.settings

.vscode/

# End to end tests
e2e/artifacts/
e2e_run.log
e2e_pidcat_run.log
e2e/test-results/*
!e2e/test-results/teststyle.css
!e2e/test-results/valora-icon.png

# keys
secrets.json
!__mocks__/secrets.json

# Branding
# See scripts/sync_branding.sh
branding/valora
android/app/src/main/res/drawable*
android/app/src/main/res/layout*
android/app/src/main/res/mipmap*
ios/celo/Base.lproj/*
!ios/celo/Base.lproj/InfoPlist.strings
ios/celo/Images.xcassets/
src/brandingConfig.ts
src/icons/Logo.tsx
src/icons/DefaultAvatar.tsx
src/images/*
!src/images/Images.ts
!src/images/link-arrow.png
Loading

0 comments on commit 2b28b69

Please sign in to comment.