@@ -2,9 +2,6 @@ name: Code Coverage
22
33on :
44 pull_request :
5- branches :
6- - develop
7- - main
85 push :
96 branches :
107 - develop
4643 coverage : xdebug # Use Xdebug for coverage (PCOV was causing PHP to crash)
4744 tools : composer
4845
49- - name : Install SVN
50- run : sudo apt-get install subversion
46+ - name : Install SVN and XML tools
47+ run : |
48+ sudo apt-get update
49+ sudo apt-get install -y subversion libxml2-utils
5150
5251 - name : Install Composer dependencies
5352 uses : ramsey/composer-install@v2
@@ -130,10 +129,10 @@ jobs:
130129 # Extract overall coverage from coverage.xml (Clover format)
131130 # This avoids running PHPUnit twice - we already have coverage.xml from the first run
132131 if [ -f coverage.xml ]; then
133- # Extract metrics from Clover XML
134- # Use xmllint to get statements and coveredstatements attributes
135- STATEMENTS=$(xmllint --xpath 'string(//project/metrics/@statements)' coverage.xml 2>/dev/null || echo "0")
136- COVERED_STATEMENTS=$(xmllint --xpath 'string(//project/metrics/@coveredstatements)' coverage.xml 2>/dev/null || echo "0")
132+ # Extract metrics from Clover XML using xmllint
133+ # Fallback to Python if xmllint fails
134+ STATEMENTS=$(xmllint --xpath 'string(//project/metrics/@statements)' coverage.xml 2>/dev/null || python3 -c "import xml.etree.ElementTree as ET; tree = ET.parse('coverage.xml'); metrics = tree.find('.//project/metrics'); print(metrics.get('statements', '0') if metrics is not None else '0')" 2>/dev/null || echo "0")
135+ COVERED_STATEMENTS=$(xmllint --xpath 'string(//project/metrics/@coveredstatements)' coverage.xml 2>/dev/null || python3 -c "import xml.etree.ElementTree as ET; tree = ET.parse('coverage.xml'); metrics = tree.find('.//project/metrics'); print(metrics.get('coveredstatements', '0') if metrics is not None else '0')" 2>/dev/null || echo "0")
137136
138137 # Calculate coverage percentage
139138 if [ "$STATEMENTS" != "0" ] && [ -n "$STATEMENTS" ] && [ -n "$COVERED_STATEMENTS" ]; then
@@ -201,9 +200,10 @@ jobs:
201200
202201 # Extract overall coverage from base-coverage.xml (Clover format)
203202 if [ -f base-coverage.xml ]; then
204- # Extract metrics from Clover XML
205- STATEMENTS=$(xmllint --xpath 'string(//project/metrics/@statements)' base-coverage.xml 2>/dev/null || echo "0")
206- COVERED_STATEMENTS=$(xmllint --xpath 'string(//project/metrics/@coveredstatements)' base-coverage.xml 2>/dev/null || echo "0")
203+ # Extract metrics from Clover XML using xmllint
204+ # Fallback to Python if xmllint fails
205+ STATEMENTS=$(xmllint --xpath 'string(//project/metrics/@statements)' base-coverage.xml 2>/dev/null || python3 -c "import xml.etree.ElementTree as ET; tree = ET.parse('base-coverage.xml'); metrics = tree.find('.//project/metrics'); print(metrics.get('statements', '0') if metrics is not None else '0')" 2>/dev/null || echo "0")
206+ COVERED_STATEMENTS=$(xmllint --xpath 'string(//project/metrics/@coveredstatements)' base-coverage.xml 2>/dev/null || python3 -c "import xml.etree.ElementTree as ET; tree = ET.parse('base-coverage.xml'); metrics = tree.find('.//project/metrics'); print(metrics.get('coveredstatements', '0') if metrics is not None else '0')" 2>/dev/null || echo "0")
207207
208208 # Calculate coverage percentage
209209 if [ "$STATEMENTS" != "0" ] && [ -n "$STATEMENTS" ] && [ -n "$COVERED_STATEMENTS" ]; then
0 commit comments