-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
82 lines (60 loc) · 2.13 KB
/
Copy pathMakefile
File metadata and controls
82 lines (60 loc) · 2.13 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
APP_NAME ?= headless-backend
GO ?= go
DIST ?= dist
SEED ?=
.PHONY: build run test conformance vet lint vuln race live-sql live-sql-up live-sql-down verify-light verify token backup restore seed docker-build docker-test clean
build:
mkdir -p $(DIST)
$(GO) build -trimpath -o $(DIST)/$(APP_NAME) ./cmd/server
$(GO) build -trimpath -o $(DIST)/headless-token ./cmd/headless-token
$(GO) build -trimpath -o $(DIST)/headless-backup ./cmd/headless-backup
$(GO) build -trimpath -o $(DIST)/headless-seed ./cmd/headless-seed
run:
$(GO) run ./cmd/server
test:
$(GO) test -count=1 ./...
conformance:
$(GO) test -count=1 ./internal/conformance
vet:
$(GO) vet ./...
lint:
$(GO) tool staticcheck ./...
vuln:
$(GO) tool govulncheck ./...
ifeq ($(OS),Windows_NT)
race:
docker compose -f docker-compose.test.yml run --build --rm test
else
race:
$(GO) test -race -count=1 -p 2 ./...
endif
live-sql-up:
docker compose -f docker-compose.live-sql.yml up -d --wait
live-sql-down:
docker compose -f docker-compose.live-sql.yml down --remove-orphans
live-sql: live-sql-up
TEST_POSTGRES_DSN='postgres://postgres@127.0.0.1:5432/headless?sslmode=disable' \
TEST_MYSQL_DSN='root@tcp(127.0.0.1:3306)/headless?parseTime=true&charset=utf8mb4' \
TEST_MARIADB_DSN='root@tcp(127.0.0.1:3307)/headless?parseTime=true&charset=utf8mb4' \
$(GO) test -count=1 -run TestLiveSQLDialects -v ./internal/storage/sqlstore
$(MAKE) live-sql-down
verify-light: test conformance vet lint vuln
$(GO) mod verify
$(GO) build ./cmd/server ./cmd/headless-token ./cmd/headless-backup ./cmd/headless-seed
seed:
@if [ -z "$(SEED)" ]; then echo "SEED is required (product seed file)"; exit 1; fi
$(GO) run ./cmd/headless-seed -path "$(SEED)"
verify: verify-light race
token:
$(GO) run ./cmd/headless-token -subject "$(SUBJECT)" -role "$(ROLE)" -ttl "$(TTL)"
backup:
$(GO) run ./cmd/headless-backup -mode export -path "$(PATH)"
restore:
$(GO) run ./cmd/headless-backup -mode restore -path "$(PATH)"
docker-build:
docker build -t $(APP_NAME):latest .
docker-test:
docker compose -f docker-compose.test.yml up --build --abort-on-container-exit
clean:
$(GO) clean
rm -rf "$(DIST)"