-
Notifications
You must be signed in to change notification settings - Fork 475
build(ci): Improve Android e2e #828
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,37 +18,35 @@ checkout step for each job: &addWorkspace | |
default config for js: &js_defaults | ||
<<: *defaults | ||
docker: | ||
- image: circleci/node:14 | ||
- image: cimg/node:14.18.1 | ||
|
||
default config for macOS: &macos_defaults | ||
<<: *defaults | ||
resource_class: 'medium' | ||
macos: | ||
xcode: '13.2.1' | ||
xcode: '13.1.0' | ||
|
||
config for macOS (android): &macos_defaults_android | ||
config for android e2e: &android_e2e | ||
<<: *defaults | ||
resource_class: 'medium' | ||
macos: | ||
xcode: '11.5.0' | ||
resource_class: large | ||
machine: | ||
image: android:2022.06.2 | ||
|
||
default config for android apk builds: &android_defaults | ||
<<: *defaults | ||
docker: | ||
- image: reactnativecommunity/react-native-android | ||
resource_class: 'medium' | ||
working_directory: ~/async_storage | ||
- image: cimg/android:2021.10.2-node # node 14.18.1 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't this also use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This image has Android SDK preinstalled, and is used to create an apk for tests. I could merge the apk creation into e2e job, since it's no longer macos. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a cost to spinning up a separate machine? I'd imagine we should stay on the same machine for as long as possible, but I don't know how CircleCI works. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think there's no cost for boot up, but rather the overall execution time. |
||
resource_class: medium | ||
environment: | ||
- _JAVA_OPTIONS: '-XX:+UnlockExperimentalVMOptions -Xmx2048m' | ||
- BUILD_THREADS: 2 | ||
JAVA_OPTIONS: '-XX:+UnlockExperimentalVMOptions -Xmx2048m' | ||
BUILD_THREADS: 2 | ||
|
||
# ============================== | ||
# CACHE CONFIG | ||
# ============================== | ||
|
||
cache keys: | ||
brew ios: &key_brew_ios cache-brew-ios-v5-{{ arch }} | ||
brew android: &key_brew_android cache-brew-android-v4-{{ arch }} | ||
yarn: &key_yarn cache-yarn-{{ checksum "package.json" }}-{{ arch }} | ||
gradle: &key_gradle cache-gradle-v2-{{ checksum "example/android/gradle/wrapper/gradle-wrapper.properties" }}-{{ checksum "package.json" }}-{{ arch }} | ||
pods: &key_pods cache-pods-v0.64-{{ checksum "example/ios/Podfile" }}-{{ checksum "package.json" }}-{{ arch }} | ||
|
@@ -66,17 +64,6 @@ cache: | |
keys: | ||
- *key_brew_ios | ||
|
||
save brew cache for android: &cache_save_brew_android | ||
name: Saving Brew cache for android | ||
paths: | ||
- ~/Library/Caches/Homebrew | ||
key: *key_brew_android | ||
|
||
restore brew cache for android: &cache_restore_brew_android | ||
name: Restoring Brew cache for android | ||
keys: | ||
- *key_brew_android | ||
|
||
# yarn | ||
save yarn cache: &cache_save_yarn | ||
name: Saving Yarn cache | ||
|
@@ -229,71 +216,48 @@ jobs: | |
- example/android/app/build/outputs/apk/* | ||
|
||
"Test: Android e2e": | ||
<<: *macos_defaults_android | ||
<<: *android_e2e | ||
steps: | ||
- *addWorkspace | ||
- run: | ||
name: Configure env variables | ||
name: "Install node v14.18.1 and yarn 1.22.17" | ||
command: | | ||
echo 'export ANDROID_HOME="/usr/local/share/android-sdk"' >> $BASH_ENV | ||
echo 'export ANDROID_SDK_ROOT="/usr/local/share/android-sdk"' >> $BASH_ENV | ||
echo 'export PATH="$ANDROID_SDK_ROOT/emulator:$ANDROID_SDK_ROOT/tools:$ANDROID_SDK_ROOT/platform-tools:$PATH"' >> $BASH_ENV | ||
echo 'export QEMU_AUDIO_DRV=none' >> $BASH_ENV | ||
echo 'export JAVA_HOME=$(/usr/libexec/java_home)' >> $BASH_ENV | ||
source $BASH_ENV | ||
- restore-cache: *cache_restore_brew_android | ||
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash | ||
source ~/.bashrc | ||
nvm install v14.18.1 | ||
tido64 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
node -v | ||
npm install --global [email protected] | ||
yarn -v | ||
- restore_cache: *cache_restore_yarn | ||
- run: | ||
name: Install Android SDK tools | ||
command: | | ||
brew update --preinstall | ||
brew bundle --file=.circleci/Brewfile.android --no-lock | ||
- save-cache: *cache_save_brew_android | ||
name: Install dependencies | ||
command: yarn --pure-lockfile --non-interactive --cache-folder ~/.cache/yarn | ||
- save_cache: *cache_save_yarn | ||
- run: | ||
name: Install Android emulator | ||
shell: /bin/bash -e | ||
name: Configure Environment Variables | ||
command: | | ||
yes | sdkmanager "platform-tools" "tools" 1> /dev/null | ||
yes | sdkmanager "platforms;android-28" "system-images;android-28;default;x86_64" 1> /dev/null | ||
yes | sdkmanager "emulator" --channel=3 1> /dev/null | ||
yes | sdkmanager "build-tools;28.0.3" 1> /dev/null | ||
yes | sdkmanager --licenses 1> /dev/null | ||
yes | sdkmanager --list | ||
echo 'export QEMU_AUDIO_DRV=none' >> $BASH_ENV | ||
echo 'export PATH="$PATH:~/async_storage/node_modules/.bin"' >> $BASH_ENV | ||
source $BASH_ENV | ||
- run: | ||
name: ADB start/stop | ||
name: Install Android system image | ||
command: | | ||
adb start-server | ||
adb devices | ||
adb kill-server | ||
ls -la ~/.android | ||
sdkmanager "system-images;android-30;default;x86_64" | ||
- run: | ||
name: Create emulator | ||
name: "Create Android emulator" | ||
command: | | ||
avdmanager create avd --force \ | ||
-n "Emu_E2E" \ | ||
-k "system-images;android-28;default;x86_64" \ | ||
-g "default" \ | ||
-d "pixel" | ||
avdmanager create avd -n E2E_API_30 -d pixel_4 --package "system-images;android-30;default;x86_64" | ||
- run: | ||
name: Start emulator in background | ||
background: true | ||
name: Launch emulator | ||
command: | | ||
emulator -avd "Emu_E2E" \ | ||
-cores 1 \ | ||
-gpu auto \ | ||
-accel on \ | ||
-memory 1024 \ | ||
-no-audio \ | ||
-no-snapshot \ | ||
-no-boot-anim \ | ||
-no-window \ | ||
-logcat '*:E ReactNative:W ReactNativeJS:*' | ||
emulator -avd E2E_API_30 -delay-adb -verbose -no-window -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim | ||
background: true | ||
- run: | ||
name: "Make sure TestButler apk is present" | ||
command: ./scripts/android_e2e.sh 'install_test_butler' | ||
- run: | ||
name: Wait for emulator to boot | ||
command: ./scripts/android_e2e.sh 'wait_for_emulator' | ||
- run: | ||
name: Wake device | ||
command: | | ||
adb shell input keyevent 82 | ||
- run: | ||
name: Run e2e tests | ||
command: yarn test:e2e:android | ||
|
Uh oh!
There was an error while loading. Please reload this page.