Skip to content

Conversation

@asmir-hub
Copy link

@asmir-hub asmir-hub commented Dec 2, 2025

User description

PR Type

Enhancement, Tests


Description

  • Add Kover plugin for Android code coverage reporting

  • Configure Jest to collect TypeScript coverage reports

  • Upload coverage artifacts in CI/CD workflows

  • Enable code coverage for iOS and Android tests


Diagram Walkthrough

flowchart LR
  A["Build Configuration"] -->|"Kover Plugin"| B["Android Coverage"]
  C["Jest Config"] -->|"Coverage Collection"| D["TypeScript Coverage"]
  E["CI/CD Workflows"] -->|"Upload Artifacts"| F["Coverage Reports"]
  B --> F
  D --> F
  G["iOS Tests"] -->|"enableCodeCoverage"| F
Loading

File Walkthrough

Relevant files
Dependencies
build.gradle.kts
Add Kover plugin for Android coverage                                       

android/build.gradle.kts

  • Add Kover plugin version 0.9.1 for code coverage
  • Add debug build type configuration block
+6/-0     
Configuration changes
ci.yml
Configure coverage uploads in CI workflows                             

.github/workflows/ci.yml

  • Upload TypeScript coverage reports as artifact
  • Enable code coverage for iOS tests with -enableCodeCoverage YES
  • Add result bundle path for iOS test results
  • Replace unit test command with Kover XML report generation
  • Upload Android and iOS coverage artifacts
+24/-1   
package.json
Configure Jest coverage collection settings                           

package.json

  • Enable Jest coverage collection globally
  • Configure coverage to include TypeScript files from src directory
  • Exclude type definition files from coverage
  • Set coverage output directory to coverage
  • Configure text and lcov coverage reporters
+10/-0   


CodeAnt-AI Description

Enable unified coverage reporting for JavaScript, Android, and iOS tests in CI

What Changed

  • JavaScript tests now collect coverage for TypeScript source files and save reports that are uploaded from CI
  • iOS tests now run with coverage enabled and upload the Xcode coverage bundle as a CI artifact
  • Android tests now generate coverage reports and upload them from CI, using an explicit debug build setup

Impact

✅ Easier access to coverage reports in CI
✅ Clearer gaps in test coverage
✅ Fewer untested changes reaching release

💡 Usage Guide

Checking Your Pull Request

Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.

Talking to CodeAnt AI

Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:

@codeant-ai ask: Your question here

This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.

Example

@codeant-ai ask: Can you suggest a safer alternative to storing this secret?

Preserve Org Learnings with CodeAnt

You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:

@codeant-ai: Your feedback here

This helps CodeAnt AI learn and adapt to your team's coding style and standards.

Example

@codeant-ai: Do not flag unused imports.

Retrigger review

Ask CodeAnt AI to review the PR again, by typing:

@codeant-ai: review

Check Your Repository Health

To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.

Summary by CodeRabbit

  • Chores
    • Implemented end-to-end code coverage collection for iOS, Android, and JavaScript tests.
    • CI now generates and publishes separate coverage artifacts for iOS, Android, and JS after test runs.
    • Added test runner configuration to enable JavaScript coverage output and HTML/XML coverage reports for native platforms.

✏️ Tip: You can customize this high-level summary in your review settings.

@codeant-ai
Copy link

codeant-ai bot commented Dec 2, 2025

CodeAnt AI is reviewing your PR.

@coderabbitai
Copy link

coderabbitai bot commented Dec 2, 2025

Walkthrough

Adds CI artifacts and coverage collection across platforms: GitHub Actions now publishes RN, iOS, and Android coverage; Android Gradle integrates Kotlin Kover and a debug buildType; package.json enables Jest coverage collection and reporters.

Changes

Cohort / File(s) Summary
CI/CD Coverage Pipeline
.github/workflows/ci.yml
Adds artifact upload steps for coverage-report, ios-coverage, and android-coverage; enables iOS code coverage in Xcode test run (-enableCodeCoverage YES, -resultBundlePath TestResults.xcresult); generates Slather HTML report for iOS; runs koverXmlReport/koverHtmlReport for Android.
Android Build Configuration
android/build.gradle.kts
Adds Kotlin Kover plugin id("org.jetbrains.kotlinx.kover") version "0.9.1" and an explicit buildTypes { getByName("debug") { } } block.
JavaScript/TypeScript Coverage
package.json
Adds Jest configuration: moduleFileExtensions, collectCoverage: true, collectCoverageFrom: ["src/**/*.{ts,tsx}", "!src/**/*.d.ts"], coverageDirectory: "coverage", and coverageReporters: ["text","lcov"].

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Review CI artifact paths and names in .github/workflows/ci.yml for correctness and cross-job consistency.
  • Verify Kotlin Kover plugin version compatibility and whether the explicit debug buildType is required.
  • Check Jest coverage globs in package.json to ensure intended files are included/excluded.

Poem

🐰
I hopped through pipelines late at night,
Gathering coverage, making metrics bright.
From Jest to Kover, artifacts in tow,
I nest the reports in a neat little row.
Happy hops — the tests now glow! ✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Add coverage reports for UNIT tests' clearly and specifically summarizes the main change: implementing code coverage reporting infrastructure for JavaScript/TypeScript, Android, and iOS unit tests.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch MSDK-3134-coverage

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cbb15cb and 21d4c6d.

📒 Files selected for processing (1)
  • .github/workflows/ci.yml (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • .github/workflows/ci.yml
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: test-android
  • GitHub Check: test-ios

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@qodo-code-review
Copy link

qodo-code-review bot commented Dec 2, 2025

PR Compliance Guide 🔍

Below is a summary of compliance checks for this PR:

Security Compliance
🟢
No security concerns identified No security vulnerabilities detected by AI analysis. Human verification advised for critical code.
Ticket Compliance
🎫 No ticket provided
  • Create ticket/issue
Codebase Duplication Compliance
Codebase context is not defined

Follow the guide to enable codebase context checks.

Custom Compliance
🟢
Generic: Meaningful Naming and Self-Documenting Code

Objective: Ensure all identifiers clearly express their purpose and intent, making code
self-documenting

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Secure Error Handling

Objective: To prevent the leakage of sensitive system information through error messages while
providing sufficient detail for internal debugging.

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Secure Logging Practices

Objective: To ensure logs are useful for debugging and auditing without exposing sensitive
information like PII, PHI, or cardholder data.

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Comprehensive Audit Trails

Objective: To create a detailed and reliable record of critical system actions for security analysis
and compliance.

Status:
Audit scope unclear: The new changes focus on enabling and uploading coverage reports but do not add or modify
any application code related to logging critical actions, so compliance cannot be
determined from this diff alone.

Referred Code
- name: Upload coverage reports
  if: always()
  uses: actions/upload-artifact@v4
  with:
    name: coverage-report
    path: coverage/

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Robust Error Handling and Edge Case Management

Objective: Ensure comprehensive error handling that provides meaningful context and graceful
degradation

Status:
CI error handling: Workflow steps were added for coverage and test execution without explicit failure
handling beyond defaults, which may be acceptable for CI but cannot confirm robust error
handling for application code from this diff.

Referred Code
      working-directory: ./sample/ios
      run: |
        set -o pipefail && \
        xcodebuild \
          -workspace sample.xcworkspace \
          -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:

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Security-First Input Validation and Data Handling

Objective: Ensure all data inputs are validated, sanitized, and handled securely to prevent
vulnerabilities

Status:
Input validation scope: The changes only configure coverage and CI steps and do not touch input handling paths, so
security validation practices cannot be assessed from the added code.

Referred Code
"collectCoverage": true,
"collectCoverageFrom": [
  "src/**/*.{ts,tsx}",
  "!src/**/*.d.ts"
],
"coverageDirectory": "coverage",
"coverageReporters": [
  "text",
  "lcov"
]

Learn more about managing compliance generic rules or creating your own custom rules

  • Update
Compliance status legend 🟢 - Fully Compliant
🟡 - Partial Compliant
🔴 - Not Compliant
⚪ - Requires Further Human Verification
🏷️ - Compliance label

@codeant-ai codeant-ai bot added the size:M This PR changes 30-99 lines, ignoring generated files label Dec 2, 2025
@qodo-code-review
Copy link

qodo-code-review bot commented Dec 2, 2025

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
High-level
Integrate a service for unified reports

Instead of uploading separate coverage reports for TypeScript, iOS, and Android
as build artifacts, integrate a coverage service like Codecov. This will
consolidate reports into a unified dashboard and provide better feedback, such
as PR comments.

Examples:

.github/workflows/ci.yml [35-40]
      - name: Upload coverage reports
        if: always()
        uses: actions/upload-artifact@v4
        with:
          name: coverage-report
          path: coverage/
.github/workflows/ci.yml [114-119]
      - name: Upload iOS coverage
        if: always()
        uses: actions/upload-artifact@v4
        with:
          name: ios-coverage
          path: sample/ios/TestResults.xcresult

Solution Walkthrough:

Before:

# .github/workflows/ci.yml

# In test-rn job:
- name: Upload coverage reports
  uses: actions/upload-artifact@v4
  with:
    name: coverage-report
    path: coverage/

# In test-ios job:
- name: Upload iOS coverage
  uses: actions/upload-artifact@v4
  with:
    name: ios-coverage
    path: sample/ios/TestResults.xcresult

# In test-android job:
- name: Upload Android coverage
  uses: actions/upload-artifact@v4
  with:
    name: android-coverage
    path: android/build/reports/kover/

After:

# .github/workflows/ci.yml

# In test-rn job:
- name: Upload TS coverage to Codecov
  uses: codecov/codecov-action@v4
  with:
    files: ./coverage/lcov.info
    flags: typescript

# In test-ios job:
- name: Upload iOS coverage to Codecov
  uses: codecov/codecov-action@v4
  with:
    files: ./sample/ios/TestResults.xcresult
    flags: ios

# In test-android job:
- name: Upload Android coverage to Codecov
  uses: codecov/codecov-action@v4
  with:
    files: ./android/build/reports/kover/report.xml
    flags: android
Suggestion importance[1-10]: 8

__

Why: The suggestion correctly identifies that uploading separate artifacts is suboptimal and proposes a significant improvement by integrating a unified reporting service, which would make the new coverage data far more actionable.

Medium
Possible issue
Correct the iOS coverage artifact path

Correct the artifact path for iOS coverage from sample/ios/TestResults.xcresult
to TestResults.xcresult, as the xcodebuild command generates the file in the
repository root.

.github/workflows/ci.yml [114-119]

 - name: Upload iOS coverage
   if: always()
   uses: actions/upload-artifact@v4
   with:
     name: ios-coverage
-    path: sample/ios/TestResults.xcresult
+    path: TestResults.xcresult
  • Apply / Chat
Suggestion importance[1-10]: 8

__

Why: The suggestion correctly identifies a bug where the path for the iOS coverage artifact is incorrect, which would cause the upload-artifact step to fail.

Medium
  • Update

@pantoaibot
Copy link

pantoaibot bot commented Dec 2, 2025

PR Summary:

Add CI coverage collection and upload for unit tests across JS, iOS and Android; enable Jest coverage locally and configure Android Kover plugin.

  • CI (.github/workflows/ci.yml)
    • Upload Jest coverage artifact from coverage/ after RN tests.
    • Enable Xcode code coverage in iOS test step (-enableCodeCoverage YES, -resultBundlePath TestResults.xcresult) and upload sample/ios/TestResults.xcresult as ios-coverage.
    • Replace Android test gradle task with koverXmlReport to generate coverage and upload android/build/reports/kover/ as android-coverage.
  • JS (package.json)
    • Turn on Jest coverage: collectCoverage = true, collectCoverageFrom = ["src//*.{ts,tsx}", "!src//*.d.ts"], coverageDirectory = "coverage", coverageReporters = ["text","lcov"].
  • Android (android/build.gradle.kts)
    • Add Kover plugin (org.jetbrains.kotlinx.kover version 0.9.1) to enable Kover coverage reports.
    • Add an explicit (empty) debug buildType block (no behavioral change).
  • Notes / potential impacts
    • No breaking changes to library code. CI will now produce coverage artifacts (increased storage/transfer). Android CI now runs koverXmlReport task instead of the previous plain test task — test execution still occurs but via Kover task which may affect caching/outputs. Jest coverage collection may slow test execution slightly.

Reviewed by Panto AI

@codeant-ai
Copy link

codeant-ai bot commented Dec 2, 2025

CodeAnt AI finished reviewing your PR.

Comment on lines 152 to 153
working-directory: ./sample/android
run: ./gradlew :react-native-usercentrics:test
run: ./gradlew :react-native-usercentrics:koverXmlReport
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[CRITICAL_BUG] You replaced the existing Gradle test invocation (./gradlew :react-native-usercentrics:test) with :react-native-usercentrics:koverXmlReport. If the Kover plugin is not applied to the same Gradle project that contains the :react-native-usercentrics module, this task will not exist and the job will fail. Ensure the kover plugin is applied to the module that contains the unit tests (or the sample/android composite project) or run the tests first (test) and then run the kover reporting task. Example: run ./gradlew :react-native-usercentrics:test :react-native-usercentrics:koverXmlReport or apply kover to the correct build.gradle in sample/android/react-native-usercentrics.

Comment on lines +155 to +160
- name: Upload Android coverage
if: always()
uses: actions/upload-artifact@v4
with:
name: android-coverage
path: android/build/reports/kover/
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[CRITICAL_BUG] The upload path for Android coverage is 'android/build/reports/kover/' which is likely incorrect given the workflow's working-directory is ./sample/android. The kover reports will usually be produced under sample/android//build/reports/kover or sample/android/build/reports/kover depending on module layout. Make the path explicit or use a glob to capture the generated report(s), e.g. path: 'sample/android//build/reports/kover/' or the exact module path 'sample/android/react-native-usercentrics/build/reports/kover/'. Otherwise the artifact will be empty and CI will appear to succeed but produce no coverage.

@pantoaibot
Copy link

pantoaibot bot commented Dec 2, 2025

Reviewed up to commit:cbb15cb6e46096ca01c36e3711e8b7739694c48c

Additional Suggestion
.github/workflows/ci.yml, line:109-110 You added -enableCodeCoverage YES and -resultBundlePath TestResults.xcresult to the xcodebuild invocation. That's appropriate to generate an .xcresult bundle, but uploading the full .xcresult can be large and not directly consumable by many coverage tools. Consider extracting coverage in a CI-friendly format (e.g. using xcrun xccov or xcresulttool to export cobertura/lcov) and upload that file instead, or compress the .xcresult before uploading to reduce artifact size.

Reviewed by Panto AI

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between aaf8f80 and cbb15cb.

📒 Files selected for processing (3)
  • .github/workflows/ci.yml (3 hunks)
  • android/build.gradle.kts (2 hunks)
  • package.json (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: test-ios
  • GitHub Check: test-android
🔇 Additional comments (5)
android/build.gradle.kts (2)

14-14: Kover plugin integration looks good.

The Kover plugin is appropriately placed and versioned. Ensure Kover 0.9.1 remains compatible with your minimum SDK version (24) and Kotlin version.


41-44: Clarify the purpose of the empty debug buildType block.

Adding an explicit empty configuration for a buildType that already exists with defaults provides no functional change. Verify whether this is required for Kover to function or if it can be removed.

.github/workflows/ci.yml (3)

35-40: RN coverage artifact upload looks good.

The path coverage/ aligns with Jest configuration, and the always() condition ensures diagnostics are captured even if tests fail.


109-119: iOS coverage collection configured correctly.

The -enableCodeCoverage YES flag and -resultBundlePath are standard Xcode coverage practices, and the upload path is consistent with the result bundle path.


153-160: Kover v0.9.1 automatically depends on and executes test tasks—no changes needed.

The koverXmlReport task in Kover 0.9.1 is configured by default to depend on all test tasks in the project and will automatically trigger test execution when invoked. The artifact upload path android/build/reports/kover/ is the correct default output location for Kover reports. The configuration in android/build.gradle.kts applies the Kover plugin with no custom overrides, so the standard behavior applies: running ./gradlew :react-native-usercentrics:koverXmlReport will compile, run tests, and generate coverage reports.

@codeant-ai
Copy link

codeant-ai bot commented Dec 3, 2025

CodeAnt AI is running Incremental review

@codeant-ai
Copy link

codeant-ai bot commented Dec 4, 2025

CodeAnt AI is running Incremental review


Thanks for using CodeAnt! 🎉

We're free for open-source projects. if you're enjoying it, help us grow by sharing.

Share on X ·
Reddit ·
LinkedIn

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Review effort 2/5 size:M This PR changes 30-99 lines, ignoring generated files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants