Skip to content

Commit 11b1ade

Browse files
ci: add npm run gate local gate + stale-green guard (#101)
Squash-merged during triage: adds up-to-date-with-base stale-green guard to CI.
1 parent 09644f5 commit 11b1ade

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,28 @@ on:
77
branches: [main]
88

99
jobs:
10+
# Stale-green guard. A PR can show a green CI run that was executed BEFORE a
11+
# breaking commit landed on the base branch — merging it would ship a broken
12+
# main. This job FAILS if the PR branch does not contain origin/<base> as an
13+
# ancestor, forcing an "Update branch" before the PR can merge.
14+
up-to-date-with-base:
15+
runs-on: ubuntu-latest
16+
if: github.event_name == 'pull_request'
17+
steps:
18+
- uses: actions/checkout@v5
19+
with:
20+
fetch-depth: 0
21+
- name: Fail if PR branch is behind its base branch
22+
run: |
23+
BASE="${{ github.event.pull_request.base.ref }}"
24+
git fetch origin "${BASE}" --depth=1
25+
if git merge-base --is-ancestor "origin/${BASE}" HEAD; then
26+
echo "PR branch contains origin/${BASE} — up to date."
27+
else
28+
echo "::error::PR branch is behind origin/${BASE}. Update the branch (merge/rebase ${BASE}) and re-run CI so it validates against current base."
29+
exit 1
30+
fi
31+
1032
build-and-test:
1133
runs-on: ubuntu-latest
1234
steps:
@@ -18,6 +40,9 @@ jobs:
1840
cache: 'npm'
1941

2042
- run: npm ci
43+
# `npm run build` runs `tsc && vite build && node scripts/prerender.mjs`.
44+
# The prerender step is part of CI — a local `vite build` alone is NOT a
45+
# valid gate. `npm run gate` (package.json) runs this exact sequence.
2146
- run: npm run build
2247
- run: npm test
2348

0 commit comments

Comments
 (0)