-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
80 lines (63 loc) · 2.14 KB
/
Makefile
File metadata and controls
80 lines (63 loc) · 2.14 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
.PHONY: build run test lint clean help compose-up compose-down migrate-up migrate-down
# Variables
BINARY_NAME=notes-api
MAIN_PATH=./cmd/notes-api
COMPOSE_FILE=deployments/docker-compose.yml
# Default target
help:
@echo "Available targets:"
@echo " build - Build the application"
@echo " run - Run the application locally"
@echo " test - Run all tests"
@echo " test-unit - Run unit tests only"
@echo " test-integration - Run integration tests only"
@echo " lint - Run linter"
@echo " clean - Clean build artifacts"
@echo " compose-up - Start services with Docker Compose"
@echo " compose-down - Stop services with Docker Compose"
@echo " migrate-up - Run database migrations up"
@echo " migrate-down - Run database migrations down"
# Build application
build:
go build -o bin/$(BINARY_NAME) $(MAIN_PATH)
# Run application locally
run:
go run $(MAIN_PATH)
# Run tests
test:
go test -v -race -coverprofile=coverage.out ./...
test-unit:
go test -v -race -short ./...
test-integration:
go test -v -race -run Integration ./...
# Lint code
lint:
golangci-lint run
# Clean build artifacts
clean:
rm -rf bin/
rm -f coverage.out
# Docker Compose commands
compose-up:
docker compose -f $(COMPOSE_FILE) up -d
compose-down:
docker compose -f $(COMPOSE_FILE) down
# Database migration commands
migrate-up:
migrate -path internal/db/migrations -database "postgres://postgres:postgres@localhost:5432/notes_db?sslmode=disable" up
migrate-down:
migrate -path internal/db/migrations -database "postgres://postgres:postgres@localhost:5432/notes_db?sslmode=disable" down
# Generate mocks (if using mockgen)
generate:
go generate ./...
# Install dependencies
deps:
go mod download
go mod tidy
# Install development tools
install-tools:
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
go install -tags 'postgres' github.com/golang-migrate/migrate/v4/cmd/migrate@latest
# Install migrate CLI tool specifically
install-migrate:
go install -tags 'postgres' github.com/golang-migrate/migrate/v4/cmd/migrate@latest