Skip to content

Commit

Permalink
[Wallet] Make it easier to build and run the different envs (#5191)
Browse files Browse the repository at this point in the history
### Description

This PR makes it easier to build the app in the different envs we have.
- We now have the following env files, which are mapped to Xcode schemes/Android flavors:
  - `.env.alfajores`
  - `.env.alfajoresdev`
  - `.env.mainnet`
  - `.env.mainnetdev`
  - `.env.test`
- Supports both `debug`/`release` for all envs (for release builds, the js bundle and assets are included in the app package)
- Supports "dev" variants for day-to-day use by developers, can be installed alongside the store apps
- Usage: `yarn dev:ios -e %envName%` or `yarn dev:android -e %envName%`, (`%envName%` can be `alfajores`, `alfajoresdev`, `mainnet`, `mainnetdev` or `test`), add the `-r` flag to produce a release build which doesn't need the packager running
- Other `run_app.sh` script improvements:
  - can build iOS too from the command line (no need to have Xcode running 🎉) and now launches the packager in a different terminal window respecting the user choice of terminal
  - doesn't need to dynamically update the google services plist anymore. This should prevent using the wrong firebase db
  - App can still be launched through Xcode: <img width="382" alt="Screenshot 2020-09-25 at 10 57 28" src="https://user-images.githubusercontent.com/57791/94270913-2233d200-ff41-11ea-98d3-bcc875b7a98e.png">
  - App can also be run from Android Studio if needed: <img width="50%" alt="Screenshot 2020-09-25 at 15 22 02" src="https://user-images.githubusercontent.com/57791/94272139-f1549c80-ff42-11ea-989c-36ff1cac71a8.png">
- Removed unused `pilot` and `integration` networks
- Removed google service configs referencing the deprecated `celo-org-mobile` Firebase project.

Finally it is relatively simple to add new envs if needed.

### Other changes

- Upgraded `react-native-config`

### Tested

Successfully ran:
- `yarn dev:ios`
- `yarn dev:ios -e aflajoresdev`
- `yarn dev:ios -e aflajores`
- `yarn dev:ios -e mainnetdev`
- `yarn dev:ios -e mainnet`
- `yarn dev:ios -r`
- `yarn dev:android`
- `yarn dev:android -e aflajoresdev`
- `yarn dev:android -e aflajores`
- `yarn dev:android -e mainnetdev`
- `yarn dev:android -e mainnet`
- `yarn dev:android -r`
- `yarn test:e2e:ios`
- `yarn test:e2e:ios -r`
- `yarn test:e2e:android` (release mode (`-r`) option doesn't work yet as it fails at runtime due to proguard not keeping some Kotlin classes used by detox).
- `bundle exec fastlane ios mainnet` (though manually disabling upload)
- `bundle exec fastlane android mainnet` (though manually disabling upload)

### Related issues

- Part of #4841
- Fixes #5294

### Backwards compatibility

Yes
  • Loading branch information
jeanregisser authored Oct 9, 2020
1 parent 41d3d03 commit 8283f0e
Show file tree
Hide file tree
Showing 54 changed files with 176 additions and 333 deletions.
2 changes: 0 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -368,8 +368,6 @@ jobs:
command: |
set -euo pipefail
cd packages/mobile
# Create dummy Google services plist
/usr/libexec/PlistBuddy -c "Save" ios/GoogleService-Info.dev.plist
yarn run test:e2e:ios
- store_artifacts:
path: packages/mobile/e2e/artifacts
Expand Down
5 changes: 3 additions & 2 deletions packages/mobile/.env.alfajores
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
ENVIRONMENT=alfajores
DEFAULT_TESTNET=alfajores
# Generated using org.celo.mobile.alfajores and the matching signing cert from the Play Store
# This means Android auto-read feature will only work from Play Store distributed builds!
SMS_RETRIEVER_APP_SIGNATURE=GH+4Okn6nOW
# If FORNO_ENABLED_INITIALLY, local geth will not run initially.
# If toggled on, it will use DEFAULT_SYNC_MODE. See src/geth/consts.ts for more info
Expand All @@ -12,7 +13,7 @@ SHOW_TESTNET_BANNER=true
SHOW_GET_INVITE_LINK=true
APP_BUNDLE_ID=org.celo.mobile.alfajores
APP_STORE_ID=1482389446
APP_DISPLAY_NAME=Celo
APP_DISPLAY_NAME=Alfajores
IOS_GOOGLE_SERVICE_PLIST=GoogleService-Info.alfajores.plist
DYNAMIC_LINK_DOMAIN=https://l.celo.org
GETH_USE_FULL_NODE_DISCOVERY=true
Expand Down
11 changes: 6 additions & 5 deletions packages/mobile/.env → packages/mobile/.env.alfajoresdev
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
ENVIRONMENT=local
DEFAULT_TESTNET=alfajores
SMS_RETRIEVER_APP_SIGNATURE=anJGrg0nQ0S
# Generated using org.celo.mobile.alfajores.dev and the debug keystore
# This means Android auto-read feature will only work from debug builds
SMS_RETRIEVER_APP_SIGNATURE=5yaJvJcZt2P
# If FORNO_ENABLED_INITIALLY, local geth will not run initially.
# If toggled on, it will use DEFAULT_SYNC_MODE. See src/geth/consts.ts for more info
FORNO_ENABLED_INITIALLY=false
Expand All @@ -12,10 +13,10 @@ SHOW_GET_INVITE_LINK=false
DEV_SETTINGS_ACTIVE_INITIALLY=true
# Enable for true hot reloading while dev-ing UI
DEV_RESTORE_NAV_STATE_ON_RELOAD=false
APP_BUNDLE_ID=org.celo.mobile.dev
APP_BUNDLE_ID=org.celo.mobile.alfajores.dev
APP_STORE_ID=1482389446
APP_DISPLAY_NAME=Celo (dev)
IOS_GOOGLE_SERVICE_PLIST=GoogleService-Info.dev.plist
APP_DISPLAY_NAME=Alfajores (dev)
IOS_GOOGLE_SERVICE_PLIST=GoogleService-Info.alfajoresdev.plist
DYNAMIC_LINK_DOMAIN=https://l.celo.org
GETH_USE_FULL_NODE_DISCOVERY=true
GETH_USE_STATIC_NODES=true
Expand Down
19 changes: 0 additions & 19 deletions packages/mobile/.env.integration

This file was deleted.

3 changes: 2 additions & 1 deletion packages/mobile/.env.mainnet
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
ENVIRONMENT=mainnet
DEFAULT_TESTNET=mainnet
# Generated using co.clabs.valora and the matching signing cert from the Play Store
# This means Android auto-read feature will only work from Play Store distributed builds!
SMS_RETRIEVER_APP_SIGNATURE=bU9E4ctGtIW
# If FORNO_ENABLED_INITIALLY, local geth will not run initially.
# If toggled on, it will use DEFAULT_SYNC_MODE. See src/geth/consts.ts for more info
Expand Down
24 changes: 24 additions & 0 deletions packages/mobile/.env.mainnetdev
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
DEFAULT_TESTNET=mainnet
# Generated using co.clabs.valora.dev and the debug keystore
# This means Android auto-read feature will only work from debug builds
SMS_RETRIEVER_APP_SIGNATURE=g9YQFjScXBz
# If FORNO_ENABLED_INITIALLY, local geth will not run initially.
# If toggled on, it will use DEFAULT_SYNC_MODE. See src/geth/consts.ts for more info
FORNO_ENABLED_INITIALLY=false
DEFAULT_SYNC_MODE=5
DEV_SETTINGS_ACTIVE_INITIALLY=true
# Enable for true hot reloading while dev-ing UI
DEV_RESTORE_NAV_STATE_ON_RELOAD=false
FIREBASE_ENABLED=true
SECRETS_KEY=debug
SHOW_TESTNET_BANNER=false
SHOW_GET_INVITE_LINK=false
APP_BUNDLE_ID=co.clabs.valora.dev
APP_STORE_ID=1520414263
APP_DISPLAY_NAME=Valora (dev)
IOS_GOOGLE_SERVICE_PLIST=GoogleService-Info.mainnetdev.plist
DYNAMIC_LINK_DOMAIN=https://vlra.app
GETH_USE_FULL_NODE_DISCOVERY=true
GETH_USE_STATIC_NODES=true
# Only for development, use with caution
GETH_START_HTTP_RPC_SERVER=false
19 changes: 0 additions & 19 deletions packages/mobile/.env.pilot

This file was deleted.

3 changes: 1 addition & 2 deletions packages/mobile/.env.test
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
ENVIRONMENT=local
DEFAULT_TESTNET=alfajores
SMS_RETRIEVER_APP_SIGNATURE=TODO
# If FORNO_ENABLED_INITIALLY, local geth will not run initially.
Expand All @@ -13,7 +12,7 @@ SHOW_TESTNET_BANNER=false
SHOW_GET_INVITE_LINK=true
APP_BUNDLE_ID=org.celo.mobile.test
APP_DISPLAY_NAME=Celo (test)
IOS_GOOGLE_SERVICE_PLIST=GoogleService-Info.dev.plist
IOS_GOOGLE_SERVICE_PLIST=GoogleService-Info.alfajores.plist
GETH_USE_FULL_NODE_DISCOVERY=true
GETH_USE_STATIC_NODES=true
# Only for development, use with caution
Expand Down
1 change: 1 addition & 0 deletions packages/mobile/__mocks__/react-native-config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export default {
DEV_SETTINGS_ACTIVE_INITIALLY: 'false',
SHOW_TESTNET_BANNER: 'true',
DEFAULT_TESTNET: 'alfajores',
DEFAULT_SYNC_MODE: 5,
}
61 changes: 21 additions & 40 deletions packages/mobile/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -77,26 +77,20 @@ project.ext.react = [
enableHermes: true, // clean and rebuild if changing
hermesFlagsRelease: ["-w", "-O", "-output-source-map"],
hermesFlagsDebug: ["-w", "-O", "-output-source-map"],
bundleInIntegration: true,
devDisabledInIntegration: true,
bundleInAlfajores: true,
devDisabledInAlfajores: true,
bundleInPilot: true,
devDisabledInPilot: true,
bundleInMainnet: true,
devDisabledInMainnet: true,
cliPath: "../../node_modules/react-native/cli.js",
hermesCommand: "../../../../node_modules/hermes-engine/%OS-BIN%/hermes",
composeSourceMapsPath: "../../node_modules/react-native/scripts/compose-source-maps.js",
entryFile: "index.js",
]

project.ext.envConfigFiles = [
debug: ".env",
integration: ".env.integration",
// IMPORTANT: longer variants should be first, as react-native-config plugin matches the first prefix it finds
alfajoresdev: ".env.alfajoresdev",
alfajores: ".env.alfajores",
pilot: ".env.pilot",
mainnetdev: ".env.mainnetdev",
mainnet: ".env.mainnet",
apptest: ".env.test",
"": ".env.alfajoresdev", // Fallback
]

project.ext.sentryCli = [
Expand All @@ -109,9 +103,9 @@ apply from: "../../../../node_modules/@sentry/react-native/sentry.gradle"

/**
* Build for Detox should be minSdkVersion >= 18
* Use the taskname to recognize the build is for detox
* Use passed property to recognize the build is for detox
*/
def isDetoxTestBuild = gradle.startParameter.taskNames.contains("assembleAndroidTest")
def isDetoxTestBuild = Boolean.valueOf(project.properties['isDetoxBuild'] ?: 'false')

/**
* Set this to true to create two separate APKs instead of one:
Expand Down Expand Up @@ -203,38 +197,29 @@ android {
signingConfig signingConfigs.debug
}

integration {
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
signingConfig signingConfigs.release
matchingFallbacks = ['release']
}

release {
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
signingConfig signingConfigs.release
}

}
flavorDimensions "default"
productFlavors {
alfajores {
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
signingConfig signingConfigs.release
matchingFallbacks = ['release']
dimension "default"
}

pilot {
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
signingConfig signingConfigs.release
matchingFallbacks = ['release']
alfajoresdev {
dimension "default"
}

mainnet {
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
signingConfig signingConfigs.release
matchingFallbacks = ['release']
dimension "default"
}
mainnetdev {
dimension "default"
}
// ProductFlavor names cannot start with 'test'
apptest {
dimension "default"
}
}
// applicationVariants are e.g. debug, release
Expand Down Expand Up @@ -290,10 +275,6 @@ dependencies {
if (enableHermes) {
def hermesPath = "../../../../node_modules/hermes-engine/android/";
debugImplementation files(hermesPath + "hermes-debug.aar")
integrationImplementation files(hermesPath + "hermes-release.aar")
alfajoresImplementation files(hermesPath + "hermes-release.aar")
pilotImplementation files(hermesPath + "hermes-release.aar")
mainnetImplementation files(hermesPath + "hermes-release.aar")
releaseImplementation files(hermesPath + "hermes-release.aar")
} else {
implementation jscFlavor
Expand Down
Binary file removed packages/mobile/android/app/google-services.json.enc
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
36 changes: 2 additions & 34 deletions packages/mobile/fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -43,34 +43,20 @@ platform :android do
environment = options[:environment].capitalize
if options[:buildApk]
ENV["GRADLE_OPTS"] = '-Dorg.gradle.daemon=false -Dorg.gradle.jvmargs="-Xmx10000m -XX:+HeapDumpOnOutOfMemoryError"'
gradle(task: 'assemble', build_type: environment, project_dir: 'android/')
gradle(task: 'assemble', build_type: 'Release', flavor: environment, project_dir: 'android/')
else
ENV["GRADLE_OPTS"] = '-Dorg.gradle.daemon=false -Dorg.gradle.jvmargs="-Xmx10000m -XX:+HeapDumpOnOutOfMemoryError"'
gradle(task: 'bundle', build_type: environment, project_dir: 'android/')
gradle(task: 'bundle', build_type: 'Release', flavor: environment, project_dir: 'android/')
end
end

desc 'Ship Integration to Playstore Internal'
lane :integration do
env = 'integration'
build(environment: env)
fastlane_supply(env, 'internal')
end

desc 'Ship Alfajores to Playstore Internal'
lane :alfajores do
env = 'alfajores'
build(environment: env)
fastlane_supply(env, 'internal')
end

desc 'Ship Pilot to Playstore Internal'
lane :pilotapp do
env = 'pilot'
build(environment: env)
fastlane_supply(env, 'internal')
end

desc 'Ship Mainnet to Playstore Internal'
lane :mainnet do
env = 'mainnet'
Expand Down Expand Up @@ -114,24 +100,6 @@ platform :ios do
)
end

desc 'Ship Pilot to TestFlight'
lane :pilotapp do
env = 'pilot'
build(environment: env)
upload_to_testflight(
skip_waiting_for_build_processing: true,
)
end

desc 'Ship Integration to TestFlight'
lane :integration do
env = 'integration'
build(environment: env)
upload_to_testflight(
skip_waiting_for_build_processing: true,
)
end

desc 'Ship Mainnet to TestFlight'
lane :mainnet do
env = 'mainnet'
Expand Down
20 changes: 0 additions & 20 deletions packages/mobile/fastlane/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,11 @@ Clean the Android application
fastlane android build
```
Build the Android application - requires environment param
### android integration
```
fastlane android integration
```
Ship Integration to Playstore Internal
### android alfajores
```
fastlane android alfajores
```
Ship Alfajores to Playstore Internal
### android pilotapp
```
fastlane android pilotapp
```
Ship Pilot to Playstore Internal
### android mainnet
```
fastlane android mainnet
Expand Down Expand Up @@ -70,16 +60,6 @@ Build the iOS application - requires environment param
fastlane ios alfajores
```
Ship Alfajores to TestFlight
### ios pilotapp
```
fastlane ios pilotapp
```
Ship Pilot to TestFlight
### ios integration
```
fastlane ios integration
```
Ship Integration to TestFlight
### ios mainnet
```
fastlane ios mainnet
Expand Down
Binary file not shown.
Binary file removed packages/mobile/ios/GoogleService-Info.dev.plist.enc
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
8 changes: 5 additions & 3 deletions packages/mobile/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -318,8 +318,10 @@ PODS:
- React
- react-native-camera/RN (3.23.1):
- React
- react-native-config (0.11.7):
- React
- react-native-config (1.3.3):
- react-native-config/App (= 1.3.3)
- react-native-config/App (1.3.3):
- React-Core
- react-native-contacts (5.0.0):
- React
- react-native-fast-crypto (1.8.3):
Expand Down Expand Up @@ -791,7 +793,7 @@ SPEC CHECKSUMS:
React-jsinspector: 512e560d0e985d0e8c479a54a4e5c147a9c83493
react-native-blind-threshold-bls: 86068a0a8890b04b5492a4a8787b53dbde1aea8d
react-native-camera: 1b52abea404d04e040edb3e74b7c5523c01a3089
react-native-config: 8f6b2b9e017f6a5e92a97353c768e19e67294bb1
react-native-config: e8c71f602c92ddd2f5c24b0b7a90d239ecab8d9f
react-native-contacts: d1a60e38dadb67dbbe481480338988e00966a30d
react-native-fast-crypto: 2ca87a31247365bbef25b2682d4cf88182cbf806
react-native-geth: 51d17abd8bac4b80c4e12adb446242ba1407a0c3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
ActionType = "Xcode.IDEStandardExecutionActionsCore.ExecutionActionType.ShellScriptAction">
<ActionContent
title = "Run Script"
scriptText = "&quot;$SRCROOT/../scripts/xcode_scheme_build_pre_action.sh&quot; &quot;${ENVFILE:-.env.integration}&quot;&#10;">
scriptText = "&quot;$SRCROOT/../scripts/xcode_scheme_build_pre_action.sh&quot; &quot;${ENVFILE:-.env.alfajoresdev}&quot;&#10;">
<EnvironmentBuildable>
<BuildableReference
BuildableIdentifier = "primary"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
ActionType = "Xcode.IDEStandardExecutionActionsCore.ExecutionActionType.ShellScriptAction">
<ActionContent
title = "Run Script"
scriptText = "&quot;$SRCROOT/../scripts/xcode_scheme_build_pre_action.sh&quot; &quot;${ENVFILE:-.env.pilot}&quot;&#10;">
scriptText = "&quot;$SRCROOT/../scripts/xcode_scheme_build_pre_action.sh&quot; &quot;${ENVFILE:-.env.mainnetdev}&quot;&#10;">
<EnvironmentBuildable>
<BuildableReference
BuildableIdentifier = "primary"
Expand Down
Loading

0 comments on commit 8283f0e

Please sign in to comment.