-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
121 lines (97 loc) · 3.54 KB
/
Makefile
File metadata and controls
121 lines (97 loc) · 3.54 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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
.PHONY: build test test-race test-cover lint typecheck check clean help benchmark benchmark-adaptive benchmark-suite ablation eval-adaptive deps fmt generate ci security version
# Version from git tag (e.g., v0.1.0 -> 0.1.0) or "dev"
VERSION=$(shell git describe --tags --always --dirty 2>/dev/null | sed 's/^v//' || echo "dev")
# Go flags
GOFLAGS=CGO_ENABLED=0
GOBIN_DIR=$(shell go env GOPATH)/bin
GO_CMD=PATH="$(shell go env GOROOT)/bin:$$PATH" go
## build: Verify the library compiles
build:
$(GOFLAGS) go build ./...
## test: Run tests
test:
$(GO_CMD) test -cover ./...
## test-race: Run tests with race detector
test-race:
$(GO_CMD) test -race ./...
## test-cover: Run tests with coverage report
test-cover:
$(GO_CMD) test -coverprofile=coverage.out ./...
$(GO_CMD) tool cover -html=coverage.out -o coverage.html
@echo "Coverage report: coverage.html"
## test-verbose: Run tests with verbose output
test-verbose:
$(GO_CMD) test -v -cover ./...
## lint: Run linters
lint:
$(GO_CMD) vet ./...
@command -v golangci-lint >/dev/null 2>&1 || (echo "golangci-lint not installed" && exit 1)
@mkdir -p .cache/go-build .cache/golangci
GOCACHE=$(CURDIR)/.cache/go-build GOLANGCI_LINT_CACHE=$(CURDIR)/.cache/golangci golangci-lint run
## typecheck: Run type checking
typecheck:
$(GO_CMD) vet ./...
## fmt: Format Go code
fmt:
gofmt -w .
goimports -w .
@echo "Formatted all Go files"
## check: Run all checks (fmt, vet, typecheck, lint, test)
check: fmt lint test
@echo "All checks passed!"
## clean: Clean build artifacts
clean:
rm -f coverage.out coverage.html
go clean -testcache
@echo "Cleaned build artifacts"
## security: Run security scans
security:
@echo "Running security scans..."
@command -v $(GOBIN_DIR)/gosec >/dev/null 2>&1 || (echo "gosec not installed; run: go install github.com/securego/gosec/v2/cmd/gosec@latest" && exit 1)
@command -v $(GOBIN_DIR)/govulncheck >/dev/null 2>&1 || (echo "govulncheck not installed; run: go install golang.org/x/vuln/cmd/govulncheck@latest" && exit 1)
$(GOBIN_DIR)/gosec -severity high -confidence high -fmt json -out security-report.json ./...
$(GOBIN_DIR)/govulncheck ./...
@echo "Security scans complete"
## coverage: Generate and view coverage report
coverage: test-cover
@echo "Coverage report: coverage.html"
## benchmark: Run benchmarks
benchmark:
go test -bench=. -benchmem ./...
## benchmark-adaptive: Run adaptive benchmark compare and save report
benchmark-adaptive:
@mkdir -p artifacts
go test -run '^$$' -bench BenchmarkPipelineAdaptiveCompare -benchmem ./internal/filter | tee artifacts/benchmark-adaptive.txt
## benchmark-suite: Run scenario benchmark suite and save report
benchmark-suite:
@mkdir -p artifacts
go test -run TestBenchmarkSuiteScenarios -v ./internal/filter | tee artifacts/benchmark-suite.txt
## ablation: Run ablation baseline and save report
ablation:
@mkdir -p artifacts
go test -run TestLayerAblationBasic -v ./internal/filter | tee artifacts/ablation-baseline.txt
## eval-adaptive: Run local baseline vs adaptive evaluation report
eval-adaptive:
./scripts/eval_adaptive.sh 5
## deps: Download and verify dependencies
deps:
go mod download
go mod verify
go mod tidy
## generate: Run go generate
generate:
go generate ./...
## ci: Run CI checks locally
ci: deps fmt lint test-race security
@echo "All CI checks passed!"
## version: Show version
version:
@echo "Version: $(VERSION)"
## help: Show this help
help:
@echo "Tok Makefile (library)"
@echo ""
@echo "Usage: make [target]"
@echo ""
@echo "Targets:"
@sed -n 's/^##//p' ${MAKEFILE_LIST} | column -t -s ':' | sed -e 's/^/ /'