-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
88 lines (72 loc) · 2.57 KB
/
Copy pathMakefile
File metadata and controls
88 lines (72 loc) · 2.57 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# AstrCode - Agent orchestration engine for AstrBot
# Copyright (C) 2026 EterUltimate
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
.PHONY: build run test clean docker fmt lint vet deps coverage ci
BINARY=bin/astrcode
VERSION?=0.4.0
COMMIT?=$(shell git rev-parse --short HEAD 2>/dev/null || echo "unknown")
LDFLAGS=-ldflags "-s -w -X main.version=$(VERSION) -X main.commit=$(COMMIT)"
# 构建
build:
go build $(LDFLAGS) -o $(BINARY) cmd/server/main.go
# 运行
run:
go run cmd/server/main.go -addr :8080 -static-dir ./web
# 测试
test:
go test -v -race ./...
# 测试覆盖率
coverage:
go test -v -race -coverprofile=coverage.txt -covermode=atomic ./...
go tool cover -func=coverage.txt
# 清理
clean:
rm -rf bin/ dist/ coverage.txt
# Docker 构建
docker:
docker build -t astrcode:$(VERSION) .
# 格式化代码
fmt:
gofmt -w .
goimports -w . 2>/dev/null || true
# 代码检查
lint:
go vet ./...
golangci-lint run --timeout=5m 2>/dev/null || go vet ./...
# 仅 vet
vet:
go vet ./...
# 检查格式
fmt-check:
@output=$$(gofmt -l .); if [ -n "$$output" ]; then echo "Files not formatted:"; echo "$$output"; exit 1; fi
# 下载依赖
deps:
go mod tidy
go mod download
# CI 完整流程
ci: fmt-check vet test build
@echo "✅ CI pipeline passed"
# 多平台构建
build-all:
@mkdir -p dist
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build $(LDFLAGS) -o dist/astrcode-linux-amd64 cmd/server/main.go
GOOS=linux GOARCH=arm64 CGO_ENABLED=0 go build $(LDFLAGS) -o dist/astrcode-linux-arm64 cmd/server/main.go
GOOS=windows GOARCH=amd64 CGO_ENABLED=0 go build $(LDFLAGS) -o dist/astrcode-windows-amd64.exe cmd/server/main.go
GOOS=darwin GOARCH=amd64 CGO_ENABLED=0 go build $(LDFLAGS) -o dist/astrcode-darwin-amd64 cmd/server/main.go
GOOS=darwin GOARCH=arm64 CGO_ENABLED=0 go build $(LDFLAGS) -o dist/astrcode-darwin-arm64 cmd/server/main.go
@echo "✅ All platforms built in dist/"
# Windows MSI 打包
msi:
powershell -ExecutionPolicy Bypass -File scripts/build-msi.ps1 -Version $(VERSION)