-
Notifications
You must be signed in to change notification settings - Fork 152
95 lines (82 loc) · 2.88 KB
/
playwright.yml
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
# Name of the GitHub Actions workflow
name: Playwright Github Actions
# Define when to trigger this workflow
on:
push:
branches:
- main
pull_request:
branches:
- main
# Define the jobs to run in this workflow
jobs:
# Define a job named 'build'
build:
# Specify the operating system for this job
runs-on: ubuntu-latest
env:
SLACK_WEBHOOK_URL: ${{secrets.SLACK_WEBHOOK_URL}}
# Define the steps to execute in this job
steps:
# Step to checkout the source code from the repository
- name: Checkout code
uses: actions/checkout@v2
# Step to set up the Node.js version
- name: Install node js v20
uses: actions/setup-node@v2
with:
node-version: "20"
# Step to install Node.js dependencies
- name: Install dependencies
run: npm ci
# Step to install Chrome browser for Playwright
- name: Install Chrome browser for Playwright
run: npx playwright install chrome
# Step to run tests with qa as environment variable similarly we can define qa|dev|qaApi|devApi
- name: Run tests
run: npm run test:serial
env:
npm_config_ENV: "qa"
# Step to wait for the job to complete
- name: Wait for job completion
# Adjust the wait time as needed
run: sleep 10s
# This step should always run, even if previous steps fail
if: always()
# Check if HTML report exists
- name: Check if HTML report exists
run: |
if [ -d "html-report" ]; then
echo "HTML report exists."
else
echo "HTML report does not exist. Exiting..."
exit 1
fi
if: always()
# Step to zip html-report folder
- name: Zip HTML report
run: zip -r html-report.zip html-report
# This step should always run, even if previous steps fail
if: always()
# Step to upload artifact
- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: html-report
path: html-report.zip
if-no-files-found: error
if: always()
# Step to generate artifact link
- name: Generate artifact link
id: artifact_link
run: echo "::set-output name=artifact_url::https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
if: always()
# Send Slack notification with html-reprt url once the tests are completed
- name: Send Slack notification
uses: rtCamp/action-slack-notify@v2
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
SLACK_CHANNEL: "#playwright-test-reports"
SLACK_USERNAME: Playwright GitHub Actions
SLACK_MESSAGE: "Test results are available in [Artifacts section](${{ steps.artifact_link.outputs.artifact_url }}) as html-report."
if: always()