40 lines
1.6 KiB
Bash
Executable File
40 lines
1.6 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Author: Guoliang Chen, a Senior Digital Design Engineer
|
|
# CI gate over the corpus score: fail on any regression from the recorded
|
|
# baseline. `scripts/corpus-baseline` holds the passing-file count the tree
|
|
# must sustain; a verification error or a crash fails regardless of the
|
|
# count — those are formatter bugs by definition (see tools/corpus_check.sh).
|
|
#
|
|
# Usage: scripts/corpus_gate.sh [corpus-dir]
|
|
#
|
|
# An improvement does not fail, it nags: bump the baseline in the same
|
|
# change that earns it, so the gate ratchets and never slides back.
|
|
|
|
set -eu
|
|
|
|
here=$(cd "$(dirname "$0")" && pwd)
|
|
corpus=${1:-corpus}
|
|
baseline=$(cat "$here/corpus-baseline")
|
|
|
|
command -v jq >/dev/null 2>&1 || { echo "FAIL: jq is required to parse corpus score JSON" >&2; exit 2; }
|
|
|
|
json=$("$here/score.sh" "$corpus")
|
|
printf '%s\n' "$json"
|
|
|
|
passing=$(printf '%s' "$json" | jq .passing)
|
|
verr=$(printf '%s' "$json" | jq '.failures_by_category["verification-error"] // 0')
|
|
crash=$(printf '%s' "$json" | jq '.failures_by_category.crash // 0')
|
|
|
|
status=0
|
|
[ "$verr" -eq 0 ] || { echo "FAIL: $verr verification error(s) — always a formatter bug" >&2; status=1; }
|
|
[ "$crash" -eq 0 ] || { echo "FAIL: $crash crash(es) — always a formatter bug" >&2; status=1; }
|
|
if [ "$passing" -lt "$baseline" ]; then
|
|
echo "FAIL: corpus regression — $passing passing, baseline is $baseline" >&2
|
|
status=1
|
|
elif [ "$passing" -gt "$baseline" ]; then
|
|
echo "note: $passing passing beats the baseline $baseline — bump scripts/corpus-baseline"
|
|
fi
|
|
exit $status
|
|
|
|
# Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love, luciochen.com
|