Skip to content

tests: add test coverage with sonar #102

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

tarruk
Copy link

@tarruk tarruk commented Jun 23, 2025

Description

What this PR adds

A self-contained coverage pipeline for our repo:

  • coverage/full_coverage.py – drives the whole flow, ending with an
    LCOV report that SonarQube understands.
  • updated sonar-project.properties – aligns sonar.sources,
    sonar.tests, and the coverage path with the script.

🛠️ How it works — step by step

# Stage What happens
1 Read config Parses sonar-project.properties and uses the exact same folders declared in sonar.sources.
2 Safety check Prints a warning if it finds modules/*/lib folders not listed in sonar.sources (they would otherwise be ignored by SonarQube).
3 Per-module tests Runs flutter test --coverage inside each module that has a test/ folder. Generates one lcov.info per module.
4 Path normalisation Rewrites every SF: line so it starts with either app/lib/… or modules/<module>/lib/… — this guarantees SonarQube can map the file.
5 Merge + zero-coverage Combines all module reports and adds 0 % blocks for every Dart file that still has no tests, giving us a full-project view.
6 Validation & upload Verifies that all paths match sonar.sources, then launches sonar-scanner to upload the final report.

Usage

# Interactive (asks before running sonar-scanner)
python3 coverage/full_coverage.py

# CI / non-interactive (always runs sonar-scanner)
python3 coverage/full_coverage.py --ci

# Dry-run (show commands, don’t execute anything)
python3 coverage/full_coverage.py --dry-run
@rs-gpt-review Describe the changes in this PR. Recommend improvements (including code improvements), possible memory leaks, and best practices.

Copy link

@ManuViola77 ManuViola77 left a comment

Choose a reason for hiding this comment

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

💜 🥳 🚀

# runs-on: ubuntu-latest

# steps:
# # 1 — Checkout the repo
Copy link
Collaborator

Choose a reason for hiding this comment

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

I hitnk you are missing the python instalation

  • name: Install Python dependencies
    run: |
    python3 -m pip install --upgrade pip
    # Add any required pip install commands here, e.g.:
    # pip install somepackage

Copy link
Author

@tarruk tarruk Jun 23, 2025

Choose a reason for hiding this comment

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

@amaury901130
Nice catch! Just a heads-up: the ubuntu-latest runners already include Python 3 by default, so we don’t need an extra installation step. Since we’re not using any third-party Python dependencies, there’s nothing else to install right now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants