172 lines
4.6 KiB
YAML
172 lines
4.6 KiB
YAML
name: Tests
|
|
|
|
on:
|
|
push:
|
|
branches: [ master, 'robolectric-*.x' ]
|
|
paths-ignore:
|
|
- '**.md'
|
|
|
|
pull_request:
|
|
branches: [ master, google ]
|
|
paths-ignore:
|
|
- '**.md'
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
env:
|
|
cache-version: v1
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-20.04
|
|
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
|
|
- name: Set up JDK 11
|
|
uses: actions/setup-java@v3
|
|
with:
|
|
distribution: 'zulu'
|
|
java-version: 11
|
|
|
|
- uses: gradle/gradle-build-action@v2
|
|
|
|
- name: Build
|
|
run: |
|
|
SKIP_ERRORPRONE=true SKIP_JAVADOC=true \
|
|
./gradlew clean assemble testClasses --parallel --stacktrace --no-watch-fs
|
|
|
|
unit-tests:
|
|
runs-on: ubuntu-20.04
|
|
needs: build
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
api-versions: [ '16,17,18', '19,21,22', '23,24,25', '26,27,28', '29,30,31', '32,33' ]
|
|
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
|
|
- name: Set up JDK 11
|
|
uses: actions/setup-java@v3
|
|
with:
|
|
distribution: 'zulu'
|
|
java-version: 11
|
|
|
|
- uses: gradle/gradle-build-action@v2
|
|
|
|
- name: Run unit tests
|
|
run: |
|
|
SKIP_ERRORPRONE=true SKIP_JAVADOC=true ./gradlew test \
|
|
--info --stacktrace --continue \
|
|
--parallel \
|
|
--no-watch-fs \
|
|
-Drobolectric.enabledSdks=${{ matrix.api-versions }} \
|
|
-Drobolectric.alwaysIncludeVariantMarkersInTestName=true \
|
|
-Dorg.gradle.workers.max=2 \
|
|
-x :integration_tests:nativegraphics:test
|
|
|
|
- name: Upload Test Results
|
|
uses: actions/upload-artifact@v3
|
|
if: always()
|
|
with:
|
|
name: test_results_${{ matrix.api-versions }}
|
|
path: '**/build/test-results/**/TEST-*.xml'
|
|
|
|
instrumentation-tests:
|
|
runs-on: macos-12
|
|
timeout-minutes: 60
|
|
needs: build
|
|
|
|
strategy:
|
|
# Allow tests to continue on other devices if they fail on one device.
|
|
fail-fast: false
|
|
matrix:
|
|
api-level: [ 29 ]
|
|
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
|
|
- name: Set up JDK 11
|
|
uses: actions/setup-java@v3
|
|
with:
|
|
distribution: 'zulu'
|
|
java-version: 11
|
|
|
|
- uses: gradle/gradle-build-action@v2
|
|
|
|
- name: Determine emulator target
|
|
id: determine-target
|
|
run: |
|
|
TARGET="google_apis"
|
|
echo "TARGET=$TARGET" >> $GITHUB_OUTPUT
|
|
|
|
- name: AVD cache
|
|
uses: actions/cache@v3
|
|
id: avd-cache
|
|
with:
|
|
path: |
|
|
~/.android/avd/*
|
|
~/.android/adb*
|
|
key: avd-${{ matrix.api-level }}-${{ env.cache-version }}
|
|
|
|
- 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 }}
|
|
target: ${{ steps.determine-target.outputs.TARGET }}
|
|
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 device tests
|
|
# See https://github.com/orgs/community/discussions/27121
|
|
uses: reactivecircus/android-emulator-runner@v2
|
|
with:
|
|
api-level: ${{ matrix.api-level }}
|
|
target: ${{ steps.determine-target.outputs.TARGET }}
|
|
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
|
|
disable-spellchecker: true
|
|
|
|
profile: Nexus One
|
|
script: |
|
|
./gradlew cAT || ./gradlew cAT || ./gradlew cAT || exit 1
|
|
|
|
- name: Upload test results
|
|
if: always()
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: test-results-${{ matrix.api-level }}-${{ steps.determine-target.outputs.TARGET }}-${{ matrix.shard }}
|
|
path: |
|
|
**/build/reports/*
|
|
**/build/outputs/*/connected/*
|
|
|
|
publish-to-snapshots:
|
|
runs-on: ubuntu-20.04
|
|
env:
|
|
SONATYPE_LOGIN: ${{ secrets.SONATYPE_LOGIN }}
|
|
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
|
|
needs: unit-tests
|
|
if: github.ref == 'refs/heads/master'
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
|
|
- name: Set up JDK 11
|
|
uses: actions/setup-java@v3
|
|
with:
|
|
distribution: 'zulu'
|
|
java-version: 11
|
|
|
|
- uses: gradle/gradle-build-action@v2
|
|
|
|
- name: Publish
|
|
run: |
|
|
./gradlew publish --stacktrace --no-watch-fs
|