Skip to content

Commit

Permalink
add detox
Browse files Browse the repository at this point in the history
try android

again

use circus, not headless

use hermes with e2e

test hermes is used

verbose

add missing await

use android 28
  • Loading branch information
vonovak committed Apr 29, 2020
1 parent c864ac4 commit 659505c
Show file tree
Hide file tree
Showing 17 changed files with 1,727 additions and 1,017 deletions.
265 changes: 235 additions & 30 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,56 +1,261 @@
version: 2.1

orbs:
rn: react-native-community/[email protected]
rn: react-native-community/[email protected]


#######
commands:
setup_macos_executor:
description: >-
Installs the required packages to build and test Android and iOS applications
on the MacOS executor. You need to run this before running any other command
on those executors.
parameters:
node_version:
default: '10'
description: >-
The version of Node to use. This can be either a major version ("8"), a
major and minor ("8.4"), or a fully qualified version ("8.4.1").
type: string
steps:
- run:
command: >
echo 'export
PATH="$PATH:/usr/local/opt/node@<<parameters.node_version>>/bin:~/.yarn/bin:~/project/node_modules/.bin:~/project/example/node_modules/.bin"'
>> $BASH_ENV
echo 'export ANDROID_HOME="/usr/local/share/android-sdk"' >> ~/.bash_profile
echo 'export ANDROID_SDK_ROOT="/usr/local/share/android-sdk"' >> ~/.bash_profile
echo 'export PATH="$ANDROID_SDK_ROOT/emulator:$ANDROID_SDK_ROOT/tools:$ANDROID_SDK_ROOT/platform-tools:$PATH"' >> ~/.bash_profile
echo 'export QEMU_AUDIO_DRV=none' >> ~/.bash_profile
echo 'export JAVA_HOME=$(/usr/libexec/java_home)' >> ~/.bash_profile
source $BASH_ENV
name: Configure Environment Variables
- restore_cache:
key: |
brew-cache-{{ arch }}-{{ .Environment.CACHE_VERSION }}
- run:
command: >
set +e
curl -o-
https://raw.githubusercontent.com/creationix/nvm/v0.35.3/install.sh |
bash
source ~/.bashrc
command -v nvm
nvm install <<parameters.node_version>>
nvm alias default <<parameters.node_version>>
name: Install node@<<parameters.node_version>>
- run:
command: node --version
name: Verify node version
- run:
command: |
HOMEBREW_NO_AUTO_UPDATE=1 brew tap wix/brew >/dev/null
HOMEBREW_NO_AUTO_UPDATE=1 brew tap homebrew/cask >/dev/null
HOMEBREW_NO_AUTO_UPDATE=1 brew install applesimutils >/dev/null
HOMEBREW_NO_AUTO_UPDATE=1 brew cask install android-sdk >/dev/null
touch .watchmanconfig
node -v
name: Configure Detox Environment
- save_cache:
key: |
brew-cache-{{ arch }}-{{ .Environment.CACHE_VERSION }}
paths:
- /usr/local/Homebrew
- ~/Library/Caches/Homebrew
android_emulator_start:
parameters:
build_tools_version:
default: 29.0.3
description: The version of the Android build tools to install.
type: string
device_name:
default: TestingAVD
description: >-
The name of the AVD. You use this name to tell which device to run tests
on.
type: string
logcat_grep:
default: com.reactnativecommunity
description: >-
ADB logs will be shown in the "Start Android Emulator" commands, but we
filter it using grep to avoid noise. You can specify additional strigns to
grep for. Make sure you escape special characters.
type: string
platform_version:
default: android-28
description: >-
The version of android to run on the emulator. Usually in the form of
"android-28".
type: string
steps:
- run:
command: >
yes | sdkmanager "platform-tools" "tools" >/dev/null
yes | sdkmanager "platforms;<<parameters.platform_version>>"
"system-images;<<parameters.platform_version>>;default;x86_64"
>/dev/null
yes | sdkmanager "emulator" --channel=3 >/dev/null
yes | sdkmanager "build-tools;<<parameters.build_tools_version>>"
>/dev/null
yes | sdkmanager --licenses >/dev/null
yes | sdkmanager --list
name: Install Android Emulator
shell: /bin/bash -e
- run:
command: |
adb start-server
adb devices
adb kill-server
ls -la ~/.android
name: ADB Start Stop
- run:
command: >-
avdmanager create avd --force --name <<parameters.device_name>> --package
"system-images;<<parameters.platform_version>>;default;x86_64" --tag
default --device pixel
name: Create Android Emulator
- run:
background: true
command: >
$ANDROID_HOME/emulator/emulator
@<<parameters.device_name>> -version
$ANDROID_HOME/emulator/emulator
@<<parameters.device_name>> -skin 1080x1920 -cores 1 -gpu auto -accel on
-memory 1024 -no-audio -no-snapshot -no-boot-anim -no-window -logcat *:W
| grep -i 'ReactNative\|<<parameters.logcat_grep>>'
name: Start Android Emulator (background)
- run:
command: >
export BOOT=""
echo "Waiting for AVD to finish booting"
export PATH=$(dirname $(dirname $(command -v
android)))/platform-tools:$PATH
until [[ "$BOOT" =~ "1" ]]; do
sleep 5
export BOOT=$(adb -e shell getprop sys.boot_completed 2>&1)
done
sleep 15
adb shell settings put global window_animation_scale 0
adb shell settings put global transition_animation_scale 0
adb shell settings put global animator_duration_scale 0
echo "Android Virtual Device is now ready."
name: Wait for AVD to be ready
no_output_timeout: 5m

jobs:
checkout_code:
executor: rn/linux_js
executor:
name: rn/linux_js
node_version: "12.10.0"
steps:
- checkout
- persist_to_workspace:
root: .
paths: .

analyse:
root: .
analyse_js:
executor: rn/linux_js
steps:
- attach_workspace:
at: .
- rn/yarn_install
- run:
name: Install
command: yarn install --frozen-lockfile
- run:
name: Lint JS Code (ESLint)
command: yarn run lint
command: yarn lint
name: Run ESLint
- run:
command: yarn flow
name: Flow
command: yarn run flow
- run:
command: yarn test
name: Jest
command: yarn run test
e2e_release_ios:
executor:
name: rn/macos
xcode_version: "11.4.0"
steps:
- attach_workspace:
at: .
- rn/setup_macos_executor:
node_version: "12.10.0"
- rn/ios_simulator_start:
device: "iPhone 11"
- rn/yarn_install
- rn/pod_install:
pod_install_directory: "example/ios"
- run:
command: yarn detox:ios:build:release
name: build for detox
- run:
command: yarn detox:ios:test:release
name: test detox
e2e_release_android:
# we need to use mac to run emulator with acceleration
# see https://support.circleci.com/hc/en-us/articles/360000028928-Testing-with-Android-emulator-on-CircleCI-2-0
executor:
name: rn/macos
xcode_version: "11.4.0"
steps:
- attach_workspace:
at: .
- setup_macos_executor:
node_version: "12.10.0"
- rn/yarn_install
- android_emulator_start:
logcat_grep: "com.reactcommunity.rndatetimepicker"
- run:
command: yarn detox:android:build:release
name: build for detox
- run:
command: yarn detox:android:test:release
name: test detox
- store_artifacts:
path: ./artifacts

workflows:
test:
jobs:
- checkout_code
- analyse:
# - analyse_js:
# requires:
# - checkout_code
# - rn/android_build:
# build_type: release
# name: build_android_release
# project_path: example/android
# requires:
# - analyse_js
# - rn/android_test:
# detox_configuration: android.emu.release
# requires:
# - build_android_release
# - e2e_release_ios:
# requires:
# - analyse_js
- e2e_release_android:
requires:
- checkout_code
# - rn/android_build:
# name: build_android_release
# project_path: "example/android"
# requires:
# - analyse
# - rn/android_test:
# detox_configuration: "android.emu.release"
# requires:
# - build_android_release
# - rn/ios_build_and_test:
# project_path: "example/ios/example.xcodeproj"
# device: "iPhone X"
# build_configuration: "Release"
# scheme: "example"
# detox_configuration: "ios.sim.release"
# requires:
# - analyse
4 changes: 3 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ module.exports = {
beforeEach: true,
afterAll: true,
jest: true,
jasmine: true
jasmine: true,
waitFor: true,
detoxCircus: true
}
};
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ local.properties
# BUCK
buck-out/
\.buckd/
*.keystore

# Editor config
.vscode
Expand Down
1 change: 0 additions & 1 deletion example/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ yarn-error.log
# BUCK
buck-out/
\.buckd/
*.keystore

# fastlane
#
Expand Down
7 changes: 3 additions & 4 deletions example/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {Header, Colors} from 'react-native/Libraries/NewAppScreen';
import React, {useState} from 'react';
import moment from 'moment';

const App = () => {
export const App = () => {
const [date, setDate] = useState(new Date(1598051730000));
const [mode, setMode] = useState('date');
const [show, setShow] = useState(false);
Expand Down Expand Up @@ -63,7 +63,7 @@ const App = () => {
<Header />
{global.HermesInternal !== null && (
<View style={styles.engine}>
<Text style={styles.footer}>Engine: Hermes</Text>
<Text testID="hermesIndicator" style={styles.footer}>Engine: Hermes</Text>
</View>
)}
<View style={styles.body}>
Expand All @@ -80,6 +80,7 @@ const App = () => {
setColor(text.toLowerCase());
}}
placeholder="color"
testID="colorInput"
/>
</View>
<View style={styles.button}>
Expand Down Expand Up @@ -188,5 +189,3 @@ const styles = StyleSheet.create({
flex: 1,
},
});

export default App;
Loading

0 comments on commit 659505c

Please sign in to comment.