Skip to content

ci: add SonarCloud analysis with coverage#82

Merged
Otoru merged 4 commits into
mainfrom
feat/sonarcloud
Jul 1, 2026
Merged

ci: add SonarCloud analysis with coverage#82
Otoru merged 4 commits into
mainfrom
feat/sonarcloud

Conversation

@Otoru

@Otoru Otoru commented Jul 1, 2026

Copy link
Copy Markdown
Owner

Summary

Brings SonarCloud static analysis + coverage tracking to Genesis, following the same pattern already used in the archcast wireframe project, adapted for the Python/Poetry/pytest stack.

Changes

  • sonar-project.properties — Python project config:
    • sonar.organization=otoru, sonar.projectKey=Otoru_Genesis
    • sonar.sources=genesis, sonar.tests=tests,examples
    • sonar.python.coverage.reportPaths=coverage.xml
    • Excludes tests/, examples/, docs/, scripts/, docker/, freeswitch/, genesis/cli/ from analysis/coverage
  • .github/workflows/main.yml:
    • test job now runs pytest --cov=genesis --cov-report=xml and uploads coverage.xml (only on the Python 3.12 matrix entry, to avoid artifact name collisions)
    • New sonar job (after test) downloads the coverage artifact and runs SonarSource/sonarcloud-github-action@v2 with -Dsonar.qualitygate.wait=true so a failing gate fails the CI

Setup required (one-time, outside this PR)

  1. Enable the project on SonarCloud under the otoru organization (GitHub login).
  2. Set the SONAR_TOKEN secret in the repo (Settings → Secrets and variables → Actions). The GITHUB_TOKEN is already available.
  3. The first run will create the project with the key Otoru_Genesis.

Validation

  • Workflow YAML parses
  • pytest --cov=genesis --cov-report=xml:coverage.xml runs locally: 242 passed, coverage 84%, coverage.xml written
  • coverage.xml already in .gitignore

Otoru added 4 commits June 30, 2026 21:25
- Add sonar-project.properties for Python (pytest-cov coverage.xml)
- Generate coverage.xml in the test job (Python 3.12 matrix entry)
- Add SonarCloud job that uploads coverage and enforces quality gate
- Excludes tests/examples/docs/scripts/docker/freeswitch from analysis
The existing .coveragerc had no relative_files setting, so coverage.py
wrote absolute <source> paths (e.g. /home/runner/work/Genesis/Genesis/
genesis) into coverage.xml. SonarCloud cannot resolve those paths and
drops all coverage measures with 'Invalid directory path in source
element' / 'Cannot resolve the file path'.

Set relative_files = true in .coveragerc so the XML uses <source>genesis
</source> with relative filenames, matching sonar.sources=genesis.
@Otoru Otoru merged commit e7c957c into main Jul 1, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant