Skip to content
This repository was archived by the owner on Apr 23, 2025. It is now read-only.

Commit 915ec20

Browse files
authored
Fix: Restore accurate test coverage reporting in CI pipeline (#14)
1 parent 48ab2b8 commit 915ec20

4 files changed

Lines changed: 9 additions & 35 deletions

File tree

.coveragerc

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
[run]
22
source = src.cli_code
3-
include =
4-
*/src/cli_code/tools/test_runner.py
5-
*/src/cli_code/models/gemini.py
63
omit =
74
*/.rules/*
85
*/.venv/*

.github/workflows/python-ci.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -87,19 +87,19 @@ jobs:
8787
run: |
8888
# Set CI variables
8989
export CI_TEST_TIMEOUT=120
90-
export CI_EXIT_ON_TEST_FAILURE=0
90+
export CI_EXIT_ON_TEST_FAILURE=1
9191
9292
# Run directly without using bash to make error handling clearer
9393
bash -ex ./scripts/run_coverage_ci.sh || echo "Coverage generation had errors but we'll continue"
9494
95-
# Generate dummy coverage if needed
96-
if [ ! -f "coverage.xml" ]; then
97-
echo "Creating placeholder coverage.xml file"
98-
echo '<?xml version="1.0" ?><coverage version="7.3.2" timestamp="1713166921" lines-valid="100" lines-covered="85" line-rate="0.85" branches-valid="0" branches-covered="0" branch-rate="0" complexity="0"><sources><source>/Users/runner/work/cli-code/cli-code/src</source></sources><packages><package name="cli_code" line-rate="0.85" branch-rate="0" complexity="0"><classes><class name="__init__.py" filename="cli_code/__init__.py" complexity="0" line-rate="0.85" branch-rate="0"></class></classes></package></packages></coverage>' > coverage.xml
95+
# Extract actual coverage percentage from XML file
96+
if [ -f "coverage.xml" ]; then
97+
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))")
98+
echo "percentage=$COVERAGE" >> $GITHUB_OUTPUT
99+
else
100+
echo "Warning: No coverage.xml file was generated"
101+
echo "percentage=0.00%" >> $GITHUB_OUTPUT
99102
fi
100-
101-
# Set a fixed coverage percentage for PR comment
102-
echo "percentage=85.00%" >> $GITHUB_OUTPUT
103103
104104
- name: Comment PR with code coverage
105105
if: github.event_name == 'pull_request'

pr_description.md

Lines changed: 0 additions & 23 deletions
This file was deleted.

scripts/run_coverage_ci.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ echo "Starting coverage generation for CI..."
1010
mkdir -p coverage_html
1111

1212
# Set environment variables for CI
13-
export CI_EXIT_ON_TEST_FAILURE=0 # Don't exit on test failures in CI
13+
export CI_EXIT_ON_TEST_FAILURE=1 # Exit on test failures to ensure code quality
1414
export CI_TEST_TIMEOUT=60 # Default timeout
1515

1616
# Special handling for GitHub Actions environment

0 commit comments

Comments
 (0)