Espresso testing for Add Item #60
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: | |
env: | |
ANDROID_ARCH: x86_64 | |
ANDROID_TARGET: google_apis_playstore | |
API_LEVEL: 34 | |
ANDROID_BUILD_TOOLS_VERSION: 34.0.0 | |
ANDROID_SDK_PACKAGES: system-images;android-34;google_apis_playstore;x86_64 platforms;android-34 build-tools;34.0.0 platform-tools emulator | |
EMULATOR_TIMEOUT: 350 | |
EMULATOR_NAME: nexus | |
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: macos-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: Add avdmanager and sdkmanager to system PATH | |
run: | | |
echo "$ANDROID_HOME/cmdline-tools/latest/bin:$ANDROID_HOME/emulator:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools:$ANDROID_HOME/build-tools/${{ env.ANDROID_BUILD_TOOLS_VERSION }}" >> $GITHUB_PATH | |
- name: Install Sdk | |
run: | | |
yes Y | sdkmanager --licenses | |
sdkmanager --install ${ANDROID_SDK_PACKAGES} | |
- name: Build emulator | |
run: | | |
echo "no" | avdmanager --verbose create avd --force -n $EMULATOR_NAME --abi "${ANDROID_TARGET}/${ANDROID_ARCH}" -k "system-images;android-${API_LEVEL};${ANDROID_TARGET};${ANDROID_ARCH}" | |
- name: Launch emulator | |
run: | | |
chmod +x ./start_emu_headless.sh | |
EMULATOR_TIMEOUT=$EMULATOR_TIMEOUT EMULATOR_NAME=$EMULATOR_NAME ./start_emu_headless.sh | |
- name: Run tests | |
run: ./gradlew connectedCheck | |
- name: Stop emulator | |
run: adb emu kill |