Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
104 lines (88 loc) · 4.25 KB
/
Copy pathMakefile
File metadata and controls
104 lines (88 loc) · 4.25 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
# Waza Build System
.PHONY: all build build-web web-deps web-deps-force clean test test-compat test-compat-inventory test-compat-prereqs lint fmt install help
# Build configuration
BINARY_NAME=waza
BUILD_DIR=.
GO_FILES=$(shell find . -name '*.go' -not -path './vendor/*' -not -path './*/node_modules/*')
GO_PACKAGES=$(shell go list ./... | grep -v '/node_modules')
VERSION?=0.1.0
LDFLAGS=-ldflags "-X main.version=$(VERSION)"
WEB_DEPS_STAMP=web/node_modules/.waza-deps-stamp
WEB_DEPS_INPUTS=web/package.json web/package-lock.json
COMPAT_PACKAGES=./cmd/waza/... ./internal/models ./internal/validation ./internal/graders/... ./internal/execution ./internal/orchestration ./internal/commandmock ./internal/mcpmock ./internal/cache ./internal/snapshot ./internal/registry ./internal/skill ./internal/checks ./internal/quality ./internal/responder ./internal/trigger ./internal/adversarial ./internal/scoring ./internal/workspace ./internal/webapi
# Default target
all: fmt lint build test
# Install locked dashboard dependencies when the manifests change.
web-deps: $(WEB_DEPS_STAMP)
$(WEB_DEPS_STAMP): $(WEB_DEPS_INPUTS)
@echo "Installing web dashboard dependencies..."
@cd web && npm ci --silent
@touch $(WEB_DEPS_STAMP)
# Force a clean dashboard dependency reinstall if node_modules is stale or corrupt.
web-deps-force:
@rm -rf web/node_modules
@$(MAKE) --no-print-directory web-deps
# Build the web dashboard (React SPA)
build-web: web-deps
@echo "Building web dashboard..."
@cd web && npm run build
# Build the binary (includes web dashboard)
build: build-web
@echo "Building $(BINARY_NAME)..."
@go build $(LDFLAGS) -o $(BUILD_DIR)/$(BINARY_NAME) ./cmd/waza
# Run tests (requires web assets for embedded FS tests)
test: build-web
@echo "Running tests..."
@go test -v -race -coverprofile=coverage.out $(GO_PACKAGES)
@go tool cover -func=coverage.out | tail -1
# Run the offline corpus without building or installing frontend dependencies.
test-compat-prereqs:
@for tool in git node; do command -v "$$tool" >/dev/null 2>&1 || { echo "test-compat requires $$tool on PATH; no grader family may be silently skipped"; exit 1; }; done
@python3 --version >/dev/null 2>&1 || python --version >/dev/null 2>&1 || { echo "test-compat requires working python3 or python on PATH; no grader family may be silently skipped"; exit 1; }
test-compat-inventory: test-compat-prereqs
@echo "Compatibility packages subsumed by the uncached ordinary Go suite:"
@printf ' %s\n' $(COMPAT_PACKAGES)
test-compat: test-compat-prereqs
@echo "Running offline compatibility corpus and package-owned preservation tests..."
@ENABLE_COPILOT_TESTS=false NO_COLOR=1 TZ=UTC LC_ALL=C go test -count=1 $(COMPAT_PACKAGES)
# Run linter
lint:
@echo "Running linter..."
@if command -v golangci-lint >/dev/null 2>&1; then \
golangci-lint run $$(go list ./... | grep -v '/node_modules' | sed 's#^github.com/microsoft/waza#.#'); \
else \
echo "golangci-lint not installed, skipping..."; \
echo "Install: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b \$$(go env GOPATH)/bin v1.64.8"; \
fi
# Format code
fmt:
@echo "Formatting code..."
@gofmt -w $(GO_FILES)
@go mod tidy
# Install binary to GOPATH (builds web dashboard first)
install: build-web
@echo "Installing $(BINARY_NAME)..."
@go install $(LDFLAGS) ./cmd/waza
# Clean build artifacts
clean:
@echo "Cleaning..."
@rm -f $(BUILD_DIR)/$(BINARY_NAME)
@rm -f coverage.out
@rm -rf web/dist/assets
@go clean -cache -testcache
# Show help
help:
@echo "Waza Makefile Targets:"
@echo " all - Format, lint, build, and test (default)"
@echo " build - Compile the binary"
@echo " test - Run all tests with coverage"
@echo " test-compat - Run offline v1 compatibility corpus (see docs/COMPATIBILITY.md)"
@echo " test-compat-inventory - Check prerequisites and list compatibility packages"
@echo " lint - Run golangci-lint"
@echo " fmt - Format Go code and tidy modules"
@echo " install - Install binary to GOPATH"
@echo " build-web - Build the web dashboard (React SPA)"
@echo " web-deps - Install dashboard dependencies when manifests change"
@echo " web-deps-force - Force a clean dashboard dependency reinstall"
@echo " clean - Remove build artifacts"
@echo " help - Show this help message"