-
Notifications
You must be signed in to change notification settings - Fork 129
226 lines (198 loc) · 7.75 KB
/
playwright.yml
File metadata and controls
226 lines (198 loc) · 7.75 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
name: Playwright Tests
on:
push:
branches: [ main, staging ]
pull_request:
branches: [ main, staging ]
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
permissions:
contents: read
env:
PYTHON_VERSION: '3.12'
NODE_VERSION: 'lts/*'
jobs:
test:
timeout-minutes: 60
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
# Detect whether AI secrets are available (not available for Dependabot / fork PRs)
- name: Check for AI secrets
id: check-secrets
run: |
if [ -n "$AZURE_API_KEY" ] && [ -n "$AZURE_API_BASE" ] && [ -n "$AZURE_API_VERSION" ]; then
echo "has-ai-secrets=true" >> "$GITHUB_OUTPUT"
echo "AI secrets are available — full E2E suite will run"
else
echo "has-ai-secrets=false" >> "$GITHUB_OUTPUT"
echo "AI secrets are NOT available — only non-AI E2E tests will run"
fi
env:
AZURE_API_KEY: ${{ secrets.AZURE_API_KEY }}
AZURE_API_BASE: ${{ secrets.AZURE_API_BASE }}
AZURE_API_VERSION: ${{ secrets.AZURE_API_VERSION }}
# Setup Python
- name: Set up Python
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6
with:
python-version: ${{ env.PYTHON_VERSION }}
# Install uv
- name: Install uv
uses: astral-sh/setup-uv@37802adc94f370d6bfd71619e3f0bf239e1f3b78 # v7.6.0
with:
version: "0.7.12"
# Setup Node.js
- uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
cache-dependency-path: |
package-lock.json
app/package-lock.json
# Install Python dependencies
- name: Install Python dependencies
run: uv sync --locked
# Install Node dependencies (root - for Playwright)
- name: Install root dependencies
run: npm ci
# Cache Playwright browsers
- name: Cache Playwright browsers
id: playwright-cache
uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5
with:
path: ~/.cache/ms-playwright
key: playwright-browsers-${{ runner.os }}-${{ hashFiles('package-lock.json') }}
# Install Node dependencies (frontend)
- name: Install frontend dependencies
run: npm ci
working-directory: ./app
# Build frontend
- name: Build frontend
run: npm run build
working-directory: ./app
# Start Docker Compose services (test databases) — only needed for AI tests
- name: Start test databases
if: steps.check-secrets.outputs.has-ai-secrets == 'true'
run: |
docker compose -f e2e/docker-compose.test.yml up -d --wait --wait-timeout 120
docker ps -a
# Start FalkorDB (Redis graph database)
- name: Start FalkorDB
run: |
docker run -d --name falkordb-test -p 6379:6379 falkordb/falkordb:latest
echo "Waiting for FalkorDB to be ready..."
# Wait for FalkorDB to accept connections and be fully initialized
for i in {1..30}; do
if docker exec falkordb-test redis-cli PING > /dev/null 2>&1; then
# Test that FalkorDB graph commands work
if docker exec falkordb-test redis-cli GRAPH.LIST > /dev/null 2>&1; then
echo "FalkorDB graph module loaded, testing vector index creation..."
# Test creating a graph with vector index (the actual operation that fails)
if docker exec falkordb-test redis-cli GRAPH.QUERY test_graph "CREATE VECTOR INDEX FOR (n:Test) ON (n.embedding)" > /dev/null 2>&1; then
# Clean up test graph
docker exec falkordb-test redis-cli GRAPH.DELETE test_graph > /dev/null 2>&1 || true
echo "FalkorDB is fully ready with vector index support!"
# Extra wait to ensure complete initialization
sleep 5
break
fi
fi
fi
echo "Waiting for FalkorDB initialization... attempt $i/30"
sleep 1
done
# Verify FalkorDB is accessible from host
echo "Testing FalkorDB connectivity from host..."
docker ps -a
# Create CI .env so load_dotenv() finds the required variables
- name: Create CI .env
run: |
cat > .env <<EOF
FASTAPI_SECRET_KEY=test-secret-key-for-ci
APP_ENV=development
FASTAPI_DEBUG=False
FALKORDB_URL=redis://localhost:6379
DISABLE_MCP=true
EOF
# Start the FastAPI application
- name: Start FastAPI application
id: start-server
run: |
# Start server in background with uv
uv run uvicorn api.index:app --host localhost --port 5000 > /tmp/uvicorn.log 2>&1 &
UVICORN_PID=$!
echo "pid=$UVICORN_PID" >> "$GITHUB_OUTPUT"
echo "Started server with PID: $UVICORN_PID"
# Wait for app to start
echo "Waiting for application to start..."
for i in {1..30}; do
if curl -f http://localhost:5000/ 2>/dev/null; then
echo "Application started successfully!"
break
fi
echo "Waiting... attempt $i/30"
sleep 1
if [ $i -eq 30 ]; then
echo "Failed to start application after 30 seconds"
echo "=== Server logs ==="
cat /tmp/uvicorn.log
exit 1
fi
done
env:
PYTHONUNBUFFERED: 1
FASTAPI_SECRET_KEY: test-secret-key-for-ci
APP_ENV: development
FASTAPI_DEBUG: False
FALKORDB_URL: redis://localhost:6379
DISABLE_MCP: true
# Azure OpenAI API keys - required for database schema analysis
AZURE_API_KEY: ${{ secrets.AZURE_API_KEY }}
AZURE_API_BASE: ${{ secrets.AZURE_API_BASE }}
AZURE_API_VERSION: ${{ secrets.AZURE_API_VERSION }}
# Install Playwright browsers (Chromium only in CI)
- name: Install Playwright Browsers
if: steps.playwright-cache.outputs.cache-hit != 'true'
run: npx playwright install --with-deps chromium
- name: Install Playwright system deps
if: steps.playwright-cache.outputs.cache-hit == 'true'
run: npx playwright install-deps chromium
# Create auth directory for storage state
- name: Create auth directory
run: mkdir -p e2e/.auth
# Run non-AI Playwright tests (always — no LLM secrets needed)
- name: Run Playwright tests (no AI)
run: npx playwright test --grep-invert @requires-ai --reporter=list
env:
CI: true
# Run AI-dependent Playwright tests (only when secrets are available)
# Use !cancelled() so AI tests still run even if non-AI tests fail
- name: Run Playwright tests (AI)
if: "!cancelled() && steps.check-secrets.outputs.has-ai-secrets == 'true'"
run: npx playwright test --grep @requires-ai --reporter=list
env:
CI: true
# Upload test results on failure
- uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7
if: failure()
with:
name: playwright-report
path: playwright-report/
retention-days: 30
# Upload test screenshots on failure
- uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7
if: failure()
with:
name: test-results
path: test-results/
retention-days: 30
# Cleanup - Stop all containers and background processes
- name: Cleanup
if: always()
run: |
kill ${{ steps.start-server.outputs.pid }} || true
docker compose -f e2e/docker-compose.test.yml down -v || true
docker stop falkordb-test || true
docker rm falkordb-test || true