Skip to content

Commit d58de79

Browse files
committed
Fix coverage aggregation in parallel test workflow
Problem: The aggregate-coverage job was failing because koverXmlReportMergedCoverage requires all tests to have run in the same Gradle session. When tests are split across separate jobs, Kover has no test execution data to merge. Root Cause: - Kover collects binary coverage data during test execution - koverXmlReportMergedCoverage merges this data from the current build - In parallel jobs, the aggregation job never ran any tests - Result: No coverage data to merge, causing exit code 1 Solution: 1. Each test job now generates its own XML coverage report immediately after running tests: - test-libraries: koverXmlReportDebug for each library module - test-app: koverXmlReportStandardDebug - test-authenticator: koverXmlReportDebug 2. Coverage artifacts now contain XML reports, not just binary data 3. Aggregation job simplified: - Remove Fastlane/Ruby setup (no longer needed) - Download all coverage-* artifacts - Upload entire coverage-reports/ directory to codecov - Codecov automatically merges multiple XML files Benefits: - Each module's coverage is captured independently - No dependency on cross-job Gradle state - Codecov handles merging (tested and reliable) - Simpler, more maintainable workflow Technical Details: - Kover generates XML reports at: module/build/reports/kover/report*.xml - Codecov action with directory parameter finds all XML files recursively - disable_search=false allows automatic file discovery
1 parent d6a5f5b commit d58de79

File tree

1 file changed

+19
-34
lines changed

1 file changed

+19
-34
lines changed

.github/workflows/test.yml

Lines changed: 19 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,12 @@ jobs:
113113
run: |
114114
./gradlew :core:testDebug :data:testDebug :network:testDebug :ui:testDebug :authenticatorbridge:testDebug :cxf:testDebug
115115
116+
- name: Generate library coverage reports
117+
env:
118+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
119+
run: |
120+
./gradlew :core:koverXmlReportDebug :data:koverXmlReportDebug :network:koverXmlReportDebug :ui:koverXmlReportDebug :authenticatorbridge:koverXmlReportDebug :cxf:koverXmlReportDebug
121+
116122
- name: Upload library test reports
117123
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
118124
if: always()
@@ -184,6 +190,11 @@ jobs:
184190
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
185191
run: ./gradlew :app:testStandardDebug
186192

193+
- name: Generate app coverage report
194+
env:
195+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
196+
run: ./gradlew :app:koverXmlReportStandardDebug
197+
187198
- name: Upload app test reports
188199
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
189200
if: always()
@@ -243,6 +254,11 @@ jobs:
243254
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
244255
run: ./gradlew :authenticator:testDebug
245256

257+
- name: Generate authenticator coverage report
258+
env:
259+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
260+
run: ./gradlew :authenticator:koverXmlReportDebug
261+
246262
- name: Upload authenticator test reports
247263
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
248264
if: always()
@@ -285,42 +301,11 @@ jobs:
285301
restore-keys: |
286302
${{ runner.os }}-gradle-v2-
287303
288-
- name: Configure Ruby
289-
uses: ruby/setup-ruby@44511735964dcb71245e7e55f72539531f7bc0eb # v1.257.0
290-
with:
291-
bundler-cache: true
292-
293-
- name: Configure JDK
294-
uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # v5.0.0
295-
with:
296-
distribution: "temurin"
297-
java-version: ${{ env._JAVA_VERSION }}
298-
299-
- name: Install Fastlane
300-
run: |
301-
gem install bundler:2.2.27
302-
bundle config path vendor/bundle
303-
bundle install --jobs 4 --retry 3
304-
305304
- name: Download all coverage artifacts
306305
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
307306
with:
308307
pattern: coverage-*
309-
merge-multiple: true
310-
path: coverage-data/
311-
312-
- name: Generate merged coverage report
313-
env:
314-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
315-
run: |
316-
bundle exec fastlane koverXmlReportMergedCoverage
317-
318-
- name: Upload merged coverage report
319-
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
320-
if: always()
321-
with:
322-
name: merged-coverage-report
323-
path: build/reports/kover/reportMergedCoverage.xml
308+
path: coverage-reports/
324309

325310
- name: Upload to codecov.io
326311
id: upload-to-codecov
@@ -329,9 +314,9 @@ jobs:
329314
continue-on-error: true
330315
with:
331316
os: linux
332-
files: build/reports/kover/reportMergedCoverage.xml
317+
directory: coverage-reports/
333318
fail_ci_if_error: true
334-
disable_search: true
319+
disable_search: false
335320

336321
- name: Comment PR if coverage upload failed
337322
if: steps.upload-to-codecov.outcome == 'failure' && (github.event_name == 'push' || github.event_name == 'pull_request')

0 commit comments

Comments
 (0)