-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
82 lines (65 loc) · 3.04 KB
/
Makefile
File metadata and controls
82 lines (65 loc) · 3.04 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
SHELL := /usr/bin/env bash
.EXPORT_ALL_VARIABLES:
MKCERT_INSTALL_PATH ?= $(HOME)/.local/bin
MKCERT_VERSION := v1.4.4
MKCERT_ASSET := mkcert-$(MKCERT_VERSION)-linux-amd64
MKCERT_URL := https://github.com/FiloSottile/mkcert/releases/latest/download/$(MKCERT_ASSET)
CERT_DIR ?= ./certs
HOSTS ?= localhost 127.0.0.1 ::1
export GODEBUG ?= default=go1.25,cgocheck=1,disablethp=0,panicnil=0,http2client=1,http2server=1,madvdontneed=0
.PHONY: check
check: ## Run linters
@go tool golangci-lint run
.PHONY: fix
fix: ## Auto-fix lint issues where possible
@go tool golangci-lint run --fix
.PHONY: fieldalign
fieldalign: ## Apply field alignment fixes
@go tool fieldalignment -fix ./...
.PHONY: fmt
fmt: ## Run project formatting helpers
@go tool golangci-lint fmt
.PHONY: tidy
tidy: ## Tidy go.mod and download modules
go mod tidy
go mod download
.PHONY: test
test: ## Run unit tests with coverage (JSON output piped through gotestfmt)
@go test -covermode=atomic -gcflags='all=-N -l' -tags testing -coverprofile=coverage.txt -timeout 5m -json -v ./... 2>&1 | go tool gotestfmt -showteststatus
.PHONY: test-api-coverage
test-api-coverage: ## Run API coverage tests to ensure all Mailpit routes are implemented
@echo "Running API coverage tests..."
@go test -v -run TestAPIRouteCoverage -timeout=3m
.PHONY: test-api-coverage-offline
test-api-coverage-offline: ## Run offline API coverage tests (faster, uses static spec)
@echo "Running offline API coverage tests..."
@go test -v -run TestAPIRouteCoverageOffline -timeout=30s
.PHONY: api-coverage-maintenance
api-coverage-maintenance: ## Show API coverage maintenance options
@./scripts/api-coverage.sh help
.PHONY: security
security: ## Run basic security checks (gosec)
go tool gosec ./...
# --- Mkcert -------------------------------
install-mkcert: ## Install mkcert binary to $(MKCERT_INSTALL_PATH) if missing
@if [ ! -f "$(MKCERT_INSTALL_PATH)/mkcert" ]; then \
mkdir -p $(MKCERT_INSTALL_PATH) 2>/dev/null || true; \
echo "Downloading mkcert from $(MKCERT_URL)..."; \
tmp=$$(mktemp -d); \
curl -L --fail -o $$tmp/$(MKCERT_ASSET) "$(MKCERT_URL)"; \
chmod +x $$tmp/$(MKCERT_ASSET); \
mv $$tmp/$(MKCERT_ASSET) $(MKCERT_INSTALL_PATH)/mkcert || { echo "Failed to move mkcert to $(MKCERT_INSTALL_PATH)"; exit 1; }; \
rm -rf $$tmp; \
echo "mkcert installed to $(MKCERT_INSTALL_PATH)/mkcert"; \
fi
mkcert-install-ca: install-mkcert ## Install mkcert CA into system trust stores
@echo "Installing mkcert CA..."
@$(MKCERT_INSTALL_PATH)/mkcert -install
mkcert-generate: mkcert-install-ca ## Generate cert/key for HOSTS into $(CERT_DIR) (usage: make mkcert-generate HOSTS='example.test localhost')
@mkdir -p $(CERT_DIR)
@echo "Generating cert for: $(HOSTS)"
@$(MKCERT_INSTALL_PATH)/mkcert -cert-file $(CERT_DIR)/smtp.crt -key-file $(CERT_DIR)/smtp.key $(HOSTS)
@echo "Created $(CERT_DIR)/smtp.crt and $(CERT_DIR)/smtp.key"
mkcert-uninstall-ca: install-mkcert ## Uninstall mkcert CA from system trust stores
@echo "Uninstalling mkcert CA..."
@mkcert -uninstall || echo "mkcert -uninstall failed (maybe not installed)"