281 lines
8.9 KiB
YAML
281 lines
8.9 KiB
YAML
name: Build and test
|
|
|
|
on:
|
|
push:
|
|
branches: [ main ]
|
|
pull_request:
|
|
branches: [ main ]
|
|
workflow_dispatch:
|
|
|
|
env:
|
|
# The guest image coordinates and QEMU flags all come from
|
|
# appium-tests/scripts/vm-config.sh, loaded by the "Load VM config" step below.
|
|
VM_DIR: /appium-vm
|
|
|
|
jobs:
|
|
build:
|
|
name: Build ${{ matrix.variant }}
|
|
runs-on: ubuntu-latest
|
|
|
|
strategy:
|
|
matrix:
|
|
variant:
|
|
- foss
|
|
- gplay
|
|
fail-fast: false
|
|
|
|
env:
|
|
JAVA_TOOL_OPTIONS: "-Xmx4g"
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v5
|
|
|
|
- name: Set up JDK
|
|
uses: actions/setup-java@v5
|
|
with:
|
|
distribution: 'temurin'
|
|
java-version: '17'
|
|
|
|
- name: Setup Gradle
|
|
uses: gradle/actions/setup-gradle@v5
|
|
with:
|
|
gradle-version: wrapper
|
|
cache-read-only: false
|
|
add-job-summary: on-failure
|
|
cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}
|
|
|
|
- name: Set up Android SDK
|
|
uses: android-actions/setup-android@v4
|
|
|
|
- name: Set up Firebase config
|
|
run: |
|
|
cat <<'EOF' > app/google-services.json
|
|
${{ secrets.GOOGLE_SERVICES_JSON }}
|
|
EOF
|
|
|
|
# Use mock if the secret is not available
|
|
if [[ "$(wc -c < app/google-services.json)" -lt 10 ]]; then
|
|
cp misc/mock-google-services.json app/google-services.json
|
|
fi
|
|
|
|
- name: Build ${{ matrix.variant }}
|
|
run: ./gradlew assemble${VARIANT^}Debug assemble${VARIANT^}Optimized --scan --configuration-cache
|
|
env:
|
|
ETCHDROID_ENABLE_SENTRY: ${{ matrix.variant == 'Gplay' }}
|
|
VARIANT: ${{ matrix.variant }}
|
|
|
|
- name: Upload built debug APK
|
|
uses: actions/upload-artifact@v5
|
|
with:
|
|
name: app-${{ matrix.variant }}-debug
|
|
path: app/build/outputs/apk/${{ matrix.variant }}/debug/app-${{ matrix.variant }}-debug.apk
|
|
|
|
- name: Upload built optimized APK
|
|
uses: actions/upload-artifact@v5
|
|
with:
|
|
name: app-${{ matrix.variant }}-optimized
|
|
path: app/build/outputs/apk/${{ matrix.variant }}/optimized/app-${{ matrix.variant }}-optimized.apk
|
|
|
|
unit-tests:
|
|
name: Unit tests for ${{ matrix.variant }}
|
|
runs-on: ubuntu-latest
|
|
|
|
strategy:
|
|
matrix:
|
|
variant:
|
|
- foss
|
|
- gplay
|
|
fail-fast: false
|
|
|
|
env:
|
|
JAVA_TOOL_OPTIONS: "-Xmx4g"
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v5
|
|
|
|
- name: Set up JDK
|
|
uses: actions/setup-java@v5
|
|
with:
|
|
distribution: 'temurin'
|
|
java-version: '17'
|
|
|
|
- name: Setup Gradle
|
|
uses: gradle/actions/setup-gradle@v5
|
|
with:
|
|
gradle-version: wrapper
|
|
cache-read-only: false
|
|
add-job-summary: on-failure
|
|
cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}
|
|
|
|
- name: Set up Android SDK
|
|
uses: android-actions/setup-android@v4
|
|
|
|
- name: Set up Firebase config
|
|
run: |
|
|
cat <<'EOF' > app/google-services.json
|
|
${{ secrets.GOOGLE_SERVICES_JSON }}
|
|
EOF
|
|
|
|
# Use mock if the secret is not available
|
|
if [[ "$(wc -c < app/google-services.json)" -lt 10 ]]; then
|
|
cp misc/mock-google-services.json app/google-services.json
|
|
fi
|
|
|
|
- name: Run unit tests for ${{ matrix.variant }}
|
|
run: ./gradlew test${VARIANT^}DebugUnitTest --scan --configuration-cache
|
|
env:
|
|
ETCHDROID_ENABLE_SENTRY: ${{ matrix.variant == 'Gplay' }}
|
|
VARIANT: ${{ matrix.variant }}
|
|
|
|
- name: Publish test report
|
|
uses: mikepenz/action-junit-report@v5
|
|
if: (success() || failure()) && github.event.pull_request.head.repo.full_name == github.repository
|
|
with:
|
|
check_name: Unit test report for ${{ matrix.variant }}
|
|
detailed_summary: true
|
|
report_paths: 'app/build/test-results/*/TEST-*.xml'
|
|
require_tests: true
|
|
|
|
qemu-tests:
|
|
name: End-to-end tests for ${{ matrix.variant }}
|
|
runs-on: ubuntu-latest
|
|
needs: build
|
|
strategy:
|
|
matrix:
|
|
variant:
|
|
- foss
|
|
- gplay
|
|
fail-fast: false
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v5
|
|
|
|
- name: Download APK
|
|
uses: actions/download-artifact@v5
|
|
with:
|
|
name: app-${{ matrix.variant }}-optimized
|
|
path: apk
|
|
|
|
- name: Install QEMU
|
|
uses: etchdroid/qemu-kvm-action/setup@v2
|
|
|
|
- name: Load VM config
|
|
run: |
|
|
source appium-tests/scripts/vm-config.sh
|
|
vm_qemu_flags
|
|
{
|
|
echo "LINEAGE_RELEASE=$LINEAGE_RELEASE"
|
|
echo "VM_GUEST_ARCH=$VM_GUEST_ARCH"
|
|
echo "VM_CPU=$VM_CPU"
|
|
echo "VM_SMP=$VM_SMP"
|
|
echo "VM_MEMORY=$VM_MEMORY"
|
|
echo "VM_ENABLE_KVM=$([ "$VM_ACCEL" = kvm ] && echo true || echo false)"
|
|
echo "VM_DISPLAY_GL=$VM_DISPLAY_GL"
|
|
# Only the device flags: -cpu/-smp/-m/-accel are passed as action inputs instead,
|
|
# since qemu-kvm-action builds those itself and duplicating them is ambiguous.
|
|
echo 'VM_QEMU_FLAGS<<VM_QEMU_FLAGS_EOF'
|
|
printf '%s\n' "${VM_QEMU_FLAGS[@]}"
|
|
echo 'VM_QEMU_FLAGS_EOF'
|
|
} >> "$GITHUB_ENV"
|
|
echo "Guest: LineageOS $LINEAGE_RELEASE ($VM_GUEST_ARCH), accel $VM_ACCEL, GL $VM_GL"
|
|
|
|
- name: Install uv
|
|
uses: astral-sh/setup-uv@v5
|
|
|
|
- name: Set up Android SDK
|
|
uses: android-actions/setup-android@v4
|
|
|
|
- name: Install Node
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: lts/*
|
|
check-latest: true
|
|
cache: 'npm'
|
|
cache-dependency-path: appium-tests/package-lock.json
|
|
|
|
- name: Install Appium
|
|
run: |
|
|
cd appium-tests
|
|
npm ci
|
|
sudo mkdir "$VM_DIR"
|
|
sudo chown "$USER" "$VM_DIR"
|
|
|
|
- name: Prepare VM
|
|
run: ./appium-tests/scripts/prepare-vm.sh
|
|
|
|
# Branches fresh overlays off the images prepare-vm.sh just fetched, so every run starts
|
|
# from identical guest state. Nothing here may be cached or reused between runs.
|
|
- name: Reset the ephemeral VM disks
|
|
run: |
|
|
mkdir -p vm-outputs
|
|
source appium-tests/scripts/vm-config.sh
|
|
vm_reset_disks
|
|
ls -l "$VM_RUN_DIR"
|
|
|
|
- name: Run QEMU
|
|
id: run-qemu
|
|
uses: etchdroid/qemu-kvm-action@v2
|
|
with:
|
|
video-record: true
|
|
video-output: vm-outputs/recording.mkv
|
|
# The guest boots from disk over UEFI, so there is no kernel/initrd/cmdline.
|
|
cpu: ${{ env.VM_CPU }}
|
|
smp: ${{ env.VM_SMP }}
|
|
memory: ${{ env.VM_MEMORY }}
|
|
enable-kvm: ${{ env.VM_ENABLE_KVM }}
|
|
flags: |
|
|
-chardev
|
|
stdio,id=char0,logfile=vm-outputs/serial.log,signal=off
|
|
-serial
|
|
chardev:char0
|
|
-display
|
|
sdl${{ env.VM_DISPLAY_GL }}
|
|
${{ env.VM_QEMU_FLAGS }}
|
|
|
|
run: |
|
|
cd appium-tests
|
|
export LOGCAT_DIR="$PWD/../vm-outputs/logcat/"
|
|
export VM_MARKERS_FILE="$PWD/../vm-outputs/markers.tsv"
|
|
mkdir -p "$LOGCAT_DIR"
|
|
./scripts/wait-vm-startup.sh
|
|
adb install -r ../apk/*.apk
|
|
adb logcat -d > "$LOGCAT_DIR/0_before.log" 2>&1
|
|
uv run pytest -sv --tb=native --junit-xml=../junit.xml
|
|
|
|
# Turns the full-length recording (early boot included) into something scrubbable: one
|
|
# chapter per test titled with its outcome, plus a subtitle track of the moments worth
|
|
# jumping to. Purely additive and never worth failing the job over -- a broken annotation
|
|
# still leaves the raw recording to upload.
|
|
#
|
|
# The start epoch comes from the file qemu-kvm-action writes beside its PID files rather
|
|
# than from its `ffmpeg-start` output, because the case that matters most is the one where
|
|
# pytest failed, and a composite action's outputs are not dependable once one of its steps
|
|
# has failed. There is exactly one such directory per job.
|
|
- name: Annotate the recording
|
|
if: always()
|
|
continue-on-error: true
|
|
run: |
|
|
./appium-tests/scripts/annotate-recording.py \
|
|
vm-outputs/recording.mkv \
|
|
vm-outputs/markers.tsv \
|
|
"$(cat /tmp/qemu-action-*/ffmpeg.start)"
|
|
|
|
- name: Publish test report
|
|
uses: mikepenz/action-junit-report@v5
|
|
if: (success() || failure()) && github.event.pull_request.head.repo.full_name == github.repository
|
|
with:
|
|
check_name: End-to-end test report for ${{ matrix.variant }}
|
|
detailed_summary: true
|
|
report_paths: junit.xml
|
|
require_tests: true
|
|
|
|
- name: Upload VM outputs
|
|
if: always()
|
|
uses: actions/upload-artifact@v5
|
|
with:
|
|
name: vm-outputs-${{ matrix.variant }}
|
|
path: vm-outputs/
|