Skip to content
This repository was archived by the owner on Apr 23, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
[run]
source = src.cli_code
include =
*/src/cli_code/*.py
*/src/cli_code/*/*.py
*/src/cli_code/*/*/*.py
omit =
*/.rules/*
*/.venv/*
Expand All @@ -10,6 +14,9 @@ omit =
*/venv/*
*/.pytest_cache/*
*/site-packages/*
# Excluded as it primarily contains integration code with external dependencies
# that is difficult to test without mocking the entire Ollama API
*/src/cli_code/models/ollama.py

[report]
exclude_lines =
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/python-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ jobs:
-Dsonar.sourceEncoding=UTF-8
-Dsonar.verbose=true
-Dsonar.scm.provider=git
-Dsonar.coverage.jacoco.xmlReportPaths=coverage.xml
-Dsonar.newCode.referenceBranch=origin/main

# Add specific PR properties based on GitHub context
- name: SonarCloud PR Analysis
Expand All @@ -158,6 +160,8 @@ jobs:
-Dsonar.pullrequest.key=${{ github.event.pull_request.number }}
-Dsonar.pullrequest.branch=${{ github.head_ref }}
-Dsonar.pullrequest.base=${{ github.base_ref }}
-Dsonar.python.coverage.reportPaths=coverage.xml
-Dsonar.coverage.jacoco.xmlReportPaths=coverage.xml

- name: Report SonarCloud Results
run: |
Expand Down
6 changes: 3 additions & 3 deletions scripts/run_coverage_ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ run_test_group "remaining" \
echo "Generating final coverage report..." | tee -a "$SUMMARY_LOG"
python -m pytest \
--cov=src.cli_code \
--cov-append \
--cov-report=xml:coverage.xml \
--cov-report=html:coverage_html \
--cov-report=term
Expand Down Expand Up @@ -295,9 +296,8 @@ fi

echo "Coverage generation for CI completed." | tee -a "$SUMMARY_LOG"

# Determine exit code based on errors and CI environment
# In CI we might want to exit gracefully for some failures
CI_EXIT_ON_TEST_FAILURE=${CI_EXIT_ON_TEST_FAILURE:-1}
# Use the CI_EXIT_ON_TEST_FAILURE value set at the beginning of the script (=1)
# to determine whether to exit with an error code on test failures

if [ $FAILED_TESTS -gt 0 -o $TIMED_OUT_TESTS -gt 0 ]; then
echo "Test run had $FAILED_TESTS failing tests and $TIMED_OUT_TESTS timed out tests" | tee -a "$SUMMARY_LOG"
Expand Down
8 changes: 8 additions & 0 deletions sonar-project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,16 @@ sonar.tests=test_dir
sonar.python.coverage.reportPaths=coverage.xml

# Configure test coverage exclusions
# ollama.py is excluded as it primarily contains integration code with external dependencies
# that is difficult to test without mocking the entire Ollama API
sonar.coverage.exclusions=test_dir/**/*,tests/**/*,src/cli_code/models/ollama.py

# Force SonarCloud to see all files as new code to get proper coverage metrics
# Note: We're using this temporarily to establish accurate baseline coverage
# TODO: Remove this line after initial coverage baseline is established to ensure
# future PRs are evaluated correctly for new code coverage
sonar.newCode.referenceBranch=origin/main

# Specify Python version
sonar.python.version=3.11

Expand Down