-
Notifications
You must be signed in to change notification settings - Fork 9
244 lines (210 loc) · 7.11 KB
/
quality.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
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
name: Quality Checks
on:
pull_request:
branches: ['**']
push:
branches: [main]
jobs:
e2e_tests:
name: Playwright Tests
runs-on: ubuntu-latest
permissions:
contents: read
services:
backend:
image: ghcr.io/ydb-platform/local-ydb:nightly
ports:
- 2135:2135
- 8765:8765
options: --hostname localhost -e YDB_ALLOW_ORIGIN="http://localhost:3000"
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 18
cache: npm
- name: Install dependencies
run: npm ci
- name: Install Playwright deps
run: npm run test:e2e:install
- name: Run Playwright tests
id: run_tests
run: npm run test:e2e
env:
CI: true
PLAYWRIGHT_VIDEO: 'on'
- name: Upload Playwright artifacts
if: always()
uses: actions/upload-artifact@v3
with:
name: playwright-artifacts
path: playwright-artifacts
retention-days: 5
- name: Get test results
if: always()
id: test-results
run: |
echo "Current directory: $(pwd)"
echo "Listing playwright-artifacts directory:"
ls -R playwright-artifacts
if [ -f "playwright-artifacts/test-results.json" ]; then
echo "Parsing JSON file:"
total=$(jq '.stats.expected + .stats.unexpected + .stats.flaky + .stats.skipped' playwright-artifacts/test-results.json)
passed=$(jq '.stats.expected' playwright-artifacts/test-results.json)
failed=$(jq '.stats.unexpected' playwright-artifacts/test-results.json)
flaky=$(jq '.stats.flaky' playwright-artifacts/test-results.json)
skipped=$(jq '.stats.skipped' playwright-artifacts/test-results.json)
echo "Parsed values:"
echo "Total: $total"
echo "Passed: $passed"
echo "Failed: $failed"
echo "Flaky: $flaky"
echo "Skipped: $skipped"
else
echo "test-results.json file not found"
total=0
passed=0
failed=0
flaky=0
skipped=0
fi
echo "total=$total" >> $GITHUB_OUTPUT
echo "passed=$passed" >> $GITHUB_OUTPUT
echo "failed=$failed" >> $GITHUB_OUTPUT
echo "flaky=$flaky" >> $GITHUB_OUTPUT
echo "skipped=$skipped" >> $GITHUB_OUTPUT
bundle_size:
name: Check Bundle Size
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
outputs:
current_size: ${{ steps.current_size.outputs.size }}
main_size: ${{ steps.main_size.outputs.size }}
diff: ${{ steps.size_diff.outputs.diff }}
percent: ${{ steps.size_diff.outputs.percent }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 18
cache: npm
- name: Install dependencies
run: npm ci
- name: Build bundle (current branch)
run: npm run build
- name: Get current bundle size
id: current_size
run: |
size=$(du -sb build | cut -f1)
echo "size=$size" >> $GITHUB_OUTPUT
- name: Checkout main branch
uses: actions/checkout@v4
with:
ref: main
- name: Install dependencies (main)
run: npm ci
- name: Build bundle (main branch)
run: npm run build
- name: Get main bundle size
id: main_size
run: |
size=$(du -sb build | cut -f1)
echo "size=$size" >> $GITHUB_OUTPUT
- name: Calculate size difference
id: size_diff
run: |
current=${{ steps.current_size.outputs.size }}
main=${{ steps.main_size.outputs.size }}
diff=$((current - main))
if [ "$main" -ne "0" ]; then
percent=$(awk "BEGIN {printf \"%.2f\", ($diff/$main) * 100}")
else
percent="N/A"
fi
echo "diff=$diff" >> $GITHUB_OUTPUT
echo "percent=$percent" >> $GITHUB_OUTPUT
deploy_report:
name: Deploy Test Report
needs: [e2e_tests]
if: always() && (github.event_name == 'push' && github.ref == 'refs/heads/main' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository))
runs-on: ubuntu-latest
permissions:
contents: write
pages: write
concurrency:
group: deploy_report
cancel-in-progress: false
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Fetch gh-pages branch
run: |
git fetch origin gh-pages:gh-pages
mkdir gh-pages
git --work-tree=gh-pages checkout gh-pages -- .
- name: Download Playwright artifacts
uses: actions/download-artifact@v3
with:
name: playwright-artifacts
path: playwright-artifacts
- name: Copy new report
run: |
if [ "${{ github.event_name }}" = "pull_request" ]; then
REPORT_DIR="${{ github.event.pull_request.number }}"
else
REPORT_DIR="main"
fi
rm -rf gh-pages/$REPORT_DIR
mkdir -p gh-pages/$REPORT_DIR
cp -r playwright-artifacts/playwright-report/* gh-pages/$REPORT_DIR/
# Also copy test-results.json if it exists
if [ -f "playwright-artifacts/test-results.json" ]; then
cp playwright-artifacts/test-results.json gh-pages/$REPORT_DIR/
fi
- name: Deploy report to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: gh-pages
destination_dir: .
force_orphan: true
update_pr:
name: Update PR Description
needs: [e2e_tests, bundle_size]
if: always() && github.event_name == 'pull_request'
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Download Playwright artifacts
uses: actions/download-artifact@v3
with:
name: playwright-artifacts
path: playwright-artifacts
- name: Fetch gh-pages branch
run: |
git fetch origin gh-pages:gh-pages
mkdir gh-pages
git --work-tree=gh-pages checkout gh-pages -- .
- name: Update PR description
uses: actions/github-script@v6
env:
CURRENT_SIZE: ${{ needs.bundle_size.outputs.current_size }}
MAIN_SIZE: ${{ needs.bundle_size.outputs.main_size }}
SIZE_DIFF: ${{ needs.bundle_size.outputs.diff }}
SIZE_PERCENT: ${{ needs.bundle_size.outputs.percent }}
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const updatePRDescription = require('./.github/workflows/scripts/update-pr-description.js');
await updatePRDescription(github, context);