-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
155 lines (128 loc) · 6.39 KB
/
Copy pathMakefile
File metadata and controls
155 lines (128 loc) · 6.39 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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
.PHONY: build mcp test test-royale test-integration test-showdown test-showdown-report vet fmt lint lint-fix lint-install tidy run down logs sync sync-diff sync-upstream validate-data check-stat-preview hooks
# Pin the linter version so local runs match CI exactly.
GOLANGCI_LINT_VERSION := v2.12.2
GOLANGCI_LINT := $(shell go env GOPATH)/bin/golangci-lint
# golangci-lint refuses to analyse a module whose Go directive is newer than
# the toolchain the linter itself was built with:
#
# can't load config: the Go language version (go1.25) used to build
# golangci-lint is lower than the targeted Go version (1.26)
#
# A bare `go install ...@$(GOLANGCI_LINT_VERSION)` uses the machine's *default*
# toolchain, which on a box that has not caught up to this module's go directive
# produces a correctly-versioned linter that cannot run here. Building it with
# the same toolchain that builds the module — the one `go build ./...` already
# selected — avoids that. GOVERSION reports the active toolchain, so this tracks
# the go directive automatically rather than hardcoding a second version to keep
# in sync.
GO_TOOLCHAIN := $(shell go env GOVERSION)
# What a correct install looks like in `golangci-lint version` output. Both
# halves matter: the pinned version (so a stale binary already sitting in
# GOPATH/bin from another project does not silently defeat the pin) and the
# build toolchain (so the unrunnable-binary case above self-heals instead of
# failing on every invocation).
GOLANGCI_LINT_STAMP := version $(GOLANGCI_LINT_VERSION:v%=%) built with $(GO_TOOLCHAIN)
# Project name for the throwaway integration-test infra stack. A distinct name
# keeps it off the dev `make run` stack (they publish the same host ports).
TEST_COMPOSE = docker compose -f docker-compose.test.yml -p pokearena-test
build:
go build ./...
# Rebuilds the MCP server binary that Claude Code spawns as a subprocess.
# The frame protocol is in lockstep with this tree; run this after pulling
# changes that touch internal/protocol or internal/mcpserver, then restart
# Claude Code so it picks up the new binary.
mcp:
go build -o bin/pokearena-mcp ./cmd/pokearena-mcp
# --- data pipeline (see tools/data-sync/README.md) ---
#
# sync-upstream refresh the committed Showdown snapshot. Rare. Node helper.
# sync Go ETL: extract → filter → transform → stage → validate → swap.
# sync-diff same as sync but stops before the swap and prints the diff.
# validate-data run the live validator over data/ (sanity check, no writes).
sync-upstream:
cd tools/data-sync/refresh-upstream && npm install --silent && node refresh.js
sync:
go run ./cmd/data-sync
sync-diff:
go run ./cmd/data-sync -no-swap
@echo "--- diff: data/.staging vs data/ ---"
@for f in pokedex.json moves.json typechart.json; do \
echo ">>> $$f"; \
diff -u data/$$f data/.staging/$$f || true; \
done
validate-data:
go run ./cmd/data-validate
# The team builder previews derived stats in JS, mirroring engine.calcStat.
# This checks the two agree; engine.TestStatPreviewChecksum is the Go half.
check-stat-preview:
node tools/check-stat-preview.js
test: test-royale
go test ./... -count=1
# The royale report generator parses agent-authored markdown — the least
# trustworthy input in the pipeline, and the one whose parsing slips turn into
# factual claims on a published page.
test-royale:
python3 royale/test_report.py
# Full suite *including* the //go:build integration tests, which dial real
# Postgres/Redis/RabbitMQ. Brings the backends up (--wait blocks until every
# healthcheck passes), runs the tests, then always tears the stack down — and
# propagates the test exit code so CI fails on a red run. Unlike plain `make
# test`, a missing backend is a hard failure here, not a silent skip.
test-integration:
$(TEST_COMPOSE) up -d --wait
@status=0; go test ./... -count=1 -tags=integration || status=$$?; \
$(TEST_COMPOSE) down -v; \
exit $$status
# The Pokémon Showdown port: internal/engine/showdown, ~2,000 cases translated
# from smogon/pokemon-showdown's test/sim suite. Gated behind the `showdown`
# build tag so `go test ./...` and CI never compile it, because the suite is
# *expected* to be partly red — it exists to say where this engine and
# competitive Pokémon disagree, and a corpus that has to be green first is a
# corpus nobody can bring over. Ledger and workflow: docs/showdown-port.md.
#
# The run is still a pass/fail: a case only fails the build when it disagrees
# with the ledger in gaps_test.go, in either direction.
test-showdown:
go test -tags=showdown ./internal/engine/showdown/ -count=1
# Same run, writing the machine-readable outcome of every case to a file for
# triage. PS_SEEDS deepens the per-case seed sweep (default 5).
test-showdown-report:
PS_REPORT=$(CURDIR)/showdown-report.json \
go test -tags=showdown ./internal/engine/showdown/ -count=1 -v 2>&1 | tail -40
@echo "wrote showdown-report.json"
vet:
go vet ./...
go vet -tags=showdown ./internal/engine/showdown/
# golangci-lint — the meta-linter (config in .golangci.yml). `make lint`
# reports; `make lint-fix` applies the auto-fixable findings (formatting,
# misspellings, simplifications). Run `make lint-install` once to get the
# pinned binary, or it's fetched automatically by these targets if missing.
lint: lint-install
$(GOLANGCI_LINT) run ./...
$(GOLANGCI_LINT) run --build-tags showdown ./internal/engine/showdown/
lint-fix: lint-install
$(GOLANGCI_LINT) run --fix ./...
# Installs only when the binary is missing, the wrong version, or built with a
# toolchain this module has outgrown — see GOLANGCI_LINT_STAMP above. Checking
# the stamp rather than mere existence is what makes the pin actually binding.
lint-install:
@$(GOLANGCI_LINT) version 2>/dev/null | grep -qF "$(GOLANGCI_LINT_STAMP)" || { \
echo "installing golangci-lint $(GOLANGCI_LINT_VERSION) with $(GO_TOOLCHAIN)..."; \
GOTOOLCHAIN=$(GO_TOOLCHAIN) go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION); \
}
fmt:
gofmt -w .
# Enable the repo's git hooks (.githooks/pre-commit runs build + lint, the same
# fast gates CI does) by pointing git at .githooks. Opt-in and idempotent — run
# once per clone/worktree. Bypass a single commit with PRECOMMIT_SKIP=1.
hooks:
git config core.hooksPath .githooks
@echo "git hooks enabled (.githooks/pre-commit: build + lint)."
tidy:
go mod tidy
run:
docker compose up --build
down:
docker compose down -v
logs:
docker compose logs -f