-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgitlab-ci.yml
More file actions
68 lines (61 loc) · 1.94 KB
/
gitlab-ci.yml
File metadata and controls
68 lines (61 loc) · 1.94 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
# .gitlab-ci.yml
#
# Integrate pytest-mrt into GitLab CI.
# Add these stages to your existing pipeline.
stages:
- migration-check
- test
variables:
POSTGRES_DB: mrt_test
POSTGRES_USER: test
POSTGRES_PASSWORD: test
# ──────────────────────────────────────────────
# Stage 1: static analysis — no DB, runs fast
# ──────────────────────────────────────────────
migration:static:
stage: migration-check
image: python:3.12-slim
rules:
- changes:
- "alembic/versions/*.py"
- "**/migrations/*.py"
script:
- pip install pytest-mrt --quiet
- mrt check alembic/versions/ --strict
# ──────────────────────────────────────────────
# Stage 2: dynamic rollback verification
# ──────────────────────────────────────────────
migration:rollback:
stage: test
image: python:3.12-slim
services:
- postgres:16
variables:
TEST_DATABASE_URL: postgresql://test:test@postgres/mrt_test
rules:
- changes:
- "alembic/versions/*.py"
- "tests/test_migrations.py"
script:
- pip install pytest-mrt[postgres] --quiet
- pytest tests/test_migrations.py -v
artifacts:
when: always
reports:
junit: test-results.xml
paths:
- migration_report.html
migration:report:
stage: test
image: python:3.12-slim
services:
- postgres:16
variables:
TEST_DATABASE_URL: postgresql://test:test@postgres/mrt_test
script:
- pip install pytest-mrt[postgres] --quiet
- mrt report alembic/versions/ --output migration_report.html
artifacts:
paths:
- migration_report.html
expose_as: "Migration Safety Report"