-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTaskfile.yml
More file actions
328 lines (277 loc) · 7.58 KB
/
Taskfile.yml
File metadata and controls
328 lines (277 loc) · 7.58 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
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
version: '3'
vars:
API_ADDR: ":8080"
USER_ADDR: ":8081"
POSTGRES_DSN: "postgres://postgres:postgres@localhost:5432/linkkeeper?sslmode=disable"
API_BASE_URL: "http://localhost:8080"
USER_SERVICE_URL: "http://localhost:8081"
TELEGRAM_TOKEN: ""
tasks:
default:
desc: Show available tasks
cmds:
- task --list
# ============================================
# Docker Compose tasks
# ============================================
docker:up:
desc: Start all services via Docker Compose
cmds:
- docker-compose up -d
preconditions:
- test: -f docker-compose.yml
docker:down:
desc: Stop all Docker Compose services
cmds:
- docker-compose down
docker:logs:
desc: Show logs for all services
cmds:
- docker-compose logs -f
docker:build:
desc: Rebuild Docker images
cmds:
- docker-compose build
docker:clean:
desc: Stop and remove containers, volumes and networks
cmds:
- docker-compose down -v --remove-orphans
# ============================================
# Database
# ============================================
db:up:
desc: Start PostgreSQL via Docker
cmds:
- docker-compose up -d postgres
db:down:
desc: Stop PostgreSQL
cmds:
- docker-compose stop postgres
db:logs:
desc: Show PostgreSQL logs
cmds:
- docker-compose logs -f postgres
db:migrate:
desc: Apply database migrations
cmds:
- |
echo "Applying migrations..."
for file in migrations/*.sql; do
if [ -f "$file" ]; then
echo "Applying $file"
docker-compose exec -T postgres psql -U postgres -d linkkeeper < "$file"
fi
done
echo "Migrations applied"
db:shell:
desc: Connect to PostgreSQL via psql
cmds:
- docker-compose exec postgres psql -U postgres -d linkkeeper
# ============================================
# API Service
# ============================================
api:build:
desc: Build API service
cmds:
- go build -o bin/api-service ./cmd/api-service
api:run:
desc: Run API service locally
deps: [db:up]
cmds:
- |
export HTTP_ADDR="{{.API_ADDR}}"
export POSTGRES_DSN="{{.POSTGRES_DSN}}"
go run ./cmd/api-service
api:test:
desc: Run API service tests
cmds:
- go test ./internal/api-service/...
# ============================================
# User Service
# ============================================
user:build:
desc: Build User service
cmds:
- go build -o bin/user-service ./cmd/user-service
user:run:
desc: Run User service locally
deps: [db:up]
cmds:
- |
export HTTP_ADDR="{{.USER_ADDR}}"
export POSTGRES_DSN="{{.POSTGRES_DSN}}"
go run ./cmd/user-service
user:test:
desc: Run User service tests
cmds:
- go test ./internal/user-service/...
# ============================================
# Bot Service
# ============================================
bot:build:
desc: Build Bot service
cmds:
- go build -o bin/bot-service ./cmd/bot-service
bot:run:
desc: Run Bot service locally
deps: [api:run, user:run]
cmds:
- |
if [ -z "{{.TELEGRAM_TOKEN}}" ]; then
echo "Error: TELEGRAM_TOKEN is not set"
echo "Set the variable: export TELEGRAM_TOKEN=your_token"
exit 1
fi
export TELEGRAM_TOKEN="{{.TELEGRAM_TOKEN}}"
export API_BASE_URL="{{.API_BASE_URL}}"
export USER_SERVICE_URL="{{.USER_SERVICE_URL}}"
go run ./cmd/bot-service
# ============================================
# Frontend
# ============================================
frontend:install:
desc: Install frontend dependencies
dir: frontend
cmds:
- npm install
frontend:start:
desc: Start frontend (Expo)
dir: frontend
deps: [frontend:install]
cmds:
- npm start
frontend:web:
desc: Start frontend in browser
dir: frontend
deps: [frontend:install]
cmds:
- npm run web
frontend:android:
desc: Start frontend on Android
dir: frontend
deps: [frontend:install]
cmds:
- npm run android
frontend:ios:
desc: Start frontend on iOS
dir: frontend
deps: [frontend:install]
cmds:
- npm run ios
# ============================================
# Development
# ============================================
dev:all:
desc: Run all services for development (DB + API + Bot)
deps: [db:up]
cmds:
- task api:run
- task bot:run
dev:api:
desc: Run only API service for development
deps: [db:up]
cmds:
- task api:run
dev:frontend:
desc: Run frontend for development
cmds:
- task frontend:start
# ============================================
# Utilities
# ============================================
clean:
desc: Clean compiled files
cmds:
- rm -rf bin/
- rm -rf frontend/node_modules/
- rm -rf frontend/.expo/
deps:
desc: Install all dependencies (Go and npm)
cmds:
- go mod download
- go mod vendor
- task frontend:install
fmt:
desc: Format Go code
cmds:
- go fmt ./...
lint:
desc: Check Go code with linter
cmds:
- go vet ./...
- |
if ! command -v golangci-lint &> /dev/null; then
echo "golangci-lint not installed. Run: brew install golangci-lint"
exit 1
fi
golangci-lint run --timeout=5m
test:
desc: Run all tests
cmds:
- go test -v -race ./...
test:unit:
desc: Run unit tests only
cmds:
- go test -v -race -short ./internal/...
test:integration:
desc: Run integration tests
cmds:
- go test -v -race ./tests/...
test:coverage:
desc: Run tests with coverage report
cmds:
- go test -v -race -coverprofile=coverage.out -covermode=atomic ./...
- go tool cover -html=coverage.out -o coverage.html
- |
echo "Coverage report generated: coverage.html"
go tool cover -func=coverage.out | grep total || true
test:watch:
desc: Watch and run tests on file changes
cmds:
- |
echo "Watching for file changes..."
while true; do
go test -v -short ./...
inotifywait -r -e modify ./internal ./cmd ./tests 2>/dev/null || fswatch -o ./internal ./cmd ./tests | read
done
hooks:install:
desc: Install pre-commit hooks
cmds:
- |
if ! command -v pre-commit &> /dev/null; then
echo "Installing pre-commit..."
pip3 install pre-commit || pip install pre-commit
fi
pre-commit install
echo "Pre-commit hooks installed successfully!"
ci:local:
desc: Run CI checks locally (fmt, vet, lint, test)
cmds:
- task: fmt
- task: lint
- task: test:coverage
- echo "All CI checks passed!"
# ============================================
# Full run
# ============================================
start:
desc: Start the entire project (Docker Compose)
cmds:
- task docker:up
- |
echo "Services started:"
echo " - PostgreSQL: localhost:5432"
echo " - User Service: http://localhost:8081"
echo " - API Service: http://localhost:8080"
echo " - Bot Service: running (requires TELEGRAM_TOKEN)"
echo ""
echo "To start frontend run: task frontend:start"
stop:
desc: Stop the entire project
cmds:
- task docker:down
restart:
desc: Restart the entire project
cmds:
- task stop
- task start