Skip to content

Commit 4e0e837

Browse files
ci: add make gate (local==CI gate) + stale-green PR guard
The local gate must run EXACTLY what CI runs. This session: fix agents verified work with a partial local gate, and stale-but-green PRs nearly shipped a broken base. - Makefile: new `gate` target = `go build ./... && go vet ./... && go test ./... -short -count=1` — the exact sequence deploy.yml's test step runs (build+vet are a fast-fail superset). One command whose green result == a green CI test step. - ci.yml: trigger fixed `main` -> `master` (this repo's default branch; the PR/push triggers never fired before). New `up-to-date-with-base` job fails a PR whose branch does not contain `origin/<base>` as an ancestor (git merge-base --is-ancestor), so a stale-green PR goes red and must update-branch before merge. Verified: `make gate` runs clean locally (build + vet + all tests pass). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 02536f5 commit 4e0e837

2 files changed

Lines changed: 35 additions & 3 deletions

File tree

.github/workflows/ci.yml

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,33 @@ name: CI
22

33
on:
44
push:
5-
branches: [main]
5+
branches: [master]
66
pull_request:
7-
branches: [main]
7+
branches: [master]
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+
# master. This job FAILS if the PR branch does not contain origin/<base> as
13+
# an 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@v4
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:

Makefile

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.PHONY: build test docker-build run smoke-buildinfo
1+
.PHONY: build test gate docker-build run smoke-buildinfo
22

33
# Build-time metadata injected into instant.dev/common/buildinfo via -ldflags.
44
# Override on the make line if needed. GIT_SHA falls back to "dev" when not
@@ -13,6 +13,16 @@ build:
1313
test:
1414
go test ./... -race -count=1
1515

16+
# PR/deploy gate: runs EXACTLY what .github/workflows/deploy.yml runs as its
17+
# test gate (`go test ./... -short -count=1`, see the deploy.yml "Run unit
18+
# tests" step), preceded by build + vet as a fast-fail. A green `make gate`
19+
# locally == a green CI test step — the local gate cannot pass while CI fails.
20+
gate:
21+
go build ./...
22+
go vet ./...
23+
go test ./... -short -count=1
24+
@echo "gate: green — matches deploy.yml test step"
25+
1626
docker-build:
1727
docker build -f Dockerfile -t instant-worker:local \
1828
--build-arg GIT_SHA=$(GIT_SHA) \

0 commit comments

Comments
 (0)