Skip to content

Commit a0253d9

Browse files
aksOpsclaude
andcommitted
Add SonarCloud workflow with coverage + test results
Runs pytest with --cov to generate coverage.xml, then pushes to SonarCloud for analysis. Badges on README auto-update with counts. Setup: add SONAR_TOKEN secret from sonarcloud.io project settings. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent c45e1ba commit a0253d9

2 files changed

Lines changed: 50 additions & 0 deletions

File tree

.github/workflows/sonarcloud.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: SonarCloud Analysis
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
workflow_dispatch:
9+
10+
permissions:
11+
contents: read
12+
13+
jobs:
14+
sonarcloud:
15+
name: SonarCloud Scan
16+
runs-on: ubuntu-latest
17+
continue-on-error: true
18+
steps:
19+
- uses: actions/checkout@v4
20+
with:
21+
fetch-depth: 0
22+
23+
- name: Set up Python
24+
uses: actions/setup-python@v5
25+
with:
26+
python-version: "3.12"
27+
28+
- name: Install project + test deps
29+
run: pip install -e ".[dev]"
30+
31+
- name: Run tests with coverage
32+
run: |
33+
pytest tests/ --cov=code_intelligence --cov-report=xml:coverage.xml --junitxml=test-results.xml -q || true
34+
35+
- name: SonarCloud Scan
36+
uses: SonarSource/sonarqube-scan-action@v5
37+
env:
38+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
39+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

sonar-project.properties

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
sonar.projectKey=RandomCodeSpace_code-iq
2+
sonar.organization=randomcodespace
3+
sonar.projectName=code-iq
4+
5+
sonar.sources=src/code_intelligence
6+
sonar.tests=tests
7+
sonar.python.version=3.11,3.12,3.13
8+
sonar.sourceEncoding=UTF-8
9+
10+
sonar.python.coverage.reportPaths=coverage.xml
11+
sonar.python.xunit.reportPath=test-results.xml

0 commit comments

Comments
 (0)