Skip to content

Commit 6d825e4

Browse files
chore: promote testing to main (#1043)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent 6913198 commit 6d825e4

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

.github/workflows/pr-validation.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)