-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
85 lines (69 loc) · 2.55 KB
/
playwright.yml
File metadata and controls
85 lines (69 loc) · 2.55 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
name: Playwright Tests
on:
pull_request:
branches:
- main
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
playwright:
if: github.actor != 'dependabot[bot]'
name: Playwright Tests
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- name: Setup Node.js
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6
with:
node-version-file: '.nvmrc'
cache: 'npm'
- name: Wait for Netlify preview
id: wait-for-preview
run: |
# Calculate the Netlify preview URL based on the PR number
PREVIEW_URL="https://deploy-preview-${{ github.event.pull_request.number }}--expressjscom-preview.netlify.app"
echo "PREVIEW_URL=$PREVIEW_URL" >> "$GITHUB_ENV"
MAX_RETRIES=10
DELAY=20
echo "Checking Netlify preview: $PREVIEW_URL"
for i in $(seq 1 $MAX_RETRIES); do
# Check if the URL returns a 200 OK
if curl -s -I "$PREVIEW_URL" | grep -q "HTTP/.* 200"; then
echo "✅ Preview is live at $PREVIEW_URL"
exit 0
fi
echo "⏳ Waiting for Netlify to deploy... ($i/$MAX_RETRIES)"
sleep $DELAY
done
echo "❌ Preview not live after $((MAX_RETRIES*DELAY)) seconds."
exit 1
- name: Install dependencies
run: npm ci
- name: Get Playwright version
id: playwright-version
run: echo "version=$(npx playwright --version | awk '{print $2}')" >> $GITHUB_OUTPUT
- name: Cache Playwright browsers
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
path: ~/.cache/ms-playwright
key: playwright-${{ runner.os }}-${{ steps.playwright-version.outputs.version }}
restore-keys: |
playwright-${{ runner.os }}-
- name: Install Playwright Browsers
if: steps.playwright-cache.outputs.cache-hit != 'true'
run: npx playwright install --with-deps
- name: Run Playwright tests
run: npm run test:e2e
env:
PLAYWRIGHT_BASE_URL: ${{ env.PREVIEW_URL }}
- name: Upload Playwright test results
if: always()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: playwright-report
path: playwright-report/
retention-days: 30