-
Notifications
You must be signed in to change notification settings - Fork 0
92 lines (80 loc) · 2.82 KB
/
playwright.yml
File metadata and controls
92 lines (80 loc) · 2.82 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
name: Playwright Tests
on:
push:
branches:
- main
pull_request:
branches:
- main
schedule:
# Run 3 times a week: Monday, Wednesday, Friday at 9 AM UTC
- cron: '0 9 * * 1,3,5'
workflow_dispatch:
jobs:
playwright:
timeout-minutes: 60
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: lts/*
- name: Setup PHP
if: github.event_name == 'push' || github.event_name == 'pull_request'
uses: shivammathur/setup-php@v2
with:
php-version: '8.4'
- name: Install PHP Dependencies
if: github.event_name == 'push' || github.event_name == 'pull_request'
run: |
composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
cp .env.example .env
php artisan key:generate
- name: Install Node.js Dependencies and Build Assets
run: npm ci && npm run build
- name: Install Playwright Browsers
run: npx playwright install chromium --with-deps
- name: Install npm dependencies (production tests)
if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'
run: npm ci
- name: Start server and run tests (local)
if: github.event_name == 'push' || github.event_name == 'pull_request'
run: |
php artisan serve &
for i in {1..15}; do
if [[ "$(curl -s -o /dev/null -w '%{http_code}' http://localhost:8000)" == "200" ]]; then
echo "Server is up with 200 response!"
break
fi
echo "Waiting for server to start..."
sleep 2
done
npx playwright test
- name: Run tests (production)
if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'
run: npm run playwright:prod
- uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
with:
name: playwright-report
path: playwright-report/
retention-days: 30
- name: Notify Slack on failure
if: failure() && (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch')
uses: slackapi/slack-github-action@v1
with:
payload: |
{
"text": "Playwright tests failed in ${{ github.repository }}",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "❌ *Playwright Tests Failed*\n*Repository:* ${{ github.repository }}\n*Branch:* ${{ github.ref_name }}\n*Workflow:* ${{ github.workflow }}\n*Run:* <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|View Run>"
}
}
]
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}