Run simple-server as a Github Actions service #30
Workflow file for this run
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: CI V2 | |
| on: | |
| pull_request: | |
| concurrency: | |
| group: ci-v2-${{ github.head_ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| integration-test: | |
| runs-on: | |
| - ubuntu-latest | |
| env: | |
| AVD_API_LEVEL: 34 | |
| AVD_ARCH: x86_64 | |
| steps: | |
| - 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: Checkout Android source | |
| uses: actions/checkout@v4 | |
| - name: Start Simple Service | |
| run: | | |
| docker compose -f ".github/docker/simple-server.compose.yml" --publish 8420:3000 up -d | |
| sleep 2 | |
| docker ps | |
| - name: Cache AVD | |
| uses: actions/cache@v4 | |
| id: avd-cache | |
| with: | |
| path: | | |
| ~/.android/avd/* | |
| ~/.android/adb* | |
| key: ${{ runner.os }}-avd-${{ env.AVD_API_LEVEL }}-${{ env.AVD_ARCH }} | |
| - 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.AVD_API_LEVEL }} | |
| arch: ${{ env.AVD_ARCH }} | |
| force-avd-creation: false | |
| emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none | |
| disable-animations: false | |
| disk-size: 8G | |
| script: echo "Generated AVD snapshot for caching." | |
| - name: set up JDK | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: 'zulu' | |
| java-version: 17 | |
| cache: 'gradle' | |
| - name: Build QA Test Artifacts | |
| id: build-instrumented-tests | |
| env: | |
| SIMPLE_SERVER_HOST: http://127.0.0.1:8420 | |
| run: | | |
| ./gradlew --build-cache --no-daemon -PmanifestEndpoint=${{ env.SIMPLE_SERVER_HOST }}/api/ assembleQaDebug assembleQaDebugAndroidTest | |
| # - name: Check connectivity to server container | |
| # run: | | |
| # curl -I http://127.0.0.1:8420 | |
| # docker exec -it $(docker ps -q -f name=server) curl -I http://server:3000 | |
| - name: Ensure the Simple Server is running | |
| id: ensure-healthy-simple | |
| env: | |
| SIMPLE_SERVER_HOST: http://127.0.0.1:8420 | |
| run: .github/scripts/wait_for_simple_server.sh ${{ env.SIMPLE_SERVER_HOST }}/api/manifest.json 200 | |
| - name: QA Android Tests | |
| id: run-instrumented-tests | |
| uses: reactivecircus/android-emulator-runner@v2 | |
| with: | |
| api-level: ${{ env.AVD_API_LEVEL }} | |
| arch: ${{ env.AVD_ARCH }} | |
| force-avd-creation: false | |
| emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none | |
| disable-animations: true | |
| disk-size: 8G | |
| script: | | |
| adb root | |
| mkdir -p app/build/outputs/test-artifacts | |
| adb install app/build/outputs/apk/qa/debug/app-qa-debug.apk | |
| adb install app/build/outputs/apk/androidTest/qa/debug/app-qa-debug-androidTest.apk | |
| adb shell am instrument -w -e filter org.simple.clinic.benchmark.SelectBenchmarkTests -e benchmark_app_performance false org.simple.clinic.qa.debug.test/org.simple.clinic.AndroidTestJUnitRunner >app/build/outputs/test-artifacts/logs.txt 2>app/build/outputs/test-artifacts/logs.txt | |
| cat app/build/outputs/test-artifacts/logs.txt | |
| adb pull /storage/emulated/0/Android/data/org.simple.clinic.qa.debug/ app/build/outputs/test-artifacts/ || true | |
| adb uninstall org.simple.clinic.qa.debug | |
| adb uninstall org.simple.clinic.qa.debug.test | |
| ! grep -q "FAILURES\!\!\!" app/build/outputs/test-artifacts/logs.txt | |
| - name: Stop Simple Service | |
| run: | | |
| docker compose -f ".github/docker/simple-server.compose.yml" down | |
| - name: Upload failed test artifacts | |
| if: always() && steps.run-instrumented-tests.outcome != 'success' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: failed-test-artifacts | |
| path: app/build/outputs/test-artifacts |