-
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,37 +18,26 @@ 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 | ||
default config for android apk tests: &android_defaults | ||
<<: *defaults | ||
resource_class: 'medium' | ||
macos: | ||
xcode: '11.5.0' | ||
|
||
default config for android apk builds: &android_defaults | ||
<<: *defaults | ||
docker: | ||
- image: reactnativecommunity/react-native-android | ||
resource_class: 'medium' | ||
working_directory: ~/async_storage | ||
environment: | ||
- _JAVA_OPTIONS: '-XX:+UnlockExperimentalVMOptions -Xmx2048m' | ||
- BUILD_THREADS: 2 | ||
resource_class: large | ||
machine: | ||
image: android:2022.06.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 +55,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 | ||
|
@@ -209,10 +187,24 @@ jobs: | |
name: Run e2e tests | ||
command: yarn test:e2e:ios | ||
|
||
"Build: Android release apk": | ||
"Test: Android e2e": | ||
<<: *android_defaults | ||
steps: | ||
- *addWorkspace | ||
- run: | ||
name: "Install node v14.18.1 and yarn 1.22.17" | ||
command: | | ||
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 dependencies | ||
command: yarn --pure-lockfile --non-interactive --cache-folder ~/.cache/yarn | ||
- save_cache: *cache_save_yarn | ||
- run: | ||
name: Bundle JS | ||
command: yarn bundle:android --dev false | ||
|
@@ -223,77 +215,31 @@ jobs: | |
name: Build APK with Next storage | ||
working_directory: example/android | ||
command: ./gradlew assembleNext --max-workers 2 | ||
- persist_to_workspace: | ||
root: ~/async_storage | ||
paths: | ||
- example/android/app/build/outputs/apk/* | ||
|
||
"Test: Android e2e": | ||
<<: *macos_defaults_android | ||
steps: | ||
- *addWorkspace | ||
- run: | ||
name: Configure env variables | ||
name: Configure Environment Variables | ||
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 | ||
echo 'export PATH="$PATH:~/async_storage/node_modules/.bin"' >> $BASH_ENV | ||
source $BASH_ENV | ||
- restore-cache: *cache_restore_brew_android | ||
- run: | ||
name: Install Android SDK tools | ||
command: | | ||
brew update --preinstall | ||
brew bundle --file=.circleci/Brewfile.android --no-lock | ||
- save-cache: *cache_save_brew_android | ||
- run: | ||
name: Install Android emulator | ||
shell: /bin/bash -e | ||
name: Install Android system image | ||
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 | ||
sdkmanager "system-images;android-30;default;x86_64" | ||
- run: | ||
name: ADB start/stop | ||
name: "Create Android emulator" | ||
command: | | ||
adb start-server | ||
adb devices | ||
adb kill-server | ||
ls -la ~/.android | ||
avdmanager create avd -n E2E_API_30 -d pixel_4 --package "system-images;android-30;default;x86_64" | ||
- run: | ||
name: Create emulator | ||
name: Launch emulator | ||
command: | | ||
avdmanager create avd --force \ | ||
-n "Emu_E2E" \ | ||
-k "system-images;android-28;default;x86_64" \ | ||
-g "default" \ | ||
-d "pixel" | ||
- run: | ||
name: Start emulator in background | ||
emulator -avd E2E_API_30 -delay-adb -verbose -no-window -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim | ||
background: true | ||
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:*' | ||
- 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 | ||
|
@@ -333,14 +279,11 @@ workflows: | |
requires: | ||
- "Test: lint" | ||
- "Test: TypeScript" | ||
- "Build: Android release apk": | ||
- "Test: Android e2e": | ||
requires: | ||
- "Test: lint" | ||
- "Test: TypeScript" | ||
- "Test: Android unit" | ||
- "Test: Android e2e": | ||
requires: | ||
- "Build: Android release apk" | ||
- "Release": | ||
requires: | ||
- "Test: iOS e2e" | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.