Makefile 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. # Canonical task runner. Mirrors .github/workflows/ci.yml so `make verify`
  2. # reproduces the PR gate locally. Run `make help` for the list.
  3. SHELL := bash
  4. GO_PKGS = $(shell go list ./... | grep -v '/frontend/node_modules/')
  5. FRONTEND = frontend
  6. .DEFAULT_GOAL := help
  7. .PHONY: help
  8. help: ## Show this help
  9. @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | \
  10. awk 'BEGIN {FS = ":.*?## "}; {printf " %-14s %s\n", $$1, $$2}'
  11. # go:embed of internal/web/dist needs the dir to exist even when the
  12. # frontend bundle has not been built. CI stubs it the same way.
  13. .PHONY: dist-stub
  14. dist-stub:
  15. @mkdir -p internal/web/dist && touch internal/web/dist/.gitkeep
  16. .PHONY: gen
  17. gen: ## Regenerate Zod schemas + OpenAPI from Go sources
  18. cd $(FRONTEND) && npm run gen
  19. .PHONY: gen-check
  20. gen-check: gen ## Fail if generated files are stale
  21. git diff --exit-code -- frontend/src/generated frontend/public/openapi.json
  22. .PHONY: lint-go
  23. lint-go: dist-stub ## golangci-lint on Go sources
  24. golangci-lint run
  25. .PHONY: lint-fe
  26. lint-fe: ## ESLint on frontend sources
  27. cd $(FRONTEND) && npm run lint
  28. .PHONY: lint
  29. lint: lint-go lint-fe ## All linters
  30. .PHONY: typecheck
  31. typecheck: ## tsc --noEmit
  32. cd $(FRONTEND) && npm run typecheck
  33. .PHONY: test-go
  34. test-go: dist-stub ## Go tests (shuffle, no cache)
  35. go test -shuffle=on -count=1 $(GO_PKGS)
  36. .PHONY: race
  37. race: dist-stub ## Go tests with the race detector (needs a C compiler)
  38. go test -race -shuffle=on -count=1 $(GO_PKGS)
  39. .PHONY: test-fe
  40. test-fe: ## Frontend tests (vitest)
  41. cd $(FRONTEND) && npm test
  42. .PHONY: test
  43. test: test-go test-fe ## All tests
  44. .PHONY: vulncheck
  45. vulncheck: dist-stub ## govulncheck
  46. go run golang.org/x/vuln/cmd/govulncheck@latest ./...
  47. .PHONY: build-fe
  48. build-fe: ## Build the Vite bundles into internal/web/dist
  49. cd $(FRONTEND) && npm run build
  50. .PHONY: build
  51. build: build-fe ## Build the frontend then the Go binary
  52. go build ./...
  53. # The PR gate. Matches ci.yml: codegen freshness, both linters, typecheck,
  54. # both test suites, and a full build.
  55. .PHONY: verify
  56. verify: gen-check lint typecheck test build ## Full local gate (mirrors CI)
  57. @echo "verify: OK"