Skip to content
27 changes: 27 additions & 0 deletions .github/workflows/sonar_python.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Sonar for Python

on:
workflow_call:


jobs:
sonarqube:
name: SonarQube
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Download coverage report
uses: actions/download-artifact@v4
with:
name: coverage-report
- name: SonarQube Scan
uses: SonarSource/sonarqube-scan-action@v5
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
with:
args: >
-Dsonar.organization=woped
-Dsonar.projectKey=woped_${{ github.event.repository.name }}
-Dsonar.python.coverage.reportPaths=coverage.xml
6 changes: 5 additions & 1 deletion .github/workflows/template_CI.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,8 @@ jobs:
testing_maven:
uses: woped/devops/.github/workflows/testing_maven.yaml@main
testing_pytest:
uses: woped/devops/.github/workflows/testing_pytest.yaml@main
uses: woped/devops/.github/workflows/testing_pytest.yaml@main
sonar_python:
needs: testing_pytest
uses: woped/devops/.github/workflows/sonar_python.yaml@main
secrets: inherit
10 changes: 9 additions & 1 deletion .github/workflows/testing_pytest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ jobs:
- name: Run tests
if: steps.check_py.outputs.found == 'true'
run: |
pytest || EXIT_CODE=$?
pip install coverage
coverage run -m pytest || EXIT_CODE=$?
coverage xml
if [ "$EXIT_CODE" -eq "5" ]; then
echo "No tests were found. Skipping test phase."
exit 0
Expand All @@ -64,3 +66,9 @@ jobs:
echo "All tests passed."
exit 0
fi
- name: Upload coverage report
if: steps.check_py.outputs.found == 'true'
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: coverage.xml