Skip to content

tests: add test coverage with sonar - #102

Merged
tarruk merged 1 commit into
mainfrom
tests/add-test-coverage-with-sonar
Nov 12, 2025
Merged

tarruk merged 1 commit into
mainfrom
tests/add-test-coverage-with-sonar

Conversation

@tarruk

@tarruk tarruk commented Jun 23, 2025

Copy link
Copy Markdown
Contributor

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.

@ManuViola77 ManuViola77 left a comment

Copy link
Copy Markdown

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
Copy Markdown
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

@tarruk tarruk Jun 23, 2025

Copy link
Copy Markdown
Contributor Author

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.

@tarruk
tarruk merged commit a5522e6 into main Nov 12, 2025
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