-
Notifications
You must be signed in to change notification settings - Fork 0
221 lines (195 loc) · 5.91 KB
/
integration-tests.yml
File metadata and controls
221 lines (195 loc) · 5.91 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
name: Integration Tests
on:
push:
branches:
- main
paths:
- 'app/**'
- 'worker/**'
- 'tests/integration/**'
- 'sql/**'
- 'requirements.txt'
- '.github/workflows/integration-tests.yml'
pull_request:
paths:
- 'app/**'
- 'worker/**'
- 'tests/integration/**'
- 'sql/**'
- 'requirements.txt'
- '.github/workflows/integration-tests.yml'
workflow_dispatch:
schedule:
# Run nightly at 2 AM UTC
- cron: '0 2 * * *'
permissions:
contents: read
jobs:
integration-tests:
name: Integration Tests
runs-on: ubuntu-latest
timeout-minutes: 30
permissions:
contents: read
actions: read
services:
postgres:
image: postgres:16
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: "3.11"
cache: 'pip'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements-dev.txt
pip install -r requirements.txt
- name: Apply database schema
env:
DATABASE_URL: postgresql://postgres:postgres@localhost:5432/postgres
run: |
PGPASSWORD=postgres psql -h localhost -U postgres -d postgres -f sql/schema.sql
- name: Run integration tests
env:
DATABASE_URL: postgresql://postgres:postgres@localhost:5432/postgres
SESSION_SECRET: test-secret-key-for-ci-only
FRONTEND_ORIGIN: http://localhost:5173
PYTEST_TIMEOUT: 300
run: |
pytest tests/integration/ \
-v \
--tb=short \
--timeout=120 \
--maxfail=5 \
-x
- name: Generate test summary
if: always()
run: |
echo "## Integration Test Results" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "Integration tests completed." >> $GITHUB_STEP_SUMMARY
- name: Upload test logs on failure
if: failure()
uses: actions/upload-artifact@v4
with:
name: integration-test-logs
path: |
*.log
/tmp/*.log
retention-days: 7
if-no-files-found: ignore
integration-tests-with-services:
name: Integration Tests (Full Stack)
runs-on: ubuntu-latest
timeout-minutes: 45
permissions:
contents: read
actions: read
# Only run full stack tests on schedule or manual trigger
if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: "3.11"
cache: 'pip'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements-dev.txt
pip install -r requirements.txt
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build Docker image
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
push: false
tags: transcript-create:test
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
ROCM_WHEEL_INDEX=https://download.pytorch.org/whl/cpu
- name: Create test environment file
run: |
cat > .env << EOF
DATABASE_URL=postgresql+psycopg://postgres:postgres@db:5432/transcripts
SESSION_SECRET=test-secret-key-for-ci-only
FRONTEND_ORIGIN=http://localhost:5173
WHISPER_MODEL=base
WHISPER_BACKEND=faster-whisper
LOG_LEVEL=INFO
EOF
- name: Start services
run: |
docker compose up -d db migrations
sleep 10
- name: Wait for database
run: |
for i in {1..30}; do
PGPASSWORD=postgres psql -h localhost -U postgres -p 5434 -d transcripts -c "SELECT 1" && break
echo "Waiting for database..."
sleep 2
done
- name: Run integration tests against services
env:
DATABASE_URL: postgresql://postgres:postgres@localhost:5434/transcripts
SESSION_SECRET: test-secret-key-for-ci-only
FRONTEND_ORIGIN: http://localhost:5173
run: |
pytest tests/integration/ \
-v \
--tb=short \
--timeout=180 \
--maxfail=5
- name: Collect service logs on failure
if: failure()
run: |
docker compose logs db > db.log
docker compose logs api > api.log || true
docker compose logs worker > worker.log || true
- name: Upload service logs
if: failure()
uses: actions/upload-artifact@v4
with:
name: service-logs
path: |
*.log
retention-days: 7
- name: Cleanup
if: always()
run: |
docker compose down -v
test-summary:
name: Integration Test Summary
runs-on: ubuntu-latest
needs: [integration-tests]
if: always()
permissions:
contents: read
steps:
- name: Generate summary
run: |
echo "# Integration Test Summary" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "✅ Integration tests completed" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "See individual job results above for details." >> $GITHUB_STEP_SUMMARY