ci: add SonarCloud analysis with coverage#82
Merged
Merged
Conversation
- 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Brings SonarCloud static analysis + coverage tracking to Genesis, following the same pattern already used in the
archcastwireframe project, adapted for the Python/Poetry/pytest stack.Changes
sonar-project.properties— Python project config:sonar.organization=otoru,sonar.projectKey=Otoru_Genesissonar.sources=genesis,sonar.tests=tests,examplessonar.python.coverage.reportPaths=coverage.xmltests/,examples/,docs/,scripts/,docker/,freeswitch/,genesis/cli/from analysis/coverage.github/workflows/main.yml:testjob now runspytest --cov=genesis --cov-report=xmland uploadscoverage.xml(only on the Python 3.12 matrix entry, to avoid artifact name collisions)sonarjob (aftertest) downloads the coverage artifact and runsSonarSource/sonarcloud-github-action@v2with-Dsonar.qualitygate.wait=trueso a failing gate fails the CISetup required (one-time, outside this PR)
otoruorganization (GitHub login).SONAR_TOKENsecret in the repo (Settings → Secrets and variables → Actions). TheGITHUB_TOKENis already available.Otoru_Genesis.Validation
pytest --cov=genesis --cov-report=xml:coverage.xmlruns locally: 242 passed, coverage 84%,coverage.xmlwrittencoverage.xmlalready in.gitignore