Skip to content

Commit 52a2f80

Browse files
committed
Add SonarQube integration for code quality analysis and coverage reporting
1 parent 2b068e1 commit 52a2f80

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

.github/workflows/ci.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,34 @@ jobs:
7979
name: Coverage-Report
8080
path: coverage/
8181
retention-days: 1
82+
sonarqube:
83+
name: SonarQube
84+
needs: code-coverage
85+
runs-on: ubuntu-latest
86+
steps:
87+
- uses: actions/checkout@v5
88+
with:
89+
fetch-depth: 0
90+
91+
- name: Setup Python
92+
uses: actions/setup-python@v4
93+
with:
94+
python-version: "3.12"
95+
96+
- name: Install Dependencies
97+
run: |
98+
pip install -r requirements.txt
99+
pip install pytest-cov
100+
101+
- name: Run Code Coverage
102+
id: coverage
103+
continue-on-error: true
104+
run: pytest --cov=. --cov-report=html --cov-report=xml
105+
- name: SonarQube Scan
106+
uses: SonarSource/sonarqube-scan-action@v5
107+
with:
108+
args: >
109+
-Dsonar.python.coverage.reportPaths=coverage.xml
110+
env:
111+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
112+
SONAR_HOST_URL: https://sonarcloud.io

sonar-project.properties

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
sonar.projectKey=karimzakzouk_graduation-project-devops
2+
sonar.organization=karimzakzouk
3+
4+
5+
# This is the name and version displayed in the SonarCloud UI.
6+
sonar.projectName=graduation-project-devops
7+
sonar.projectVersion=1.0
8+
9+
10+
# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows.
11+
sonar.sources=.
12+
13+
# Encoding of the source code. Default is default system encoding
14+
sonar.sourceEncoding=UTF-8

0 commit comments

Comments
 (0)