Fix/e2e create event #886
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 - 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) | |
# 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 | |
# Create the necessary AVD directories | |
- name: Create AVD directories | |
run: | | |
mkdir -p ~/.android/avd | |
# 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: 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." | |
# Load google-services.json and local.properties from the secrets | |
- name: Decode secrets | |
env: | |
GOOGLE_SERVICES: ${{ secrets.GOOGLE_SERVICES }} | |
LOCAL_PROPERTIES: ${{ secrets.LOCAL_PROPERTIES }} | |
run: | | |
echo "$GOOGLE_SERVICES" | base64 --decode > ./app/google-services.json | |
echo "$LOCAL_PROPERTIES" | base64 --decode > ./local.properties | |
# Load keystore.jks from the secrets | |
- name: Load Keystore file | |
env: | |
KEYSTORE_BASE64: ${{ secrets.KEYSTORE_BASE64 }} | |
run: | | |
# Check if the environment variable is set | |
if [ -z "$KEYSTORE_BASE64" ]; then | |
echo "KEYSTORE_BASE64 is not set!" | |
exit 1 | |
else | |
echo "KEYSTORE_BASE64 is set, decoding..." | |
fi | |
# Decode the keystore and save it to keystore.jks | |
echo "$KEYSTORE_BASE64" | base64 --decode > keystore.jks | |
# Verify that the keystore file has been created | |
if [ -f keystore.jks ]; then | |
echo "keystore.jks created successfully." | |
else | |
echo "Failed to create keystore.jks." | |
exit 1 | |
fi | |
# Check the file size (for debugging purposes) | |
echo "Size of keystore.jks:" | |
ls -lh keystore.jks | |
- 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 | |
env: | |
KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }} | |
KEYSTORE_ALIAS: ${{ secrets.KEYSTORE_ALIAS }} | |
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }} | |
PERSPECTIVE_API_KEY: ${{ secrets.PERSPECTIVE_API_KEY }} | |
run: | | |
# To run the CI with debug information, add --info | |
./gradlew assemble lint --parallel --build-cache | |
# Run Unit tests | |
- name: Run Unit tests | |
run: | | |
# To run the CI with debug information, add --info | |
./gradlew check --parallel --build-cache | |
# Run connected tests on the emulator | |
- name: Run emulated tests | |
env: | |
KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }} | |
KEYSTORE_ALIAS: ${{ secrets.KEYSTORE_ALIAS }} | |
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }} | |
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: | | |
adb wait-for-device | |
adb shell input keyevent 82 | |
./gradlew connectedCheck --parallel --build-cache | |
# This step generates the coverage report which will be uploaded to sonar | |
- name: Generate Coverage Report | |
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 |