This repository was archived by the owner on Apr 23, 2025. It is now read-only.
forked from raizamartin/gemini-code
-
Notifications
You must be signed in to change notification settings - Fork 0
Fix SonarCloud scan issues #9
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,59 +1,38 @@ | ||
| #!/bin/bash | ||
| # Ultra-simplified coverage script that definitely won't fail | ||
| # Script to generate coverage for CI pipeline | ||
|
|
||
| # Print commands for debugging | ||
| set -x | ||
| set -e # Exit on error | ||
|
|
||
| echo "Generating minimal coverage report for SonarCloud..." | ||
| echo "Starting coverage generation for CI..." | ||
|
|
||
| # Create a coverage directory for HTML report | ||
| # Set up coverage directory | ||
| mkdir -p coverage_html | ||
|
|
||
| # Create a simple HTML coverage report | ||
| cat > coverage_html/index.html << EOF | ||
| <!DOCTYPE html> | ||
| <html> | ||
| <head><title>Coverage Report</title></head> | ||
| <body> | ||
| <h1>Coverage Report</h1> | ||
| <p>This is a simplified coverage report created for CI pipeline.</p> | ||
| </body> | ||
| </html> | ||
| EOF | ||
|
|
||
| # Create a SonarCloud-compatible coverage XML file | ||
| cat > coverage.xml << EOF | ||
| <?xml version="1.0" ?> | ||
| <coverage version="1"> | ||
| <file path="src/cli_code/tools/file_tools.py"> | ||
| <lineToCover lineNumber="1" covered="true"/> | ||
| <lineToCover lineNumber="2" covered="true"/> | ||
| <lineToCover lineNumber="3" covered="true"/> | ||
| <lineToCover lineNumber="4" covered="true"/> | ||
| <lineToCover lineNumber="5" covered="true"/> | ||
| </file> | ||
| <file path="src/cli_code/tools/directory_tools.py"> | ||
| <lineToCover lineNumber="1" covered="true"/> | ||
| <lineToCover lineNumber="2" covered="true"/> | ||
| <lineToCover lineNumber="3" covered="true"/> | ||
| <lineToCover lineNumber="4" covered="true"/> | ||
| <lineToCover lineNumber="5" covered="true"/> | ||
| </file> | ||
| <file path="src/cli_code/tools/system_tools.py"> | ||
| <lineToCover lineNumber="1" covered="true"/> | ||
| <lineToCover lineNumber="2" covered="true"/> | ||
| <lineToCover lineNumber="3" covered="true"/> | ||
| <lineToCover lineNumber="4" covered="true"/> | ||
| <lineToCover lineNumber="5" covered="true"/> | ||
| </file> | ||
| </coverage> | ||
| EOF | ||
|
|
||
| # Print generated coverage report for verification | ||
| echo "Coverage XML file content:" | ||
| cat coverage.xml | ||
|
|
||
| echo "✅ Successfully generated coverage report for SonarCloud." | ||
|
|
||
| # Always exit with success | ||
| exit 0 | ||
| # Run pytest with coverage enabled and generate reports | ||
| echo "Running test suite with coverage enabled..." | ||
| python -m pytest \ | ||
| --cov=src.cli_code \ | ||
| --cov-report=xml:coverage.xml \ | ||
| --cov-report=html:coverage_html \ | ||
| --cov-report=term \ | ||
| test_dir/test_file_tools.py test_dir/test_directory_tools.py test_dir/test_system_tools.py \ | ||
| test_dir/improved/test_quality_tools.py test_dir/improved/test_summarizer_tool.py test_dir/improved/test_tree_tool.py | ||
|
|
||
| echo "Coverage report generated in coverage.xml and coverage_html/" | ||
|
|
||
| # 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 | ||
|
|
||
| echo "Coverage generation for CI completed." | ||
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
Oops, something went wrong.
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.
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.