-
Notifications
You must be signed in to change notification settings - Fork 25
240 lines (203 loc) · 6.97 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
name: ci
on: [push]
jobs:
install:
runs-on: ubuntu-20.04
steps:
# https://github.com/actions/checkout
- name: Checkout 🛎️
uses: actions/checkout@v4
with:
# check out all commits to get accurate created date
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: 20
- name: Print Node version 🖨️
run: node -v
# only install dependencies using
# https://github.com/cypress-io/github-action
# will restore / create folders
# ~/.npm
# ~/.cache/Cypress
- name: Install 📦
uses: cypress-io/github-action@v6
with:
runTests: false
- name: Set Cypress version 🎁
id: cypress
run: echo "version=$(node ./src/print-cypress-version)" >> $GITHUB_OUTPUT
- name: Print Cypress version 🖨
run: echo "Cypress version is ${{ steps.cypress.outputs.version }}"
# will create folder ./public
- name: Build site 🏗
run: npm run docs:build
# will create new JS files inside ./docs
- name: Export Markdown specs 🖨
run: node ./md-to-js http://localhost:5000/cypress-examples/
- name: Catch stray .only tests 🚦
run: npm run stop-only
# we do not want to run all specs together
# since I believe it to be a really bad practice
# only pass the local folders we built / updated
# ./docs and ./public
# TIP: we want to avoid uploading node_modules since it is SLOW
# https://glebbahmutov.com/blog/parallel-cypress-tests-gh-action/
- name: Save built folders 🆙
uses: actions/upload-artifact@v4
with:
name: built
path: |
docs
public
test-link:
runs-on: ubuntu-20.04
needs: install
steps:
- name: Checkout 🛎️
uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- name: Print Node version 🖨️
run: node -v
- name: Download built folders ⏬
uses: actions/download-artifact@v4
with:
name: built
- name: Install 📦
uses: cypress-io/github-action@v6
with:
runTests: false
- name: Check just the room md 🦷
run: npx markdown-link-check --config ./links-check-config.json --verbose ./docs/index.md
- name: Check links ⚓️
run: npm run check:links
test-markdown:
runs-on: ubuntu-20.04
needs: install
strategy:
# when one test fails, DO NOT cancel the other
# containers, because this will kill Cypress processes
# leaving the Dashboard hanging ...
# https://github.com/cypress-io/github-action/issues/48
fail-fast: false
matrix:
# run N copies of the current job in parallel
containers: [1, 2, 3, 4, 5, 6, 7]
steps:
# https://github.com/actions/checkout
- name: Checkout 🛎️
uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- name: Print Node version 🖨️
run: node -v
- name: Download built folders ⏬
uses: actions/download-artifact@v4
with:
name: built
# download cached ~/.npm and ~/.cache/Cypress
# and install node_modules
- name: Cypress tests 🧪
uses: cypress-io/github-action@v6
# run all tests straight from Markdown files
# using Cypress GH action
# https://github.com/cypress-io/github-action
with:
record: true
parallel: true
group: 1. Markdown
tag: markdown
env:
CYPRESS_RECORD_KEY: ${{ secrets.recordKey }}
# pass GitHub token to allow accurately detecting a build vs a re-run build
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: See any changed files 👀
run: git status
# if there are any updated PNG images, commit and push them
- name: Commit any changed images 💾
# https://github.com/stefanzweifel/git-auto-commit-action
uses: stefanzweifel/git-auto-commit-action@v5
# only perform it for the master branch
if: github.ref == 'refs/heads/master'
with:
commit_message: Updated screenshots
branch: master
file_pattern: '*.png'
test-js:
runs-on: ubuntu-20.04
# temporarily skip testing JavaScript
# https://github.com/bahmutov/cypress-examples/issues/137
if: ${{ false }}
needs: deploy
strategy:
# when one test fails, DO NOT cancel the other
# containers, because this will kill Cypress processes
# leaving the Dashboard hanging ...
# https://github.com/cypress-io/github-action/issues/48
fail-fast: false
matrix:
# run 4 copies of the current job in parallel
containers: [1, 2, 3, 4]
steps:
# https://github.com/actions/checkout
- name: Checkout 🛎️
uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- name: Print Node version 🖨️
run: node -v
- name: Download built folders ⏬
uses: actions/download-artifact@v4
with:
name: built
- name: Test built site 🧪
uses: cypress-io/github-action@v6
with:
start: npm run serve
config-file: cypress-dist.config.js
record: true
parallel: true
# use a custom CI build id to put the JavaScript spec results into a separate run
ci-build-id: '${{ github.sha }}-${{ github.workflow }}-javascript'
group: 2. JavaScript specs
tag: javascript
env:
CYPRESS_RECORD_KEY: ${{ secrets.recordKey }}
# pass GitHub token to allow accurately detecting a build vs a re-run build
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
deploy:
runs-on: ubuntu-20.04
# do not depend on testing the links
# since some external sites are not always available
needs: [install, test-markdown]
# only deploy from the master branch
if: github.ref == 'refs/heads/master'
steps:
- name: Checkout 🛎️
uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- name: Print Node version 🖨️
run: node -v
- name: Download built folders ⏬
uses: actions/download-artifact@v4
with:
name: built
- name: Install 📦
uses: cypress-io/github-action@v6
with:
runTests: false
- name: Set Cypress version 🎁
id: cypress
run: echo "version=$(node ./src/print-cypress-version)" >> $GITHUB_OUTPUT
# https://github.com/marketplace/actions/github-pages-action
- name: Deploy 🚀
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./public/cypress-examples