-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmise.toml
More file actions
298 lines (253 loc) · 10.4 KB
/
Copy pathmise.toml
File metadata and controls
298 lines (253 loc) · 10.4 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
# mise configuration for stickerlandia
experimental_monorepo_root = true
[settings]
experimental = true
auto_install = false
# =============================================================================
# setup: Local development environment setup
# =============================================================================
[tasks."setup_localdev"]
description = "Install all development tools required for local development"
run = """
echo "Installing development tools..."
mise use --global node@22
mise use --global go@1.25
mise use --global java@temurin-21
mise use --global maven@3.9
mise use --global dotnet@10
echo "All development tools installed successfully!"
echo "Tools can be activated by running 'mise activate' in your shell."
"""
# =============================================================================
# env: Environment setup
# =============================================================================
[env]
_.file = { path = ".env", optional = true }
[tasks."env:setup"]
description = "Create .env file with required configuration"
hide = true
run = """
if [ -f .env ]; then
exit 0
fi
echo "Creating .env file..."
echo "Press Enter to use default values shown in brackets"
read -p "Environment name (e.g., your initials) [dev]: " ENV
ENV=${ENV:-dev}
read -p "Datadog API Key: " DD_API_KEY
read -p "Datadog Site [datadoghq.eu]: " DD_SITE
DD_SITE=${DD_SITE:-datadoghq.eu}
read -p "Datadog RUM Application ID [default-rum-app-id]: " DD_RUM_APPLICATION_ID
DD_RUM_APPLICATION_ID=${DD_RUM_APPLICATION_ID:-default-rum-app-id}
read -p "Datadog RUM Client Token [default-rum-client-token]: " DD_RUM_CLIENT_TOKEN
DD_RUM_CLIENT_TOKEN=${DD_RUM_CLIENT_TOKEN:-default-rum-client-token}
read -p "Commit SHA [latest]: " COMMIT_SHA
COMMIT_SHA=${COMMIT_SHA:-latest}
if [ -n "$CODESPACE_NAME" ]; then
DEPLOYMENT_HOST_URL="https://${CODESPACE_NAME}-8080.app.github.dev"
else
DEPLOYMENT_HOST_URL="http://localhost:8080"
fi
cat > .env << EOF
# Deployment Configuration
ENV=$ENV
COMMIT_SHA=$COMMIT_SHA
DEPLOYMENT_HOST_URL=$DEPLOYMENT_HOST_URL
# Datadog Configuration
DD_API_KEY=$DD_API_KEY
DD_SITE=$DD_SITE
DD_RUM_APPLICATION_ID=$DD_RUM_APPLICATION_ID
DD_RUM_CLIENT_TOKEN=$DD_RUM_CLIENT_TOKEN
EOF
echo ""
echo ".env file created successfully!"
"""
# =============================================================================
# build: Build tasks
# =============================================================================
[tasks."build:local"]
description = "Build all services locally"
run = "mise run '//...:build:local'"
[tasks."build:docker-dev"]
description = "Build all dev containers"
run = "mise run '//...:build:docker-dev'"
[tasks."build:docker-release"]
description = "Build all release containers"
run = "mise run '//...:build:docker-release'"
# =============================================================================
# infra: Infrastructure setup tasks
# =============================================================================
[tasks."infra:install"]
description = "Install all CDK dependencies"
run = "mise run '//...:infra:install'"
# =============================================================================
# compose: Docker Compose tasks
# =============================================================================
[tasks."compose:deploy:local"]
description = "Deploy all services locally (build from source)"
depends = ["env:setup"]
run = "docker compose --profile monitoring build && docker compose --profile monitoring up -d"
[tasks."compose:deploy:release"]
description = "Deploy all services using prebuilt GHCR images"
depends = ["env:setup"]
run = "docker compose --profile monitoring --profile load-test -f docker-compose.yml -f docker-compose.prebuilt.yml up -d"
[tasks."compose:deploy:ci"]
description = "Deploy services for CI (no monitoring)"
depends = ["env:setup"]
run = "docker compose build && docker compose up -d"
[tasks."compose:dev"]
description = "Deploy all services with hot reload"
depends = ["env:setup"]
run = "docker compose --profile monitoring -f docker-compose.yml -f docker-compose.dev.yml build && docker compose --profile monitoring -f docker-compose.yml -f docker-compose.dev.yml up -d"
[tasks."compose:down"]
description = "Stop and remove all containers and volumes"
run = "docker compose --profile monitoring down -v"
# =============================================================================
# test: Testing tasks
# =============================================================================
[tasks."test:wait"]
description = "Wait for all services to be healthy"
depends = ["env:setup"]
run = "./scripts/wait-for-services.sh"
[tasks."test:services"]
description = "Test that all services are responding"
depends = ["env:setup"]
run = "./scripts/test-services.sh --max-retries 5 --retry-delay 10"
# =============================================================================
# aws: AWS deployment tasks
#
# Deployment modes are controlled via the DEPLOY_MODE environment variable:
# - local: Build containers from local Dockerfiles (DEPLOY_MODE=local)
# - release: Pull prebuilt images from GHCR tagged "latest" (DEPLOY_MODE=release)
# - (unset): Falls back to COMMIT_SHA env var, or "latest" if not set
#
# DEPLOY_MODE is NOT stored in .env, so it propagates naturally through
# subprocess calls. CDK's SharedProps reads DEPLOY_MODE and sets the
# appropriate image tag. Services can define their own aws:deploy:local
# and aws:deploy:release tasks that set DEPLOY_MODE and delegate to aws:deploy.
#
# To deploy a specific tagged version from the registry (e.g., a CI-built
# image), set COMMIT_SHA to the desired tag and run aws:deploy directly
# without setting DEPLOY_MODE. For example:
# COMMIT_SHA=abc123 npx cdk deploy (from infra/aws directory)
# =============================================================================
[tasks."aws:deploy:local"]
description = "Deploy to AWS (build containers locally)"
depends = ["env:setup"]
env = { DEPLOY_MODE = "local" }
run = """
echo "=== Deploying Stickerlandia to AWS: $ENV (DEPLOY_MODE=$DEPLOY_MODE) ==="
mise run //shared:aws:deploy:local
mise run //user-management:aws:deploy:local
mise run //sticker-award:aws:deploy:local
mise run //sticker-catalogue:aws:deploy:local
mise run //print-service:aws:deploy:local
mise run //web-backend:aws:deploy:local
mise run //web-frontend:aws:deploy:local
echo "=== Deployment complete! ==="
"""
[tasks."aws:deploy:release"]
description = "Deploy to AWS using prebuilt GHCR images"
depends = ["env:setup"]
env = { DEPLOY_MODE = "release" }
run = """
echo "=== Deploying Stickerlandia to AWS: $ENV (DEPLOY_MODE=$DEPLOY_MODE) ==="
mise run //shared:aws:deploy:release
mise run //user-management:aws:deploy:release
mise run //sticker-award:aws:deploy:release
mise run //print-service:aws:deploy:release
mise run //sticker-catalogue:aws:deploy:release
mise run //web-backend:aws:deploy:release
mise run //web-frontend:aws:deploy:release
echo "=== Deployment complete! ==="
"""
[tasks."aws:down"]
description = "Destroy all AWS stacks"
depends = ["//shared:aws:down"]
run = """
echo '=== Cleaning up CDK context cache ==='
find . -name 'cdk.context.json' -type f -delete
echo '=== All AWS stacks destroyed! ==='
"""
[tasks."aws:info"]
description = "Show AWS stack outputs for all services"
run = """
mise run //shared:aws:info
mise run //user-management:aws:info
mise run //sticker-award:aws:info
mise run //sticker-catalogue:aws:info
mise run //print-service:aws:info
mise run //web-backend:aws:info
mise run //web-frontend:aws:info
"""
# =============================================================================
# ui-test: UI Testing infrastructure
# =============================================================================
[tasks."ui-test:install"]
description = "Install UI test dependencies and Playwright browsers"
dir = "e2e"
sources = ["package-lock.json"]
outputs = ["node_modules/.package-lock.json"]
run = "npm ci && npx playwright install --with-deps chromium"
[tasks."ui-test:codegen"]
description = "Record tests with Playwright codegen"
dir = "e2e"
depends = ["ui-test:install", "env:setup"]
run = "npx playwright codegen ${DEPLOYMENT_HOST_URL:-http://localhost:8080}"
# =============================================================================
# compose: UI test tasks for Docker Compose deployment
# =============================================================================
[tasks."compose:ui-test"]
description = "Run UI tests against Docker Compose deployment"
dir = "e2e"
depends = ["ui-test:install", "env:setup"]
env = { BASE_URL = "http://localhost:8080" }
run = "npx playwright test"
[tasks."compose:ui-test:ui"]
description = "Open Playwright UI mode for Docker Compose deployment"
dir = "e2e"
depends = ["ui-test:install", "env:setup"]
env = { BASE_URL = "http://localhost:8080" }
run = "npx playwright test --ui"
# =============================================================================
# aws: UI test tasks for AWS deployment
# =============================================================================
[tasks."aws:ui-test"]
description = "Run UI tests against AWS deployment"
dir = "e2e"
depends = ["ui-test:install"]
run = """
BASE_URL=$(aws cloudformation describe-stacks \
--stack-name "StickerlandiaSharedResources-${ENV:-dev}" \
--query "Stacks[0].Outputs[?OutputKey=='BaseUrl'].OutputValue" \
--output text)
echo "Running tests against: $BASE_URL"
BASE_URL=$BASE_URL npx playwright test
"""
# =============================================================================
# load: Load testing
# =============================================================================
[tasks."compose:load-test:smoke"]
depends = ["env:setup"]
description = "Run smoke load test (2 users, 30 seconds, mixed flows)"
run = """
docker compose --profile load-test up -d
docker compose --profile load-test run --rm load-simulator
docker compose --profile load-test down -v
"""
[tasks."aws:load-test:smoke"]
description = "Run load tests against AWS deployment"
dir = "e2e"
depends = ["ui-test:install"]
run = """
BASE_URL=$(aws cloudformation describe-stacks \
--stack-name "StickerlandiaSharedResources-${ENV:-dev}" \
--query "Stacks[0].Outputs[?OutputKey=='BaseUrl'].OutputValue" \
--output text)
DEPLOYMENT_HOST_URL=$(aws cloudformation describe-stacks \
--stack-name "StickerlandiaSharedResources-${ENV:-dev}" \
--query "Stacks[0].Outputs[?OutputKey=='BaseUrl'].OutputValue" \
--output text)
echo "Running tests against: $BASE_URL"
BASE_URL=$BASE_URL DEPLOYMENT_HOST_URL=$DEPLOYMENT_HOST_URL npx playwright test
"""