Skip to content

docs: update README #1578

docs: update README

docs: update README #1578

Workflow file for this run

name: CI - Test Runner
# Run the workflow when commits are pushed on main or when a PR is modified
on:
push:
branches:
- main
- "**"
pull_request:
types:
- opened
- synchronize
- reopened
jobs:
ci:
name: CI
# Execute the CI on the course's runners
runs-on: ubuntu-latest
steps:
# First step : Checkout the repository on the runner
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of Sonar analysis (if we use Sonar Later)
# Load google-services.json from the secrets
- name: Decode secrets
env:
GOOGLE_SERVICES: ${{ secrets.GOOGLE_SERVICES }}
KEYSTORE_PROPERTIES: ${{ secrets.KEYSTORE_PROPERTIES }}
KEYSTORE: ${{ secrets.KEYSTORE }}
run: |
echo "$GOOGLE_SERVICES" | base64 --decode > ./app/google-services.json
echo "$KEYSTORE_PROPERTIES" | base64 --decode > ./keystore.properties
echo "$KEYSTORE" | base64 --decode > ./keystore.jks
# Kernel-based Virtual Machine (KVM) is an open source virtualization technology built into Linux. Enabling it allows the Android emulator to run faster.
- name: Enable KVM group perms
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: Setup JDK
uses: actions/setup-java@v4
with:
distribution: "temurin"
java-version: "17"
# Caching is a very useful part of a CI, as a workflow is executed in a clean environment every time,
# this means that one would need to re-download and re-process gradle files for every run. Which is very time consuming.
#
# To avoid that, we cache the the gradle folder to reuse it later.
- name: Gradle cache
uses: gradle/actions/setup-gradle@v3
# Cache the Emulator, if the cache does not hit, create the emulator
- name: AVD cache
uses: actions/cache@v4
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-34
- name: Cache SonarCloud packages
uses: actions/cache@v4
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- 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: 34
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: Grant execute permission for gradlew
run: |
chmod +x ./gradlew
# Check formatting
- name: KTFmt Check
run: |
./gradlew ktfmtCheck
# This step runs gradle commands to build the application
- name: Assemble
run: |
# To run the CI with debug information, add --info
./gradlew assemble lint --parallel --build-cache
# Run Unit tests
- name: Run tests
run: |
# To run the CI with debug information, add --info
./gradlew check --parallel --build-cache
# Run connected tests on the emulator
- name: Run Android tests
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 34
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: "./gradlew connectedCheck --parallel --build-cache; first_command_status=$?; /usr/local/lib/android/sdk/platform-tools/adb logcat -d > logcat-output.txt; exit $first_command_status"
- name: Upload logcat output
uses: actions/upload-artifact@v4
if: always()
with:
name: logcat-output
path: logcat-output.txt
- name: Upload build folder
uses: actions/upload-artifact@v4
if: always()
with:
name: build
path: ${{ github.workspace }}/app/build/
# Generate coverage report
- name: Generate coverage
run: ./gradlew jacocoTestReport
# Upload the various reports to sonar
- name: Upload report to SonarCloud
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: ./gradlew sonar --parallel --build-cache
- name: Upload Code Coverage Artifacts
uses: actions/upload-artifact@v4
with:
name: Code-coverage-report
path: ${{ github.workspace }}/app/build/reports/jacoco/jacocoTestReport/
- name: Jacoco Report to PR
id: jacoco
uses: madrapps/jacoco-report@v1.7.1
if: ${{ startsWith(github.event_name, 'pull_request') }}
with:
paths: ${{ github.workspace }}/app/build/reports/jacoco/jacocoTestReport/jacocoTestReport.xml
token: ${{ secrets.GITHUB_TOKEN }}
min-coverage-overall: 80
min-coverage-changed-files: 80
title: Code Coverage
update-comment: true
- name: Fail PR if overall coverage is less than 80%
if: ${{ startsWith(github.event_name, 'pull_request') && steps.jacoco.outputs.coverage-overall < 80.0 }}
uses: actions/github-script@v6
with:
script: |
core.setFailed('Overall coverage is less than 80%!')