Improve CI further with test devices and new stages #226
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
| name: Android CI | |
| on: | |
| push: | |
| branches: [ 'main' ] | |
| pull_request: | |
| permissions: | |
| contents: read | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - &checkout | |
| name: Checkout repository | |
| uses: actions/checkout@v6 | |
| - &setup-java | |
| name: Set up JDK | |
| uses: actions/setup-java@v5 | |
| with: | |
| distribution: 'zulu' | |
| java-version: '17' | |
| - &write-api-key | |
| name: Access API_KEY | |
| env: | |
| API_KEY: ${{ secrets.API_KEY }} | |
| run: echo API_KEY=\"$API_KEY\" > ./apikey.properties | |
| - &setup-gradle | |
| name: Set up Gradle | |
| uses: gradle/actions/setup-gradle@v6 | |
| - name: Build with Gradle | |
| run: ./gradlew build | |
| - name: Upload unit test reports | |
| if: failure() | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: unit-test-reports | |
| path: | | |
| app/build/reports/tests/testDebugUnitTest/ | |
| app/build/test-results/testDebugUnitTest/ | |
| if-no-files-found: ignore | |
| retention-days: 7 | |
| screenshot-tests: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - *checkout | |
| - *setup-java | |
| - *write-api-key | |
| - *setup-gradle | |
| - name: Run screenshot tests | |
| run: ./gradlew validateDebugScreenshotTest | |
| - name: Upload screenshot reports | |
| if: failure() | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: screenshot-test-reports | |
| path: | | |
| app/build/reports/screenshotTest/ | |
| app/build/test-results/validateDebugScreenshotTest/ | |
| app/build/outputs/screenshotTest-results/ | |
| if-no-files-found: ignore | |
| retention-days: 7 | |
| instrumented-tests: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 30 | |
| steps: | |
| - *checkout | |
| - *setup-java | |
| - *write-api-key | |
| - *setup-gradle | |
| - name: Run managed device instrumented tests | |
| run: ./gradlew pixel2api30DebugAndroidTest -Pandroid.testoptions.manageddevices.emulator.gpu=swiftshader_indirect | |
| - name: Upload instrumented test reports | |
| if: failure() | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: instrumented-test-reports | |
| path: | | |
| app/build/reports/androidTests/managedDevice/ | |
| app/build/outputs/androidTest-results/managedDevice/ | |
| app/build/outputs/managed_device_android_test_additional_output/ | |
| if-no-files-found: ignore | |
| retention-days: 7 |