@@ -174,10 +174,7 @@ jobs:
174174 runs-on : ubuntu-22.04
175175 needs : install_dependencies
176176 timeout-minutes : 20
177- strategy :
178- matrix :
179- python-version : ['3.10', '3.11']
180- container : python:${{ matrix.python-version }}-slim-buster
177+ container : python:3.11-slim-buster
181178 steps :
182179 - name : Setup git
183180 run : |
@@ -186,6 +183,8 @@ jobs:
186183 git config --global --add safe.directory $(realpath .)
187184 - name : Checkout repository
188185 uses : actions/checkout@v4
186+ with :
187+ fetch-depth : 0 # Important for SonarQube to analyze all history
189188 - name : Install uv
190189 uses : astral-sh/setup-uv@v5
191190 - name : Load venv cache
@@ -196,15 +195,12 @@ jobs:
196195 - name : Run unit tests with coverage
197196 run : |
198197 . .venv/bin/activate
199- # Use number of cores available, with a maximum of 4
200- CORES=$(nproc)
201- MAX_WORKERS=$(( CORES > 4 ? 4 : CORES ))
202- uv run pytest tests/ -n $MAX_WORKERS --cov=app --cov-report=xml
198+ uv run pytest tests/ --cov=app --cov-report=xml:coverage.xml
203199 shell : bash
204200 - name : Upload coverage report
205201 uses : actions/upload-artifact@v4
206202 with :
207- name : coverage-unit-python-${{ matrix.python-version }}
203+ name : coverage-report
208204 path : coverage.xml
209205
210206 sonarcloud_analysis :
@@ -213,36 +209,20 @@ jobs:
213209 steps :
214210 - name : Checkout repository
215211 uses : actions/checkout@v4
212+ with :
213+ fetch-depth : 0 # Important for SonarQube
216214
217- - name : Download coverage reports
215+ - name : Download coverage report
218216 uses : actions/download-artifact@v4
219217 with :
220- path : coverage-reports
218+ name : coverage-report
219+ path : .
221220
222- - name : Prepare coverage reports
221+ - name : Display coverage file
223222 run : |
224- # Create proper coverage-reports directory structure for SonarCloud
225- mkdir -p coverage-reports
226-
227- # Find the Python 3.11 report (most recent version) and use it as main
228- if [ -d "coverage-reports/coverage-unit-python-3.11" ]; then
229- cp coverage-reports/coverage-unit-python-3.11/coverage.xml coverage-reports/coverage-python-3.11.xml
230- elif [ -d "coverage-reports/coverage-unit-python-3.10" ]; then
231- cp coverage-reports/coverage-unit-python-3.10/coverage.xml coverage-reports/coverage-python-3.10.xml
232- else
233- echo "Warning: No coverage reports found!"
234- ls -la coverage-reports/
235- exit 1
236- fi
237-
238- # Clean up directories
239- rm -rf coverage-reports/coverage-unit-python-*
240- rm -rf coverage-reports/artifact
241- rm -rf coverage-reports/setup
242- shell : bash
243-
244- - name : Display structure of downloaded files
245- run : ls -R coverage-reports
223+ ls -la
224+ echo "Coverage file content check (first few lines):"
225+ head -n 20 coverage.xml || echo "coverage.xml file not found or empty"
246226
247227 - name : Run SonarCloud Scan
248228 uses : SonarSource/sonarqube-scan-action@master
@@ -253,7 +233,7 @@ jobs:
253233 args : >
254234 -Dsonar.projectKey=rapiddweller_datamimic-performance-report
255235 -Dsonar.organization=rapiddweller
256- -Dsonar.python.coverage.reportPaths=coverage-reports/coverage-* .xml
236+ -Dsonar.python.coverage.reportPaths=coverage.xml
257237 -Dsonar.sources=app
258238 -Dsonar.tests=tests
259239 -Dsonar.cpd.exclusions=tests/**
@@ -265,7 +245,7 @@ jobs:
265245 runs-on : ubuntu-22.04
266246 needs : [ unit_test, build ]
267247 environment :
268- name : test
248+ name : testpypi
269249 url : https://test.pypi.org/p/datamimic-perf
270250 permissions :
271251 id-token : write # Mandatory for trusted publishing
@@ -296,14 +276,15 @@ jobs:
296276 - name : Publish to TestPyPI
297277 uses : pypa/gh-action-pypi-publish@release/v1
298278 with :
279+ password : ${{ secrets.TEST_PYPI_API_TOKEN }}
299280 repository-url : https://test.pypi.org/legacy/
300281
301282 release :
302283 if : startsWith(github.ref, 'refs/tags/')
303284 runs-on : ubuntu-22.04
304285 needs : [ unit_test, build ]
305286 environment :
306- name : production
287+ name : pypi
307288 url : https://pypi.org/p/datamimic-perf
308289 permissions :
309290 id-token : write # Mandatory for trusted publishing
0 commit comments