.PHONY: vet fmt-check test race ci

# ci is the one gate: what a runner executes and what you run before
# pushing are the same definition (amadan's own rule — CI steps delegate
# to make targets, never keep their own copies of the commands).
#
# There is no separate migration-check step. The scaffold's Makefile
# shells out to the `rastrillo` CLI for one, which would make this
# module's gate depend on building that binary; the example's
# TestSchemaAndModelsAgree does the same work — replay the app's own
# Schema, diff it against the app's own Models, fail on any pending
# change — through migrate.Generate, inside `test`. idear's own
# migrations are checked by schema_test.go, which is where a frozen
# checksum belongs.
ci: vet fmt-check test race

vet:
	go vet ./...

fmt-check:
	@out=$$(gofmt -l .); if [ -n "$$out" ]; then echo "gofmt needed:"; echo "$$out"; exit 1; fi

# -count=1 on purpose: these tests build a real SQLite database and
# race real goroutines against it, and a cached PASS re-reports one
# scheduling of a race as though it were every scheduling.
test:
	go test ./... -count=1

# race is a separate target because it needs a different toolchain
# setting, not because it is optional. The store's invariants are
# transaction invariants and race_test.go drives them with real
# goroutines; -race is what makes those tests able to report a data
# race in the store itself rather than only a broken outcome. -race
# requires cgo, and everything else in this Makefile runs with
# CGO_ENABLED=0, so this target sets it for its own command and no
# other.
race:
	CGO_ENABLED=1 go test ./... -race -count=1
