@@ -106,35 +106,31 @@ jobs:
106106 export PROTOCOL="http"
107107 export PYTHONPATH="../:$PYTHONPATH"
108108
109- # Generate coverage with proper relative paths for SonarCloud
109+ # Generate coverage for SonarCloud (using simple format)
110110 pytest unit_tests/ integration_tests/ e2e_tests/ \
111111 --cov=../crypto_service \
112112 --cov=../pki_service \
113113 --cov=../common \
114- --cov-report=xml:coverage.xml \
114+ --cov-report=term-missing \
115115 --junitxml=test-results.xml \
116116 -v
117117
118- # CRITICAL: Fix absolute paths to relative paths for SonarCloud
119- sed -i 's|filename="/home/runner/work/fmcrypto/fmcrypto/|filename="|g' coverage.xml
120- sed -i 's|filename="home/runner/work/fmcrypto/fmcrypto/|filename="|g' coverage.xml
121-
122- # FINAL FIX: Fix sources section to match sonar.sources=.
123- sed -i 's|<source>../common</source>|<source>common</source>|g' coverage.xml
124- sed -i 's|<source>../crypto_service</source>|<source>crypto_service</source>|g' coverage.xml
125- sed -i 's|<source>../pki_service</source>|<source>pki_service</source>|g' coverage.xml
126-
127- # Verify ALL fixes worked (paths AND sources)
128- echo "=== Verifying path fix ==="
129- grep 'filename=' coverage.xml | head -3
130- echo "=== Verifying sources section ==="
131- grep '<source>' coverage.xml
118+ # Generate SonarCloud-compatible coverage using coverage.py directly
119+ cd ..
120+ coverage run --source=crypto_service,pki_service,common -m pytest testing/unit_tests/ testing/integration_tests/ testing/e2e_tests/ -q
121+ coverage xml -o testing/coverage.xml
122+ cd testing
132123
133- # DIAGNOSTIC: Show coverage file stats for SonarCloud
134- echo "=== Coverage file diagnostic ==="
135- echo "File size: $(ls -lh coverage.xml | awk '{print $5}')"
136- echo "Line count: $(wc -l < coverage.xml)"
137- echo "Coverage rate: $(grep 'line-rate=' coverage.xml | head -1)"
124+ # Verify coverage file generated correctly
125+ echo "=== Coverage file verification ==="
126+ if [ -f coverage.xml ]; then
127+ echo "Coverage file generated successfully"
128+ echo "File size: $(ls -lh coverage.xml | awk '{print $5}')"
129+ echo "First few lines:"
130+ head -10 coverage.xml
131+ else
132+ echo "ERROR: coverage.xml not generated"
133+ fi
138134
139135 - name : stop services
140136 if : always()
@@ -174,14 +170,13 @@ jobs:
174170 find . -name "*.py" -path "./common/*" | head -3
175171
176172 - name : sonarcloud scan
177- uses : SonarSource/sonarcloud-github -action@master
173+ uses : SonarSource/sonarqube-scan -action@v5.0.0
178174 env :
179175 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
180176 SONAR_TOKEN : ${{ secrets.SONAR_TOKEN }}
181177 with :
182178 projectBaseDir : .
183- # use the sonar-project.properties file from testing directory
184- # override key settings for sonarcloud
179+ # use the sonar-project.properties file from project root
185180 args : >
186181 -Dsonar.projectKey=jagnd1_fmcrypto
187182 -Dsonar.organization=jagnd1
0 commit comments