-
Notifications
You must be signed in to change notification settings - Fork 23
142 lines (121 loc) · 4.89 KB
/
Copy pathci.yml
File metadata and controls
142 lines (121 loc) · 4.89 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
name: CI
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
permissions:
contents: read
jobs:
build:
name: Build & Test (${{ matrix.flavor }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
# full is the shipped flavor (F-Droid / GitHub releases) and carries every
# quality gate: coverage ratchet, lint, and (in release.yml) the instrumented
# suite. play is deprecated and unshipped — its leg is kept as a cheap
# debug-compile-and-unit-test signal only, so source-level rot is caught while
# the flavor stays revivable (see the "Where to get it" note in README.md;
# playRelease/R8 and play lint are deliberately NOT exercised anywhere).
- flavor: full
flavorName: Full
- flavor: play
flavorName: Play
steps:
- name: Checkout
uses: actions/checkout@v7
with:
fetch-depth: 0
fetch-tags: true
- name: Set up JDK 21
uses: actions/setup-java@v5
with:
java-version: '21'
distribution: 'temurin'
cache: gradle
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Run unit tests
run: ./gradlew test${{ matrix.flavorName }}DebugUnitTest
- name: Coverage gate (ratcheting)
if: matrix.flavor == 'full'
run: ./gradlew koverVerifyFullDebug
- name: Android Lint
if: matrix.flavor == 'full'
run: ./gradlew lint${{ matrix.flavorName }}Debug
- name: Build debug APK
run: ./gradlew assemble${{ matrix.flavorName }}Debug
- name: Upload test results
if: always()
uses: actions/upload-artifact@v7
with:
name: test-results-${{ matrix.flavor }}
path: app/build/reports/tests/
- name: Upload lint results
if: always() && matrix.flavor == 'full'
uses: actions/upload-artifact@v7
with:
name: lint-results-${{ matrix.flavor }}
path: app/build/reports/lint-results-*.html
- name: Upload debug APK
uses: actions/upload-artifact@v7
with:
name: debug-apk-${{ matrix.flavor }}
path: app/build/outputs/apk/${{ matrix.flavor }}/debug/app-${{ matrix.flavor }}-debug.apk
# Posts (and updates in place) a coverage summary on each PR. The hard gate is
# koverVerifyFullDebug in the build job above; this is just the at-a-glance number so a
# reviewer sees where a change moves coverage without opening the report artifact.
coverage-comment:
name: Coverage comment
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Set up JDK 21
uses: actions/setup-java@v5
with:
java-version: '21'
distribution: 'temurin'
cache: gradle
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Generate coverage XML
run: ./gradlew koverXmlReportFullDebug
- name: Extract line coverage
id: cov
run: |
python3 - <<'PY' >> "$GITHUB_OUTPUT"
import xml.etree.ElementTree as ET
root = ET.parse("app/build/reports/kover/reportFullDebug.xml").getroot()
line = [c for c in root.findall("counter") if c.get("type") == "LINE"][0]
covered = int(line.get("covered"))
total = covered + int(line.get("missed"))
pct = (100.0 * covered / total) if total else 0.0
print(f"pct={pct:.2f}")
print(f"covered={covered}")
print(f"total={total}")
# Read the ratchet floor from the baseline file so the comment can never go
# stale against the real gate (it previously hardcoded an outdated number).
with open("app/kover-baseline.properties") as f:
for raw in f:
if raw.strip().startswith("line.coverage.min="):
print(f"floor={raw.strip().split('=', 1)[1]}")
break
else:
raise SystemExit("line.coverage.min not found in kover-baseline.properties")
PY
- name: Post sticky coverage comment
uses: marocchino/sticky-pull-request-comment@5770ad5eb8f42dd2c4f34da00c94c5381e49af88 # v3.0.5
with:
header: coverage-fulldebug
message: |
### 📊 Code coverage (fullDebug)
**${{ steps.cov.outputs.pct }}%** line coverage — ${{ steps.cov.outputs.covered }} / ${{ steps.cov.outputs.total }} lines covered · ratchet floor **${{ steps.cov.outputs.floor }}%**
Hard-gated by `koverVerifyFullDebug`. Raise `app/kover-baseline.properties` as coverage grows. Generated code and Compose UI screens are excluded from the measurement.