-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
93 lines (77 loc) · 2.21 KB
/
Makefile
File metadata and controls
93 lines (77 loc) · 2.21 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
.PHONY: all build run test clean generate generate-db generate-api lint help
# Variables
BINARY_NAME=orchestrix-api
WORKER_BINARY=orchestrix-worker
OPENAPI_SPEC=../api/openapi/v1/openapi.bundled.yaml
# Default target
all: generate build
# Build the API binary
build:
@echo "Building $(BINARY_NAME)..."
go build -o bin/$(BINARY_NAME) ./cmd/api
# Build the worker binary
build-worker:
@echo "Building $(WORKER_BINARY)..."
go build -o bin/$(WORKER_BINARY) ./cmd/worker
# Run the API server
run:
go run ./cmd/api
# Run the worker
run-worker:
go run ./cmd/worker
# Run tests
test:
go test -v ./...
# Clean build artifacts
clean:
rm -rf bin/
rm -rf internal/api/oas/
# Generate all code
generate: generate-db generate-api
# Generate database code with sqlc
generate-db:
@echo "Generating database code with sqlc..."
sqlc generate
# Generate API code with ogen
generate-api:
@echo "Bundling OpenAPI spec..."
cd .. && bunx @redocly/cli bundle api/openapi/v1/openapi.yaml -o api/openapi/v1/openapi.bundled.yaml
@echo "Generating API code with ogen..."
go run github.com/ogen-go/ogen/cmd/ogen@latest \
--target ./internal/api/oas \
--package oas \
--clean \
$(OPENAPI_SPEC)
# Install development tools
tools:
@echo "Installing development tools..."
go install github.com/ogen-go/ogen/cmd/ogen@latest
go install github.com/sqlc-dev/sqlc/cmd/sqlc@latest
# Lint the code
lint:
@echo "Running linter..."
golangci-lint run
# Format the code
fmt:
go fmt ./...
# Tidy dependencies
tidy:
go mod tidy
# Help
help:
@echo "Available targets:"
@echo " all - Generate code and build"
@echo " build - Build the API binary"
@echo " build-worker - Build the worker binary"
@echo " run - Run the API server"
@echo " run-worker - Run the worker"
@echo " test - Run tests"
@echo " clean - Remove build artifacts"
@echo " generate - Generate all code (db + api)"
@echo " generate-db - Generate database code with sqlc"
@echo " generate-api - Generate API code with ogen"
@echo " tools - Install development tools"
@echo " lint - Run linter"
@echo " fmt - Format code"
@echo " tidy - Tidy dependencies"
@echo " help - Show this help"