-
Notifications
You must be signed in to change notification settings - Fork 58
Expand file tree
/
Copy pathMakefile
More file actions
53 lines (44 loc) · 1.73 KB
/
Makefile
File metadata and controls
53 lines (44 loc) · 1.73 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
SHELL := /bin/bash
.PHONY: oapi-generate build dev test clean
BIN_DIR ?= $(CURDIR)/bin
RECORDING_DIR ?= $(CURDIR)/recordings
$(BIN_DIR):
mkdir -p $(BIN_DIR)
$(RECORDING_DIR):
mkdir -p $(RECORDING_DIR)
# Generate Go code from the OpenAPI spec
# 1. Convert 3.1 → 3.0 since oapi-codegen doesn't support 3.1 yet (https://github.com/oapi-codegen/oapi-codegen/issues/373)
# 2. Run oapi-codegen with our config (version pinned via go.mod tool directive)
# 3. go mod tidy to pull deps
oapi-generate:
pnpm i -g @apiture/openapi-down-convert
openapi-down-convert --input openapi.yaml --output openapi-3.0.yaml
go tool oapi-codegen -config ./oapi-codegen.yaml ./openapi-3.0.yaml
@echo "Fixing oapi-codegen issue https://github.com/oapi-codegen/oapi-codegen/issues/1764..."
go run ./scripts/oapi/patch_sse_methods -file ./lib/oapi/oapi.go -expected-replacements 4
go fmt ./lib/oapi/oapi.go
go mod tidy
build: | $(BIN_DIR)
go build -o $(BIN_DIR)/api ./cmd/api
dev: build $(RECORDING_DIR)
OUTPUT_DIR=$(RECORDING_DIR) DISPLAY_NUM=$(DISPLAY_NUM) ./bin/api
# we run the e2e tests separately so that we can see the logs from the e2e tests as they run instead of waiting for all tests to complete
test:
go vet ./...
go test -v -race $$(go list ./... | grep -v /e2e$$)
@echo ""
@echo "=== Running e2e tests (testcontainers — this may take a few minutes) ==="
@echo ""
go test -v -race ./e2e/
clean:
@rm -rf $(BIN_DIR)
@rm -f openapi-3.0.yaml
@echo "Clean complete"
DISPLAY_NUM := $(shell \
if [ "$$(uname)" = "Linux" ]; then \
echo "1"; \
elif [ "$$(uname)" = "Darwin" ]; then \
ffmpeg -f avfoundation -list_devices true -i "" 2>&1 | grep "Capture screen" | head -1 | sed 's/.*\[\([0-9]*\)\].*/\1/' 2>/dev/null || echo "2"; \
else \
echo "0"; \
fi)