Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ The most common defect is a change that works on the path you tested and is miss

## Verifying

- **`make check-fast` before every push (mandatory).** It runs gofmt, `go vet`, golangci-lint, the test-location check and plain `go test` (no `-race`) on only the packages your changes can affect, plus the generators whose inputs changed, the `deploy/` module (vet, lint, names and `make deploy-vars`) when it, `.env.example` or the Makefile changed, the migration order when a migration changed (see "Migrations"), and `make vulncheck` when a `go.mod`, `go.sum`, `package.json` or `pnpm-lock.yaml` changed. Changes mean everything that differs from the merge base with origin/main: commits, staged, unstaged and untracked files, mapped to packages by `scripts/affected.sh` (`make affected` prints them), so a shared input (go.mod, tooling, lint config, migrations) checks everything. It takes seconds (a docs-only change: under a second; a full run: under 10 s warm), so it fits machines where a full `make ci` is not allowed. Database tests skip unless `TEST_DATABASE_URL` is set; `make test` runs them with `-race` against Postgres. `make hooks` installs a pre-push hook that runs it from every worktree of the clone (`make hooks-remove` undoes it; `git push --no-verify` skips it once, for emergencies only). Anything that runs git or go from a hook drops git's repository env first (`git rev-parse --local-env-vars`), as the hook and `scripts/check-fast.sh` do.
- **`make check-fast` before every push (mandatory).** It runs gofmt, golangci-lint (whose `govet` runs `go vet`'s analyzers), the test-location check and plain `go test` (no `-race`) on only the packages your changes can affect, plus the generators whose inputs changed, the `deploy/` module (lint, names and `make deploy-vars`) when it, `.env.example` or the Makefile changed, the migration order when a migration changed (see "Migrations"), and `make vulncheck` when a `go.mod`, `go.sum`, `package.json` or `pnpm-lock.yaml` changed. Changes mean everything that differs from the merge base with origin/main: commits, staged, unstaged and untracked files, mapped to packages by `scripts/affected.sh` (`make affected` prints them), so a shared input (go.mod, tooling, lint config, migrations) checks everything. It takes seconds (a docs-only change: under a second; a full run: under 10 s warm), so it fits machines where a full `make ci` is not allowed. Database tests skip unless `TEST_DATABASE_URL` is set; `make test` runs them with `-race` against Postgres. `make hooks` installs a pre-push hook that runs it from every worktree of the clone (`make hooks-remove` undoes it; `git push --no-verify` skips it once, for emergencies only). Anything that runs git or go from a hook drops git's repository env first (`git rev-parse --local-env-vars`), as the hook and `scripts/check-fast.sh` do.
- **Release smoke** (`make release-smoke`; run it whenever a build input changes: a Dockerfile, or code a Dockerfile's binary is built from): builds every binary that has a Dockerfile with that Dockerfile's own build-stage `ENV` and `RUN` line (`scripts/dockerfile-builds.sh` reads them, so never copy build flags elsewhere) and fails on a dynamically linked one, runs `server migrate` and `admin migrate` on fresh databases, and boots web and admin with `APP_ENV=production` and only the config production requires until `/healthz` answers 200. It catches what tests cannot: an image that will not start on distroless (a dependency that links dynamically even with `CGO_ENABLED=0`), and a production config that refuses to boot without an optional integration. A new required production setting goes in its env list.
- `make lint test` before every commit when you can run the full suite. `make ci` runs every check on the checkout as it is: build, generated-code diff (sqlc, mocks, templ), gofmt + golangci-lint, the test-location check, `go test -race` against a throwaway Postgres with per-boundary coverage floors, and the probes that prove the layering and test rules still bite (`make lint-layering lint-tests`). `make vulncheck` (also in `make ci`) fails on any known vulnerability in a dependency of any Go module or the mobile lockfile ([docs/CI.md](docs/CI.md#known-vulnerabilities)).
- **A pull request is verified locally, on its exact head, then attested (mandatory; [docs/CI.md](docs/CI.md)).** Run what the change needs ("What to run" there): for Go, `make lint test` scoped with `LINT_DIRS`/`TEST_PKGS` from `scripts/affected.sh`, plus `make check-generated`, `make check-migrations`, `make deploy-check`, `make actionlint` or `make release-smoke` for what you touched, `make ci` for a change to the tooling. Commit, push, then `make ci-local RAN="<what you ran>"` in the clean worktree. It runs nothing and takes seconds: it refuses a dirty, unpushed or already-failed head, posts the `local-ci` commit status and fills the PR body's "Local verification" section with your statement, which is never edited by hand. Every push or rebase needs a new attestation. Stack PRs and merge right away.
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ vulncheck: ## Known vulnerabilities: govulncheck (pinned) on every Go module + p
$(GO) run ./scripts/vulncheck $(ARGS)

.PHONY: check-fast
check-fast: ## Before every push: gofmt, vet, golangci-lint, plain tests for only what your changes vs origin/main affect (seconds)
check-fast: ## Before every push: gofmt, golangci-lint (incl. govet), plain tests for only what your changes vs origin/main affect (seconds)
./scripts/check-fast.sh

.PHONY: release-smoke
Expand Down
18 changes: 8 additions & 10 deletions scripts/check-fast.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
#!/usr/bin/env bash
# The pre-push check (`make check-fast`, and the hook `make hooks` installs):
# gofmt, go vet, golangci-lint and plain go test for only the packages this
# checkout's changes can affect, the generators whose inputs changed, and the
# deploy/ module when it changed, the migration order when a migration
# changed, and make vulncheck when a dependency manifest or lockfile changed. "Changes" are everything that differs from
# gofmt, golangci-lint (its govet runs go vet's analyzers, so no separate go
# vet) and plain go test for only the packages this checkout's changes can
# affect, the generators whose inputs changed, the deploy/ module when it
# changed, the migration order when a migration changed, and make vulncheck
# when a dependency manifest or lockfile changed. "Changes" are everything that differs from
# the merge base with origin/main (scripts/branches.sh): commits, staged, unstaged and untracked
# files. scripts/affected.sh maps them to packages (as make affected prints them), so a
# change to a shared input (go.mod, tooling, lint config, migrations,
# generator config) checks everything.
#
# No -race and no Postgres: database tests skip unless TEST_DATABASE_URL is
# set; make test runs -race against Postgres. It catches what fails it most often
# (format, lint, vet, a broken test, stale generated code) in seconds.
# (format, lint, a broken test, stale generated code) in seconds.
#
# Usage: scripts/check-fast.sh (CHECK_BASE=<ref> compares with another base)
set -euo pipefail
Expand Down Expand Up @@ -135,9 +136,6 @@ if printf '%s\n' "${changed[@]}" | grep -qE '(^|/)(go\.(mod|sum)|package\.json|p
fi

if [ "${#pkgs[@]}" -gt 0 ]; then
step "go vet"
if ! out=$("$GO" vet "${pkgs[@]}" 2>&1); then done_; echo "$out" | sed 's/^/ /'; fail vet; else done_; fi

step "golangci-lint"
if ! out=$(lint run "${pkgdirs[@]}" 2>&1); then done_; echo "$out" | sed 's/^/ /'; fail golangci-lint; else done_; fi

Expand All @@ -163,9 +161,9 @@ if [ "${#pkgs[@]}" -gt 0 ]; then
fi

if [ "$deploy" = true ] && [ -d deploy ]; then
step "deploy/ vet, lint, names, vars"
step "deploy/ lint, names, vars"
if ! out=$(mkdir -p .cache && "$GO" build -o .cache/namelint ./scripts/namelint 2>&1 &&
cd deploy && { "$GO" vet ./... && "$GO" tool -modfile=../tools/go.mod golangci-lint run -c ../.golangci.yml ./... && ../.cache/namelint ./... && cd .. && make --no-print-directory deploy-vars >/dev/null; } 2>&1); then
cd deploy && { "$GO" tool -modfile=../tools/go.mod golangci-lint run -c ../.golangci.yml ./... && ../.cache/namelint ./... && cd .. && make --no-print-directory deploy-vars >/dev/null; } 2>&1); then
done_
echo "$out" | grep -vE '^(ok|\?) ' | sed 's/^/ /'
fail deploy
Expand Down
Loading