Skip to content

Commit 1fd7cba

Browse files
authored
Merge pull request #140 from Usercentrics/MSDK-3135-cover
Add code coverage
2 parents 7508a17 + defcad7 commit 1fd7cba

File tree

3 files changed

+33
-7
lines changed

3 files changed

+33
-7
lines changed

.github/workflows/ci.yml

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,21 @@ jobs:
6161
steps:
6262
- name: Checkout code
6363
uses: actions/checkout@v4
64+
- name: Install lcov
65+
run: sudo apt-get update && sudo apt-get install -y lcov
6466
- name: Get dependencies
6567
run: flutter pub get
6668
- name: Run all tests
6769
run: flutter test --reporter=expanded --coverage
6870
- name: Check coverage
6971
run: dart scripts/check_coverage.dart coverage/lcov.info
72+
- name: Generate HTML report
73+
run: genhtml coverage/lcov.info -o coverage/html
74+
- name: Upload coverage report
75+
uses: actions/upload-artifact@v4
76+
with:
77+
name: flutter-coverage-report
78+
path: coverage/html
7079

7180
test-android:
7281
name: Test Android
@@ -98,21 +107,29 @@ jobs:
98107
- name: Validate Gradle
99108
working-directory: ./example/android
100109
run: dart ../../scripts/check_gradle_version.dart
101-
- name: Run all tests
110+
- name: Run all tests and coverage
102111
working-directory: ./example/android
103-
run: ./gradlew :usercentrics_sdk:test
112+
run: ./gradlew :usercentrics_sdk:testDebugUnitTest :usercentrics_sdk:koverHtmlReportDebug
113+
- name: List coverage files
114+
working-directory: ./example
115+
run: find build -name "*.html" -o -name "index.html" | head -20
116+
- name: Upload coverage report
117+
uses: actions/upload-artifact@v4
118+
with:
119+
name: android-coverage-report
120+
path: example/build/usercentrics_sdk/reports/kover/htmlDebug
104121

105122
test-ios:
106123
name: Test iOS
107124
needs: [ lint, format, pub-dry-run ]
108-
runs-on: macos-13
125+
runs-on: macos-14
109126
timeout-minutes: 20
110127

111128
steps:
112129
- name: Setup code
113130
uses: maxim-lobanov/setup-xcode@v1
114131
with:
115-
xcode-version: '14.2'
132+
xcode-version: '15.4'
116133
- name: Checkout code
117134
uses: actions/checkout@v4
118135
- name: Setup Flutter
@@ -128,6 +145,9 @@ jobs:
128145
- name: Run all tests
129146
working-directory: ./example/ios
130147
run: ../../scripts/ios_unit_tests.sh
148+
- name: Show coverage report
149+
working-directory: ./example/ios
150+
run: xcrun xccov view --report TestResults.xcresult
131151

132152
build-android:
133153
name: Build Android Example
@@ -148,14 +168,14 @@ jobs:
148168
build-ios:
149169
name: Build iOS Example
150170
needs: [ lint, format, pub-dry-run ]
151-
runs-on: macos-13
171+
runs-on: macos-14
152172
timeout-minutes: 20
153173

154174
steps:
155175
- name: Setup code
156176
uses: maxim-lobanov/setup-xcode@v1
157177
with:
158-
xcode-version: '14.2'
178+
xcode-version: '15.4'
159179
- name: Checkout code
160180
uses: actions/checkout@v4
161181
- name: Setup Flutter

android/build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ buildscript {
1313
dependencies {
1414
classpath 'com.android.tools.build:gradle:8.3.2'
1515
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
16+
classpath "org.jetbrains.kotlinx:kover-gradle-plugin:0.7.6"
1617
}
1718
}
1819

@@ -25,6 +26,7 @@ rootProject.allprojects {
2526

2627
apply plugin: 'com.android.library'
2728
apply plugin: 'kotlin-android'
29+
apply plugin: 'org.jetbrains.kotlinx.kover'
2830

2931
android {
3032
namespace "com.usercentrics.sdk"

scripts/ios_unit_tests.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
#!/bin/sh -xe
22

3+
rm -rf TestResults.xcresult
4+
35
xcodebuild test -workspace 'Runner.xcworkspace' \
46
-scheme 'Runner' \
5-
-destination 'platform=iOS Simulator,name=iPhone 14 Pro'
7+
-destination 'platform=iOS Simulator,name=iPhone 15 Pro' \
8+
-enableCodeCoverage YES \
9+
-resultBundlePath TestResults

0 commit comments

Comments
 (0)