-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
91 lines (72 loc) · 3.05 KB
/
Copy pathMakefile
File metadata and controls
91 lines (72 loc) · 3.05 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
GO ?= go
BIN_DIR ?= bin
APP ?= mnemos
VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null || echo dev)
COMMIT ?= $(shell git rev-parse --short HEAD 2>/dev/null || echo unknown)
BUILD_DATE ?= $(shell date -u +%Y-%m-%dT%H:%M:%SZ)
LDFLAGS := -ldflags "-X main.version=$(VERSION) -X main.commit=$(COMMIT) -X main.buildDate=$(BUILD_DATE)"
PROTO_DIR := proto
PROTO_GEN := proto/gen
# SQLC_VERSION pins the exact sqlc used to (re)generate internal/store/sqlite/sqlcgen.
# It MUST match the `// sqlc vX.Y.Z` header stamped into the committed generated
# files: an off-version sqlc silently rewrites the generated SQL and has, in the
# past, corrupted a query string. The `sqlc` target runs this exact version via
# `go run ...@$(SQLC_VERSION)` so whatever `sqlc` sits on the operator's PATH is
# never used. The same version is recorded as a `tool` dependency in go.mod.
SQLC_VERSION := v1.30.0
.PHONY: fmt lint test test-integration build check sqlc install release-snapshot release-check proto mutation mutation-trust mutation-relate mutation-query
fmt:
$(GO) fmt ./...
lint:
$(GO) vet ./...
golangci-lint run
test:
$(GO) test ./...
# test-integration spins up ephemeral postgres + mysql containers,
# runs the gated integration suites against them, and tears the
# containers down. Skips the run with a clear message if Docker
# is not available. Mirrors the GitHub Actions database-providers
# job so developers can reproduce CI locally.
test-integration:
@command -v docker >/dev/null 2>&1 || { echo "docker not installed; skipping integration tests"; exit 0; }
@scripts/test-integration.sh
build:
mkdir -p $(BIN_DIR)
$(GO) build $(LDFLAGS) -o $(BIN_DIR)/$(APP) ./cmd/mnemos
install:
$(GO) install $(LDFLAGS) ./cmd/mnemos
sqlc:
$(GO) run github.com/sqlc-dev/sqlc/cmd/sqlc@$(SQLC_VERSION) generate
proto:
@mkdir -p $(PROTO_GEN)
@protoc \
--go_out=$(PROTO_GEN) --go_opt=paths=source_relative \
--go-grpc_out=$(PROTO_GEN) --go-grpc_opt=paths=source_relative \
-I$(PROTO_DIR) \
$(shell find $(PROTO_DIR) -name '*.proto')
$(GO) fmt ./$(PROTO_GEN)/...
check: fmt lint test build
# nox-scan runs the security baseline scan and exits non-zero when any
# new finding is detected (anything not present in findings.json).
# Operators refresh the baseline by reviewing diffs in findings.json.
nox-scan:
@if command -v nox >/dev/null 2>&1; then \
nox scan .; \
else \
echo "nox not installed, skipping"; \
fi
release-check:
goreleaser check
release-snapshot:
goreleaser release --snapshot --clean
# mutation runs the in-tree mutation harness against internal/trust
# and gates on a 0.70 kill rate. See docs/testing/mutation.md for
# rationale and the threshold-ratchet plan. Add internal/relate and
# internal/query as advisory (non-gating) runs.
mutation: mutation-trust
mutation-trust:
$(GO) run ./tools/mutate -pkg ./internal/trust -threshold 0.70 -v
mutation-relate:
$(GO) run ./tools/mutate -pkg ./internal/relate -threshold 0.0 -v -json mutation-relate.json
mutation-query:
$(GO) run ./tools/mutate -pkg ./internal/query -threshold 0.0 -v -json mutation-query.json