-
Notifications
You must be signed in to change notification settings - Fork 2
165 lines (143 loc) · 4.74 KB
/
Copy pathe2e.yml
File metadata and controls
165 lines (143 loc) · 4.74 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
# End-to-end test workflow
# Runs Playwright-based e2e tests against a live backend + frontend stack.
# Separate from CI so unit tests remain fast; e2e tests run in parallel.
name: E2E Tests
on:
push:
branches: [main, develop]
pull_request:
branches: [main, develop]
jobs:
e2e:
runs-on: ubuntu-latest
timeout-minutes: 30
env:
HUSKY: 0
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
# Backend configuration
VITE_API_URL: http://localhost:3000
CORS_ORIGINS: "http://localhost:5173,http://localhost:5174"
POSTGRES: postgresql://test:test@localhost:5432/test
POSTGRES_TEST: postgresql://test:test@localhost:5432/test
JWT_SECRET: e2e_test_secret_that_is_at_least_32_chars_long!
ADMIN_EMAIL: admin@datacollect.lan
ADMIN_PASSWORD: "Correct horse battery staple 42!"
SYNC_SERVER_PORT: 3000
services:
# PostgreSQL 15 service container (mirrors ci.yml)
postgres:
image: postgres:15
env:
POSTGRES_USER: test
POSTGRES_PASSWORD: test
POSTGRES_DB: test
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
steps:
# --- Setup ---
- uses: actions/checkout@v4
- name: Use Node.js 22.x
uses: actions/setup-node@v4
with:
node-version: 22.x
- uses: pnpm/action-setup@v4
with:
run_install: false
- name: Get pnpm store directory
shell: bash
run: echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- name: Setup pnpm cache
uses: actions/cache@v4
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: HUSKY=0 pnpm run ci:install
# --- Build ---
- name: Build all packages
run: pnpm run build
# --- Backend startup ---
- name: Start backend in background
run: |
node packages/backend/dist/index.js &
echo "Backend PID: $!"
shell: bash
- name: Wait for backend to be ready
run: |
echo "Waiting for backend on port 3000..."
for i in $(seq 1 30); do
if curl -sf http://localhost:3000/health > /dev/null 2>&1 || curl -sf http://localhost:3000/ > /dev/null 2>&1; then
echo "Backend is ready"
exit 0
fi
echo " attempt $i/30..."
sleep 2
done
echo "Backend failed to start within 60s"
exit 1
shell: bash
# --- Seed demo data ---
- name: Seed demo data
run: pnpm run seed
# --- Install Playwright browsers ---
- name: Install Playwright browsers
run: pnpm --filter @idpass/data-collect-admin exec playwright install --with-deps chromium
# --- Backend e2e tests ---
- name: Run backend e2e tests
run: pnpm run test:e2e:backend
# --- Admin e2e tests ---
- name: Start admin dev server in background
run: |
pnpm run dev:admin &
echo "Waiting for admin on port 5173..."
for i in $(seq 1 30); do
if curl -sf http://localhost:5173 > /dev/null 2>&1; then
echo "Admin dev server is ready"
exit 0
fi
echo " attempt $i/30..."
sleep 2
done
echo "Admin dev server failed to start within 60s"
exit 1
shell: bash
- name: Run admin e2e tests
run: pnpm run test:e2e:admin
# --- Web e2e tests ---
- name: Start web dev server in background
run: |
pnpm run dev:web &
echo "Waiting for web on port 5174..."
for i in $(seq 1 30); do
if curl -sf http://localhost:5174 > /dev/null 2>&1; then
echo "Web dev server is ready"
exit 0
fi
echo " attempt $i/30..."
sleep 2
done
echo "Web dev server failed to start within 60s"
exit 1
shell: bash
- name: Run web e2e tests
run: pnpm --filter @idpass/data-collect-web run test:e2e
# --- Cross-service integration tests ---
- name: Run integration e2e tests
run: pnpm run test:e2e:integration
# --- Upload artifacts on failure ---
- name: Upload Playwright reports
if: failure()
uses: actions/upload-artifact@v4
with:
name: playwright-reports
path: |
**/playwright-report/
**/test-results/
retention-days: 7