-
Notifications
You must be signed in to change notification settings - Fork 17
217 lines (181 loc) · 7.29 KB
/
Copy pathnightly-integration-tests.yml
File metadata and controls
217 lines (181 loc) · 7.29 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
name: Nightly Integration Tests
on:
schedule:
# Run every day at 2 AM UTC
- cron: '0 2 * * *'
workflow_dispatch: # Allow manual trigger
jobs:
integration-tests:
name: Backend Integration Tests
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Node.js and pnpm
uses: pnpm/action-setup@v4
with:
version: 8
- uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'pnpm'
cache-dependency-path: 'webapp/pnpm-lock.yaml'
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install Node.js dependencies
working-directory: ./webapp
run: pnpm install
- name: Install Python dependencies
working-directory: ./webapp/packages/api/user-service
run: pip install -r requirements.txt
- name: Create .env file for Docker Compose
working-directory: ./webapp/infra/docker
run: |
echo "OPENAI_API_KEY=${{ secrets.OPENAI_API_KEY }}" >> .env
echo "GEMINI_API_KEY=${{ secrets.GEMINI_API_KEY }}" >> .env
echo "AWS_ACCESS_KEY_ID=${{ secrets.AWS_ACCESS_KEY_ID }}" >> .env
echo "AWS_SECRET_ACCESS_KEY=${{ secrets.AWS_SECRET_ACCESS_KEY }}" >> .env
echo "AWS_REGION=${{ secrets.AWS_REGION || 'us-east-1' }}" >> .env
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: ${{ secrets.AWS_REGION }}
- name: Start services with Docker Compose
working-directory: ./webapp/infra/docker
run: docker compose up -d --build
- name: Wait for services to be healthy
run: |
echo "Waiting for API server to be ready..."
timeout 120s bash -c 'until curl -s http://localhost:8000/health | grep -q "healthy"; do sleep 2; done'
echo "API server is up."
echo "Waiting for Web UI to be ready..."
timeout 60s bash -c 'until curl -s -o /dev/null http://localhost:3000; do sleep 2; done'
echo "Web UI is up."
echo "Waiting for CouchDB to be ready..."
timeout 60s bash -c 'until curl -s -o /dev/null http://localhost:5984; do sleep 2; done'
echo "CouchDB is up."
echo "Waiting for MinIO to be ready..."
timeout 60s bash -c 'until curl -s -o /dev/null http://localhost:9000; do sleep 2; done'
echo "MinIO is up."
- name: Run backend integration tests
working-directory: ./webapp/packages/api/user-service
run: python -m pytest tests/integration -v --cov=. --cov-report=xml --cov-report=term-missing
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: ${{ secrets.AWS_REGION }}
- name: Upload integration test coverage
uses: codecov/codecov-action@v4
with:
files: ./webapp/packages/api/user-service/coverage.xml
flags: integration
name: integration-coverage
- name: Collect Docker logs on failure
if: failure()
working-directory: ./webapp/infra/docker
run: |
echo "=== API Logs ==="
docker compose logs api
echo "=== WebUI Logs ==="
docker compose logs webui
echo "=== CouchDB Logs ==="
docker compose logs couchdb
echo "=== MinIO Logs ==="
docker compose logs minio
- name: Stop services
if: always()
working-directory: ./webapp/infra/docker
run: docker compose down -v
e2e-tests:
name: End-to-End Tests
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Node.js and pnpm
uses: pnpm/action-setup@v4
with:
version: 8
- uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'pnpm'
cache-dependency-path: 'webapp/pnpm-lock.yaml'
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install Node.js dependencies
working-directory: ./webapp
run: pnpm install
- name: Install Python dependencies
working-directory: ./webapp/packages/api/user-service
run: pip install -r requirements.txt
- name: Install Playwright Browsers
working-directory: ./webapp
run: pnpm exec playwright install --with-deps chromium
- name: Create .env file for Docker Compose
working-directory: ./webapp/infra/docker
run: |
echo "OPENAI_API_KEY=${{ secrets.OPENAI_API_KEY }}" >> .env
echo "GEMINI_API_KEY=${{ secrets.GEMINI_API_KEY }}" >> .env
echo "AWS_ACCESS_KEY_ID=${{ secrets.AWS_ACCESS_KEY_ID }}" >> .env
echo "AWS_SECRET_ACCESS_KEY=${{ secrets.AWS_SECRET_ACCESS_KEY }}" >> .env
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
- name: Start services with Docker Compose
working-directory: ./webapp/infra/docker
run: docker compose up -d --build
- name: Wait for services to be healthy
run: |
echo "Waiting for API server to be ready..."
timeout 120s bash -c 'until curl -s http://localhost:8000/health | grep -q "healthy"; do sleep 2; done'
echo "API server is up."
echo "Waiting for Web UI to be ready..."
timeout 60s bash -c 'until curl -s -o /dev/null http://localhost:3000; do sleep 2; done'
echo "Web UI is up."
- name: Run Playwright E2E Tests
working-directory: ./webapp
run: pnpm test:e2e
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
- name: Upload Playwright report
if: always()
uses: actions/upload-artifact@v4
with:
name: playwright-report
path: webapp/playwright-report/
retention-days: 30
- name: Collect Docker logs on failure
if: failure()
working-directory: ./webapp/infra/docker
run: |
echo "=== API Logs ==="
docker compose logs api
echo "=== WebUI Logs ==="
docker compose logs webui
- name: Stop services
if: always()
working-directory: ./webapp/infra/docker
run: docker compose down -v
notify-on-failure:
name: Notify on Failure
runs-on: ubuntu-latest
needs: [integration-tests, e2e-tests]
if: failure()
steps:
- name: Send notification
run: |
echo "Nightly tests failed. Please check the GitHub Actions logs."
echo "Integration tests: ${{ needs.integration-tests.result }}"
echo "E2E tests: ${{ needs.e2e-tests.result }}"