-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
146 lines (108 loc) · 4.24 KB
/
Copy pathMakefile
File metadata and controls
146 lines (108 loc) · 4.24 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
BINARY := synaps3
SYSTEMTEST_BINARY := synaps3-systemtest
INTEGRATION_BINARY := synaps3-integration-server
MODULE := github.com/strahe/synaps3
PKG := ./cmd/synaps3
GOFLAGS := -trimpath
CGO_ENABLED := 1
CGO := CGO_ENABLED=$(CGO_ENABLED)
DOCKER_DEPLOYMENT ?= sh docker/deployment.sh
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 := -X $(MODULE)/internal/buildinfo.Version=$(VERSION) \
-X $(MODULE)/internal/buildinfo.Commit=$(COMMIT) \
-X $(MODULE)/internal/buildinfo.Date=$(DATE)
.PHONY: all build build-go build-systemtest-server build-integration-server docs-build test test-fast test-race test-system test-integration test-ui-e2e test-docker-entrypoint test-docker-deployment lint fmt check verify-e2e verify-fast verify-norace verify-race clean run ui-install ui-build ui-dev ui-e2e-install
.PHONY: docker-init docker-up docker-verify docker-down docker-status docker-logs docker-password
all: build
ui-install:
cd ui && pnpm install --frozen-lockfile --config.confirmModulesPurge=false
ui-build: ui-install
cd ui && pnpm run build
docs-build:
cd docs && pnpm install --frozen-lockfile
cd docs && pnpm run build
build: ui-build build-go
build-go:
@test -f ui/dist/index.html || { echo "ui/dist/index.html not found; run make ui-build first"; exit 1; }
$(CGO) go build $(GOFLAGS) -ldflags '$(LDFLAGS)' -o bin/$(BINARY) $(PKG)
build-systemtest-server:
@test -f ui/dist/index.html || { echo "ui/dist/index.html not found; run make ui-build first"; exit 1; }
$(CGO) go build $(GOFLAGS) -tags=systemtest -o bin/$(SYSTEMTEST_BINARY) ./cmd/synaps3-systemtest
build-integration-server:
$(CGO) go build $(GOFLAGS) -tags=dev -ldflags '$(LDFLAGS)' -o bin/$(INTEGRATION_BINARY) $(PKG)
test: test-race
test-fast:
$(CGO) go test -count=1 ./cmd/... ./internal/...
test-race:
$(CGO) go test -race -count=1 ./cmd/... ./internal/...
test-system:
$(CGO) go test $(GOFLAGS) -tags='dev systemtest' -count=1 ./tests/testutil/... ./internal/systemtest ./tests/system
test-integration: build-integration-server
$(CGO) go test -v $(GOFLAGS) -tags=integration -count=1 -timeout=45m ./tests/integration/...
ui-e2e-install:
cd ui && pnpm exec playwright install $(PLAYWRIGHT_INSTALL_FLAGS) chromium
test-ui-e2e:
@test -f ui/dist/index.html || { echo "ui/dist/index.html not found; run make ui-build first"; exit 1; }
@test -x bin/$(SYSTEMTEST_BINARY) || { echo "bin/$(SYSTEMTEST_BINARY) not found; run make build-systemtest-server first"; exit 1; }
cd ui && pnpm exec playwright test
test-docker-entrypoint:
sh docker/entrypoint.test.sh
test-docker-deployment:
sh docker/deployment.test.sh
docker-init:
@$(DOCKER_DEPLOYMENT) init
docker-up:
@$(DOCKER_DEPLOYMENT) up
docker-verify:
@$(DOCKER_DEPLOYMENT) verify
docker-down:
@$(DOCKER_DEPLOYMENT) down
docker-status:
@$(DOCKER_DEPLOYMENT) status
docker-logs:
@$(DOCKER_DEPLOYMENT) logs
docker-password:
@$(DOCKER_DEPLOYMENT) password
lint:
@command -v golangci-lint >/dev/null 2>&1 || { echo "golangci-lint not found"; exit 1; }
$(CGO) golangci-lint run
cd ui && pnpm run check
fmt:
@command -v golangci-lint >/dev/null 2>&1 || { echo "golangci-lint not found"; exit 1; }
golangci-lint fmt
cd ui && pnpm run format
check: ui-build
@command -v golangci-lint >/dev/null 2>&1 || { echo "golangci-lint not found"; exit 1; }
golangci-lint config verify
golangci-lint fmt --diff
$(CGO) golangci-lint run
cd ui && pnpm run check
cd ui && pnpm run test
$(MAKE) test-race
verify-norace: ui-build
@command -v golangci-lint >/dev/null 2>&1 || { echo "golangci-lint not found"; exit 1; }
golangci-lint config verify
golangci-lint fmt --diff
$(CGO) golangci-lint run
cd ui && pnpm run check
cd ui && pnpm run test
$(MAKE) test-docker-entrypoint
$(MAKE) build-go
verify-fast: verify-norace
$(MAKE) test-fast
verify-e2e: ui-build build-systemtest-server test-system test-ui-e2e
verify-race:
$(CGO) go test -race -tags dev -count=1 ./cmd/... ./internal/...
clean:
rm -rf bin/
rm -rf ui/dist/
rm -rf ui/node_modules/
run: build
./bin/$(BINARY) serve
ui-dev:
cd ui && pnpm run dev
.PHONY: migrate
migrate: build
./bin/$(BINARY) migrate