-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
184 lines (157 loc) · 5.67 KB
/
Copy pathbasic-ci.yml
File metadata and controls
184 lines (157 loc) · 5.67 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
name: Backend CI
on:
push:
branches: [main, master, v5.0.1-bate]
pull_request:
branches: [main, master]
concurrency:
group: backend-ci-${{ github.ref }}
cancel-in-progress: true
jobs:
quality:
name: Lint and structure guardrails
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v7
- name: Set up Python 3.12
uses: actions/setup-python@v6
with:
python-version: '3.12'
- name: Documentation structure and links
run: python scripts/check_docs.py
- name: Install lint dependency
working-directory: ./backend_api_python
run: python -m pip install --disable-pip-version-check "ruff>=0.12.0,<0.15" "packaging>=24,<27"
- name: Python syntax check
working-directory: ./backend_api_python
run: |
python -m py_compile run.py
python -m compileall -q app scripts tests
- name: Ruff critical lint
working-directory: ./backend_api_python
run: ruff check app scripts tests
- name: Backend structure guardrail
working-directory: ./backend_api_python
run: python scripts/backend_quality_check.py
- name: Production dependency lock guardrail
working-directory: ./backend_api_python
run: python scripts/check_requirements_lock.py
tests:
name: Backend tests (${{ matrix.shard_label }})
runs-on: ubuntu-latest
timeout-minutes: 10
strategy:
fail-fast: false
matrix:
include:
- shard_index: 0
shard_label: 1/2
- shard_index: 1
shard_label: 2/2
services:
postgres:
image: postgres:18-alpine
env:
POSTGRES_USER: quantdinger_test
POSTGRES_PASSWORD: quantdinger_test
POSTGRES_DB: quantdinger_test
ports:
- 5432:5432
options: >-
--health-cmd "pg_isready -U quantdinger_test -d quantdinger_test"
--health-interval 10s
--health-timeout 5s
--health-retries 5
redis:
image: redis:8-alpine
ports:
- 6379:6379
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
env:
DATABASE_URL: postgresql://quantdinger_test:quantdinger_test@127.0.0.1:5432/quantdinger_test
DB_TYPE: postgresql
REDIS_HOST: 127.0.0.1
REDIS_PORT: 6379
CACHE_ENABLED: 'false'
SKIP_STARTUP_HOOKS: '1'
SECRET_KEY: ci-secret-key-with-at-least-thirty-two-bytes
ADMIN_USER: testadmin
ADMIN_PASSWORD: testpass123
steps:
- name: Checkout code
uses: actions/checkout@v7
- name: Set up Python 3.12
uses: actions/setup-python@v6
with:
python-version: '3.12'
cache: pip
cache-dependency-path: |
backend_api_python/requirements-dev.txt
backend_api_python/requirements.lock
- name: Install development dependencies
working-directory: ./backend_api_python
run: python -m pip install --disable-pip-version-check -r requirements-dev.txt
- name: Python import check
if: matrix.shard_index == 0
working-directory: ./backend_api_python
run: python -c "from app import create_app; from app.config import settings; from app.openapi import init_openapi; print('Core modules imported successfully')"
- name: Run database migrations
working-directory: ./backend_api_python
env:
QD_PROCESS_ROLE: migration
run: python -m app.commands.migrate
- name: Run backend test shard
working-directory: ./backend_api_python
shell: bash
run: |
mapfile -t test_files < <(find tests -maxdepth 1 -type f -name 'test_*.py' | sort)
selected=()
for index in "${!test_files[@]}"; do
if (( index % 2 == ${{ matrix.shard_index }} )); then
selected+=("${test_files[$index]}")
fi
done
if (( ${#selected[@]} == 0 )); then
echo "::error::No tests selected for shard ${{ matrix.shard_label }}"
exit 1
fi
python -m pytest "${selected[@]}" -m "not integration and not stress" -q
- name: Run release gates independently
if: matrix.shard_index == 0
working-directory: ./backend_api_python
run: python -m pytest tests/release_gate -q
compose-check:
name: Docker Compose validation
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v7
- name: Validate local compose
run: docker compose -f docker-compose.yml config -q
- name: Validate GHCR compose
run: docker compose -f docker-compose.ghcr.yml config -q
- name: Validate local build override
run: docker compose -f docker-compose.yml -f docker-compose.build.yml config -q
- name: Validate observability override
run: docker compose -f docker-compose.yml -f docker-compose.observability.yml config -q
- name: Validate production hardening override
run: docker compose -f docker-compose.yml -f docker-compose.production.yml -f docker-compose.observability.yml config -q
version-check:
name: Repository consistency
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v7
- name: Set up Python 3.12
uses: actions/setup-python@v6
with:
python-version: '3.12'
- name: Verify version declarations
run: python scripts/check_version.py
- name: Check tracked text encoding
run: python scripts/check_mojibake.py