-
-
Notifications
You must be signed in to change notification settings - Fork 102
123 lines (104 loc) · 3.3 KB
/
playwright-e2e.yml
File metadata and controls
123 lines (104 loc) · 3.3 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
# Playwright end-to-end tests
# This workflow uses docker compose to start the development environment,
# then runs Playwright tests against it.
name: Playwright E2E Tests
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
e2e:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Create .env file
run: |
cat > .env << EOF
NPDI_WEB_PORT=3000
NPDI_API_PORT=5001
GRAPH_PASSWORD=test_password
GRAPH_USER=neo4j
GRAPH_NM_URI="db:7687"
FLASK_ENV=development
MIXPANEL_TOKEN=notset
EOF
- name: Start services with docker compose
uses: hoverkraft-tech/compose-action@v2.5.0
with:
compose-file: docker-compose.yml
up-flags: --build --detach
- name: Wait for services to be healthy
run: |
echo "Waiting for services to be ready..."
# Wait for Neo4j
echo "Waiting for Neo4j..."
for i in {1..30}; do
if curl -f http://localhost:7474 > /dev/null 2>&1; then
echo "Neo4j is ready!"
break
fi
echo "Attempt $i: Neo4j not ready yet..."
sleep 2
done
# Wait for API
echo "Waiting for API..."
for i in {1..30}; do
if curl -f http://localhost:5001/api/v1/healthcheck > /dev/null 2>&1; then
echo "API is ready!"
break
fi
echo "Attempt $i: API not ready yet..."
sleep 2
done
# Wait for Frontend
echo "Waiting for Frontend..."
for i in {1..30}; do
if curl -f http://localhost:3000 > /dev/null 2>&1; then
echo "Frontend is ready!"
break
fi
echo "Attempt $i: Frontend not ready yet..."
sleep 2
done
echo "All services are ready!"
- name: Check service logs
if: failure()
run: |
docker compose logs
- name: Fix permissions for frontend directory
run: |
# Docker volumes may have created files with container user permissions
# Fix ownership so the runner can install npm dependencies
sudo chown -R $USER:$USER frontend/
- name: Set up Node.js
uses: actions/setup-node@v6
with:
node-version: "20"
cache: "npm"
cache-dependency-path: frontend/package-lock.json
- name: Install frontend dependencies
working-directory: frontend
run: npm ci
- name: Install Playwright Browsers
working-directory: frontend
run: npx playwright install --with-deps chromium
- name: Run Playwright tests
working-directory: frontend
env:
NPDI_WEB_PORT: 3000
NPDI_API_PORT: 5001
NEXT_PUBLIC_API_BASE_URL: http://0.0.0.0:5001/api/v1
run: npm run test:e2e
- name: Upload test results
uses: actions/upload-artifact@v7
if: always()
with:
name: playwright-results
path: frontend/test-results/
retention-days: 30
- name: Stop services
if: always()
run: docker compose down -v