ci(mobile): add ci job to build & test android app #106
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
# | |
# Flowmotion | |
# CI/CD Pipeline | |
# | |
name: Flowmotion CI/CD | |
on: | |
push: {} | |
jobs: | |
mobile-android: | |
name: Build & Test Mobile App (Android) | |
runs-on: ubuntu-22.04 | |
env: | |
ANDROID_API_LEVEL: 23 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup Gradle build cache | |
uses: gradle/actions/setup-gradle@v3 | |
- name: Setup Flutter | |
uses: subosito/flutter-action@v2 | |
with: | |
channel: stable | |
flutter-version-file: pubspec.yaml | |
- name: Build Android APK | |
run: flutter build apk | |
- name: Upload Android APK | |
uses: actions/upload-artifact@v4 | |
with: | |
name: flowmotion-debug.apk | |
path: build/app/outputs/flutter-apk/app-debug.apk | |
# setup android emulator for testing | |
- name: Enable KVM for Android emulator | |
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 AVD emulator cache | |
uses: actions/cache@v4 | |
id: avd-cache | |
with: | |
path: | | |
~/.android/avd/* | |
~/.android/adb* | |
key: avd-${{ env.ANDROID_API_LEVEL }} | |
- 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: ${{ env.ANDROID_API_LEVEL }} | |
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: Write test_auth_info.dart secrets | |
run: printf "${{ secrets.TEST_AUTH_INFO_B64 }}" | base64 -d > test_auth_info.dart | |
- name: Test Mobile App (Android) | |
uses: reactivecircus/android-emulator-runner@v2 | |
with: | |
api-level: ${{ env.ANDROID_API_LEVEL }} | |
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: flutter drive --driver=test_driver/integration_driver.dart --target=integration_test/main.dart | |
pipeline: | |
strategy: | |
fail-fast: false | |
matrix: | |
target: [lint, test] | |
name: "${{ matrix.target }} Pipeline" | |
defaults: | |
run: | |
working-directory: pipeline | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: "3.10.13" | |
# cache pip dependencies | |
cache: "pip" | |
- name: Install Pip dependencies | |
run: pip install -r requirements.txt | |
- name: "${{ matrix.target }} Pipeline" | |
run: "make ${{ matrix.target }}" | |
schema: | |
name: "Validate JSON Schema" | |
runs-on: ubuntu-22.04 | |
defaults: | |
run: | |
working-directory: schema | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 20.9.x | |
# cache npm dependencies | |
cache: npm | |
cache-dependency-path: schema/package-lock.json | |
- name: Install npm dependencies | |
run: npm ci | |
- name: Validate json schema | |
run: npx ajv compile -s "*.schema.json" --spec=draft2020 -c ajv-formats |