Skip to content

Commit 5bca706

Browse files
committed
fix(sonar): FTRS-0006 Attempt to resolve coverage failure in sonar
1 parent c3d1f41 commit 5bca706

File tree

3 files changed

+35
-9
lines changed

3 files changed

+35
-9
lines changed

.github/actions/perform-static-analysis/action.yaml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,19 @@ runs:
2525
id: coverage-files
2626
shell: bash
2727
run: |
28-
FILES=$(find coverage -name 'coverage-*.xml' | paste -sd "," -)
28+
# Look for coverage files in the downloaded artifacts directory
29+
FILES=$(find coverage -name 'coverage-*.xml' 2>/dev/null | paste -sd "," - || echo "")
2930
echo "files=$FILES" >> $GITHUB_OUTPUT
31+
echo "Found coverage files: $FILES"
32+
33+
if [ -n "$FILES" ]; then
34+
echo "Coverage files will be passed to SonarCloud: $FILES"
35+
else
36+
echo "No coverage files found - SonarCloud will run without coverage"
37+
fi
3038
3139
- name: "Perform SonarCloud static analysis"
40+
id: sonar-analysis
3241
uses: sonarsource/sonarqube-scan-action@v5.3.1
3342
env:
3443
SONAR_TOKEN: ${{ inputs.sonar_token }}
@@ -37,6 +46,5 @@ runs:
3746
-Dsonar.organization=${{ inputs.sonar_organisation_key }}
3847
-Dsonar.projectKey=${{ inputs.sonar_project_key }}
3948
-Dsonar.branch.name=${{ github.ref_name }}
40-
-Dsonar.python.coverage.reportPaths=${{ steps.coverage-files.outputs.files }}
49+
${{ steps.coverage-files.outputs.files && format('-Dsonar.python.coverage.reportPaths={0}', steps.coverage-files.outputs.files) || '' }}
4150
-Dproject.settings=./scripts/config/sonar-scanner.properties
42-
continue-on-error: true

application/packages/python/Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,9 @@ lint-fix:
7474
poetry run ruff format
7575

7676
unit-test:
77-
poetry run pytest
77+
poetry run pytest --cov-report xml:coverage-$(PACKAGE).xml
78+
79+
coverage: unit-test
7880

7981
publish:
8082
@echo "Publishing Python packages layer to $(ARTEFACT_DEVELOPMENT_PATH)..."

scripts/config/sonar-scanner.properties

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,25 @@
33
sonar.host.url=https://sonarcloud.io
44
sonar.qualitygate.wait=true
55
sonar.sourceEncoding=UTF-8
6-
sonar.sources=.
7-
sonar.coverage.exclusions=services/read-only-viewer/**, services/dos-ui/**, architecture/**, **/*__init__.py, scripts/**, infrastructure/**, tests/**, scripts/workflow/tests/**, **/*.test.ts, **/*.spec.ts, tests/ui/src/**, scripts/workflow/create_open_search_index.py, scripts/workflow/populate_open_search_index.py
8-
sonar.exclusions=services/read-only-viewer/**, services/dos-ui/**, tests/**, scripts/workflow/tests/**, /**/__tests__/**, */*.test.tsx, **/*.test.ts, **/*test*.py, **/test_*.py, **/tests/unit/**
96

10-
#sonar.python.coverage.reportPaths=.coverage/coverage.xml
11-
#sonar.[javascript|typescript].lcov.reportPaths=.coverage/lcov.info
7+
# New Code analysis configuration - only fail on issues introduced in current branch
8+
sonar.newCode.referenceBranch=main
9+
10+
# Quality gate configuration - fail pipeline on new code issues
11+
sonar.qualitygate.requiredOnlyOnNewCode=true
12+
13+
# Language-specific configurations
14+
sonar.python.version=3.12
15+
sonar.python.coverage.reportPaths=**/coverage-*.xml,coverage.xml,.coverage.xml
16+
17+
# Source and test configuration
18+
sonar.sources=application,services,infrastructure
19+
sonar.tests=tests
20+
sonar.test.inclusions=**/test_*.py,**/*_test.py,**/*.test.ts,**/*.spec.ts,**/tests/**
21+
22+
# Coverage exclusions - files that don't need coverage
23+
sonar.coverage.exclusions=**/*__init__.py,**/*.test.*,**/test_*,**/tests/**,services/read-only-viewer/**,services/dos-ui/**,architecture/**,scripts/**,infrastructure/**,tests/ui/src/**,scripts/workflow/create_open_search_index.py,scripts/workflow/populate_open_search_index.py
24+
25+
# Analysis exclusions - files that should not be analyzed at all
26+
sonar.exclusions=services/read-only-viewer/**,services/dos-ui/**,tests/**,scripts/workflow/tests/**,/**/__tests__/**,**/*.test.*,**/test_*.py,**/tests/unit/**,**/.terraform/**,**/node_modules/**,**/.venv/**,**/__pycache__/**
27+

0 commit comments

Comments
 (0)