-
-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathMakefile
More file actions
186 lines (150 loc) · 5.52 KB
/
Copy pathMakefile
File metadata and controls
186 lines (150 loc) · 5.52 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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
.PHONY: help build backend frontend frontend-bundle dev dev-frontend test test-go test-go-fast test-frontend e2e e2e-build e2e-web e2e-cli lint lint-json logpolicy pathpolicy literalpolicy architecturepolicy workflow-contracts workflow-contracts-check literalpolicy-fix precommit prepush fmt fmt-go fmt-frontend gofix gofix-check gofix-changed gofix-check-changed commitmsg-check clean
ifeq ($(OS),Windows_NT)
EXE := .exe
FULL_BUILD := pwsh -NoProfile -File ./scripts/build.ps1
MKDIR_DIST := powershell -NoProfile -Command "New-Item -ItemType Directory -Force -Path dist | Out-Null"
RM_DIST := powershell -NoProfile -Command "Remove-Item -Recurse -Force dist, webui/dist -ErrorAction SilentlyContinue"
BLANK := echo.
else
EXE :=
FULL_BUILD := ./scripts/build.sh
MKDIR_DIST := mkdir -p dist
RM_DIST := rm -rf dist webui/dist
BLANK := echo
endif
CLI_OUT := dist/upbrr$(EXE)
E2E_CLI_OUT := dist/upbrr-e2e$(EXE)
GO_TEST_FLAGS := -race -v -timeout 20m
# Per-binary limits; package test concurrency remains Go's default -p.
GO_TEST_SCHEDULER_FLAGS := -cpu=4 -parallel=4
GO_TEST_FAST_FLAGS := -timeout 20m
GOLANGCI_FLAGS := --timeout=5m
help:
@echo Build
@echo make build Full build: WebUI, embedded assets, CLI
@echo make backend Build CLI binary only
@echo make frontend Typecheck and build frontend bundle
@echo make frontend-bundle Build frontend bundle only
@$(BLANK)
@echo Development
@echo make dev Start WebUI server without auth on loopback
@echo make dev-frontend Start Vite dev server only
@$(BLANK)
@echo Testing
@echo make test Run Go and frontend checks
@echo make test-go Run full Go test suite with race detector
@echo make test-go-fast Run full Go test suite without race detector
@echo make test-frontend Run frontend lint/type/format/dead-code/unit checks
@echo make e2e Run all Playwright E2E projects
@echo make e2e-web Run embedded web E2E projects
@echo make e2e-cli Run CLI full-upload E2E project
@$(BLANK)
@echo Linting
@echo make lint Run architecture/path/literal policies and full Go lint
@echo make architecturepolicy Run architecture ownership policy check
@echo make workflow-contracts Generate workflow OpenAPI and WebUI transport types
@echo make workflow-contracts-check Check workflow OpenAPI and WebUI type drift
@echo make lint-json Write Go lint JSON to lint-report.json
@echo make logpolicy Run logging policy check
@echo make pathpolicy Run path portability policy check
@$(BLANK)
@echo Pre-commit
@echo make precommit Run Lefthook pre-commit
@echo make prepush Run Lefthook pre-push
@$(BLANK)
@echo Formatting
@echo make fmt Run Go formatter and frontend Prettier
@echo make fmt-go Run configured Go formatters
@echo make fmt-frontend Run frontend Prettier
@echo make gofix Apply reviewed Go fixes with omitzero disabled
@echo make gofix-check Check Go fix drift with omitzero disabled
@echo make gofix-changed Apply Go fixes to changed packages
@echo make gofix-check-changed Check Go fix drift on changed packages
build:
$(FULL_BUILD)
backend:
$(MKDIR_DIST)
go build -o $(CLI_OUT) ./cmd/upbrr
frontend:
pnpm --dir webui run build
frontend-bundle:
pnpm --dir webui run build:bundle
dev:
go run ./cmd/upbrr serve --dev-no-auth
dev-frontend:
pnpm --dir webui run dev
test: test-go test-frontend
# GO_TEST_SCHEDULER_FLAGS limits each package's test binary, not package concurrency.
test-go:
go test $(GO_TEST_SCHEDULER_FLAGS) $(GO_TEST_FLAGS) ./...
# Keep the fast suite on Go's default per-binary and package concurrency.
test-go-fast:
go test $(GO_TEST_FAST_FLAGS) ./...
test-frontend:
pnpm --dir webui run lint
pnpm --dir webui run lint:dead
pnpm --dir webui run typecheck
pnpm --dir webui run test:unit
pnpm --dir webui run format:check
e2e: e2e-build
pnpm --dir webui run test:e2e:full
e2e-build:
pnpm --dir webui install --frozen-lockfile
pnpm --dir webui run build
ifeq ($(OS),Windows_NT)
pwsh -NoProfile -File ./scripts/sync-webui-assets.ps1
else
sh ./scripts/sync-webui-assets.sh
endif
$(MKDIR_DIST)
go build -tags e2e -o $(E2E_CLI_OUT) ./cmd/upbrr
e2e-web: e2e-build
pnpm --dir webui run test:e2e:web
e2e-cli: e2e-build
pnpm --dir webui exec playwright test --project=cli-full-upload
lint: architecturepolicy pathpolicy literalpolicy workflow-contracts-check
golangci-lint run $(GOLANGCI_FLAGS) ./...
lint-json:
golangci-lint run $(GOLANGCI_FLAGS) --output.json.path lint-report.json ./...
logpolicy:
go run ./cmd/logpolicy
pathpolicy:
go run ./cmd/pathpolicy
literalpolicy:
go run ./cmd/literalpolicy
architecturepolicy:
go run ./cmd/architecturepolicy
workflow-contracts:
go run ./cmd/workflowcontractgen
workflow-contracts-check:
go run ./cmd/workflowcontractgen -check
literalpolicy-fix:
go run ./cmd/literalpolicy -fix
golangci-lint fmt
precommit:
lefthook run pre-commit
git diff --check
$(MAKE) gofix-check-changed
$(MAKE) lint
$(MAKE) logpolicy
$(MAKE) test-frontend
prepush:
lefthook run pre-push
fmt: fmt-go fmt-frontend
fmt-go:
go run ./cmd/literalpolicy -fix
golangci-lint fmt
fmt-frontend:
pnpm --dir webui run format
gofix:
go fix -omitzero=false ./...
gofix-check:
go fix -diff -omitzero=false ./...
gofix-changed:
go run ./cmd/gofixchanged -write
gofix-check-changed:
go run ./cmd/gofixchanged
commitmsg-check:
go run ./cmd/commitmsgcheck $(MSG)
clean:
$(RM_DIST)