File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -185,6 +185,25 @@ jobs:
185185 cat coverage/kcov/summary.md >> "${GITHUB_STEP_SUMMARY}"
186186 rm -rf "${KCOV_RAW_DIR}"
187187
188+ - name : Enforce BATS coverage threshold
189+ run : |
190+ set -euo pipefail
191+ # Minimum line coverage threshold (raise this as coverage improves).
192+ THRESHOLD=30
193+ COBERTURA="coverage/kcov/cobertura.xml"
194+ if [[ ! -f "${COBERTURA}" ]]; then
195+ echo "warning: ${COBERTURA} not found; skipping threshold check" >&2
196+ exit 0
197+ fi
198+ RATE=$(python3 -c "import xml.etree.ElementTree as ET; root=ET.parse('${COBERTURA}').getroot(); print(root.attrib.get('line-rate','0'))")
199+ PCT=$(python3 -c "print(f'{float(\"${RATE}\") * 100:.1f}')")
200+ echo "BATS line coverage: ${PCT}% (threshold: ${THRESHOLD}%)"
201+ python3 -c "import sys; sys.exit(0 if float('${RATE}') * 100 >= ${THRESHOLD} else 1)" || {
202+ echo "FAIL: coverage ${PCT}% is below ${THRESHOLD}% minimum" >&2
203+ exit 1
204+ }
205+ echo "PASS: coverage ${PCT}% >= ${THRESHOLD}%"
206+
188207 - name : Upload TAP results
189208 if : always()
190209 uses : actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
You can’t perform that action at this time.
0 commit comments