Espresso testing for Add Item #57
This file contains 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
name: Android CI | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
jobs: | |
buildUnitTest: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
cache: gradle | |
- name: Cache Gradle dependencies | |
uses: actions/cache@v3 | |
with: | |
path: ~/.gradle/caches | |
key: gradle-${{ runner.os }}-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | |
restore-keys: | | |
gradle-${{ runner.os }}- | |
- name: Build with Gradle | |
run: | | |
chmod +x gradlew | |
./gradlew test | |
continue-on-error: true | |
androidTest: | |
runs-on: ubuntu-latest | |
steps: | |
- name: checkout | |
uses: actions/checkout@v3 | |
- name: set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
cache: gradle | |
- name: Cache Gradle dependencies | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.gradle/caches | |
~/.gradle/wrapper | |
key: gradle-${{ runner.os }}-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | |
restore-keys: | | |
gradle- | |
- name: Cache Android SDK components | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.android | |
key: android-sdk-${{ runner.os }} | |
restore-keys: | | |
android-sdk- | |
- name: Make gradlew executable | |
run: chmod +x ./gradlew | |
- name: Create and start Android emulator | |
run: | | |
export ANDROID_SDK_ROOT=$RUNNER_WORKSPACE/android-sdk | |
mkdir -p $ANDROID_SDK_ROOT | |
wget -q https://dl.google.com/android/repository/commandlinetools-linux-7302050_latest.zip -O android-sdk.zip | |
unzip -q android-sdk.zip -d $ANDROID_SDK_ROOT | |
yes | $ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager "platforms;android-29" | |
yes | $ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager "system-images;android-29;google_apis;x86_64" | |
echo no | $ANDROID_SDK_ROOT/cmdline-tools/latest/bin/avdmanager create avd -n test -k "system-images;android-29;google_apis;x86_64" --force | |
$ANDROID_SDK_ROOT/emulator/emulator -avd test -no-audio -no-window -no-boot-anim -gpu swiftshader_indirect -camera-back none -dns-server 8.8.8.8 & | |
- name: Wait for emulator to start | |
run: | | |
while [ -z "$(adb shell getprop sys.boot_completed)" ]; do | |
echo "Waiting for emulator to start..." | |
sleep 1 | |
done | |
- name: Run tests | |
run: ./gradlew connectedCheck | |
- name: Stop emulator | |
run: adb emu kill |