-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathMakefile
More file actions
101 lines (78 loc) · 2.5 KB
/
Makefile
File metadata and controls
101 lines (78 loc) · 2.5 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
build: generate test server client
generate: sqlc
go generate ./...
sqlc:
sqlc compile
sqlc generate
test:
go test -v ./...
# Test database management
test-db-start:
./scripts/test-db.sh start
test-db-stop:
./scripts/test-db.sh stop
test-db-restart:
./scripts/test-db.sh restart
test-db-status:
./scripts/test-db.sh status
test-db-shell:
./scripts/test-db.sh shell
test-db-reset:
@echo "Resetting test database (drop, recreate, load schema)..."
./scripts/test-db.sh reset
# Run unit tests only (fast, no dependencies)
test-unit:
go test ./... -short -v
# Run integration tests (requires test database)
test-integration:
@if [ -z "$$TEST_DATABASE_URL" ]; then \
echo "Starting test database..."; \
./scripts/test-db.sh start > /dev/null 2>&1 || true; \
echo "Running integration tests..."; \
TEST_DATABASE_URL="monitor:test123@tcp(localhost:3308)/monitor_test?parseTime=true&multiStatements=true" go test ./... -tags=integration -v; \
else \
echo "Using existing TEST_DATABASE_URL..."; \
go test ./... -tags=integration -v; \
fi
# Run load tests (requires test database)
test-load:
@if [ -z "$$TEST_DATABASE_URL" ]; then \
echo "Starting test database..."; \
./scripts/test-db.sh start > /dev/null 2>&1 || true; \
echo "Running load tests..."; \
TEST_DATABASE_URL="monitor:test123@tcp(localhost:3308)/monitor_test?parseTime=true&multiStatements=true" go test ./... -tags=load -v -timeout=30m; \
else \
echo "Using existing TEST_DATABASE_URL..."; \
go test ./... -tags=load -v -timeout=30m; \
fi
# Run all tests (unit + integration + load)
test-all: test-unit test-integration
# Generate test coverage report
coverage:
go test -coverprofile=coverage.out ./...
go tool cover -html=coverage.out -o coverage.html
@echo "Coverage report generated: coverage.html"
# Benchmark tests
benchmark:
go test -bench=. -benchmem ./...
# CI-like testing locally
test-ci-local:
@echo "Running CI-like tests locally..."
./scripts/test-ci-local.sh
test-ci-debug:
@echo "Running CI tests with debugging..."
./scripts/test-ci-debug.sh
test-ci-minimal:
@echo "Running minimal CI test..."
./scripts/test-minimal-ci.sh
tools:
go install github.com/fullstorydev/grpcurl/cmd/grpcurl@latest
go install github.com/twitchtv/twirp/protoc-gen-twirp@latest
TAG ?= ""
tag:
GIT_COMMITTER_DATE="$(git show --format=%aD | head -1)" git tag -a $(TAG)
docker:
docker build -t harbor.ntppool.org/ntppool/monitor-api:$(TAG) .
docker push harbor.ntppool.org/ntppool/monitor-api:$(TAG)
sign:
drone sign --save ntppool/monitor