-
Notifications
You must be signed in to change notification settings - Fork 0
Fix SonarCloud scan issues #9
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @ipv1337, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
Summary of Changes
This pull request addresses SonarCloud scan failures by updating the CI/CD pipeline and fixing the coverage script. Specifically, it updates the GitHub Action used for SonarCloud scanning, fixes the coverage script to run actual tests and generate a proper coverage report, and cleans up the sonar-project.properties file by removing unnecessary settings. This should resolve the failing CI checks previously observed.
Highlights
- SonarCloud Action Update: The pull request updates the GitHub Action used for SonarCloud scanning from the deprecated
SonarSource/sonarcloud-github-actionto the recommendedsonarqube-scan-action. - Coverage Script Fix: The coverage script (
scripts/run_coverage_ci.sh) is updated to execute the pytest test suite with coverage enabled, generating XML and HTML reports. It also extracts the overall coverage percentage and sets it as a GitHub Actions output variable. - Sonar Properties Cleanup: The
sonar-project.propertiesfile is cleaned up by removing redundant and unnecessary settings related to coverage reporting, issue ignoring, quality gate waiting, branch patterns, and new code reference.
Changelog
- scripts/run_coverage_ci.sh
- The script is rewritten to run pytest with coverage enabled instead of creating a dummy coverage report.
- It generates coverage reports in XML and HTML formats.
- It extracts the overall coverage percentage from the XML report and sets it as a GitHub Actions output.
- Error handling is improved by using
set -eto exit on error.
- sonar-project.properties
- Multiple redundant coverage report paths are removed, leaving only
sonar.python.coverage.reportPaths=coverage.xml. - Settings related to ignoring issues, forcing 100% coverage, skipping quality gate waiting, and branch patterns are removed.
- The
sonar.scm.forceReloadAllproperty is removed.
- Multiple redundant coverage report paths are removed, leaving only
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
A scan's red glare,
The tests now running true,
Code smell takes its leave.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This PR addresses SonarCloud scan failures by updating the scan action, fixing the coverage script, and cleaning up the sonar-project.properties file. The changes look good overall and should resolve the failing CI checks.
Summary of Findings
- Coverage Percentage Output: The script now extracts and outputs the coverage percentage, which is great for monitoring coverage trends in CI. Consider adding a check to ensure the coverage meets a minimum threshold.
- Error Handling: The script includes error handling for cases where the coverage XML file is not generated. This is important for ensuring the CI pipeline doesn't fail silently.
- Unnecessary SonarCloud Properties: The removal of unnecessary SonarCloud properties simplifies the configuration and reduces potential conflicts.
Merge Readiness
The changes in this pull request appear to be well-implemented and address the stated issues. The updated coverage script and cleaned-up SonarCloud configuration should resolve the failing CI checks. I am unable to directly approve the pull request, and recommend that others review and approve this code before merging. I recommend merging this pull request after addressing the comments below.
| # Extract overall coverage percentage for GitHub output | ||
| if [ -f "coverage.xml" ]; then | ||
| echo "✅ coverage.xml file exists" | ||
|
|
||
| # Extract overall coverage percentage | ||
| COVERAGE=$(python -c "import xml.etree.ElementTree as ET; tree = ET.parse('coverage.xml'); root = tree.getroot(); line_rate = float(root.attrib['line-rate'])*100; print('{:.2f}%'.format(line_rate))") | ||
| echo "Overall coverage percentage: $COVERAGE" | ||
|
|
||
| # Set output for GitHub Actions | ||
| echo "percentage=$COVERAGE" >> $GITHUB_OUTPUT | ||
| else | ||
| echo "❌ coverage.xml file not generated!" | ||
| echo "percentage=0.00%" >> $GITHUB_OUTPUT | ||
| fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This section extracts the coverage percentage from the coverage.xml file and sets it as an output for GitHub Actions. It's good to see error handling for the case where the file doesn't exist. Consider adding a check to ensure the coverage percentage meets a minimum threshold, and fail the CI job if it doesn't.
if [ -f "coverage.xml" ]; then
echo "✅ coverage.xml file exists"
# Extract overall coverage percentage
COVERAGE=$(python -c "import xml.etree.ElementTree as ET; tree = ET.parse('coverage.xml'); root = tree.getroot(); line_rate = float(root.attrib['line-rate'])*100; print('{:.2f}%'.format(line_rate))")
echo "Overall coverage percentage: $COVERAGE"
# Set output for GitHub Actions
echo "percentage=$COVERAGE" >> $GITHUB_OUTPUT
# Check if coverage meets the minimum threshold (e.g., 80%)
MIN_COVERAGE=80.00
if (( $(echo "${COVERAGE%\%}< $MIN_COVERAGE" | bc -l) )); then
echo "❌ Coverage is below the minimum threshold of $MIN_COVERAGE%!"
exit 1 # Fail the CI job
else
echo "✅ Coverage meets the minimum threshold of $MIN_COVERAGE%!"
fi
else
echo "❌ coverage.xml file not generated!"
echo "percentage=0.00%" >> $GITHUB_OUTPUT
fi
Code Coverage Report📊 Current Coverage: 85.00% Detailed coverage analysis is available in SonarCloud Coverage Change DetailsThis shows code coverage for changes in this PR. To improve coverage, consider adding tests for new or modified code. |
|



This PR resolves SonarCloud scan failures by:\n\n1. Updating to the recommended sonarqube-scan-action instead of the deprecated SonarSource/sonarcloud-github-action\n2. Properly fixing the coverage script to run actual tests\n3. Cleaning up sonar-project.properties to remove unnecessary settings\n\nThis will fix the failing CI checks in PR #8.