-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathMakefile
More file actions
313 lines (264 loc) · 11.3 KB
/
Makefile
File metadata and controls
313 lines (264 loc) · 11.3 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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
# Revyl CLI Makefile
# Build, test, and development commands
# Version info (set via ldflags during build)
VERSION ?= $(shell cat VERSION 2>/dev/null | tr -d '[:space:]' || git describe --tags --always --dirty 2>/dev/null || echo "dev")
COMMIT ?= $(shell git rev-parse --short HEAD 2>/dev/null || echo "none")
DATE ?= $(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
# Build flags
LDFLAGS := -ldflags "-X main.version=$(VERSION) -X main.commit=$(COMMIT) -X main.date=$(DATE)"
# Binary name
BINARY := revyl
# Go commands
GOCMD := go
GOBUILD := $(GOCMD) build
GOTEST := $(GOCMD) test
GOGET := $(GOCMD) get
GOMOD := $(GOCMD) mod
GOFMT := gofmt
# Directories
CMD_DIR := ./cmd/revyl
BUILD_DIR := ./build
SCRIPTS_DIR := ./scripts
.PHONY: all build clean test lint fmt deps dev generate install help check vet-all setup-merge-drivers version bump-patch bump-minor bump-major device-prod-smoke device-prod-smoke-ios device-prod-smoke-android device-prod-sdk-smoke device-prod-sdk-smoke-ios device-prod-sdk-smoke-android e2e e2e-quick e2e-device e2e-sdk e2e-local
## help: Show this help message
help:
@echo "Revyl CLI - Development Commands"
@echo ""
@echo "Usage: make [target]"
@echo ""
@echo "Targets:"
@sed -n 's/^##//p' $(MAKEFILE_LIST) | column -t -s ':' | sed -e 's/^/ /'
## all: Build the CLI
all: build
## check: Quick compile and vet check (used by pre-commit)
check:
@echo "Checking Go code..."
@$(GOBUILD) ./cmd/revyl/...
@$(GOCMD) vet ./...
@echo "✅ Go checks passed"
## vet-all: Run go vet for all release platforms (catches cross-compilation errors)
vet-all:
@echo "Running go vet for all platforms..."
@for os in darwin linux windows; do \
echo " vet $$os/amd64..." ; \
GOOS=$$os GOARCH=amd64 $(GOCMD) vet ./... || exit 1 ; \
done
@echo "✅ Cross-platform vet passed"
## build: Build the CLI binary
build:
@echo "Building $(BINARY)..."
@mkdir -p $(BUILD_DIR)
$(GOBUILD) $(LDFLAGS) -o $(BUILD_DIR)/$(BINARY) $(CMD_DIR)
@echo "Built: $(BUILD_DIR)/$(BINARY)"
## build-all: Build for all platforms
build-all:
@echo "Building for all platforms..."
@$(SCRIPTS_DIR)/build-all.sh
## install: Install the CLI to $GOPATH/bin
install:
@echo "Installing $(BINARY)..."
$(GOBUILD) $(LDFLAGS) -o $(GOPATH)/bin/$(BINARY) $(CMD_DIR)
@echo "Installed to $(GOPATH)/bin/$(BINARY)"
## clean: Remove build artifacts
clean:
@echo "Cleaning..."
@rm -rf $(BUILD_DIR)
@rm -f $(BINARY)
## test: Run tests with summary
test:
@echo "Running tests..."
@JSONFILE=$$(mktemp /tmp/revyl-test-XXXXXX.json) ; \
if command -v gotestsum &> /dev/null; then \
gotestsum --format testdox --jsonfile "$$JSONFILE" ./... ; \
TEST_EXIT=$$? ; \
else \
$(GOTEST) -json ./... > "$$JSONFILE" ; \
TEST_EXIT=$$? ; \
fi ; \
PASSED=$$(grep '"Action":"pass"' "$$JSONFILE" | grep -c '"Test":' || true) ; \
FAILED=$$(grep '"Action":"fail"' "$$JSONFILE" | grep -c '"Test":' || true) ; \
SKIPPED=$$(grep '"Action":"skip"' "$$JSONFILE" | grep -c '"Test":' || true) ; \
TOTAL=$$((PASSED + FAILED + SKIPPED)) ; \
echo "" ; \
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" ; \
if [ "$$FAILED" -gt 0 ]; then \
echo " FAIL: $$PASSED passed, $$FAILED failed, $$SKIPPED skipped ($$TOTAL total)" ; \
else \
echo " OK: $$PASSED passed, $$SKIPPED skipped ($$TOTAL total)" ; \
fi ; \
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" ; \
rm -f "$$JSONFILE" ; \
exit $$TEST_EXIT
## test-coverage: Run tests with coverage
test-coverage:
@echo "Running tests with coverage..."
$(GOTEST) -v -coverprofile=coverage.out ./...
$(GOCMD) tool cover -html=coverage.out -o coverage.html
@echo "Coverage report: coverage.html"
## lint: Run linters
lint:
@echo "Running linters..."
@if command -v golangci-lint &> /dev/null; then \
golangci-lint run; \
else \
echo "golangci-lint not installed. Run: go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest"; \
fi
## fmt: Format code
fmt:
@echo "Formatting code..."
$(GOFMT) -s -w .
## deps: Download dependencies
deps:
@echo "Downloading dependencies..."
$(GOMOD) download
$(GOMOD) tidy
## generate: Generate types from cached OpenAPI spec (for CI/contributors)
generate:
@echo "Generating types from cached OpenAPI spec..."
@$(SCRIPTS_DIR)/generate-types.sh
## generate-fetch: Fetch fresh OpenAPI spec and generate types (for internal devs)
generate-fetch:
@echo "Fetching fresh OpenAPI spec and generating types..."
@$(SCRIPTS_DIR)/generate-types.sh --fetch
## dev: Run with hot reload (uses air)
dev:
@if command -v air &> /dev/null; then \
echo "Starting hot reload with air..."; \
air; \
elif command -v watchexec &> /dev/null; then \
$(MAKE) watch; \
else \
echo "Neither air nor watchexec installed."; \
echo "Install air: go install github.com/air-verse/air@latest"; \
echo "Or watchexec: brew install watchexec"; \
echo "Running single build instead..."; \
$(MAKE) build; \
fi
## watch: Watch for changes and rebuild (requires watchexec)
watch:
@if command -v watchexec &> /dev/null; then \
echo "Watching for changes... (Ctrl+C to stop)"; \
watchexec -e go -- $(GOBUILD) $(LDFLAGS) -o $(BUILD_DIR)/$(BINARY) $(CMD_DIR); \
else \
echo "watchexec not installed. Run: brew install watchexec"; \
exit 1; \
fi
## setup-merge-drivers: Register custom merge drivers for generated files
setup-merge-drivers:
@echo "Registering custom merge drivers..."
git config merge.gen-ours.name "Auto-accept ours for generated files"
git config merge.gen-ours.driver true
@echo "✓ Merge driver 'gen-ours' registered (accepts ours for generated files on merge)"
## setup: Install development tools and configure merge drivers
## Tool versions are pinned for reproducibility — update explicitly when upgrading.
setup: setup-merge-drivers
@echo "Installing development tools..."
go install github.com/air-verse/air@v1.61.7
go install github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen@v2.4.1
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.64.8
go install gotest.tools/gotestsum@v1.12.1
brew install watchexec || true
@echo "Done! Run 'make dev' to start development with hot reload."
## run: Run the CLI (pass ARGS for arguments)
run:
@$(GOBUILD) $(LDFLAGS) -o $(BUILD_DIR)/$(BINARY) $(CMD_DIR)
@$(BUILD_DIR)/$(BINARY) $(ARGS)
## device-prod-smoke: Build the local CLI and run the prod device smoke script
device-prod-smoke: build
@REVYL_BIN=$(BUILD_DIR)/$(BINARY) $(SCRIPTS_DIR)/device_prod_smoke.sh $(ARGS)
## device-prod-smoke-ios: Build the local CLI and run the iOS prod device smoke script
device-prod-smoke-ios: build
@REVYL_BIN=$(BUILD_DIR)/$(BINARY) $(SCRIPTS_DIR)/device_prod_smoke.sh --platform ios $(ARGS)
## device-prod-smoke-android: Build the local CLI and run the Android prod device smoke script
device-prod-smoke-android: build
@REVYL_BIN=$(BUILD_DIR)/$(BINARY) $(SCRIPTS_DIR)/device_prod_smoke.sh --platform android $(ARGS)
## device-prod-sdk-smoke: Build the local CLI and run the Python SDK prod smoke script
device-prod-sdk-smoke: build
@cd python && UV_CACHE_DIR=$${UV_CACHE_DIR:-/tmp/uv-cache} uv run python scripts/device_prod_smoke.py --binary ../build/revyl $(ARGS)
## device-prod-sdk-smoke-ios: Build the local CLI and run the iOS Python SDK prod smoke script
device-prod-sdk-smoke-ios: build
@cd python && UV_CACHE_DIR=$${UV_CACHE_DIR:-/tmp/uv-cache} uv run python scripts/device_prod_smoke.py --binary ../build/revyl --platform ios $(ARGS)
## device-prod-sdk-smoke-android: Build the local CLI and run the Android Python SDK prod smoke script
device-prod-sdk-smoke-android: build
@cd python && UV_CACHE_DIR=$${UV_CACHE_DIR:-/tmp/uv-cache} uv run python scripts/device_prod_smoke.py --binary ../build/revyl --platform android $(ARGS)
# ---------- Version management ----------
# Read the current version from the VERSION file
CURRENT_VERSION := $(shell cat VERSION 2>/dev/null | tr -d '[:space:]')
## version: Print the current version from the VERSION file
version:
@echo "$(CURRENT_VERSION)"
## bump-patch: Bump patch version (e.g. 0.1.1 -> 0.1.2) and sync all version files
bump-patch:
@OLD="$(CURRENT_VERSION)" ; \
MAJOR=$$(echo "$$OLD" | cut -d. -f1) ; \
MINOR=$$(echo "$$OLD" | cut -d. -f2) ; \
PATCH=$$(echo "$$OLD" | cut -d. -f3) ; \
NEW="$$MAJOR.$$MINOR.$$((PATCH + 1))" ; \
$(MAKE) _set-version OLD="$$OLD" NEW="$$NEW"
## bump-minor: Bump minor version (e.g. 0.1.1 -> 0.2.0) and sync all version files
bump-minor:
@OLD="$(CURRENT_VERSION)" ; \
MAJOR=$$(echo "$$OLD" | cut -d. -f1) ; \
MINOR=$$(echo "$$OLD" | cut -d. -f2) ; \
NEW="$$MAJOR.$$((MINOR + 1)).0" ; \
$(MAKE) _set-version OLD="$$OLD" NEW="$$NEW"
## bump-major: Bump major version (e.g. 0.1.1 -> 1.0.0) and sync all version files
bump-major:
@OLD="$(CURRENT_VERSION)" ; \
MAJOR=$$(echo "$$OLD" | cut -d. -f1) ; \
NEW="$$((MAJOR + 1)).0.0" ; \
$(MAKE) _set-version OLD="$$OLD" NEW="$$NEW"
# Internal target: write the new version to all version files.
# Called by bump-patch, bump-minor, bump-major with OLD and NEW variables.
_set-version:
@echo "Bumping version: $(OLD) -> $(NEW)"
@printf "$(NEW)\n" > VERSION
@sed -i.bak 's/"version": "$(OLD)"/"version": "$(NEW)"/' npm/package.json && rm -f npm/package.json.bak
@sed -i.bak 's/version = "$(OLD)"/version = "$(NEW)"/' python/pyproject.toml && rm -f python/pyproject.toml.bak
@sed -i.bak 's/__version__ = "$(OLD)"/__version__ = "$(NEW)"/' python/revyl/_binary.py && rm -f python/revyl/_binary.py.bak
@echo "Updated files:"
@echo " VERSION $(NEW)"
@echo " npm/package.json $(NEW)"
@echo " python/pyproject.toml $(NEW)"
@echo " python/revyl/_binary.py $(NEW)"
@echo ""
@echo "Next steps:"
@echo " git add -A && git commit -m 'chore: bump version to $(NEW)'"
@echo " Then merge to main to trigger a release."
# ---------- E2E regression suite ----------
## e2e: Run all e2e regression tests (auto-detects local backend or staging)
e2e:
@echo "Running e2e regression tests..."
@if command -v gotestsum &> /dev/null; then \
gotestsum --format testdox -- -tags e2e -v -timeout 15m ./e2e/... ; \
else \
$(GOTEST) -tags e2e -v -timeout 15m ./e2e/... ; \
fi
## e2e-quick: Run non-device e2e tests only (faster, no device session needed)
e2e-quick:
@echo "Running quick e2e tests (no device)..."
@if command -v gotestsum &> /dev/null; then \
gotestsum --format testdox -- -tags e2e -v -timeout 10m -run 'Test(Auth|Test|Workflow|App|Module|Tag|Variable|Script|Sync|CLI|Error|TUI)' ./e2e/... ; \
else \
$(GOTEST) -tags e2e -v -timeout 10m -run 'Test(Auth|Test|Workflow|App|Module|Tag|Variable|Script|Sync|CLI|Error|TUI)' ./e2e/... ; \
fi
## e2e-device: Run device e2e tests only (requires REVYL_E2E_DEVICE=true)
e2e-device:
@echo "Running device e2e tests..."
@REVYL_E2E_DEVICE=true $(GOTEST) -tags e2e -v -timeout 15m -run TestDevice ./e2e/...
## e2e-sdk: Run Python SDK regression tests
e2e-sdk:
@echo "Running Python SDK regression tests..."
@cd python && UV_CACHE_DIR=$${UV_CACHE_DIR:-/tmp/uv-cache} uv run pytest tests/test_sdk_regression.py -v --tb=short
## e2e-local: Run CLI-local tests only (zero backend, always passes)
e2e-local:
@echo "Running local CLI tests (no backend needed)..."
@$(GOTEST) -tags e2e -v -timeout 2m -run TestCLILocal ./e2e/...
# Development shortcuts
.PHONY: r b t
## r: Shortcut for 'make run'
r: run
## b: Shortcut for 'make build'
b: build
## t: Shortcut for 'make test'
t: test