Skip to content

Commit 50bbf0a

Browse files
Add alert_historian to SonarQube
1 parent 68e97b7 commit 50bbf0a

File tree

4 files changed

+48
-0
lines changed

4 files changed

+48
-0
lines changed

.github/workflows/sonar.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ on:
77
- "server/**"
88
- "frontend/**"
99
- "screenshot/**"
10+
- "alert_historian/**"
1011
workflow_dispatch: # add ability to run workflow.
1112
pull_request:
1213
types: [opened, synchronize, reopened]
@@ -121,3 +122,33 @@ jobs:
121122
run: |
122123
cd screenshot/
123124
./gradlew build sonar
125+
126+
sonarQubeAlertHistorian:
127+
name: SonarQube Alert Historian
128+
runs-on: ubuntu-latest
129+
needs: sonarCheck
130+
if: ${{ needs.sonarCheck.outputs.enabled == 'true' }}
131+
steps:
132+
- uses: actions/checkout@v4
133+
with:
134+
fetch-depth: 0
135+
- name: Set up Python 3.11
136+
uses: actions/setup-python@v5
137+
with:
138+
python-version: "3.11"
139+
- name: Install dependencies
140+
run: |
141+
cd alert_historian
142+
python -m pip install --upgrade pip
143+
pip install -e ".[dev]"
144+
- name: Run coverage
145+
run: |
146+
cd alert_historian
147+
pytest --cov=src/alert_historian --cov-report=xml:coverage.xml
148+
- name: Scan alert_historian
149+
uses: SonarSource/sonarqube-scan-action@v6.0.0
150+
env:
151+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
152+
SONAR_HOST_URL: ${{ secrets.SONAR_HOST }}
153+
with:
154+
projectBaseDir: alert_historian/

alert_historian/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,14 @@ python -m alert_historian report
3030
python -m alert_historian run-once
3131
```
3232

33+
## SonarQube local prep
34+
35+
Generate the coverage report used by SonarQube:
36+
37+
```bash
38+
pytest --cov=src/alert_historian --cov-report=xml:coverage.xml
39+
```
40+
3341
## Configuration
3442

3543
Copy `.env.example` to `.env` and set:

alert_historian/pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ dependencies = [
1717
[project.optional-dependencies]
1818
dev = [
1919
"pytest>=8.2.0",
20+
"pytest-cov>=5.0.0",
2021
]
2122

2223
[tool.setuptools]
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
sonar.projectKey=antonrasmussen_findfirst_alert_historian
2+
sonar.organization=antonrasmussen
3+
sonar.projectName=alert_historian
4+
sonar.sources=src
5+
sonar.tests=tests
6+
sonar.python.version=3.11
7+
sonar.python.coverage.reportPaths=coverage.xml
8+
sonar.exclusions=.venv/**,.pytest_cache/**,artifacts/**,reports/**,state/**

0 commit comments

Comments
 (0)