This repository has been archived by the owner on Feb 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 63
282 lines (216 loc) · 8.75 KB
/
ci.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
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
name: CI
on:
push:
branches:
- main
pull_request:
# Cancels all previous workflow runs for pull requests that have not completed.
concurrency:
# The concurrency group contains the workflow name and the branch name for pull requests
# or the commit hash for any other events.
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}
cancel-in-progress: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
types:
name: Check types
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/setup-node-env
- name: Check types
run: pnpm types
lint:
name: Lint files
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/setup-node-env
- name: Lint with ESLint and Prettier
run: pnpm pc:lint
unit:
name: Unit tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/setup-node-env
- name: Run unit tests
run: pnpm test:unit
clean-playwright-failure-comment:
name: Remove previous Playwright test failure comments
runs-on: ubuntu-latest
if: github.ref != 'refs/heads/main'
steps:
- uses: peter-evans/find-comment@v2
id: test-results-comment
with:
issue-number: ${{ github.event.pull_request.number }}
body-includes: Playwright Failure Test Results
- uses: actions/github-script@v6
if: steps.test-results-comment.outputs.comment-id != 0
with:
script: |
await github.rest.issues.deleteComment({
repo: context.repo.repo,
owner: context.repo.owner,
comment_id: ${{ steps.test-results-comment.outputs.comment-id }}
})
console.log('Deleted comment with ID ${{ steps.test-results-comment.outputs.comment-id }}')
nuxt-playwright-e2e:
name: Nuxt Playwright e2e tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/setup-node-env
- name: Run Nuxt Playwright e2e tests
run: pnpm test:playwright e2e --workers=2
- uses: actions/upload-artifact@v3
if: failure()
with:
name: nuxt-e2e-test-results
path: test-results
nuxt-playwright-vr:
name: Nuxt Playwright VR tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/setup-node-env
- name: Run Nuxt Playwright visual regression tests
run: pnpm test:playwright visual-regression --workers=2
- uses: actions/upload-artifact@v3
if: failure()
with:
name: nuxt-vr-test-results
path: test-results
storybook-playwright:
name: Storybook Playwright tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/setup-node-env
- name: Run Storybook Playwright tests
run: pnpm test:storybook
- uses: actions/upload-artifact@v3
if: failure()
id: test-results
with:
name: storybook-test-results
path: test-results
playwright-test-failure-comment:
name: Share Playwright test debugging instructions
runs-on: ubuntu-latest
if: always() && github.ref != 'refs/heads/main' && (needs.nuxt-playwright-vr.result == 'failure' || needs.nuxt-playwright-e2e.result == 'failure' ||needs.storybook-playwright.result == 'failure')
needs:
- nuxt-playwright-e2e
- nuxt-playwright-vr
- storybook-playwright
steps:
- uses: peter-evans/create-or-update-comment@v2
with:
issue-number: ${{ github.event.pull_request.number }}
body: |
**Playwright Failure Test Results**
It looks like some of the Playwright tests failed. You can download the Playwright trace
output for both Storybook and Nuxt Playwright tests that have failed at the bottom of this
page, under the "Artifacts" section:
<https://github.com/WordPress/openverse-frontend/actions/runs/${{ github.run_id }}>
Read more about how to use this artifact here: <https://github.com/WordPress/openverse-frontend/blob/main/test/playwright/README.md#debugging>
storybook:
name: Check Storybook build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/setup-node-env
- name: Run Storybook smoke-test
run: pnpm storybook:smoke
build:
name: Check Nuxt build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/setup-node-env
- name: Run build
run: pnpm build
gh-pages:
name: PR Storybook and Tailwind Preview
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.owner.login == 'WordPress'
runs-on: ubuntu-latest
steps:
- uses: peter-evans/find-comment@v2
id: preview-comment
with:
issue-number: ${{ github.event.pull_request.number }}
body-includes: Storybook and Tailwind configuration previews
- uses: peter-evans/create-or-update-comment@v2
if: steps.preview-comment.outputs.comment-id != 0
with:
comment-id: ${{ steps.preview-comment.outputs.comment-id }}
edit-mode: replace
body: |
**Storybook and Tailwind configuration previews**: _Updating_
(This comment will be automatically updated with the preview URLs once they are ready)
- uses: peter-evans/create-or-update-comment@v2
if: steps.preview-comment.outputs.comment-id == 0
with:
issue-number: ${{ github.event.pull_request.number }}
body: |
**Storybook and Tailwind configuration previews**: _Updating_
(This comment will be automatically updated with the preview URLs once they are ready)
- name: Checkout
uses: actions/checkout@v3
- uses: ./.github/actions/setup-node-env
- name: Fetch translation files
run: pnpm i18n
- name: Build Storybook
run: pnpm storybook:build
- name: Build Tailwind Config Viewer
run: pnpm tcv:build
# This makes the TCV available at the `/tailwind` directory in the gh-pages
- name: Merge TCV and Storybook builds
run: |
mv .tcv-export ./storybook-static/tailwind
mv ./storybook-static /tmp/preview
# Otherwise we end up with `node_modules` and other things only necessary for building
# but not necessary for deploying the `gh-pages` branch
- name: Recreate working directory to avoid superfluous files
run: |
cd ..
rm -rf openverse-frontend
mkdir openverse-frontend
- uses: actions/checkout@v3
with:
ref: gh-pages
- name: Merge preview with existing gh-pages
run: |
cd ..
cp -r ./openverse-frontend /tmp/gh-pages
# trash the existing preview folder and replace it with the newly generated one
# if the preview hasn't been pushed yet this will still exit(0)
rm -rf /tmp/gh-pages/_preview/${{ github.event.pull_request.number }}
mv /tmp/preview /tmp/gh-pages/_preview/${{ github.event.pull_request.number }}
cd openverse-frontend
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: /tmp/gh-pages
force_orphan: true
- uses: peter-evans/find-comment@v2
id: final-preview-comment
with:
issue-number: ${{ github.event.pull_request.number }}
body-includes: Storybook and Tailwind configuration previews
- uses: peter-evans/create-or-update-comment@v2
with:
comment-id: ${{ steps.final-preview-comment.outputs.comment-id }}
edit-mode: replace
body: |
**Storybook and Tailwind configuration previews**: _Ready_
**Storybook:** <https://wordpress.github.io/openverse-frontend/_preview/${{ github.event.pull_request.number }}>
**Tailwind:** <https://wordpress.github.io/openverse-frontend/_preview/${{ github.event.pull_request.number }}/tailwind>
Please note that GitHub pages takes a little time to deploy newly pushed code, if the links above don't work or you see old versions, wait 5 minutes and try again.
You can check [the GitHub pages deployment action list](https://github.com/WordPress/openverse-frontend/actions/workflows/pages/pages-build-deployment) to see the current status of the deployments.
- name: Checkout branch again to enable cleaning
uses: actions/checkout@v3
if: always()