-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTaskfile.yaml
More file actions
195 lines (166 loc) · 4.97 KB
/
Copy pathTaskfile.yaml
File metadata and controls
195 lines (166 loc) · 4.97 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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
version: '3'
vars:
BINARY_NAME: pganalyzer
BUILD_DIR: ./bin
VERSION:
sh: git describe --tags --always --dirty 2>/dev/null || echo "dev"
COMMIT:
sh: git rev-parse --short HEAD 2>/dev/null || echo "unknown"
BUILD_DATE:
sh: date -u +"%Y-%m-%dT%H:%M:%SZ"
LDFLAGS: -s -w -X main.version={{.VERSION}} -X main.commit={{.COMMIT}} -X main.buildDate={{.BUILD_DATE}}
tasks:
default:
desc: Show available tasks
cmds:
- task --list-all
css:
desc: Build CSS with Tailwind
cmds:
- ./scripts/build-css.sh
sources:
- internal/web/templates/**/*.html
- internal/web/tailwind/**/*
generates:
- internal/web/static/style.css
css:watch:
desc: Watch and rebuild CSS on changes
cmds:
- |
./bin/tailwindcss \
-c internal/web/tailwind/tailwind.config.js \
-i internal/web/tailwind/input.css \
-o internal/web/static/style.css \
--watch
css:install:
desc: Download Tailwind CLI binary
cmds:
- ./scripts/build-css.sh
status:
- test -f ./bin/tailwindcss
build:
desc: Build the application
deps: [css]
cmds:
- mkdir -p {{.BUILD_DIR}}
- go build -ldflags "{{.LDFLAGS}}" -o {{.BUILD_DIR}}/{{.BINARY_NAME}} ./cmd/pganalyzer
sources:
- ./**/*.go
generates:
- "{{.BUILD_DIR}}/{{.BINARY_NAME}}"
build:dev:
desc: Build with race detector enabled (for development)
cmds:
- mkdir -p {{.BUILD_DIR}}
- go build -race -ldflags "{{.LDFLAGS}}" -o {{.BUILD_DIR}}/{{.BINARY_NAME}} ./cmd/pganalyzer
run:
desc: Build and run the application
deps: [build]
cmds:
- "{{.BUILD_DIR}}/{{.BINARY_NAME}} {{.CLI_ARGS}}"
test:
desc: Run tests
cmds:
- go test -v ./...
test:coverage:
desc: Run tests with coverage
cmds:
- go test -v -coverprofile=coverage.out ./...
- go tool cover -html=coverage.out -o coverage.html
test:race:
desc: Run tests with race detector
cmds:
- go test -race -v ./...
lint:
desc: Run linters
cmds:
- golangci-lint run ./...
fmt:
desc: Format code
cmds:
- go fmt ./...
- goimports -w .
tidy:
desc: Tidy dependencies
cmds:
- go mod tidy
clean:
desc: Clean build artifacts
cmds:
- rm -rf {{.BUILD_DIR}}
- rm -f coverage.out coverage.html
version:
desc: Show version information
cmds:
- echo "Version:" {{.VERSION}}
- echo "Commit:" {{.COMMIT}}
- echo "Build Date:" {{.BUILD_DATE}}
docker:build:
desc: Build Docker image
cmds:
- docker build
--build-arg VERSION={{.VERSION}}
--build-arg COMMIT={{.COMMIT}}
--build-arg BUILD_DATE={{.BUILD_DATE}}
-t {{.BINARY_NAME}}:{{.VERSION}}
-t {{.BINARY_NAME}}:latest .
docker:run:
desc: Run Docker container (standalone)
cmds:
- docker run --rm -p 8080:8080
-v $(pwd)/data:/app/data
-v $(pwd)/configs/config.yaml:/app/configs/config.yaml:ro
{{.BINARY_NAME}}:{{.VERSION}}
docker:up:
desc: Start all services with docker-compose (pganalyzer + postgres)
cmds:
- docker compose --profile full up -d
docker:up:standalone:
desc: Start pganalyzer only (connects to external postgres)
cmds:
- docker compose --profile standalone up -d
docker:up:postgres:
desc: Start only PostgreSQL for development
cmds:
- docker compose --profile postgres-only up -d
docker:down:
desc: Stop all docker-compose services
cmds:
- docker compose --profile full --profile standalone --profile postgres-only down
docker:logs:
desc: View docker-compose logs
cmds:
- docker compose logs -f {{.CLI_ARGS}}
docker:clean:
desc: Remove docker volumes and images
cmds:
- docker compose --profile full --profile standalone --profile postgres-only down -v
- docker rmi {{.BINARY_NAME}}:{{.VERSION}} {{.BINARY_NAME}}:latest 2>/dev/null || true
install:tools:
desc: Install development tools
cmds:
- go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
- go install golang.org/x/tools/cmd/goimports@latest
test:integration:
desc: Run integration tests (requires PostgreSQL)
cmds:
- go test -v -tags=integration ./tests/integration/...
test:integration:docker:
desc: Run integration tests with docker postgres
cmds:
- task: docker:up:postgres
- defer: { task: docker:down }
- sleep 5 # Wait for postgres to be ready
- POSTGRES_HOST=localhost POSTGRES_PORT=5432 POSTGRES_USER=postgres POSTGRES_PASSWORD=postgres POSTGRES_DATABASE=testdb go test -v -tags=integration ./tests/integration/...
migrate:
desc: Run database migrations manually
deps: [build]
cmds:
- "{{.BUILD_DIR}}/{{.BINARY_NAME}} --migrate-only {{.CLI_ARGS}}"
all:
desc: Run fmt, lint, test, and build
cmds:
- task: fmt
- task: lint
- task: test
- task: build