Skip to content

Commit e07d8a7

Browse files
authored
feat(ci): Beater Eval Gate GitHub Action — pass/fail/inconclusive PR verdicts (#154) (#553)
Ships the turnkey eval-CI GitHub Action from #154: a repo-root composite action.yml wrapping beaterctl gate-run with pass/fail/inconclusive verdicts, step-summary + sticky PR comment rendering (effect size, CI, p-value, MDE/required_n when underpowered), demo-fixture seeding, report-only mode, and an end-to-end proof workflow. Also carries docs/issue-backlog-audit-2026-07-01.md.
1 parent 6de79b3 commit e07d8a7

7 files changed

Lines changed: 1021 additions & 0 deletions

File tree

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
name: eval-gate-action
2+
3+
# Proof gate for the repo-root "Beater Eval Gate" composite action (#154).
4+
#
5+
# Two layers, so a regression in either the renderer or the action wiring
6+
# cannot land silently:
7+
# 1. `render-selfcheck` exercises render_verdict.py against synthetic
8+
# reports covering all three GateDecision variants (pass /
9+
# fail_regression / inconclusive) — fast, no Rust build.
10+
# 2. `action-selftest` runs the action itself end-to-end in demo-fixture
11+
# mode (`beaterctl gate-run-fixture` seeds a gate whose latest
12+
# experiment is a regression) and asserts the emitted outputs:
13+
# verdict=fail, passed=false. `fail-on-gate-failure: false` keeps the
14+
# failing verdict from failing the selftest step itself.
15+
16+
# Supersede an in-flight run when a PR branch is pushed again, so the shared CI
17+
# runner pool is not starved by stacked redundant runs. main pushes are never
18+
# cancelled (their CI history must stay complete).
19+
concurrency:
20+
group: ${{ github.workflow }}-${{ github.ref }}
21+
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
22+
23+
on:
24+
pull_request:
25+
paths:
26+
- "action.yml"
27+
- "scripts/gate-action/**"
28+
- ".github/workflows/eval-gate-action.yml"
29+
merge_group:
30+
push:
31+
branches: [main]
32+
workflow_dispatch:
33+
34+
permissions:
35+
contents: read
36+
37+
env:
38+
CARGO_NET_RETRY: "10"
39+
CARGO_HTTP_MULTIPLEXING: "false"
40+
RUST_BACKTRACE: "1"
41+
42+
jobs:
43+
render-selfcheck:
44+
name: renderer self-check
45+
runs-on: ubuntu-latest
46+
timeout-minutes: 5
47+
steps:
48+
- name: Checkout
49+
uses: actions/checkout@v7
50+
- name: Render all three verdicts from synthetic reports
51+
run: python3 scripts/gate-action/test_render.py
52+
53+
action-selftest:
54+
name: action end-to-end (demo fixture)
55+
runs-on: ubuntu-latest
56+
timeout-minutes: 30
57+
steps:
58+
- name: Checkout
59+
uses: actions/checkout@v7
60+
- name: Install Rust
61+
run: rustup toolchain install stable --profile minimal && rustup default stable
62+
# Debug profile: the fixture workload is milliseconds of SQLite, so
63+
# build time dominates and release optimization buys nothing here.
64+
# Passing beaterctl-path also exercises the prebuilt-binary input.
65+
- name: Build beaterctl
66+
run: cargo build -q -p beaterctl
67+
- name: Run the eval gate action against the demo fixture
68+
id: gate
69+
uses: ./
70+
with:
71+
data-dir: ${{ runner.temp }}/beater-selftest
72+
demo-fixture: "true"
73+
beaterctl-path: target/debug/beaterctl
74+
# The fixture's latest experiment is a regression on purpose; the
75+
# selftest asserts on outputs instead of failing the step.
76+
fail-on-gate-failure: "false"
77+
comment-tag: selftest
78+
- name: Assert the fixture regression produced verdict=fail
79+
env:
80+
VERDICT: ${{ steps.gate.outputs.verdict }}
81+
PASSED: ${{ steps.gate.outputs.passed }}
82+
DECISION: ${{ steps.gate.outputs.decision }}
83+
REASON: ${{ steps.gate.outputs.reason }}
84+
REPORT_PATH: ${{ steps.gate.outputs.report-path }}
85+
run: |
86+
set -euo pipefail
87+
echo "verdict=${VERDICT} passed=${PASSED} decision=${DECISION}"
88+
test "${VERDICT}" = "fail"
89+
test "${PASSED}" = "false"
90+
test "${DECISION}" = "fail_regression"
91+
test -n "${REASON}"
92+
test -s "${REPORT_PATH}"

‎README.md‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,12 @@ $t$ / exact McNemar, bootstrap CIs, sequential e-values, CUPED) live in
136136
[`crates/beater-stats`](crates/beater-stats/src/lib.rs); the gate wiring is in
137137
[`crates/beater-experiments/src/rsi.rs`](crates/beater-experiments/src/rsi.rs).
138138

139+
The same gate runs as a GitHub Action: `uses: jadenfix/beater@main` posts a
140+
pass / fail / **inconclusive** verdict — with effect size, CI, $p$-value, and
141+
"how many more cases would make this conclusive" when underpowered — as a PR
142+
comment, with no server and no API keys. See
143+
[`docs/eval-gate-action.md`](docs/eval-gate-action.md).
144+
139145
## Repository map
140146

141147
| Path | Purpose |

‎action.yml‎

Lines changed: 215 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,215 @@
1+
name: "Beater Eval Gate"
2+
description: >-
3+
Run a Beater statistical eval gate in CI and post a pass / fail /
4+
INCONCLUSIVE verdict — with effect size, confidence interval, p-value, and
5+
(when underpowered) the minimum detectable effect and how many more cases
6+
would make the comparison conclusive — to the step summary and, optionally,
7+
a sticky PR comment. Runs entirely against the local `--data-dir` store:
8+
no Beater server, no API keys.
9+
author: "Beater"
10+
branding:
11+
icon: "check-circle"
12+
color: "green"
13+
14+
inputs:
15+
data-dir:
16+
description: >-
17+
Beater data directory holding gates.sqlite / experiments.sqlite,
18+
produced by the eval steps earlier in the job (or by demo-fixture mode).
19+
required: false
20+
default: ".beater"
21+
tenant-id:
22+
description: "Tenant id the gate belongs to."
23+
required: false
24+
default: "demo"
25+
project-id:
26+
description: "Project id the gate belongs to."
27+
required: false
28+
default: "demo"
29+
gate-id:
30+
description: "Gate id to run."
31+
required: false
32+
default: "main"
33+
experiment-run-id:
34+
description: >-
35+
Specific experiment run to gate on. Empty = the gate's latest
36+
experiment run.
37+
required: false
38+
default: ""
39+
beaterctl-path:
40+
description: >-
41+
Path to a prebuilt beaterctl binary. Empty = build it from this
42+
action's checkout with cargo (requires a Rust toolchain on the runner;
43+
the first uncached build is slow — prefer a prebuilt binary or a cargo
44+
cache in latency-sensitive workflows).
45+
required: false
46+
default: ""
47+
demo-fixture:
48+
description: >-
49+
"true" seeds the deterministic demo gate + experiments
50+
(`beaterctl gate-run-fixture`) into data-dir before running. Zero-config
51+
demo/self-test mode; uses tenant/project/gate demo/demo/main.
52+
required: false
53+
default: "false"
54+
fail-on-gate-failure:
55+
description: >-
56+
"true" (default) fails the step when the gate does not pass, so the
57+
gate can be a required check. "false" always succeeds and only reports
58+
— the verdict is still available via outputs.
59+
required: false
60+
default: "true"
61+
github-token:
62+
description: >-
63+
Token used to upsert a sticky verdict comment on the pull request.
64+
Empty = no comment (the step summary is always written). Needs
65+
`pull-requests: write`.
66+
required: false
67+
default: ""
68+
comment-tag:
69+
description: >-
70+
Marker distinguishing this gate's sticky comment when a workflow runs
71+
several gates on one PR.
72+
required: false
73+
default: "default"
74+
75+
outputs:
76+
verdict:
77+
description: "pass | fail | inconclusive"
78+
value: ${{ steps.render.outputs.verdict }}
79+
passed:
80+
description: "true when the gate passed under its inconclusive policy"
81+
value: ${{ steps.render.outputs.passed }}
82+
decision:
83+
description: "Raw GateDecision: pass | fail_regression | inconclusive"
84+
value: ${{ steps.render.outputs.decision }}
85+
reason:
86+
description: "The gate's human-readable reason string"
87+
value: ${{ steps.render.outputs.reason }}
88+
report-path:
89+
description: "Path to the raw gate-run JSON report"
90+
value: ${{ steps.gate.outputs.report-path }}
91+
92+
# Every `${{ inputs.* }}` below is passed to bash via `env:`, never spliced
93+
# into the script text: interpolation into a `run:` body happens before bash
94+
# parses it, so a crafted input value could otherwise inject shell commands.
95+
runs:
96+
using: "composite"
97+
steps:
98+
- name: Resolve beaterctl
99+
id: resolve
100+
shell: bash
101+
env:
102+
BEATERCTL_INPUT: ${{ inputs.beaterctl-path }}
103+
run: |
104+
set -euo pipefail
105+
if [ -n "$BEATERCTL_INPUT" ]; then
106+
BEATERCTL="$BEATERCTL_INPUT"
107+
else
108+
echo "::group::Building beaterctl from ${GITHUB_ACTION_PATH}"
109+
# Pin --target-dir: a consumer job exporting CARGO_TARGET_DIR would
110+
# otherwise relocate the build and break the path below.
111+
cargo build --release -q -p beaterctl \
112+
--manifest-path "${GITHUB_ACTION_PATH}/Cargo.toml" \
113+
--target-dir "${GITHUB_ACTION_PATH}/target"
114+
echo "::endgroup::"
115+
BEATERCTL="${GITHUB_ACTION_PATH}/target/release/beaterctl"
116+
fi
117+
"$BEATERCTL" --help >/dev/null
118+
echo "beaterctl=$BEATERCTL" >> "$GITHUB_OUTPUT"
119+
120+
- name: Seed demo fixture
121+
if: ${{ inputs.demo-fixture == 'true' }}
122+
shell: bash
123+
env:
124+
BEATERCTL: ${{ steps.resolve.outputs.beaterctl }}
125+
DATA_DIR: ${{ inputs.data-dir }}
126+
run: |
127+
set -euo pipefail
128+
"$BEATERCTL" gate-run-fixture --data-dir "$DATA_DIR" >/dev/null
129+
130+
- name: Run the gate
131+
id: gate
132+
shell: bash
133+
env:
134+
BEATERCTL: ${{ steps.resolve.outputs.beaterctl }}
135+
DATA_DIR: ${{ inputs.data-dir }}
136+
TENANT_ID: ${{ inputs.tenant-id }}
137+
PROJECT_ID: ${{ inputs.project-id }}
138+
GATE_ID: ${{ inputs.gate-id }}
139+
EXPERIMENT_RUN_ID: ${{ inputs.experiment-run-id }}
140+
run: |
141+
set -euo pipefail
142+
REPORT="$(mktemp "${RUNNER_TEMP}/beater-gate-report.XXXXXX.json")"
143+
ARGS=(gate-run
144+
--data-dir "$DATA_DIR"
145+
--tenant-id "$TENANT_ID"
146+
--project-id "$PROJECT_ID"
147+
--gate-id "$GATE_ID")
148+
if [ -n "$EXPERIMENT_RUN_ID" ]; then
149+
ARGS+=(--experiment-run-id "$EXPERIMENT_RUN_ID")
150+
fi
151+
# gate-run exits 1 on a non-passing gate; capture instead of aborting
152+
# so the verdict is rendered either way.
153+
GATE_EXIT=0
154+
"$BEATERCTL" "${ARGS[@]}" > "$REPORT" || GATE_EXIT=$?
155+
if [ ! -s "$REPORT" ]; then
156+
echo "gate-run produced no report (exit ${GATE_EXIT})" >&2
157+
exit "$GATE_EXIT"
158+
fi
159+
echo "report-path=$REPORT" >> "$GITHUB_OUTPUT"
160+
161+
- name: Render verdict
162+
id: render
163+
shell: bash
164+
env:
165+
REPORT: ${{ steps.gate.outputs.report-path }}
166+
COMMENT_TAG: ${{ inputs.comment-tag }}
167+
run: |
168+
set -euo pipefail
169+
COMMENT_FILE="$(mktemp "${RUNNER_TEMP}/beater-gate-comment.XXXXXX.md")"
170+
python3 "${GITHUB_ACTION_PATH}/scripts/gate-action/render_verdict.py" \
171+
--report "$REPORT" \
172+
--summary "$GITHUB_STEP_SUMMARY" \
173+
--outputs "$GITHUB_OUTPUT" \
174+
--comment-file "$COMMENT_FILE" \
175+
--comment-tag "$COMMENT_TAG"
176+
echo "comment-file=$COMMENT_FILE" >> "$GITHUB_OUTPUT"
177+
178+
- name: Upsert sticky PR comment
179+
if: ${{ inputs.github-token != '' && github.event_name == 'pull_request' }}
180+
shell: bash
181+
env:
182+
GH_TOKEN: ${{ inputs.github-token }}
183+
PR_NUMBER: ${{ github.event.pull_request.number }}
184+
# Built as an env value (not spliced into the script), and matched in
185+
# jq via env.MARKER so quotes/backslashes in the tag cannot break the
186+
# filter program.
187+
MARKER: "<!-- beater-eval-gate:${{ inputs.comment-tag }} -->"
188+
BODY_FILE: ${{ steps.render.outputs.comment-file }}
189+
run: |
190+
set -euo pipefail
191+
EXISTING=$(gh api "repos/${GITHUB_REPOSITORY}/issues/${PR_NUMBER}/comments" \
192+
--paginate --jq '.[] | select(.body | startswith(env.MARKER)) | .id' | head -n1)
193+
if [ -n "$EXISTING" ]; then
194+
gh api --method PATCH \
195+
"repos/${GITHUB_REPOSITORY}/issues/comments/${EXISTING}" \
196+
-F "body=@${BODY_FILE}" >/dev/null
197+
else
198+
gh api --method POST \
199+
"repos/${GITHUB_REPOSITORY}/issues/${PR_NUMBER}/comments" \
200+
-F "body=@${BODY_FILE}" >/dev/null
201+
fi
202+
203+
- name: Enforce gate result
204+
if: ${{ inputs.fail-on-gate-failure == 'true' }}
205+
shell: bash
206+
env:
207+
PASSED: ${{ steps.render.outputs.passed }}
208+
VERDICT: ${{ steps.render.outputs.verdict }}
209+
REASON: ${{ steps.render.outputs.reason }}
210+
run: |
211+
set -euo pipefail
212+
if [ "$PASSED" != "true" ]; then
213+
echo "Beater eval gate verdict: ${VERDICT} — ${REASON}" >&2
214+
exit 1
215+
fi

0 commit comments

Comments
 (0)