-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
168 lines (130 loc) · 5.11 KB
/
Makefile
File metadata and controls
168 lines (130 loc) · 5.11 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
156
157
158
159
160
161
162
163
164
165
166
167
168
# Terrain — signal-first test intelligence platform
VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null || echo dev)
COMMIT ?= $(shell git rev-parse --short HEAD 2>/dev/null || echo unknown)
DATE ?= $(shell date -u +%Y-%m-%dT%H:%M:%SZ)
LDFLAGS := -s -w -X main.version=$(VERSION) -X main.commit=$(COMMIT) -X main.date=$(DATE)
GO_OWNED_PKGS := ./cmd/... ./internal/...
.PHONY: build test lint clean demo benchmark-fetch benchmark-smoke benchmark-full benchmark-stress benchmark-summary benchmark-convert install \
test-golden test-determinism test-schema test-adversarial test-e2e test-cli test-bench golden-update pr-gate release-gate \
sbom sbom-cyclonedx sbom-spdx release-dry-run go-release-verify js-release-verify extension-verify release-verify
# Build the CLI binary
build:
go build -ldflags "$(LDFLAGS)" -o terrain ./cmd/terrain
# Install to $GOPATH/bin
install:
go install -ldflags "$(LDFLAGS)" ./cmd/terrain
# Run all Go tests
test:
go test $(GO_OWNED_PKGS)
# Run tests with verbose output
test-v:
go test -v $(GO_OWNED_PKGS)
# Run tests with coverage
test-cover:
go test -coverprofile=coverage.out $(GO_OWNED_PKGS)
go tool cover -func=coverage.out
# Build check (compile only, no binary output)
check:
go vet $(GO_OWNED_PKGS)
go build ./cmd/terrain
# Clean build artifacts
clean:
rm -f terrain coverage.out terrain.cdx.json terrain.spdx.json
# Run demo: analyze the current repository
demo:
@echo "=== Terrain Demo ==="
@echo ""
@echo "--- terrain analyze ---"
go run ./cmd/terrain analyze
@echo ""
@echo "--- terrain summary ---"
go run ./cmd/terrain summary
@echo ""
@echo "--- terrain metrics ---"
go run ./cmd/terrain metrics
# ── Verification Layer Targets ──────────────────────────────
# Run golden tests only (fast)
test-golden:
go test ./internal/testdata/ -run 'Golden' -count=1
# Run determinism tests only
test-determinism:
go test ./internal/testdata/ -run 'Determinism' -count=1
# Run schema tests only
test-schema:
go test ./internal/testdata/ -run 'Schema' -count=1
# Run adversarial tests only
test-adversarial:
go test ./internal/testdata/ -run 'Adversarial' -count=1
# Run E2E scenario tests only
test-e2e:
go test ./internal/testdata/ -run 'E2E' -count=1
# Run CLI regression tests only
test-cli:
go test ./internal/testdata/ -run 'CLI' -count=1 -timeout 120s
# Run benchmarks
test-bench:
go test -bench . -benchmem ./internal/testdata/ -run '^$$'
# Update golden files (review changes in git diff before committing)
golden-update:
go test ./internal/testdata/ -run 'Golden' -update
# ── SBOM Generation ───────────────────────────────────────
# Requires: syft (https://github.com/anchore/syft)
# brew install syft OR go install github.com/anchore/syft/cmd/syft@latest
# Generate CycloneDX SBOM from the built binary
sbom-cyclonedx: build
syft terrain --output cyclonedx-json=terrain.cdx.json
@echo "CycloneDX SBOM written to terrain.cdx.json"
# Generate SPDX SBOM from the built binary
sbom-spdx: build
syft terrain --output spdx-json=terrain.spdx.json
@echo "SPDX SBOM written to terrain.spdx.json"
# Generate both SBOM formats
sbom: sbom-cyclonedx sbom-spdx
# Dry-run GoReleaser to verify config and preview artifacts
release-dry-run:
goreleaser release --snapshot --clean --skip=publish,sign
# ── Release Gates ──────────────────────────────────────────
# PR gate: fast checks required on every PR
pr-gate:
$(MAKE) check
$(MAKE) test
# Release gate: full verification required before release
release-gate: go-release-verify
go-release-verify:
go vet $(GO_OWNED_PKGS)
go test $(GO_OWNED_PKGS)
go build ./cmd/terrain
go test ./cmd/terrain/ -run TestSnapshot -count=1 -v
npm-release-verify:
npm ci
npm run release:verify
extension-verify:
npm --prefix extension/vscode ci
npm --prefix extension/vscode run compile
npm --prefix extension/vscode test
release-verify:
$(MAKE) go-release-verify
$(MAKE) npm-release-verify
$(MAKE) extension-verify
# ── Public Benchmark Matrix ──────────────────────────────────
# Download benchmark repos (shallow clone by default)
benchmark-fetch:
./scripts/benchmarks/fetch_public_repos.sh
# Quick benchmark (smoke-tier repos only)
benchmark-smoke:
./scripts/benchmarks/run_public_matrix.sh smoke
python3 ./scripts/benchmarks/summarize_public_matrix.py
# Full benchmark matrix
benchmark-full:
./scripts/benchmarks/run_public_matrix.sh full
python3 ./scripts/benchmarks/summarize_public_matrix.py
# Stress benchmark (all repos including very large ones)
benchmark-stress:
./scripts/benchmarks/run_public_matrix.sh stress
python3 ./scripts/benchmarks/summarize_public_matrix.py
# Just regenerate the summary from existing artifacts
benchmark-summary:
python3 ./scripts/benchmarks/summarize_public_matrix.py
# Compare current Go converters against the legacy JS runtime floor.
benchmark-convert:
go run ./cmd/terrain-convert-bench