[WIP] Major update #132
Workflow file for this run
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: CI | |
on: | |
pull_request: | |
branches: [ master ] | |
# Allows for running this workflow manually from the Actions tab | |
workflow_dispatch: | |
jobs: | |
analyze: | |
name: Analyze | |
if: ${{ github.actor != 'dependabot[bot]' }} | |
runs-on: ubuntu-latest | |
timeout-minutes: 10 | |
steps: | |
- name: Checkout the code | |
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c | |
- name: Set up JDK 17 | |
uses: actions/setup-java@387ac29b308b003ca37ba93a6cab5eb57c8f5f93 | |
with: | |
java-version: '17' | |
distribution: 'corretto' | |
cache: gradle | |
- name: Clear gradle cache | |
run: | | |
mv ~/.gradle ~/.invalid || true | |
- name: Cache dependencies | |
uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 | |
with: | |
path: | | |
~/.gradle/caches | |
~/.gradle/wrapper | |
key: ${{ runner.os }}-gradle-${{ env.CACHE_VERSION }}-${{ hashFiles('**/**.gradle.kts', '**/gradle/wrapper/gradle-wrapper.properties', '**/libs.versions.toml') }} | |
- name: Check Gradle wrapper | |
uses: gradle/wrapper-validation-action@56b90f209b02bf6d1deae490e9ef18b21a389cd4 | |
- name: Check code style | |
run: ./gradlew ktlintCheck | |
- name: Check code quality | |
run: ./gradlew detekt | |
# TODO: Investigate why this is not working and encountering the following: | |
# `snyk` requires an authenticated account. Please run `snyk auth` and try again | |
# - name: Check dependencies with snyk | |
# uses: snyk/actions/gradle-jdk@dc22abdbe8ec00e2a925256fef96f319ca5510ce | |
# continue-on-error: true # To make sure that SARIF upload gets called | |
# env: | |
# SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }} | |
# with: | |
# args: --sarif-file-output=snyk.sarif | |
# | |
# - name: Upload snyk result to GitHub Code Scanning | |
# uses: github/codeql-action/upload-sarif@81b419c908d540ec4c7da9bfb4b5d941fca8f624 | |
# with: | |
# sarif_file: snyk.sarif | |
- name: Upload reports | |
uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 | |
with: | |
name: analyze-reports | |
path: app/build/reports | |
if: always() | |
unit-tests: | |
name: Unit tests | |
runs-on: ubuntu-latest | |
timeout-minutes: 10 | |
needs: analyze | |
steps: | |
- name: Checkout the code | |
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c | |
- name: Set up JDK 17 | |
uses: actions/setup-java@387ac29b308b003ca37ba93a6cab5eb57c8f5f93 | |
with: | |
java-version: '17' | |
distribution: 'corretto' | |
cache: gradle | |
- name: Clear gradle cache | |
run: | | |
mv ~/.gradle ~/.invalid || true | |
- name: Cache dependencies | |
uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 | |
with: | |
path: | | |
~/.gradle/caches | |
~/.gradle/wrapper | |
key: ${{ runner.os }}-gradle-${{ env.CACHE_VERSION }}-${{ hashFiles('**/**.gradle.kts', '**/gradle/wrapper/gradle-wrapper.properties', '**/libs.versions.toml') }} | |
- name: Check Gradle wrapper | |
uses: gradle/wrapper-validation-action@56b90f209b02bf6d1deae490e9ef18b21a389cd4 | |
# TODO: Add code coverage metrics | |
# See https://about.codecov.io/blog/code-coverage-for-android-development-using-kotlin-jacoco-github-actions-and-codecov/ | |
- name: Run unit tests | |
run: ./gradlew testDebugUnitTest | |
- name: Upload reports | |
uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 | |
with: | |
name: unit-tests-reports | |
path: app/build/reports | |
if: always() | |
instrumentation-tests: | |
name: Instrumentation tests on API ${{ matrix.api-level }} | |
runs-on: ubuntu-latest | |
timeout-minutes: 30 | |
needs: unit-tests | |
strategy: | |
fail-fast: false | |
matrix: | |
api-level: [ 26, 27, 28, 29, 30, 31, 32, 33, 34 ] | |
steps: | |
- name: Checkout the code | |
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c | |
- name: Set up JDK 17 | |
uses: actions/setup-java@387ac29b308b003ca37ba93a6cab5eb57c8f5f93 | |
with: | |
java-version: '17' | |
distribution: 'corretto' | |
cache: gradle | |
- name: Clear gradle cache | |
run: | | |
mv ~/.gradle ~/.invalid || true | |
- name: Cache dependencies | |
uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 | |
with: | |
path: | | |
~/.gradle/caches | |
~/.gradle/wrapper | |
key: ${{ runner.os }}-gradle-${{ env.CACHE_VERSION }}-${{ hashFiles('**/**.gradle.kts', '**/gradle/wrapper/gradle-wrapper.properties', '**/libs.versions.toml') }} | |
- name: Check Gradle wrapper | |
uses: gradle/wrapper-validation-action@56b90f209b02bf6d1deae490e9ef18b21a389cd4 | |
- name: Enable KVM | |
run: | | |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules | |
sudo udevadm control --reload-rules | |
sudo udevadm trigger --name-match=kvm | |
- name: Get AVD info | |
uses: ./.github/actions/get-avd-info | |
id: avd-info | |
with: | |
api-level: ${{ matrix.api-level }} | |
# Retrieve the cached emulator snapshot | |
- name: Retrieve cached emulator snapshot | |
uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 | |
id: avd-cache | |
with: | |
path: | | |
~/.android/avd/* | |
~/.android/adb* | |
key: ${{ runner.os }}-avd-${{ env.CACHE_VERSION }}-${{ steps.avd-info.outputs.arch }}-${{ steps.avd-info.outputs.target }}-${{ matrix.api-level }} | |
# Create a new emulator snapshot if it isn't present in the cache | |
- name: Create AVD snapshot | |
if: steps.avd-cache.outputs.cache-hit != 'true' | |
uses: reactivecircus/android-emulator-runner@6b0df4b0efb23bb0ec63d881db79aefbc976e4b2 | |
with: | |
api-level: ${{ matrix.api-level }} | |
arch: ${{ steps.avd-info.outputs.arch }} | |
target: ${{ steps.avd-info.outputs.target }} | |
disable-animations: false | |
force-avd-creation: false | |
ram-size: 4096M | |
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none | |
script: echo "Generated AVD snapshot" | |
- name: Run instrumentation tests | |
uses: reactivecircus/android-emulator-runner@6b0df4b0efb23bb0ec63d881db79aefbc976e4b2 | |
with: | |
api-level: ${{ matrix.api-level }} | |
arch: ${{ steps.avd-info.outputs.arch }} | |
target: ${{ steps.avd-info.outputs.target }} | |
disable-animations: true | |
force-avd-creation: false | |
ram-size: 4096M | |
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none | |
script: ./gradlew connectedCheck | |
- name: Upload reports | |
uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 | |
with: | |
name: instrumentation-tests-reports-api${{ matrix.api-level }} | |
path: app/build/reports | |
if: always() |