-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTaskfile.yml
More file actions
135 lines (121 loc) · 3.77 KB
/
Taskfile.yml
File metadata and controls
135 lines (121 loc) · 3.77 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
version: "3"
vars:
BACKEND_DIR: backend
EXAMPLE_CLIENT_DIR: example-client-nestjs
UI_DIR: UI
tasks:
# Start MongoDB and run migrations, then start the backend server
backend:
desc: Start the backend server (MongoDB + migrations + server)
dir: "{{.BACKEND_DIR}}"
preconditions:
- test -f go.mod
cmds:
- task: setup-db
- echo "🚀 Starting backend server..."
- go run cmd/server/main.go
# Setup database (MongoDB + migrations)
setup-db:
desc: Start MongoDB and run migrations (no auth for local dev)
cmds:
- echo "📦 Starting MongoDB and RabbitMQ..."
- docker-compose -f docker-compose.localdev.yml up -d mongodb rabbitmq
- echo "⏳ Waiting for MongoDB to be ready..."
- sleep 5
- echo "🔄 Running migrations..."
- task: migrate
- echo "✅ Database setup complete!"
# Run database migrations
migrate:
desc: Run database migrations
dir: "{{.BACKEND_DIR}}"
cmds:
- go run cmd/migrate/main.go create-collections
# Start the NestJS example client
example-client-nestjs:
desc: Start the NestJS example client
dir: "{{.EXAMPLE_CLIENT_DIR}}"
preconditions:
- test -f package.json
cmds:
- echo "🚀 Starting NestJS example client..."
- npm run start:dev
# Start the UI
ui:
desc: Start the UI frontend
dir: "{{.UI_DIR}}"
preconditions:
- test -f package.json
cmds:
- echo "🚀 Starting UI..."
- pnpm dev
# Generate OpenAPI documentation and API client
gen:openapi:
desc: Generate OpenAPI documentation (backend) and TypeScript API client (frontend)
cmds:
- ./scripts/generate-openapi.sh
# Generate gomock mocks
gen:mocks:
desc: Generate gomock mocks for interfaces
dir: "{{.BACKEND_DIR}}"
cmds:
- echo "🔨 Generating mocks..."
- go run go.uber.org/mock/mockgen@latest -source=internal/repositories/repository.go -destination=mocks/mock_repository.go -package=mocks
- go run go.uber.org/mock/mockgen@latest -source=internal/deleteworker/worker.go -destination=mocks/mock_worker.go -package=mocks
- echo "✅ Mocks generated successfully!"
# Run tests
test:
desc: Run all backend tests
dir: "{{.BACKEND_DIR}}"
preconditions:
- test -f go.mod
cmds:
- echo "Running tests..."
- go test ./... -v
- echo "Tests completed!"
# Run tests for a specific package
test:package:
desc: "Run tests for a specific package (usage: task test:package -- package-path)"
dir: "{{.BACKEND_DIR}}"
preconditions:
- test -f go.mod
cmds:
- echo "Running tests for {{.CLI_ARGS}}..."
- go test {{.CLI_ARGS}} -v
- echo "Tests completed!"
# Run tests with coverage
test:coverage:
desc: Run all tests with coverage report
dir: "{{.BACKEND_DIR}}"
preconditions:
- test -f go.mod
cmds:
- echo "Running tests with coverage..."
- go test ./... -v -coverprofile=coverage.out
- go tool cover -html=coverage.out -o coverage.html
- echo "Coverage report generated at coverage.html"
# Cleanup: Kill all services and free ports
cleanup:
desc: Clean up all services and free ports
cmds:
- ./scripts/cleanup.sh
# Start all services (backend, example-client-nestjs, and UI)
up:
desc: Start all services (backend, example-client-nestjs, and UI)
cmds:
- task: cleanup
- |
echo "🚀 Starting all services..."
PIDS=()
task backend &
PIDS+=($!)
task example-client-nestjs &
PIDS+=($!)
task ui &
PIDS+=($!)
wait
# Build and push Docker image
build:
desc: Build Docker image and optionally push to Docker Hub
cmds:
- bash scripts/build-and-push.sh {{.CLI_ARGS}}