-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
79 lines (63 loc) · 2.19 KB
/
Makefile
File metadata and controls
79 lines (63 loc) · 2.19 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
.PHONY: build test lint clean install help test-all test-integration test-e2e test-coverage coverage docker-up docker-down
BINARY_NAME=dbdiff
VERSION=$(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
COMMIT=$(shell git rev-parse HEAD 2>/dev/null || echo "unknown")
BUILD_DATE=$(shell date -u '+%Y-%m-%d_%H:%M:%S')
LDFLAGS=-ldflags "-X=main.version=${VERSION} -X=main.commit=${COMMIT} -X=main.buildDate=${BUILD_DATE}"
help:
@echo "DBDiff Makefile"
@echo ""
@echo "Targets:"
@echo " build Build binary"
@echo " test Run unit tests"
@echo " test-coverage Run tests with coverage"
@echo " test-all Run all tests (unit + integration)"
@echo " test-integration Run integration tests (requires Docker)"
@echo " test-e2e Run E2E tests"
@echo " lint Run linter"
@echo " lint-fix Run linter with auto-fix"
@echo " coverage Generate coverage report"
@echo " docker-up Start test containers"
@echo " docker-down Stop test containers"
@echo " clean Clean build artifacts"
@echo " install Install binary"
@echo " release Create release (requires tag)"
build:
@echo "Building ${BINARY_NAME}..."
go build ${LDFLAGS} -o ${BINARY_NAME} .
@echo "Build complete: ./${BINARY_NAME}"
test:
go test -v -race -coverprofile=coverage.out ./...
test-all: test test-integration
test-integration:
@echo "Running integration tests..."
@if ! command -v docker-compose &> /dev/null; then \
echo "docker-compose not found. Skipping integration tests."; \
exit 0; \
fi
./scripts/run_integration_tests.sh
test-e2e:
@echo "Running E2E tests..."
go run -tags=e2e test/e2e/main.go
test-coverage:
go test -race -coverprofile=coverage.out ./...
go tool cover -html=coverage.out -o coverage.html
@echo "Coverage report: coverage.html"
coverage: test-coverage
lint:
golangci-lint run ./...
lint-fix:
golangci-lint run ./... --fix
docker-up:
docker-compose up -d
@echo "Waiting for databases..."
sleep 10
docker-down:
docker-compose down -v
clean:
rm -f ${BINARY_NAME}
rm -f coverage.out coverage.html
install:
go install ${LDFLAGS}
release:
goreleaser release --clean