-
Notifications
You must be signed in to change notification settings - Fork 18
236 lines (209 loc) · 9.61 KB
/
Copy pathci.yml
File metadata and controls
236 lines (209 loc) · 9.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
name: Android CI
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v7
- name: Extract VersionCode
id: extract_vc
run: |
VERSION_CODE=$(grep "versionCode =" app/build.gradle.kts | sed 's/.*versionCode = \(.*\)/\1/' | tr -d ' ')
echo "VERSION_CODE=$VERSION_CODE" >> $GITHUB_ENV
echo "Extracted versionCode: $VERSION_CODE"
- name: Check changelogs
run: |
for lang in en-US de-DE; do
file="fastlane/metadata/android/$lang/changelogs/${{ env.VERSION_CODE }}.txt"
if [ ! -f "$file" ]; then
echo "::error file=$file::Missing $lang changelog (versionCode ${{ env.VERSION_CODE }})"
exit 1
fi
echo "✔ Found changelog: $file"
done
- name: Set up JDK 17
uses: actions/setup-java@v5
with:
java-version: '17'
distribution: 'temurin'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v6.3.0
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Run linters
run: ./gradlew lintDebug
- name: Run unit tests
run: ./gradlew testDebugUnitTest
- name: Upload Unit Test Results (XML)
if: always()
uses: actions/upload-artifact@v7
with:
name: unit-test-results
path: app/build/test-results/testDebugUnitTest/
retention-days: 7
- name: Upload Lint Report (HTML)
if: always()
uses: actions/upload-artifact@v7
with:
name: lint-report-debug-html
path: app/build/reports/lint-results-debug.html
retention-days: 7
- name: Upload Lint Report (XML)
if: always()
uses: actions/upload-artifact@v7
with:
name: lint-report-debug-xml
path: app/build/reports/lint-results-debug.xml
retention-days: 7
- name: Generate Job Summary
if: always()
run: |
echo "## CI Job Summary" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Lint Report (Debug)" >> $GITHUB_STEP_SUMMARY
if [ -f app/build/reports/lint-results-debug.html ]; then
echo "Lint issues may have been found. Download the HTML report from the artifacts section of this run." >> $GITHUB_STEP_SUMMARY
echo "- [Download Lint Report (HTML)](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}#artifacts)" >> $GITHUB_STEP_SUMMARY
else
echo "No Lint HTML report found or lint task failed to produce one." >> $GITHUB_STEP_SUMMARY
fi
echo "" >> $GITHUB_STEP_SUMMARY
# Unit Test Summary Table
echo "### Unit Test Results" >> $GITHUB_STEP_SUMMARY
UNIT_REPORTS=$(find app/build/test-results/testDebugUnitTest -name "TEST-*.xml" 2>/dev/null)
if [[ -n "$UNIT_REPORTS" ]]; then
echo "| Suite | Total | ✅ Pass | 🔴 Fail | ⚪ Skip | ⏱️ Duration (s) |" >> $GITHUB_STEP_SUMMARY
echo "| ----- | -----: | ------: | ------: | -----: | ----------: |" >> $GITHUB_STEP_SUMMARY
GRAND_TOTAL=0; GRAND_PASS=0; GRAND_FAIL=0; GRAND_SKIP=0
while IFS= read -r REPORT; do
NAME=$(grep -oP '<testsuite[^>]* name="\K[^"]+' "$REPORT" | head -1)
TOTAL=$(grep -oP 'tests="\K[0-9]+' "$REPORT" | head -1); TOTAL=${TOTAL:-0}
FAIL=$(grep -oP 'failures="\K[0-9]+' "$REPORT" | head -1); FAIL=${FAIL:-0}
ERR=$(grep -oP 'errors="\K[0-9]+' "$REPORT" | head -1); ERR=${ERR:-0}
SKIP=$(grep -oP 'skipped="\K[0-9]+' "$REPORT" | head -1); SKIP=${SKIP:-0}
TIME=$(grep -oP 'time="\K[0-9.]+' "$REPORT" | head -1)
FAIL_TOT=$((FAIL + ERR))
PASSED=$((TOTAL - FAIL_TOT - SKIP))
echo "| $NAME | $TOTAL | $PASSED | $FAIL_TOT | $SKIP | $TIME |" >> $GITHUB_STEP_SUMMARY
GRAND_TOTAL=$((GRAND_TOTAL + TOTAL))
GRAND_PASS=$((GRAND_PASS + PASSED))
GRAND_FAIL=$((GRAND_FAIL + FAIL_TOT))
GRAND_SKIP=$((GRAND_SKIP + SKIP))
done <<< "$UNIT_REPORTS"
echo "| **Total** | **$GRAND_TOTAL** | **$GRAND_PASS** | **$GRAND_FAIL** | **$GRAND_SKIP** | — |" >> $GITHUB_STEP_SUMMARY
else
echo "_No unit test results found._" >> $GITHUB_STEP_SUMMARY
fi
echo "" >> $GITHUB_STEP_SUMMARY
# Changelog Status
echo "### Changelog Status (versionCode: ${{ env.VERSION_CODE }})" >> $GITHUB_STEP_SUMMARY
if [ -f "fastlane/metadata/android/en-US/changelogs/${{ env.VERSION_CODE }}.txt" ]; then
echo "- ✅ en-US Changelog: Found" >> $GITHUB_STEP_SUMMARY
else
echo "- ❌ en-US Changelog: NOT Found" >> $GITHUB_STEP_SUMMARY
fi
if [ -f "fastlane/metadata/android/de-DE/changelogs/${{ env.VERSION_CODE }}.txt" ]; then
echo "- ✅ de-DE Changelog: Found" >> $GITHUB_STEP_SUMMARY
else
echo "- ❌ de-DE Changelog: NOT Found" >> $GITHUB_STEP_SUMMARY
fi
instrumented-tests:
needs: build-and-test
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
api-level: [ 35 ]
profile: [ "Nexus 6", "Nexus 10", "7.6in Foldable" ]
steps:
- name: Checkout code
uses: actions/checkout@v7
- name: Set up JDK 17
uses: actions/setup-java@v5
with:
distribution: 'temurin'
java-version: '17'
- name: Cache Gradle dependencies
uses: actions/cache@v6
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: gradle-${{ runner.os }}-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: gradle-${{ runner.os }}-
- name: Make gradlew executable (+ normalize endings)
run: |
chmod +x ./gradlew
if command -v dos2unix >/dev/null; then dos2unix ./gradlew || true; fi
- name: Enable KVM for hardware acceleration
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: Cache AVD & SDK
uses: actions/cache@v6
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-${{ runner.os }}-api-${{ matrix.api-level }}-arch-x86_64-profile-${{ matrix.profile }}
- name: Generate AVD snapshot for API ${{ matrix.api-level }} on ${{ matrix.profile }}
if: steps.avd-cache.outputs.cache-hit != 'true'
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ matrix.api-level }}
arch: x86_64
target: google_apis
profile: ${{ matrix.profile }}
force-avd-creation: true
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -no-metrics
disable-animations: false
script: echo "First boot complete; snapshot created."
- name: Run Instrumented Tests on API ${{ matrix.api-level }} on ${{ matrix.profile }}
uses: ReactiveCircus/android-emulator-runner@v2
with:
api-level: ${{ matrix.api-level }}
arch: x86_64
target: google_apis
profile: ${{ matrix.profile }}
force-avd-creation: false
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -no-metrics
disable-animations: true
script: |
timeout --preserve-status 25m ./gradlew connectedDebugAndroidTest
- name: Upload Instrumented Test Results for API ${{ matrix.api-level }} on ${{ matrix.profile }}
if: always()
shell: bash
run: |
echo "## Instrumented Tests (API ${{ matrix.api-level }} - ${{ matrix.profile }})" >> "$GITHUB_STEP_SUMMARY"
echo "| Suite | Total | ✅ Pass | 🔴 Fail | ⚪ Skip | ⏱️ Duration (s) |" >> "$GITHUB_STEP_SUMMARY"
echo "| --------------------------------------- | -----: | ------: | ------: | -----: | ----------: |" >> "$GITHUB_STEP_SUMMARY"
REPORT=$(find app/build -type f -path "*/connected/**/TEST-*.xml" | head -n1)
if [[ -f "$REPORT" ]]; then
NAME=$(grep -oP '<testsuite[^>]* name="\K[^"]+' "$REPORT" | head -1)
TOTAL=$(grep -oP 'tests="\K[0-9]+' "$REPORT" | head -1)
FAIL=$(grep -oP 'failures="\K[0-9]+' "$REPORT" | head -1)
ERR=$(grep -oP 'errors="\K[0-9]+' "$REPORT" | head -1)
SKIP=$(grep -oP 'skipped="\K[0-9]+' "$REPORT" | head -1 || echo 0)
TIME=$(grep -oP 'time="\K[0-9.]+' "$REPORT" | head -1)
PASSED=$((TOTAL - FAIL - ERR - SKIP))
echo "| $NAME | $TOTAL | $PASSED | $((FAIL+ERR)) | $SKIP | $TIME |" >> "$GITHUB_STEP_SUMMARY"
else
echo "_No instrumented test results found._" >> "$GITHUB_STEP_SUMMARY"
fi
- name: Upload Instrumented Test Artifacts
if: always()
uses: actions/upload-artifact@v7
with:
name: instrumented-test-results-api-${{ matrix.api-level }}-${{ matrix.profile }}
path: |
app/build/reports/androidTests/connected/**/*
app/build/outputs/androidTest-results/connected/**/*
retention-days: 7