From cbb15cb6e46096ca01c36e3711e8b7739694c48c Mon Sep 17 00:00:00 2001 From: "andrei.smirennikov" Date: Tue, 2 Dec 2025 20:55:31 +0000 Subject: [PATCH 1/2] Add coverage --- .github/workflows/ci.yml | 25 ++++++++++++++++++++++++- android/build.gradle.kts | 6 ++++++ package.json | 10 ++++++++++ 3 files changed, 40 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2cdb325..ce5f881 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,6 +32,13 @@ jobs: - name: Run Tests run: yarn test + - name: Upload coverage reports + if: always() + uses: actions/upload-artifact@v4 + with: + name: coverage-report + path: coverage/ + - name: Assert that every file that should be public has been exported run: ./scripts/assert_export.sh @@ -99,9 +106,18 @@ jobs: -scheme "sample" \ -sdk iphonesimulator \ -destination 'platform=iOS Simulator,OS=latest,name=iPhone 16 Pro' \ + -enableCodeCoverage YES \ + -resultBundlePath TestResults.xcresult \ -only-testing:sampleTests \ test | bundle exec xcpretty && exit ${PIPESTATUS[0]} + - name: Upload iOS coverage + if: always() + uses: actions/upload-artifact@v4 + with: + name: ios-coverage + path: sample/ios/TestResults.xcresult + test-android: needs: test-rn runs-on: macOS-13 @@ -134,4 +150,11 @@ jobs: - name: Run SDK Unit Tests working-directory: ./sample/android - run: ./gradlew :react-native-usercentrics:test + run: ./gradlew :react-native-usercentrics:koverXmlReport + + - name: Upload Android coverage + if: always() + uses: actions/upload-artifact@v4 + with: + name: android-coverage + path: android/build/reports/kover/ diff --git a/android/build.gradle.kts b/android/build.gradle.kts index cb4f624..d307d90 100644 --- a/android/build.gradle.kts +++ b/android/build.gradle.kts @@ -11,6 +11,7 @@ val isHermesEnabled = BooleanProperty("hermesEnabled") plugins { id("com.android.library") id("kotlin-android") + id("org.jetbrains.kotlinx.kover") version "0.9.1" } if (isNewArchitectureEnabled) { @@ -37,6 +38,11 @@ android { } + buildTypes { + getByName("debug") { + } + } + compileOptions { sourceCompatibility = JavaVersion.VERSION_17 targetCompatibility = JavaVersion.VERSION_17 diff --git a/package.json b/package.json index 6b0f805..52077fb 100644 --- a/package.json +++ b/package.json @@ -79,6 +79,16 @@ "jsx", "json", "node" + ], + "collectCoverage": true, + "collectCoverageFrom": [ + "src/**/*.{ts,tsx}", + "!src/**/*.d.ts" + ], + "coverageDirectory": "coverage", + "coverageReporters": [ + "text", + "lcov" ] }, "directories": { From 21d4c6d8a71391b1ea1fc0a84eb374fb2f43bdfe Mon Sep 17 00:00:00 2001 From: "andrei.smirennikov" Date: Wed, 3 Dec 2025 14:37:08 +0000 Subject: [PATCH 2/2] Add coverage --- .github/workflows/ci.yml | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ce5f881..5b3b0de 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -111,12 +111,22 @@ jobs: -only-testing:sampleTests \ test | bundle exec xcpretty && exit ${PIPESTATUS[0]} + - name: Install Slather + run: gem install slather + + - name: Generate iOS HTML Report + working-directory: ./sample/ios + run: | + slather coverage --html --output-directory html-report --scheme sample --workspace sample.xcworkspace sample.xcodeproj + - name: Upload iOS coverage if: always() uses: actions/upload-artifact@v4 with: name: ios-coverage - path: sample/ios/TestResults.xcresult + path: | + sample/ios/TestResults.xcresult + sample/ios/html-report/ test-android: needs: test-rn @@ -150,7 +160,7 @@ jobs: - name: Run SDK Unit Tests working-directory: ./sample/android - run: ./gradlew :react-native-usercentrics:koverXmlReport + run: ./gradlew :react-native-usercentrics:koverXmlReport :react-native-usercentrics:koverHtmlReport - name: Upload Android coverage if: always()