-
Notifications
You must be signed in to change notification settings - Fork 1
119 lines (99 loc) · 3.23 KB
/
playwright.yml
File metadata and controls
119 lines (99 loc) · 3.23 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
name: Playwright E2E Tests
on:
push:
branches: [master, main]
pull_request:
branches: [master, main]
workflow_dispatch: # Allow manual trigger
jobs:
test:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout playwright tests
uses: actions/checkout@v4
- name: Checkout confac
uses: actions/checkout@v4
with:
repository: itenium-be/confac
path: confac
# Use the same branch if it exists, otherwise master
ref: ${{ github.head_ref || github.ref_name || 'master' }}
continue-on-error: true
- name: Fallback to confac master
if: failure()
uses: actions/checkout@v4
with:
repository: itenium-be/confac
path: confac
ref: master
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
cache: 'npm'
- name: Install Playwright dependencies
run: |
npm ci
npx playwright install --with-deps chromium
- name: Install confac backend dependencies
working-directory: ./confac/backend
run: npm ci
- name: Install confac frontend dependencies
working-directory: ./confac/frontend
run: npm ci
- name: Start infrastructure (MongoDB + mocks)
run: |
docker compose -f docker-compose.test.yml up -d --build
# Wait for MongoDB to be ready
sleep 10
docker compose -f docker-compose.test.yml ps
- name: Setup backend environment
working-directory: ./confac/backend
run: |
cp ../../.env.test .env
cp -r templates-example templates || true
- name: Start backend
working-directory: ./confac/backend
run: npm start &
env:
NODE_ENV: test
- name: Start frontend
working-directory: ./confac/frontend
run: npm start &
env:
CI: true
BROWSER: none
- name: Wait for services
run: |
echo "Waiting for backend..."
timeout 60 bash -c 'until curl -s http://localhost:9000/health > /dev/null 2>&1 || curl -s http://localhost:9000 > /dev/null 2>&1; do sleep 2; done' || true
echo "Waiting for frontend..."
timeout 120 bash -c 'until curl -s http://localhost:3000 > /dev/null 2>&1; do sleep 2; done'
echo "Services ready!"
- name: Seed database
run: npm run seed
- name: Run Playwright tests
run: npx playwright test --project=chromium --reporter=html
env:
CI: true
- name: Upload test results
if: always()
uses: actions/upload-artifact@v4
with:
name: playwright-report
path: playwright-report/
retention-days: 30
- name: Upload test artifacts
if: failure()
uses: actions/upload-artifact@v4
with:
name: test-results
path: test-results/
retention-days: 30
- name: Show docker logs on failure
if: failure()
run: docker compose -f docker-compose.test.yml logs
- name: Cleanup
if: always()
run: docker compose -f docker-compose.test.yml down -v