mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-09-04 17:37:19 +00:00
13e87a18c8
The race job failed with "panic: test timed out after 10m0s" in internal/web/service (FAIL at 600.106s) while every other package passed and the non-race go-test job ran the same package in 57s. Nothing hung. The race detector costs this repo ~8.5-10x (internal/database 8.4s -> 73s, internal/sub 17.8s -> 149s), and internal/web/service has 671 tests, ~40 of which each pay a full InitDB + AutoMigrate. That puts it right on go test's 10-minute default per-package timeout: the last four race jobs finished in 10m10s-10m28s before this one crossed the line. Pass -timeout 25m in ci.yml and `make race` so the largest package has real headroom while a genuine deadlock is still bounded. Verified locally: ok internal/web/service 265.425s, 658 tests, no data races.
89 lines
2.7 KiB
Makefile
89 lines
2.7 KiB
Makefile
# Canonical task runner. Mirrors .github/workflows/ci.yml so `make verify`
|
|
# reproduces the PR gate locally. Run `make help` for the list.
|
|
|
|
SHELL := bash
|
|
GO_PKGS = $(shell go list ./... | grep -v '/frontend/node_modules/')
|
|
FRONTEND = frontend
|
|
|
|
.DEFAULT_GOAL := help
|
|
|
|
.PHONY: help
|
|
help: ## Show this help
|
|
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | \
|
|
awk 'BEGIN {FS = ":.*?## "}; {printf " %-14s %s\n", $$1, $$2}'
|
|
|
|
# go:embed of internal/web/dist needs the dir to exist even when the
|
|
# frontend bundle has not been built. CI stubs it the same way.
|
|
.PHONY: dist-stub
|
|
dist-stub:
|
|
@mkdir -p internal/web/dist && touch internal/web/dist/.gitkeep
|
|
|
|
.PHONY: gen
|
|
gen: ## Regenerate Zod schemas + OpenAPI from Go sources
|
|
cd $(FRONTEND) && npm run gen
|
|
|
|
.PHONY: gen-check
|
|
gen-check: gen ## Fail if generated files are stale
|
|
git diff --exit-code -- frontend/src/generated frontend/public/openapi.json
|
|
|
|
.PHONY: lint-go
|
|
lint-go: dist-stub ## golangci-lint on Go sources
|
|
golangci-lint run
|
|
|
|
.PHONY: lint-fe
|
|
lint-fe: ## oxlint on frontend sources
|
|
cd $(FRONTEND) && npm run lint
|
|
|
|
.PHONY: lint
|
|
lint: lint-go lint-fe ## All linters
|
|
|
|
.PHONY: format-check
|
|
format-check: ## oxfmt in check mode on frontend sources
|
|
cd $(FRONTEND) && npm run format:check
|
|
|
|
.PHONY: typecheck
|
|
typecheck: ## tsc --noEmit
|
|
cd $(FRONTEND) && npm run typecheck
|
|
|
|
.PHONY: msw-worker-check
|
|
msw-worker-check: ## Verify the tracked worker matches the installed MSW runtime
|
|
cmp $(FRONTEND)/public/mockServiceWorker.js $(FRONTEND)/node_modules/msw/lib/mockServiceWorker.js
|
|
|
|
.PHONY: test-go
|
|
test-go: dist-stub ## Go tests (shuffle, no cache)
|
|
go test -shuffle=on -count=1 $(GO_PKGS)
|
|
|
|
.PHONY: race
|
|
# internal/web/service runs ~10x slower under -race and overruns go test's 10m default.
|
|
race: dist-stub ## Go tests with the race detector (needs a C compiler)
|
|
go test -race -shuffle=on -count=1 -timeout 25m $(GO_PKGS)
|
|
|
|
.PHONY: test-fe
|
|
test-fe: ## Frontend tests (vitest)
|
|
cd $(FRONTEND) && npm test
|
|
|
|
.PHONY: test
|
|
test: test-go test-fe ## All tests
|
|
|
|
.PHONY: vulncheck
|
|
vulncheck: dist-stub ## govulncheck
|
|
go run golang.org/x/vuln/cmd/govulncheck@latest ./...
|
|
|
|
.PHONY: build-fe
|
|
build-fe: ## Build the Vite bundles into internal/web/dist
|
|
cd $(FRONTEND) && npm run build
|
|
|
|
.PHONY: build
|
|
build: build-fe ## Build the frontend then the Go binary
|
|
go build ./...
|
|
|
|
.PHONY: build-storybook
|
|
build-storybook: ## Build the static Storybook (compile-checks all stories)
|
|
cd $(FRONTEND) && npm run build-storybook
|
|
|
|
# The PR gate. Matches ci.yml: codegen freshness, both linters, the formatter,
|
|
# typecheck, both test suites, a full build, and the Storybook compile-check.
|
|
.PHONY: verify
|
|
verify: gen-check lint format-check typecheck msw-worker-check test build build-storybook ## Full local gate (mirrors CI)
|
|
@echo "verify: OK"
|