run tests on github actions #34
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 SDK CI | |
on: | |
push: | |
branches: | |
- main | |
# Build on all pull requests, regardless of target. | |
pull_request: | |
jobs: | |
build: | |
strategy: | |
fail-fast: false | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set up JDK 11 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '11' | |
distribution: 'adopt' | |
- name: Restore gradle.properties | |
env: | |
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }} | |
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }} | |
shell: bash | |
run: | | |
mkdir -p ~/.gradle/ | |
echo "GRADLE_USER_HOME=${HOME}/.gradle" >> $GITHUB_ENV | |
echo "MAVEN_USERNAME=${MAVEN_USERNAME}" > ~/.gradle/gradle.properties | |
echo "MAVEN_PASSWORD=${MAVEN_PASSWORD}" >> ~/.gradle/gradle.properties | |
- name: Build with Gradle | |
run: ./gradlew build | |
unit-tests: | |
strategy: | |
fail-fast: false | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set up JDK 11 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '11' | |
distribution: 'adopt' | |
- name: Restore gradle.properties | |
env: | |
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }} #TODO: populate | |
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }} #TODO: populate | |
shell: bash | |
run: | | |
mkdir -p ~/.gradle/ | |
echo "GRADLE_USER_HOME=${HOME}/.gradle" >> $GITHUB_ENV | |
echo "MAVEN_USERNAME=${MAVEN_USERNAME}" > ~/.gradle/gradle.properties | |
echo "MAVEN_PASSWORD=${MAVEN_PASSWORD}" >> ~/.gradle/gradle.properties | |
- name: Build with Gradle | |
run: make unit-test | |
instrumentation-tests: | |
runs-on: macos-latest | |
timeout-minutes: 30 | |
strategy: | |
# Allow tests to continue on other devices if they fail on one device. | |
fail-fast: false | |
matrix: | |
api-level: [ 34 ] | |
steps: | |
- name: Check out Android SDK | |
uses: actions/checkout@v3 | |
- name: Set up JDK 11 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '11' | |
distribution: 'adopt' | |
- name: 'Set up GCP SDK' | |
uses: 'google-github-actions/setup-gcloud@v0' | |
- name: Restore gradle.properties | |
env: | |
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }} #TODO: populate | |
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }} #TODO: populate | |
shell: bash | |
run: | | |
mkdir -p ~/.gradle/ | |
echo "GRADLE_USER_HOME=${HOME}/.gradle" >> $GITHUB_ENV | |
echo "MAVEN_USERNAME=${MAVEN_USERNAME}" > ~/.gradle/gradle.properties | |
echo "MAVEN_PASSWORD=${MAVEN_PASSWORD}" >> ~/.gradle/gradle.properties | |
- name: Gradle cache | |
uses: gradle/gradle-build-action@v2 | |
- name: AVD cache | |
uses: actions/cache@v3 | |
id: avd-cache | |
with: | |
path: | | |
~/.android/avd/* | |
~/.android/adb* | |
key: avd-${{ matrix.api-level }} | |
- name: create AVD and generate snapshot for caching | |
if: steps.avd-cache.outputs.cache-hit != 'true' | |
uses: reactivecircus/android-emulator-runner@v2 | |
with: | |
api-level: ${{ matrix.api-level }} | |
profile: Pixel 7 | |
target: google_apis | |
arch: x86_64 | |
force-avd-creation: false | |
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none | |
disable-animations: false | |
script: echo "Generated AVD snapshot for caching." | |
- name: run tests | |
uses: reactivecircus/android-emulator-runner@v2 | |
with: | |
api-level: ${{ matrix.api-level }} | |
profile: Pixel 7 | |
target: google_apis | |
arch: x86_64 | |
force-avd-creation: false | |
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none | |
disable-animations: true | |
script: make instrumentation-test |