Skip to content

Commit 66d96eb

Browse files
committed
Job matrix for different API levels
#189
1 parent 0c66015 commit 66d96eb

4 files changed

Lines changed: 154 additions & 5 deletions

File tree

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
name: android-compat
2+
3+
# Checks the app still starts on the Android versions it supports
4+
# (humhub/app#189): the app launch smoke test on one emulator per API level,
5+
# from minSdk (24) up to targetSdk (36). Called by version-release.yml to gate
6+
# the Google Play upload; can also be run manually.
7+
8+
on:
9+
workflow_call:
10+
workflow_dispatch:
11+
# TEMP: run on every push while developing the suite; remove before merging.
12+
push:
13+
branches: [f-internal-172-v2]
14+
15+
permissions:
16+
contents: read
17+
18+
concurrency:
19+
group: android-compat-${{ github.ref }}
20+
cancel-in-progress: ${{ github.event_name == 'push' }}
21+
22+
jobs:
23+
android:
24+
name: Android API ${{ matrix.api-level }}
25+
runs-on: ubuntu-latest
26+
timeout-minutes: 30
27+
strategy:
28+
# Every level's result is wanted, not only the first failure.
29+
fail-fast: false
30+
matrix:
31+
api-level: [24, 26, 28, 30, 33, 36]
32+
env:
33+
HUMHUB_IMAGE_TAG: '1.18'
34+
EMULATOR_OPTIONS: -no-window -gpu swiftshader_indirect -no-audio -no-boot-anim -camera-back none
35+
steps:
36+
- name: Checkout
37+
uses: actions/checkout@v4
38+
39+
# The test harness needs the backend's fixture values. Runs in the
40+
# background while the toolchain and emulator are set up.
41+
- name: Start HumHub backend (background)
42+
run: |
43+
mkdir -p scripts/e2e/logs
44+
nohup scripts/e2e/up.sh > scripts/e2e/logs/up.txt 2>&1 &
45+
46+
- name: Enable KVM
47+
run: |
48+
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
49+
sudo udevadm control --reload-rules
50+
sudo udevadm trigger --name-match=kvm
51+
52+
- uses: actions/setup-java@v5
53+
with:
54+
distribution: 'zulu'
55+
java-version: '17'
56+
cache: gradle
57+
58+
- uses: subosito/flutter-action@v2
59+
with:
60+
flutter-version: '3.47.0'
61+
channel: 'stable'
62+
cache: true
63+
64+
- name: Install dependencies
65+
run: flutter pub get
66+
67+
# Same AVD caching as the android job in e2e-tests.yml.
68+
- name: Restore AVD
69+
uses: actions/cache/restore@v4
70+
id: avd-cache
71+
with:
72+
path: |
73+
~/.android/avd/*
74+
~/.android/adb*
75+
key: avd-${{ matrix.api-level }}-google_apis-x86_64-v1
76+
77+
- name: Create AVD snapshot
78+
if: steps.avd-cache.outputs.cache-hit != 'true'
79+
uses: reactivecircus/android-emulator-runner@v2
80+
with:
81+
api-level: ${{ matrix.api-level }}
82+
target: google_apis
83+
arch: x86_64
84+
force-avd-creation: false
85+
emulator-options: ${{ env.EMULATOR_OPTIONS }}
86+
disable-animations: false
87+
script: echo "Generated AVD snapshot for caching."
88+
89+
- name: Save AVD
90+
if: steps.avd-cache.outputs.cache-hit != 'true'
91+
uses: actions/cache/save@v4
92+
with:
93+
path: |
94+
~/.android/avd/*
95+
~/.android/adb*
96+
key: ${{ steps.avd-cache.outputs.cache-primary-key }}
97+
98+
- name: Wait for HumHub backend
99+
timeout-minutes: 10
100+
run: |
101+
while pgrep -f scripts/e2e/up.sh > /dev/null; do sleep 2; done
102+
cat scripts/e2e/logs/up.txt
103+
test -f scripts/e2e/.e2e_fixtures.env
104+
105+
- name: Run app launch test on emulator
106+
uses: reactivecircus/android-emulator-runner@v2
107+
with:
108+
api-level: ${{ matrix.api-level }}
109+
target: google_apis
110+
arch: x86_64
111+
force-avd-creation: false
112+
emulator-options: -no-snapshot-save ${{ env.EMULATOR_OPTIONS }}
113+
disable-animations: true
114+
script: scripts/e2e/run_android.sh integration_test/app_launch_test.dart
115+
116+
- name: Upload logs
117+
if: always()
118+
uses: actions/upload-artifact@v4
119+
with:
120+
name: e2e-android-api${{ matrix.api-level }}-logs
121+
path: scripts/e2e/logs
122+
if-no-files-found: ignore
123+
retention-days: 7

‎.github/workflows/version-release.yml‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,13 @@ jobs:
118118
name: E2E smoke tests
119119
uses: ./.github/workflows/e2e-tests.yml
120120

121+
android_compat:
122+
name: Android version compatibility
123+
uses: ./.github/workflows/android-compat.yml
124+
121125
release_android:
122126
name: Release APK to Google Play
123-
needs: [build_android, e2e]
127+
needs: [build_android, e2e, android_compat]
124128
runs-on: ubuntu-latest
125129
steps:
126130
- name: Checkout

‎scripts/e2e/README.md‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,18 @@ By default it runs `integration_test/all_test.dart`, i.e. every test in one
5252
app, since each `flutter test` file means another Xcode build of a few
5353
minutes. Videos are then named after the test's description.
5454

55+
## Android version compatibility
56+
57+
`.github/workflows/android-compat.yml` runs the app launch test
58+
(`integration_test/app_launch_test.dart`) on one emulator per API level, from
59+
the app's minSdk (24) up to its targetSdk (36), see humhub/app#189. It gates
60+
the Google Play upload in `version-release.yml` and can be started manually.
61+
To check one level locally, start an emulator with that API level and run:
62+
63+
```bash
64+
scripts/e2e/run_android.sh integration_test/app_launch_test.dart
65+
```
66+
5567
## What's where
5668

5769
- `docker-compose.yml` – HumHub + MariaDB, plain HTTP on :8080.
@@ -64,7 +76,7 @@ minutes. Videos are then named after the test's description.
6476
PHP's built-in server).
6577
- `up.sh` – unattended install, test user, fixtures → `.e2e_fixtures.env`
6678
(`.e2e_fixtures.native.env` for the native backend).
67-
- `run_android.sh` – runs each test file separately with a screen recording,
79+
- `run_android.sh [test_file...]` – runs each test file separately with a screen recording,
6880
passes the fixtures to the tests via `--dart-define`,
6981
grants runtime permissions in the background (`grant_permissions.sh`) so
7082
the app's startup permission request doesn't block, writes `logs/logcat.txt`,

‎scripts/e2e/run_android.sh‎

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
#!/usr/bin/env bash
22
# Runs the integration_test suite on an Android emulator against the backend
3-
# started by up.sh. Used both locally and in CI (.github/workflows/e2e-tests.yml).
3+
# started by up.sh. Used both locally and in CI (.github/workflows/e2e-tests.yml,
4+
# android-compat.yml).
5+
#
6+
# Usage: run_android.sh [test_file...]
7+
# By default runs every integration_test/*_test.dart file separately.
48
#
59
# Env:
610
# DEVICE adb serial of the emulator (default: emulator-5554)
@@ -89,8 +93,12 @@ stop_recording() {
8993
fi
9094
}
9195

96+
if [ $# -eq 0 ]; then
97+
set -- integration_test/*_test.dart
98+
fi
99+
92100
status=0
93-
for test_file in integration_test/*_test.dart; do
101+
for test_file in "$@"; do
94102
name="$(basename "$test_file" .dart)"
95103
# Runs all the others in one app; used on iOS.
96104
[ "$name" != all_test ] || continue
@@ -108,6 +116,8 @@ for test_file in integration_test/*_test.dart; do
108116
stop_recording "$name"
109117
done
110118

111-
e2e_assert_upload "$E2E_USERNAME" "$upload_file_name" || status=1
119+
if [[ " $* " == *file_upload_test.dart* ]]; then
120+
e2e_assert_upload "$E2E_USERNAME" "$upload_file_name" || status=1
121+
fi
112122

113123
exit "$status"

0 commit comments

Comments
 (0)