Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
63 lines (50 loc) · 1.76 KB
/
Copy pathMakefile
File metadata and controls
63 lines (50 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
.DEFAULT_GOAL := help
APP := gpt-load
WEB_DIR := web
GO ?= go
PNPM ?= corepack pnpm
.PHONY: _web-deps
_web-deps:
$(PNPM) --dir $(WEB_DIR) install --frozen-lockfile
.PHONY: _web-build
_web-build: _web-deps
$(PNPM) --dir $(WEB_DIR) run build
.PHONY: dev
dev: _web-build ## Build the Web UI and run with race detection
$(GO) run -race .
.PHONY: run
run: _web-build ## Build the Web UI and run the application
$(GO) run .
.PHONY: build
build: _web-build ## Build the Web UI and application binary
$(GO) build -o $(APP) .
.PHONY: test
test: ## Run Go unit tests
$(GO) test -count=1 . ./internal/...
# Go 与前端检查并行;vite build 会清空 internal/webui/dist,必须等 Go 编译结束后再执行。
.PHONY: check
check: _web-deps ## Run source checks and build
@$(MAKE) --no-print-directory -j2 _check-go _check-web
$(PNPM) --dir $(WEB_DIR) exec vite build
$(GO) build -o $(APP) .
git --no-pager diff --check
.PHONY: _check-go
_check-go:
@go_root="$$($(GO) env GOROOT)"; formatted_files="$$("$${go_root}/bin/gofmt" -l .)"; test -z "$${formatted_files}"
$(GO) mod tidy -diff
$(GO) vet ./...
$(GO) test -count=1 . ./internal/...
.PHONY: _check-web
_check-web:
$(PNPM) --dir $(WEB_DIR) run lint
$(PNPM) --dir $(WEB_DIR) run format
$(PNPM) --dir $(WEB_DIR) run type-check
.PHONY: release
release: ## Validate latest main and ask before pushing one release tag
python3 -m scripts.release
.PHONY: release-simulate
release-simulate: ## Rehearse acceptance on committed HEAD without creating a tag
python3 -m scripts.release --simulate
.PHONY: help
help: ## Display available targets
@awk 'BEGIN {FS = ":.*?## "; printf "Usage:\n make \033[36m<target>\033[0m\n\nTargets:\n"} /^[a-zA-Z0-9_-]+:.*?## / { printf " \033[36m%-12s\033[0m %s\n", $$1, $$2 }' $(MAKEFILE_LIST)