-
Notifications
You must be signed in to change notification settings - Fork 37
258 lines (210 loc) · 7.63 KB
/
visual-comparison.yaml
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
245
246
247
248
249
250
251
252
253
254
255
256
257
258
name: Visual Comparison
on:
pull_request:
types: [opened, reopened, synchronize, labeled]
branches-ignore: ["version-*", "release-*"]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PALETTE_API_KEY: ${{ secrets.PALETTE_API_KEY }}
FULLSTORY_ORGID: ${{ secrets.FULLSTORY_ORGID }}
ALGOLIA_ADMIN_KEY: ${{ secrets.ALGOLIA_ADMIN_KEY }}
ALGOLIA_APP_ID: ${{ secrets.ALGOLIA_APP_ID }}
ALGOLIA_SEARCH_KEY: ${{ secrets.ALGOLIA_SEARCH_KEY }}
ALGOLIA_INDEX_NAME: ${{ secrets.ALGOLIA_INDEX_NAME }}
HTML_REPORT_URL_PATH: reports/${{ github.head_ref }}/${{ github.run_id }}/${{ github.run_attempt }}
DISABLE_PACKS_INTEGRATIONS: ${{ secrets.DISABLE_PACKS_INTEGRATIONS }}
DISABLE_SECURITY_INTEGRATIONS: ${{ secrets.DISABLE_SECURITY_INTEGRATIONS }}
DSO_AUTH_TOKEN: ${{ secrets.DSO_AUTH_TOKEN }}
concurrency:
group: "visual-comparison-${{ github.workflow }}-${{ github.head_ref }}"
cancel-in-progress: true
jobs:
run-ci:
runs-on: ubuntu-latest
defaults:
run:
shell: bash
if: ${{ !github.event.pull_request.draft && github.actor != 'dependabot[bot]' && github.actor != 'dependabot-preview[bot]' && contains(github.event.pull_request.labels.*.name, 'visual-tests') }}
steps:
# If the condition above is not met, aka, the PR is not in draft status, then this step is skipped.
# Because this step is part of the critical path, omission of this step will result in remaining CI steps not gettinge executed.
# As of 8/8/2022 there is now way to enforce this beahvior in GitHub Actions CI.
- run: |
echo "GITHUB_BASE_REF: ${{ github.base_ref }}"
echo "GITHUB_HEAD_REF: ${{ github.head_ref }}"
echo "GITHUB_REF_NAME: ${{ github.ref_name }}"
echo "HTML_REPORT_URL_PATH ${{ env.HTML_REPORT_URL_PATH }}"
exit 0
create-assets:
name: create-assets
needs: [run-ci]
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Setup Node.js Environment
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "npm"
- name: Post PR Comment
uses: mshick/add-pr-comment@v2
with:
message: |
🤖 Starting the visual tests. This will take approximately an hour.
refresh-message-position: true
- name: Install Dependencies
uses: Wandalen/wretry.action@v3
with:
command: npm ci
attempt_limit: 3
attempt_delay: 60000 # 1 minute
- name: Build
run: |
touch .env
make build-ci
- name: Build with cached packs
if: ${{ env.BUILD_EXIT_CODE == '5' }}
uses: ./.github/actions/build-cached-packs
with:
gh-token: ${{ secrets.GITHUB_TOKEN }}
- name: Upload Build
uses: actions/upload-artifact@v4
with:
name: "build"
path: |
build/
if-no-files-found: error
retention-days: 1
take-screenshots:
name: Visual Comparison
needs: [run-ci, create-assets]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
shardIndex: [1, 2, 3, 4]
shardTotal: [4]
steps:
- name: Check out repository code
uses: actions/checkout@v4
- name: Setup Node.js environment
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "npm"
- name: Install Dependencies
uses: Wandalen/wretry.action@v3
with:
command: npm ci
attempt_limit: 3
attempt_delay: 60000 # 1 minute
- name: Install Playwright browsers
run: npx playwright install --with-deps chromium
- name: Download Build
uses: Wandalen/wretry.action@v3
with:
attempt_limit: 3
action: actions/download-artifact@v4
with: |
name: build
path: build
attempt_delay: 60000 # 1 minute
- name: Download Reference Screenshots
run: ./scripts/screenshot_artifacts.sh ./screenshots
- name: Take screenshots with Playwright
run: npx playwright test --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }} || exit 0
- name: Upload blob report to GitHub Actions Artifacts
uses: actions/upload-artifact@v4
with:
name: blob-report-${{ matrix.shardIndex }}
path: blob-report
retention-days: 1
merge-reports:
name: Merge Reports
needs: [take-screenshots]
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v4
- name: Setup Node.js environment
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "npm"
- name: Install Dependencies
uses: Wandalen/wretry.action@v3
with:
command: npm ci
attempt_limit: 3
attempt_delay: 60000 # 1 minute
- name: Download blob reports from GitHub Actions Artifacts
uses: actions/download-artifact@v4
with:
path: all-blob-reports
pattern: blob-report-*
merge-multiple: true
- name: Merge into HTML Report
run: npx playwright merge-reports --reporter html ./all-blob-reports
- name: Upload Report
uses: actions/upload-artifact@v4
id: report
with:
name: "report"
path: |
playwright-report/
if-no-files-found: error
retention-days: 1
publish_report:
name: Publish HTML Report
needs: [run-ci, take-screenshots, merge-reports]
runs-on: ubuntu-latest
continue-on-error: true
steps:
- name: Checkout GitHub Pages Branch
uses: actions/checkout@v4
with:
ref: gh-pages
- name: Set Git User
# see: https://github.com/actions/checkout/issues/13#issuecomment-724415212
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
- name: Download zipped HTML report
uses: actions/download-artifact@v4
with:
name: report
path: ${{ env.HTML_REPORT_URL_PATH }}
- name: Push HTML Report
timeout-minutes: 5
run: |
git add .
git commit -m "workflow: add HTML report for run-id ${{ github.run_id }} (attempt: ${{ github.run_attempt }})"
while true; do
git pull --rebase
if [ $? -ne 0 ]; then
echo "Failed to rebase. Please review manually."
exit 1
fi
git push
if [ $? -eq 0 ]; then
echo "Successfully pushed HTML report to repo."
exit 0
fi
done
- name: DNS Wait
run: sleep 120
- name: GH Pages URL
run: |
echo "::notice title= Published Playwright Test Report::https://spectrocloud.github.io/librarium/$HTML_REPORT_URL_PATH"
- name: Post Report URL Comment
uses: mshick/add-pr-comment@v2
with:
message: |
📋 Visual Report for branch ${{ github.head_ref }} with CI run ${{ github.run_id }} and attempt ${{ github.run_attempt }} is ready at
https://spectrocloud.github.io/librarium/${{env.HTML_REPORT_URL_PATH}}
💡 You may have to wait for DNS to resolve or the GitHub Pages job to complete. You can view the progress of the GitHub Pages job [here](https://github.com/spectrocloud/librarium/actions/workflows/pages/pages-build-deployment).
message-failure: |
👎 Uh oh! Unable to publish Visual Report URL.
refresh-message-position: true
update-only: true