38
38
name : Playwright Tests
39
39
runs-on : ubuntu-latest
40
40
permissions :
41
- contents : write
42
- pull-requests : write
43
- pages : write
41
+ contents : read
44
42
45
43
services :
46
44
backend :
82
80
path : playwright-artifacts
83
81
retention-days : 5
84
82
85
- - name : Setup Pages
86
- if : always()
87
- uses : actions/configure-pages@v3
88
-
89
- - name : Deploy report to GitHub Pages
90
- if : always()
91
- uses : peaceiris/actions-gh-pages@v3
92
- with :
93
- github_token : ${{ secrets.GITHUB_TOKEN }}
94
- publish_dir : ./playwright-artifacts/playwright-report
95
- destination_dir : ${{ github.event.pull_request.number }}
96
-
97
83
- name : Get test results
98
84
if : always()
99
85
id : test-results
@@ -102,13 +88,13 @@ jobs:
102
88
echo "Listing playwright-artifacts directory:"
103
89
ls -R playwright-artifacts
104
90
105
- if [ -f "playwright-artifacts/test-results.json" ]; then
91
+ if [ -f "playwright-artifacts/test-results.json" ]; then
106
92
echo "Parsing JSON file:"
107
93
total=$(jq '.stats.expected + .stats.unexpected + .stats.skipped' playwright-artifacts/test-results.json)
108
94
passed=$(jq '.stats.expected' playwright-artifacts/test-results.json)
109
95
failed=$(jq '.stats.unexpected' playwright-artifacts/test-results.json)
110
96
skipped=$(jq '.stats.skipped' playwright-artifacts/test-results.json)
111
-
97
+
112
98
echo "Parsed values:"
113
99
echo "Total: $total"
114
100
echo "Passed: $passed"
@@ -127,19 +113,59 @@ jobs:
127
113
echo "failed=$failed" >> $GITHUB_OUTPUT
128
114
echo "skipped=$skipped" >> $GITHUB_OUTPUT
129
115
116
+ deploy_and_update :
117
+ name : Deploy and Update PR
118
+ needs : e2e_tests
119
+ runs-on : ubuntu-latest
120
+ if : github.event.pull_request.head.repo.full_name == github.repository
121
+ permissions :
122
+ contents : write
123
+ pages : write
124
+ pull-requests : write
125
+
126
+ steps :
127
+ - uses : actions/checkout@v4
128
+
129
+ - name : Download artifacts
130
+ uses : actions/download-artifact@v3
131
+ with :
132
+ name : playwright-artifacts
133
+ path : playwright-artifacts
134
+
135
+ - name : Setup Pages
136
+ uses : actions/configure-pages@v3
137
+
138
+ - name : Deploy report to GitHub Pages
139
+ uses : peaceiris/actions-gh-pages@v3
140
+ with :
141
+ github_token : ${{ secrets.GITHUB_TOKEN }}
142
+ publish_dir : ./playwright-artifacts/playwright-report
143
+ destination_dir : ${{ github.event.pull_request.number }}
144
+
130
145
- name : Update PR description
131
- if : always()
132
146
uses : actions/github-script@v6
133
147
with :
134
148
github-token : ${{secrets.GITHUB_TOKEN}}
135
149
script : |
150
+ const fs = require('fs');
151
+ const testResultsPath = 'playwright-artifacts/test-results.json';
152
+ let testResults;
153
+
154
+ if (fs.existsSync(testResultsPath)) {
155
+ const rawData = fs.readFileSync(testResultsPath);
156
+ const data = JSON.parse(rawData);
157
+ testResults = {
158
+ total: data.stats.expected + data.stats.unexpected + data.stats.skipped,
159
+ passed: data.stats.expected,
160
+ failed: data.stats.unexpected,
161
+ skipped: data.stats.skipped
162
+ };
163
+ } else {
164
+ console.log('Test results file not found');
165
+ testResults = { total: 0, passed: 0, failed: 0, skipped: 0 };
166
+ }
167
+
136
168
const reportUrl = `https://${context.repo.owner}.github.io/${context.repo.repo}/${context.issue.number}/`;
137
- const testResults = {
138
- total: ${{ steps.test-results.outputs.total || 0 }},
139
- passed: ${{ steps.test-results.outputs.passed || 0 }},
140
- failed: ${{ steps.test-results.outputs.failed || 0 }},
141
- skipped: ${{ steps.test-results.outputs.skipped || 0 }}
142
- };
143
169
const status = testResults.failed > 0 ? '❌ FAILED' : '✅ PASSED';
144
170
const statusColor = testResults.failed > 0 ? 'red' : 'green';
145
171
0 commit comments