-
-
Notifications
You must be signed in to change notification settings - Fork 0
503 lines (419 loc) · 14.7 KB
/
Copy pathtest.yml
File metadata and controls
503 lines (419 loc) · 14.7 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
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
name: Test Suite
on:
pull_request:
branches: [main, develop]
push:
branches: [main, develop]
workflow_dispatch:
# One run per workflow per ref. Merging a queue of dependency PRs fires a
# run per commit on main, and every one but the newest is already stale by
# the time a runner picks it up.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
validate-compose:
name: Validate Docker Compose
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v7
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Validate docker-compose.yml
run: |
docker compose config > /dev/null
echo "✓ docker-compose.yml is valid"
- name: Check for docker-compose syntax issues
run: |
docker compose config --quiet
echo "✓ No syntax errors found"
validate-env:
name: Validate Environment Configuration
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v7
- name: Validate .env.example exists
run: |
if [ ! -f .env.example ]; then
echo "✗ .env.example not found"
exit 1
fi
echo "✓ .env.example exists"
- name: Check .env.example format
run: |
# Check for basic environment variable format
if ! grep -qE '^[A-Z_]+=.*$' .env.example; then
echo "✗ .env.example has invalid format"
exit 1
fi
echo "✓ .env.example format is valid"
- name: Check for required variables
run: |
required_vars=(
"VAULT_ADDR"
"VAULT_TOKEN"
"POSTGRES_USER"
"POSTGRES_DB"
"POSTGRES_PASSWORD"
"MYSQL_USER"
"MYSQL_DATABASE"
"RABBITMQ_VHOST"
"MONGODB_USER"
"MONGODB_DATABASE"
)
missing=0
for var in "${required_vars[@]}"; do
if ! grep -q "^${var}=" .env.example; then
echo "✗ Missing required variable: $var"
missing=1
fi
done
if [ $missing -eq 1 ]; then
exit 1
fi
echo "✓ All required variables present (Vault-managed credentials)"
validate-scripts:
name: Validate Shell Scripts
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v7
- name: Check script executability
run: |
scripts=(
"manage-colima.sh"
"configs/vault/scripts/vault-init.sh"
"configs/vault/scripts/vault-bootstrap.sh"
)
for script in "${scripts[@]}"; do
if [ -f "$script" ] && [ ! -x "$script" ]; then
echo "✗ Script not executable: $script"
exit 1
fi
done
echo "✓ All scripts are executable"
- name: Check for bash shebangs
run: |
scripts=$(find . -name "*.sh" -type f)
for script in $scripts; do
shebang=$(head -n 1 "$script")
if [[ ! "$shebang" =~ ^#!/bin/bash$ ]] && \
[[ ! "$shebang" =~ ^#!/usr/bin/env\ bash$ ]] && \
[[ ! "$shebang" =~ ^#!/bin/sh$ ]]; then
echo "✗ Missing or incorrect shebang in: $script"
echo " Found: $shebang"
echo " Expected: #!/bin/bash, #!/usr/bin/env bash, or #!/bin/sh"
exit 1
fi
done
echo "✓ All scripts have proper shebangs"
validate-configs:
name: Validate Configuration Files
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v7
- name: Validate JSON files
run: |
json_files=$(find configs -name "*.json" -type f)
if [ -n "$json_files" ]; then
for file in $json_files; do
if ! python3 -m json.tool "$file" > /dev/null 2>&1; then
echo "✗ Invalid JSON in: $file"
exit 1
fi
done
echo "✓ All JSON files are valid"
else
echo "ℹ No JSON files to validate"
fi
- name: Validate YAML files
run: |
yaml_files=$(find configs -name "*.yml" -o -name "*.yaml" -type f)
if [ -n "$yaml_files" ]; then
pip install pyyaml
for file in $yaml_files; do
if ! python3 -c "import yaml; yaml.safe_load(open('$file'))" 2>/dev/null; then
echo "✗ Invalid YAML in: $file"
exit 1
fi
done
echo "✓ All YAML files are valid"
else
echo "ℹ No YAML files to validate"
fi
test-documentation:
name: Test Documentation
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v7
- name: Check README exists and is not empty
run: |
if [ ! -f README.md ]; then
echo "✗ README.md not found"
exit 1
fi
if [ ! -s README.md ]; then
echo "✗ README.md is empty"
exit 1
fi
echo "✓ README.md exists and has content"
# wiki/ is left out on purpose: it mirrors GitHub-wiki pages, whose links
# are wiki page names and verbatim copies of docs/ paths that resolve on
# the wiki, never in this tree (27 of them fail here, none elsewhere).
# The checker is pinned because 3.13.x exited 0 on dead links; the
# "ERROR:" marker is a second detector in case that ever recurs. The
# config counts 403 and 429 as alive: bot protection (dev.mysql.com)
# and rate limiting answer those to a CI runner, while a removed page
# answers 404 or 410 and still fails.
- name: Check for broken markdown links
run: |
npm install --no-save --no-package-lock --no-audit --no-fund markdown-link-check@3.15.0
checked=0
failed=0
while read -r file; do
checked=$((checked + 1))
# The runner's bash -e would end the script on the first failing
# substitution, before anything is printed; `|| rc=$?` keeps the
# loop alive so every file is reported.
rc=0
out=$(./node_modules/.bin/markdown-link-check -q \
-c .github/workflows/markdown-link-check-config.json "$file" 2>&1) || rc=$?
if [ "$rc" -ne 0 ] || echo "$out" | grep -q "ERROR:"; then
echo "$out"
failed=$((failed + 1))
fi
done < <(find . -name '*.md' -not -path './wiki/*' -not -path '*/node_modules/*' | sort)
echo "Checked $checked Markdown files, $failed with dead links"
[ "$failed" -eq 0 ]
# tests/test-documentation-accuracy.sh cross-checks the documentation
# against docker-compose.yml, the AppRole bootstrap and the wiki
# mirror. It had never run in CI, and three of its tests had drifted
# red unnoticed; from here on it gates.
- name: Check documentation accuracy
run: bash tests/test-documentation-accuracy.sh
- name: Validate required documentation sections
run: |
required_sections=(
"Quick Start"
"Installation"
"Prerequisites"
"Services"
"Troubleshooting"
)
for section in "${required_sections[@]}"; do
if ! grep -qi "## $section" README.md; then
echo "⚠ Missing recommended section: $section"
fi
done
echo "✓ Documentation validation complete"
test-python:
name: Test Python Scripts
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v7
- name: Set up Python
uses: actions/setup-python@v7
with:
python-version: '3.11'
- name: Check Python syntax
run: |
python_files=$(find scripts tests -name "*.py" -type f)
if [ -n "$python_files" ]; then
for file in $python_files; do
if ! python3 -m py_compile "$file"; then
echo "✗ Syntax error in: $file"
exit 1
fi
done
echo "✓ All Python files have valid syntax"
else
echo "ℹ No Python files to validate"
fi
unit-tests:
name: Unit Tests
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v7
- name: Set up Python
uses: actions/setup-python@v7
with:
python-version: '3.11'
- name: Set up Go
uses: actions/setup-go@v7
with:
go-version-file: 'reference-apps/golang/go.mod'
- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
# Current LTS. The mongodb driver both Node.js apps pin requires
# Node >= 20, which the node:18-alpine images they ship do not meet;
# that is a Dockerfile problem to fix separately, not a reason to test
# on a runtime the dependencies reject.
- name: Set up Node.js
uses: actions/setup-node@v7
with:
node-version: '22'
- name: Install Python test dependencies
run: |
pip install pytest pytest-asyncio pytest-cov pytest-mock httpx
- name: Run FastAPI unit tests
run: |
cd reference-apps/fastapi
pip install -r requirements.txt
# Run tests that don't require external services
pytest tests/ -v --ignore=tests/test_integration.py -k "not integration" \
--tb=short
- name: Run Go unit tests
run: |
cd reference-apps/golang
go test -v -short ./...
- name: Run Rust unit tests
run: |
cd reference-apps/rust
# The package is a single binary crate; --lib finds no target.
cargo test -- --test-threads=1
- name: Run Node.js unit tests
run: |
cd reference-apps/nodejs
npm ci
npm test
- name: Run TypeScript unit tests
run: |
cd reference-apps/typescript-api-first
npm ci
npm test
- name: Test summary
run: |
echo "=========================================="
echo "Unit Test Summary"
echo "=========================================="
echo ""
echo "Unit tests that need no running services were executed for the"
echo "FastAPI, Go, Rust, Node.js and TypeScript reference apps."
echo ""
echo "For full integration tests, run locally with:"
echo " ./devstack start --profile standard"
echo " ./tests/run-all-tests.sh"
integration-test:
name: Integration Test (Basic)
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v7
- name: Create .env from example
run: cp .env.example .env
- name: Validate Docker Compose can parse files
run: |
docker compose config > /dev/null
echo "✓ Docker Compose configuration is valid"
- name: Check service definitions (no profile)
run: |
services=$(docker compose config --services)
echo "Services with no profile: $services"
# Vault should always be available (no profile)
if ! echo "$services" | grep -q "^vault$"; then
echo "✗ Missing vault (should have no profile)"
exit 1
fi
echo "✓ Vault is defined (no profile required)"
- name: Check minimal profile services
run: |
services=$(docker compose --profile minimal config --services)
expected_services=(
"vault"
"postgres"
"pgbouncer"
"redis-1"
"forgejo"
)
echo "Minimal profile services:"
echo "$services"
for service in "${expected_services[@]}"; do
if ! echo "$services" | grep -q "^${service}$"; then
echo "✗ Missing expected service in minimal profile: $service"
exit 1
fi
done
echo "✓ All minimal profile services are defined"
- name: Check standard profile services
run: |
services=$(docker compose --profile standard config --services)
expected_services=(
"vault"
"postgres"
"pgbouncer"
"mysql"
"mongodb"
"redis-1"
"redis-2"
"redis-3"
"rabbitmq"
"forgejo"
)
echo "Standard profile services:"
echo "$services"
for service in "${expected_services[@]}"; do
if ! echo "$services" | grep -q "^${service}$"; then
echo "✗ Missing expected service in standard profile: $service"
exit 1
fi
done
echo "✓ All standard profile services are defined"
test-summary:
name: Test Summary
runs-on: ubuntu-latest
needs:
- validate-compose
- validate-env
- validate-scripts
- validate-configs
- test-documentation
- test-python
- unit-tests
- integration-test
if: always()
steps:
- name: Check test results
run: |
failed=0
if [ "${{ needs.validate-compose.result }}" != "success" ]; then
echo "❌ Docker Compose validation failed"
failed=1
fi
if [ "${{ needs.validate-env.result }}" != "success" ]; then
echo "❌ Environment validation failed"
failed=1
fi
if [ "${{ needs.validate-scripts.result }}" != "success" ]; then
echo "❌ Script validation failed"
failed=1
fi
if [ "${{ needs.validate-configs.result }}" != "success" ]; then
echo "❌ Config validation failed"
failed=1
fi
if [ "${{ needs.test-documentation.result }}" != "success" ]; then
echo "❌ Documentation tests failed"
failed=1
fi
if [ "${{ needs.test-python.result }}" != "success" ]; then
echo "❌ Python syntax check failed"
failed=1
fi
if [ "${{ needs.integration-test.result }}" != "success" ]; then
echo "❌ Integration tests failed"
failed=1
fi
if [ "${{ needs.unit-tests.result }}" != "success" ]; then
echo "❌ Unit tests failed"
failed=1
fi
if [ $failed -eq 1 ]; then
exit 1
fi
echo "✅ All tests passed"