forked from Nova-reward/Nova-Rewards
-
Notifications
You must be signed in to change notification settings - Fork 0
304 lines (261 loc) · 9.38 KB
/
Copy pathe2e.yml
File metadata and controls
304 lines (261 loc) · 9.38 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
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
name: E2E Tests - Reward Issuance Flow
on:
push:
branches: [main, develop, feature/e2e-*]
pull_request:
branches: [main, develop]
schedule:
# Run E2E tests daily at 2 AM UTC
- cron: '0 2 * * *'
env:
NODE_VERSION: '18'
CI: true
jobs:
e2e:
name: E2E Tests - Full Reward Issuance Flow
runs-on: ubuntu-latest
timeout-minutes: 30
services:
postgres:
image: postgres:15-alpine
env:
POSTGRES_DB: nova_rewards_test
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
redis:
image: redis:7-alpine
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 6379:6379
steps:
- name: Checkout code
uses: actions/checkout@v7
- name: Setup Node.js
uses: actions/setup-node@v7
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
- name: Install backend dependencies
working-directory: ./novaRewards/backend
run: npm install --frozen-lockfile
- name: Install frontend dependencies
working-directory: ./novaRewards/frontend
run: npm install --frozen-lockfile
- name: Install Playwright browsers
working-directory: ./novaRewards/frontend
run: npx playwright install --with-deps
- name: Setup environment variables
run: |
cat > .env.test << EOF
NODE_ENV=test
DATABASE_URL=postgresql://postgres:postgres@localhost:5432/nova_rewards_test
REDIS_URL=redis://localhost:6379
API_BASE_URL=http://localhost:3000/api
TESTNET_USER_WALLET=${{ secrets.TESTNET_USER_WALLET || 'GBRPYHIL2CI3WHSCULVRJC3P4ABWOY4XHALUKYAPXL73MRLN42HDA5O' }}
TESTNET_ISSUER_PUBLIC=${{ secrets.TESTNET_ISSUER_PUBLIC || 'GDQOE23CFSUMSVQK4Y5R3ZARVIVTD4XVXUUJX3SP27YMGNXC2OGXJVM' }}
EOF
- name: Run database migrations
working-directory: ./novaRewards/backend
env:
DATABASE_URL: postgresql://postgres:postgres@localhost:5432/nova_rewards_test
run: npm run migrate || true
- name: Seed test data
working-directory: ./novaRewards/backend
env:
DB_HOST: localhost
DB_PORT: 5432
DB_NAME: nova_rewards_test
DB_USER: postgres
DB_PASSWORD: postgres
run: node scripts/seed-test-data.js
- name: Start backend server
working-directory: ./novaRewards/backend
env:
NODE_ENV: test
DATABASE_URL: postgresql://postgres:postgres@localhost:5432/nova_rewards_test
REDIS_URL: redis://localhost:6379
PORT: 3001
run: |
npm run start &
sleep 5
timeout-minutes: 5
- name: Start frontend dev server
working-directory: ./novaRewards/frontend
run: |
npm run dev &
sleep 10
timeout-minutes: 5
- name: Wait for services
run: |
until curl -f http://localhost:3000; do
echo "Waiting for frontend..."
sleep 2
done
until curl -f http://localhost:3001/health; do
echo "Waiting for backend..."
sleep 2
done
- name: Run E2E tests - Reward Issuance Flow
working-directory: ./novaRewards/frontend
env:
CI: true
BASE_URL: http://localhost:3000
run: npx playwright test reward-issuance-flow.spec.js --reporter=html
- name: Run E2E tests - All Specs
working-directory: ./novaRewards/frontend
env:
CI: true
BASE_URL: http://localhost:3000
run: npx playwright test --reporter=html
continue-on-error: true
- name: Upload test results
if: always()
uses: actions/upload-artifact@v7
with:
name: playwright-report
path: ./novaRewards/frontend/playwright-report/
retention-days: 30
- name: Upload test results (JSON)
if: always()
uses: actions/upload-artifact@v7
with:
name: test-results-json
path: ./novaRewards/frontend/test-results/
retention-days: 30
- name: Publish test report
if: always()
uses: daghnawal/playwright-report-comment@v3
with:
report-path: ./novaRewards/frontend/playwright-report
only-on-failure: false
- name: Comment PR with test results
if: github.event_name == 'pull_request' && always()
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const resultsPath = './novaRewards/frontend/test-results/results.json';
if (fs.existsSync(resultsPath)) {
const results = JSON.parse(fs.readFileSync(resultsPath, 'utf-8'));
const passed = results.stats?.expected || 0;
const failed = results.stats?.unexpected || 0;
const skipped = results.stats?.skipped || 0;
const body = `
## E2E Test Results
- ✅ Passed: ${passed}
- ❌ Failed: ${failed}
- ⏭️ Skipped: ${skipped}
[View detailed report](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})
`;
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: body
});
}
- name: Fail if tests failed
if: failure()
run: exit 1
e2e-testnet:
name: E2E Tests - Stellar Testnet Integration
runs-on: ubuntu-latest
timeout-minutes: 45
# Only run on main branch or when explicitly triggered
if: github.ref == 'refs/heads/main' || contains(github.event.head_commit.message, '[testnet]')
steps:
- name: Checkout code
uses: actions/checkout@v7
- name: Setup Node.js
uses: actions/setup-node@v7
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
- name: Install dependencies
working-directory: ./novaRewards/frontend
run: npm install --frozen-lockfile
- name: Install Playwright browsers
working-directory: ./novaRewards/frontend
run: npx playwright install --with-deps
- name: Run E2E tests against testnet
working-directory: ./novaRewards/frontend
env:
CI: true
TESTNET_MODE: true
BASE_URL: ${{ secrets.TESTNET_BASE_URL || 'https://staging.nova-rewards.com' }}
TESTNET_USER_WALLET: ${{ secrets.TESTNET_USER_WALLET }}
TESTNET_ISSUER_PUBLIC: ${{ secrets.TESTNET_ISSUER_PUBLIC }}
run: npx playwright test reward-issuance-flow.spec.js --reporter=html
- name: Upload testnet test results
if: always()
uses: actions/upload-artifact@v7
with:
name: testnet-playwright-report
path: ./novaRewards/frontend/playwright-report/
retention-days: 30
name: Playwright E2E Tests
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
e2e:
name: E2E (${{ matrix.browser }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
browser: [chromium, firefox, webkit]
steps:
- uses: actions/checkout@v7
- uses: actions/setup-node@v7
with:
node-version: 20
cache: npm
cache-dependency-path: novaRewards/package-lock.json
- name: Install workspace dependencies
run: npm ci
working-directory: novaRewards
- name: Install Playwright browsers
run: npx playwright install --with-deps ${{ matrix.browser }}
working-directory: novaRewards/frontend
- name: Run E2E tests (against staging)
# When STAGING_URL is set, Playwright hits the live staging environment.
# When it is not set (e.g. forks or missing secret), we start a local dev
# server instead so the job doesn't fail outright.
run: npx playwright test --project=${{ matrix.browser }}
working-directory: novaRewards/frontend
env:
CI: true
STAGING_URL: ${{ secrets.STAGING_URL }}
NEXT_PUBLIC_API_URL: ${{ secrets.STAGING_API_URL || 'http://localhost:3001' }}
# Required for local webServer fallback (used when STAGING_URL is empty)
NEXT_PUBLIC_HORIZON_URL: https://horizon-testnet.stellar.org
NEXT_PUBLIC_STELLAR_NETWORK: testnet
NEXT_PUBLIC_ISSUER_PUBLIC: GAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
- name: Upload Playwright report
if: always()
uses: actions/upload-artifact@v7
with:
name: playwright-report-${{ matrix.browser }}
path: novaRewards/frontend/playwright-report/
retention-days: 14
- name: Upload visual snapshots
if: always()
uses: actions/upload-artifact@v7
with:
name: visual-snapshots-${{ matrix.browser }}
path: novaRewards/frontend/e2e/**/*.png
retention-days: 14