Skip to content

Commit 43e1c44

Browse files
chore(sonar): add SonarQube analysis workflow
1 parent 1dc5260 commit 43e1c44

1 file changed

Lines changed: 45 additions & 0 deletions

File tree

.github/workflows/build.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: SonarQube
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- master
8+
- develop
9+
pull_request:
10+
types: [opened, synchronize, reopened]
11+
12+
jobs:
13+
sonarqube:
14+
name: SonarQube Scan
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0
20+
21+
- name: Set up Python
22+
uses: actions/setup-python@v5
23+
with:
24+
python-version: '3.x'
25+
26+
- name: Install dependencies (best effort)
27+
continue-on-error: true
28+
run: |
29+
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
30+
if [ -f pyproject.toml ]; then pip install . || true; fi
31+
pip install coverage pytest || true
32+
33+
- name: Run tests with coverage (best effort)
34+
continue-on-error: true
35+
run: |
36+
if [ -d tests ] || [ -d test ]; then
37+
coverage run -m pytest || true
38+
coverage xml -o coverage.xml || true
39+
fi
40+
41+
- name: SonarQube Scan
42+
uses: SonarSource/sonarqube-scan-action@v5
43+
env:
44+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
45+
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}

0 commit comments

Comments
 (0)