Skip to content

Commit 14f7888

Browse files
committed
Merge branch 'feat/agent-skills-rebuild' into fix/async-blocking-cleanup
2 parents 39c8035 + 251b397 commit 14f7888

2 files changed

Lines changed: 36 additions & 5 deletions

File tree

agent-skills/run-quality-gate/SKILL.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,13 @@ stack already running (`docker-compose up -d db`; `pre-commit`, `frontend`,
2222

2323
Run the cheap gates (`pre-commit` ~6s, `bun run ts` 2–3s) freely; run the
2424
expensive gates (`build` ~78s, `pytest` ~96s) once per PR, right before push —
25-
not on every edit. One shortcut: `test-backend.yml` reruns pytest in CI on
26-
every push touching `backend/**`, so a local pytest re-run right before such a
27-
push just waits twice for the same answer; no equivalent CI job covers
28-
`bun run build` outside previews/deploys.
25+
not on every edit. The script automates one shortcut itself: when HEAD is
26+
exactly the pushed tip (clean `backend/` worktree) and CI's `test-backend.yml`
27+
already completed for that SHA, it reuses CI's verdict instead of running
28+
pytest locally — the summary line says so when it happens. A CI *failure* for
29+
the pushed SHA still runs pytest locally (fresh log) and prints a pointer to
30+
the CI record. No equivalent CI job covers `bun run build` outside
31+
previews/deploys, so the build gate always runs locally.
2932

3033
## ESLint is deliberately not a gate
3134

agent-skills/run-quality-gate/scripts/run-gates.sh

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,38 @@ if [ "${run_frontend}" = true ]; then
8484
build_pid=$!
8585
fi
8686

87+
# CI-reuse: when HEAD is exactly what's pushed (clean backend/ worktree, local
88+
# tip == remote tip) and the test-backend workflow already completed for that
89+
# SHA, reuse CI's verdict instead of a duplicate multi-minute local run. One
90+
# gh call inside this script — no extra agent round-trips. Any doubt (dirty
91+
# tree, unpushed commits, gh missing, run still in progress) falls through to
92+
# a normal local run.
93+
ci_verdict=""
94+
if [ "${run_backend}" = true ] && command -v gh >/dev/null 2>&1 \
95+
&& [ -z "$(git status --porcelain -- backend/ 2>/dev/null)" ]; then
96+
head_sha="$(git rev-parse HEAD)"
97+
branch_name="$(git rev-parse --abbrev-ref HEAD)"
98+
remote_sha="$(git ls-remote origin "refs/heads/${branch_name}" 2>/dev/null | cut -f1)"
99+
if [ "${remote_sha}" = "${head_sha}" ]; then
100+
ci_verdict="$(gh run list --commit "${head_sha}" --workflow test-backend.yml \
101+
--json status,conclusion --jq \
102+
'first(.[] | select(.status == "completed")) | .conclusion // empty' \
103+
2>/dev/null || true)"
104+
fi
105+
fi
106+
87107
pytest_status=0
88108
pytest_pid=""
89109
pytest_ran=false
90-
if [ "${run_backend}" = true ]; then
110+
if [ "${run_backend}" = true ] && [ "${ci_verdict}" = "success" ]; then
111+
pytest_ran=true
112+
echo "backend pytest: PASS (reusing CI test-backend run for pushed HEAD $(git rev-parse --short HEAD); local run skipped)"
113+
echo "CI verdict reused; see: gh run list --commit $(git rev-parse HEAD)" >"${pytest_log}"
114+
elif [ "${run_backend}" = true ]; then
115+
if [ "${ci_verdict}" = "failure" ]; then
116+
echo "note: CI test-backend FAILED for this exact commit — check the CI record" \
117+
"(gh run list --commit $(git rev-parse HEAD)); running locally anyway for a fresh log."
118+
fi
91119
pytest_ran=true
92120
echo "Starting backend pytest in background..."
93121
docker-compose exec -T backend pytest >"${pytest_log}" 2>&1 &

0 commit comments

Comments
 (0)