Skip to content

Commit

Permalink
[WIP] Build flow for mobile app (#1476)
Browse files Browse the repository at this point in the history
* fix CI

* bitrise config

* bitrise config

* bitrise config

* bitrise config

* bitrise config

* bitrise config

* bitrise config

* bitrise config

* react-native-ci
  • Loading branch information
nicastelo committed Mar 30, 2020
1 parent 8119a62 commit 8c96055
Show file tree
Hide file tree
Showing 18 changed files with 102 additions and 428 deletions.
1 change: 1 addition & 0 deletions .env.test
Expand Up @@ -13,3 +13,4 @@ REACT_APP_AMPLITUDE_API_KEY=
REACT_APP_THROW_SAVE_PROFILE_ERRORS=true
REACT_APP_ADMIN_MNEMONIC="myth like bonus scare over problem client lizard pioneer submit female collect"
REACT_APP_MNEMONIC_TO_SEED=true
TEST_REACT_NATIVE=true
16 changes: 16 additions & 0 deletions android/app/build.gradle
Expand Up @@ -76,6 +76,8 @@ import com.android.build.OutputFile
* ]
*/

def isTesting = new Boolean(System.getenv('TEST_REACT_NATIVE'))

project.ext.react = [
entryFile: "index.js",
enableHermes: false, // clean and rebuild if changing
Expand Down Expand Up @@ -189,6 +191,10 @@ android {
// Make sure libjsc.so does not packed in APK
exclude "**/libjsc.so"
}

dexOptions {
javaMaxHeapSize "4G"
}
}

dependencies {
Expand Down Expand Up @@ -216,4 +222,14 @@ task copyDownloadableDepsToLibs(type: Copy) {
into 'libs'
}

gradle.projectsEvaluated {
def tasksToSkip = project.tasks.matching {
it.name.contains("SentryUpload")
}

if (isTesting) {
tasksToSkip.all { enabled = false }
}
}

apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
@@ -1,4 +1,4 @@
package org.gooddollar;
package com.gooddollar;

import com.wix.detox.Detox;

Expand Down
4 changes: 4 additions & 0 deletions android/gradle.properties
Expand Up @@ -19,3 +19,7 @@

android.useAndroidX=true
android.enableJetifier=true

# That's needed for java to be able the create the APK with our 300MB native library
# Basically we grant java a 4GB heap.
org.gradle.jvmargs=-Xmx4608m
2 changes: 1 addition & 1 deletion e2e/firstTest.spec.js
Expand Up @@ -9,4 +9,4 @@ describe('Example', () => {
await element(by.id('signInButton')).tap();
await expect(element(by.id('recoverPhrase'))).toBeVisible();
});
});
});
5 changes: 2 additions & 3 deletions index.js
Expand Up @@ -2,6 +2,5 @@
* @format
*/

require('./shim.js')
require('./native.js')

import './shim.js'
import './native.js'
372 changes: 12 additions & 360 deletions ios/GoodDollar.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

10 changes: 0 additions & 10 deletions ios/Podfile
Expand Up @@ -56,16 +56,6 @@ target 'GoodDollar' do
use_native_modules!
end

target 'GoodDollar-tvOS' do
# Pods for GoodDollar-tvOS

target 'GoodDollar-tvOSTests' do
inherit! :search_paths
# Pods for testing
end

end

post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
Expand Down
2 changes: 1 addition & 1 deletion ios/Podfile.lock
Expand Up @@ -533,6 +533,6 @@ SPEC CHECKSUMS:
TcpSockets: 8d839b9b14f6f344d98e4642ded13ab3112b462d
Yoga: f2a7cd4280bfe2cca5a7aed98ba0eb3d1310f18b

PODFILE CHECKSUM: 01135d5d631459becd985ae3e1cd311876afd4d7
PODFILE CHECKSUM: 72df449847822d4808fc45faddaaa8c1bc499696

COCOAPODS: 1.9.1
4 changes: 4 additions & 0 deletions metro.config.js
Expand Up @@ -6,13 +6,17 @@
*/

const nodeLibs = require('node-libs-react-native')
const defaultSourceExts = require('metro-config/src/defaults/defaults').sourceExts

module.exports = {
resolver: {
extraNodeModules: {
...nodeLibs,
vm: require.resolve('vm-browserify')
},
sourceExts: process.env.TEST_REACT_NATIVE
? ['e2e.js'].concat(defaultSourceExts)
: defaultSourceExts
},
transformer: {
getTransformOptions: async () => ({
Expand Down
3 changes: 3 additions & 0 deletions native.js
Expand Up @@ -4,6 +4,7 @@ import React from 'react'
//global.crypto = {} dont know why
import 'react-native-crypto'
import WebviewCrypto from '@gooddollar/react-native-webview-crypto'
import Config from 'react-native-config'
import App from './src/App'
import { name as appName } from './app.json'
import 'react-native-gesture-handler'
Expand All @@ -16,4 +17,6 @@ const DeApp = () => (
</SafeAreaProvider>
)

console.disableYellowBox = !!Config.TEST_REACT_NATIVE;

AppRegistry.registerComponent(appName, () => DeApp)
14 changes: 7 additions & 7 deletions package.json
Expand Up @@ -22,10 +22,10 @@
"test": "npm run link && npm run test:web && npm run test:native",
"test:web-watch": "npm run link && react-app-rewired test --watch",
"test:web": "npm run link && react-app-rewired test",
"test:native": "npm run link && export TEST_REACT_NATIVE=1; react-app-rewired test",
"test:native-watch": "npm run link && TEST_REACT_NATIVE=1; react-app-rewired test --watch",
"test:native": "npm run test:ios && npm run test:android",
"test:ios": "npm run animation:assets && ENVFILE=.env.test detox build -c ios.sim.debug && detox test -c ios.sim.debug",
"test:android": "npm run animation:assets && ENVFILE=.env.test detox build -c android.emu.release && detox test -c android.emu.release",
"coverage": "react-app-rewired test --coverage",
"coverage:native": "TEST_REACT_NATIVE=1; react-app-rewired test --coverage",
"coveralls": "cat ./coverage/lcov.info | node node_modules/.bin/coveralls",
"bundlesize:check": "bundlesize",
"flow": "flow",
Expand Down Expand Up @@ -273,19 +273,19 @@
"detox": {
"configurations": {
"ios.sim.debug": {
"binaryPath": "ios/build/Build/Products/Debug-iphonesimulator/GoodDollar.app",
"build": "xcodebuild -workspace ios/GoodDollar.xcworkspace -scheme GoodDollar -configuration Debug -sdk iphonesimulator -derivedDataPath ios/build",
"binaryPath": "ios/build/Build/Products/Release-iphonesimulator/GoodDollar.app",
"build": "xcodebuild -workspace ios/GoodDollar.xcworkspace -scheme GoodDollar -configuration Release -sdk iphonesimulator -derivedDataPath ios/build",
"type": "ios.simulator",
"device": {
"type": "iPhone 11"
}
},
"android.emu.release": {
"binaryPath": "android/app/build/outputs/apk/release/app-release.apk",
"build": "cd android && gradlew assembleRelease assembleAndroidTest -DtestBuildType=release && cd ..",
"build": "cd android && ./gradlew assembleRelease assembleAndroidTest -DtestBuildType=release && cd ..",
"type": "android.emulator",
"device": {
"avdName": "Nexus_5_API_26"
"avdName": "android-29"
}
}
},
Expand Down
46 changes: 1 addition & 45 deletions src/lib/hooks/hasConnectionChange.js
@@ -1,48 +1,4 @@
import { useCallback, useEffect, useState } from 'react'
import API from '../API/api'
import { delay } from '../utils/async'
import logger from '../logger/pino-logger'
export { default as useConnectionWeb3 } from './useConnectionWeb3'
export { default as useConnectionGun } from './useConnectionGun'
export { default as useConnection } from './useConnection'

const log = logger.child({ from: 'hasConnectionChange' })

export const useAPIConnection = () => {
const [isConnection, setIsConnection] = useState(false)

/**
* Don't start app if server isn't responding
*/
const apiReady = useCallback(async () => {
try {
await API.ready
const res = await Promise.race([
API.ping()
.then(_ => true)
.catch(_ => 'ping error'),
delay(3000).then(_ => 'timeout'),
])
log.debug('apiReady:', { res })
if (res !== true) {
setIsConnection(false)
await delay(3000)
return apiReady()
}
setIsConnection(true)
return
} catch (e) {
log.debug('apiReady:', e.message)
setIsConnection(false)
await delay(3000)

// return apiReady()
}
})

useEffect(() => {
apiReady()
}, [apiReady])

return isConnection
}
export { default as useAPIConnection } from './useAPIConnection'
1 change: 1 addition & 0 deletions src/lib/hooks/useAPIConnection.e2e.js
@@ -0,0 +1 @@
export default () => true
45 changes: 45 additions & 0 deletions src/lib/hooks/useAPIConnection.js
@@ -0,0 +1,45 @@
import { useCallback, useEffect, useState } from 'react'
import API from '../API/api'
import logger from '../logger/pino-logger'
import { delay } from '../utils/async'

const log = logger.child({ from: 'useAPIConnection' })

export default () => {
const [isConnection, setIsConnection] = useState(false)

/**
* Don't start app if server isn't responding
*/
const apiReady = useCallback(async () => {
try {
await API.ready
const res = await Promise.race([
API.ping()
.then(_ => true)
.catch(_ => 'ping error'),
delay(3000).then(_ => 'timeout'),
])
log.debug('apiReady:', { res })
if (res !== true) {
setIsConnection(false)
await delay(3000)
return apiReady()
}
setIsConnection(true)
return
} catch (e) {
log.debug('apiReady:', e.message)
setIsConnection(false)
await delay(3000)

// return apiReady()
}
})

useEffect(() => {
apiReady()
}, [apiReady])

return isConnection
}
1 change: 1 addition & 0 deletions src/lib/hooks/useConnection.e2e.js
@@ -0,0 +1 @@
export default () => true
1 change: 1 addition & 0 deletions src/lib/hooks/useConnectionGun.e2e.js
@@ -0,0 +1 @@
export default () => true
1 change: 1 addition & 0 deletions src/lib/hooks/useConnectionWeb3.e2e.js
@@ -0,0 +1 @@
export default () => true

0 comments on commit 8c96055

Please sign in to comment.