1
0

Makefile 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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: ## oxlint on frontend sources
  27. cd $(FRONTEND) && npm run lint
  28. .PHONY: lint
  29. lint: lint-go lint-fe ## All linters
  30. .PHONY: format-check
  31. format-check: ## oxfmt in check mode on frontend sources
  32. cd $(FRONTEND) && npm run format:check
  33. .PHONY: typecheck
  34. typecheck: ## tsc --noEmit
  35. cd $(FRONTEND) && npm run typecheck
  36. .PHONY: msw-worker-check
  37. msw-worker-check: ## Verify the tracked worker matches the installed MSW runtime
  38. cmp $(FRONTEND)/public/mockServiceWorker.js $(FRONTEND)/node_modules/msw/lib/mockServiceWorker.js
  39. .PHONY: test-go
  40. test-go: dist-stub ## Go tests (shuffle, no cache)
  41. go test -shuffle=on -count=1 $(GO_PKGS)
  42. .PHONY: race
  43. # internal/web/service runs ~10x slower under -race and overruns go test's 10m default.
  44. race: dist-stub ## Go tests with the race detector (needs a C compiler)
  45. go test -race -shuffle=on -count=1 -timeout 25m $(GO_PKGS)
  46. .PHONY: node-e2e
  47. # Two real panel processes (master + node); test-go only runs nodee2e as a skip.
  48. NODE_E2E_BIN = $(CURDIR)/.cache/node-e2e/x-ui$(shell go env GOEXE)
  49. node-e2e: dist-stub ## Master+node sync end to end with two real panel processes
  50. go build -o $(NODE_E2E_BIN) .
  51. XUI_NODE_E2E_BINARY=$(NODE_E2E_BIN) go test -count=1 -timeout 20m -v ./internal/nodee2e/
  52. .PHONY: test-fe
  53. test-fe: ## Frontend tests (vitest)
  54. cd $(FRONTEND) && npm test
  55. .PHONY: test
  56. test: test-go test-fe ## All tests
  57. .PHONY: vulncheck
  58. vulncheck: dist-stub ## govulncheck
  59. go run golang.org/x/vuln/cmd/govulncheck@latest ./...
  60. .PHONY: build-fe
  61. build-fe: ## Build the Vite bundles into internal/web/dist
  62. cd $(FRONTEND) && npm run build
  63. .PHONY: build
  64. build: build-fe ## Build the frontend then the Go binary
  65. go build ./...
  66. .PHONY: build-storybook
  67. build-storybook: ## Build the static Storybook (compile-checks all stories)
  68. cd $(FRONTEND) && npm run build-storybook
  69. # The PR gate. Matches ci.yml: codegen freshness, both linters, the formatter,
  70. # typecheck, both test suites, a full build, and the Storybook compile-check.
  71. .PHONY: verify
  72. verify: gen-check lint format-check typecheck msw-worker-check test build build-storybook ## Full local gate (mirrors CI)
  73. @echo "verify: OK"