-
Notifications
You must be signed in to change notification settings - Fork 11
144 lines (128 loc) · 4.48 KB
/
Copy pathci.yml
File metadata and controls
144 lines (128 loc) · 4.48 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
# This workflow will do a clean install of node dependencies, cache/restore them,
# build the source code and run tests
# source: https://github.com/actions/starter-workflows/blob/main/ci/node.js.yml
name: ci
permissions:
contents: read
on:
push:
branches:
- main
pull_request:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Use Node.js 18.12.0
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
node-version: "18.12.0"
cache: "yarn"
- run: yarn install --frozen-lockfile
- run: yarn prepublishOnly
- run: node index.node.js
- run: yarn test
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
- run: yarn check-deps
e2e-tests:
runs-on: ubuntu-latest
timeout-minutes: 15
container:
image: mcr.microsoft.com/playwright:v1.56.1-jammy
options: --user 1001
strategy:
matrix:
browser: [chromium, firefox, webkit]
fail-fast: false
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Setup Node.js
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
node-version: "18.12.0"
cache: "yarn"
- name: Install dependencies
run: |
yarn install --frozen-lockfile
yarn prepublishOnly
- name: Cache React dependencies
uses: actions/cache@v4
with:
path: react-example/node_modules
key: ${{ runner.os }}-react-deps-${{ hashFiles('react-example/yarn.lock') }}
restore-keys: |
${{ runner.os }}-react-deps-
- name: Install React example dependencies
working-directory: ./react-example
run: yarn install --frozen-lockfile
- name: Install Playwright browsers
working-directory: ./react-example
run: |
echo "📥 Installing ${{ matrix.browser }} browser (dependencies already in Docker image)..."
yarn playwright install ${{ matrix.browser }}
echo "✅ Browser installed"
- name: Create environment configuration
working-directory: ./react-example
run: |
cat > .env << 'EOF'
API_KEY=${{ secrets.ITERABLE_NO_JWT_API_KEY }}
USE_JWT=false
LOGIN_EMAIL=websdk-playwright-test@iterable.com
EOF
- name: Build React example app
working-directory: ./react-example
run: yarn build
- name: Start React example server
working-directory: ./react-example
run: |
echo "🚀 Starting React server..."
yarn webpack serve --config webpack.config.js --port 8080 --host 0.0.0.0 &
# Wait for server to be ready
for i in {1..30}; do
if curl -f http://localhost:8080 >/dev/null 2>&1; then
echo "✅ Server ready after ${i} attempts"
break
fi
if [ $i -eq 30 ]; then
echo "❌ Server startup failed"
exit 1
fi
sleep 2
done
- name: Run Playwright tests
working-directory: ./react-example
run: yarn playwright test --project=${{ matrix.browser }}
env:
CI: true
- name: Upload Playwright report
uses: actions/upload-artifact@v4
if: always()
with:
name: playwright-report-${{ matrix.browser }}-${{ github.run_number }}
path: react-example/playwright-report/
retention-days: 14
- name: Upload test results
uses: actions/upload-artifact@v4
if: always()
with:
name: test-results-${{ matrix.browser }}-${{ github.run_number }}
path: react-example/test-results/
retention-days: 7
- name: Cleanup server processes
if: always()
run: |
echo "🧹 Cleaning up server processes..."
# Kill all processes using port 8080
sudo lsof -ti:8080 | xargs -r sudo kill -9 || true
# Kill by process names
pkill -f "webpack serve" || true
pkill -f "node.*webpack" || true
# Kill any remaining browser processes
pkill -f "chrome" || true
pkill -f "firefox" || true
pkill -f "webkit" || true
echo "✅ Cleanup completed"