Skip to content

Commit fb6debe

Browse files
Tarek RadovanTarek Radovan
authored andcommitted
tests: add test coverage with sonar
1 parent 4d7b528 commit fb6debe

File tree

3 files changed

+78
-36
lines changed

3 files changed

+78
-36
lines changed
Lines changed: 64 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,64 @@
1-
#SonarQube Configuration
2-
# This is the sonarqube configuration, check readme for instructions
3-
#name: 'sonarqube'
4-
#
5-
#on: push
6-
#
7-
#jobs:
8-
# sonarQubeTrigger:
9-
# name: Sonarqube-Trigger
10-
# runs-on: ubuntu-latest
11-
# steps:
12-
# - uses: dart-lang/setup-dart@v1
13-
# - name: Checkout code
14-
# uses: actions/checkout@v2
15-
# - uses: webfactory/[email protected]
16-
# with:
17-
# ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
18-
# - name: Set up Flutter
19-
# uses: subosito/flutter-action@v2
20-
# with:
21-
# channel: stable
22-
# flutter-version: 3.24.3
23-
# - run: flutter --version
24-
# - name: Get Dependencies
25-
# run: flutter pub get app && flutter pub get modules/domain && flutter pub get modules/data && flutter pub get modules/common
26-
# - name: Analyze App
27-
# #run analyze first
28-
# run: flutter analyze
29-
# - name: Setup Sonarqube Scanner
30-
# uses: warchant/setup-sonar-scanner@v8
31-
# - name: Run Sonarqube Scanner
32-
# run: sonar-scanner
33-
# -Dsonar.token=${{ secrets.SONAR_TOKEN }}
34-
# -Dsonar.host.url=${{ secrets.SONAR_URL }}
1+
# name: sonarqube
2+
3+
# # ────────────────────────────────────────────────────────────────
4+
# # CI TRIGGERS
5+
# # · push on main → historical baseline
6+
# # · pull_request PRs → quality gate before merge
7+
# # ────────────────────────────────────────────────────────────────
8+
# on:
9+
# push:
10+
# branches: [main]
11+
# pull_request:
12+
# types: [opened, synchronize, reopened]
13+
14+
# jobs:
15+
# sonarQubeTrigger:
16+
# name: Sonarqube Trigger
17+
# runs-on: ubuntu-latest
18+
19+
# steps:
20+
# # 1 — Checkout the repo
21+
# - name: Checkout code
22+
# uses: actions/checkout@v3
23+
24+
# # 2 — SSH agent for any Git-based pub dependencies
25+
# - name: Start ssh-agent
26+
# uses: webfactory/[email protected]
27+
# with:
28+
# ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
29+
30+
# # 3 — Install Dart SDK
31+
# - uses: dart-lang/setup-dart@v1
32+
33+
# # 4 — Install Flutter SDK
34+
# - name: Set up Flutter
35+
# uses: subosito/flutter-action@v2
36+
# with:
37+
# channel: stable
38+
# flutter-version: 3.24.3
39+
40+
# # 5 — Install all pub packages (app + each module)
41+
# - name: Get pub packages
42+
# run: |
43+
# set -e
44+
# for dir in app modules/*; do
45+
# if [ -f "$dir/pubspec.yaml" ]; then
46+
# echo "▶ flutter pub get --directory $dir"
47+
# flutter pub get --directory "$dir"
48+
# fi
49+
# done
50+
51+
# # 6 — Static analysis (kept exactly as before)
52+
# - name: Analyze App
53+
# run: flutter analyze
54+
55+
# # 7 — Install SonarScanner CLI (needed by full_coverage.py)
56+
# - name: Setup Sonarqube Scanner
57+
# uses: warchant/setup-sonar-scanner@v8
58+
59+
# # 8 — Run tests, build combined lcov.info and upload to SonarQube
60+
# - name: Generate coverage & run SonarQube
61+
# run: python3 coverage/full_coverage.py --ci
62+
# env:
63+
# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
64+
# SONAR_URL: ${{ secrets.SONAR_URL }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ unlinked_spec.ds
110110

111111
# Coverage
112112
coverage/
113+
+!coverage/full_coverage.py
113114

114115
# Symbols
115116
app.*.symbols

sonar-project.properties

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,17 @@ sonar.host.url=https://your-sonarqube-server.net
44
sonar.projectVersion=1.0
55
sonar.sourceEncoding=UTF-8
66
# Main source directories
7-
sonar.sources=app/lib,modules/domain,modules/data,modules/common
8-
sonar.dart.exclusions=pubspec.yaml
7+
sonar.sources=app/lib,modules/domain/lib,modules/data/lib,modules/common/lib
8+
99
sonar.dart.analyzer.report.mode=LEGACY
10+
# Exclude generated code from both analysis *and* coverage
11+
sonar.exclusions=**/*.g.dart,**/generated/**,**/*.freezed.dart, pubspec.yaml, coverage/**
12+
sonar.coverage.exclusions=**/*.g.dart,**/generated/**,**/*.freezed.dart, pubspec.yaml, coverage/**
13+
14+
# common & data have no tests yet
15+
sonar.tests=app/test,modules/domain/test
16+
17+
# Coverage report – property understood by the **sonar-flutter** plugin
18+
sonar.flutter.coverage.reportPath=coverage/lcov.info
19+
20+

0 commit comments

Comments
 (0)