-
Notifications
You must be signed in to change notification settings - Fork 1.1k
405 lines (369 loc) · 12.6 KB
/
tests.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
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
name: CI
on:
push:
branches:
- master
pull_request:
jobs:
should_run_tests:
name: Should run tests
runs-on: ubuntu-latest
outputs:
shouldRunTests: ${{ env.SHOULD_RUN_TESTS }}
steps:
- uses: dorny/paths-filter@v2
id: filter
if: github.event_name == 'pull_request'
with:
filters: |
shouldRunTests:
- '!{{design-system}/**,**/*.md}'
- run: echo "SHOULD_RUN_TESTS=$SHOULD_RUN" >> $GITHUB_ENV
if: github.event_name == 'pull_request'
env:
SHOULD_RUN: ${{ steps.filter.outputs.shouldRunTests }}
- run: echo "SHOULD_RUN_TESTS=true" >> $GITHUB_ENV
if: github.event_name != 'pull_request'
cypress:
name: Cypress tests
needs: should_run_tests
runs-on: ubuntu-latest
services:
postgres:
image: postgres:12
env:
POSTGRES_USER: keystone5
POSTGRES_PASSWORD: k3yst0n3
POSTGRES_DB: test_db
ports:
- 5432:5432
env:
DATABASE_URL: 'postgres://keystone5:k3yst0n3@localhost:5432/test_db'
CLOUDINARY_CLOUD_NAME: $CLOUDINARY_CLOUD_NAME
CLOUDINARY_KEY: $CLOUDINARY_KEY
CLOUDINARY_SECRET: $CLOUDINARY_SECRET
PORT: 3000
strategy:
fail-fast: false
matrix:
project:
- docs
steps:
- name: Checkout Repo
if: needs.should_run_tests.outputs.shouldRunTests == 'true'
uses: actions/checkout@v2
- name: Setup Node.js 14.x
uses: actions/setup-node@main
if: needs.should_run_tests.outputs.shouldRunTests == 'true'
with:
node-version: 14.x
- name: Get yarn cache directory path
id: yarn-cache-dir-path
if: needs.should_run_tests.outputs.shouldRunTests == 'true'
run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache@v2
id: yarn-cache
if: needs.should_run_tests.outputs.shouldRunTests == 'true'
with:
path: |
${{ steps.yarn-cache-dir-path.outputs.dir }}
node_modules
key: ${{ runner.os }}-yarn-v4-${{ hashFiles('yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-v4-
- name: Install Dependencies
run: yarn
if: needs.should_run_tests.outputs.shouldRunTests == 'true'
- run: yarn --cwd ${{ matrix.project }} cypress install
if: needs.should_run_tests.outputs.shouldRunTests == 'true'
- run: yarn --cwd ${{ matrix.project }} cypress:run:ci
if: needs.should_run_tests.outputs.shouldRunTests == 'true'
- uses: actions/upload-artifact@v2
if: failure()
with:
name: cypress-screenshots
path: cypress/screenshots
- uses: actions/upload-artifact@v2
if: failure()
with:
name: cypress-videos
path: cypress/videos
graphql-api-tests:
name: API Tests
needs: should_run_tests
runs-on: ubuntu-latest
services:
postgres:
image: postgres:12
env:
POSTGRES_USER: keystone5
POSTGRES_PASSWORD: k3yst0n3
POSTGRES_DB: test_db
ports:
- 5432:5432
mongodb:
image: mongo
env:
MONGO_INITDB_ROOT_USERNAME: keystone5
MONGO_INITDB_ROOT_PASSWORD: k3yst0n3
ports:
- 27017:27017
strategy:
fail-fast: false
matrix:
index: [0, 1, 2, 3, 4, 5, 6, 7, 8]
adapter: ['postgresql', 'sqlite', 'mongodb']
steps:
- name: Checkout Repo
uses: actions/checkout@v2
if: needs.should_run_tests.outputs.shouldRunTests == 'true'
- name: Setup Node.js 14.x
uses: actions/setup-node@main
if: needs.should_run_tests.outputs.shouldRunTests == 'true'
with:
node-version: 14.x
- name: Get yarn cache directory path
if: needs.should_run_tests.outputs.shouldRunTests == 'true'
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache@v2
id: yarn-cache
if: needs.should_run_tests.outputs.shouldRunTests == 'true'
with:
path: |
${{ steps.yarn-cache-dir-path.outputs.dir }}
node_modules
key: ${{ runner.os }}-yarn-v4-${{ hashFiles('yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-v4-
- name: Install Dependencies
run: yarn
if: needs.should_run_tests.outputs.shouldRunTests == 'true'
- name: Unit tests
if: needs.should_run_tests.outputs.shouldRunTests == 'true'
run: yarn jest --ci --runInBand api-tests
env:
CLOUDINARY_CLOUD_NAME: ${{ secrets.CLOUDINARY_CLOUD_NAME }}
CLOUDINARY_KEY: ${{ secrets.CLOUDINARY_KEY }}
CLOUDINARY_SECRET: ${{ secrets.CLOUDINARY_SECRET }}
CI_NODE_TOTAL: 9
CI_NODE_INDEX: ${{ matrix.index }}
TEST_ADAPTER: ${{ matrix.adapter }}
DATABASE_URL: ${{ matrix.adapter == 'sqlite' && 'file:./dev.db' || matrix.adapter == 'postgresql' && 'postgres://keystone5:k3yst0n3@localhost:5432/test_db' || 'mongodb://keystone5:k3yst0n3@localhost:27017/test_db' }}
non-api-tests:
name: Package Unit Tests
needs: should_run_tests
runs-on: ubuntu-latest
services:
postgres:
image: postgres:12
env:
POSTGRES_USER: keystone5
POSTGRES_PASSWORD: k3yst0n3
POSTGRES_DB: test_db
ports:
- 5432:5432
env:
DATABASE_URL: 'postgres://keystone5:k3yst0n3@localhost:5432/test_db'
strategy:
fail-fast: false
steps:
- name: Checkout Repo
uses: actions/checkout@v2
- name: Setup Node.js 14.x
uses: actions/setup-node@main
with:
node-version: 14.x
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache@v2
id: yarn-cache
with:
path: |
${{ steps.yarn-cache-dir-path.outputs.dir }}
node_modules
key: ${{ runner.os }}-yarn-v4-${{ hashFiles('yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-v4-
- name: Install Dependencies
run: yarn
- name: Unit tests
run: yarn jest --ci --runInBand --testPathIgnorePatterns=admin-ui-tests --testPathIgnorePatterns=api-tests --testPathIgnorePatterns=examples-smoke-tests --testPathIgnorePatterns=examples/testing
env:
CLOUDINARY_CLOUD_NAME: ${{ secrets.CLOUDINARY_CLOUD_NAME }}
CLOUDINARY_KEY: ${{ secrets.CLOUDINARY_KEY }}
CLOUDINARY_SECRET: ${{ secrets.CLOUDINARY_SECRET }}
example-testing:
name: Testing example project
needs: should_run_tests
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
- name: Checkout Repo
uses: actions/checkout@v2
- name: Setup Node.js 14.x
uses: actions/setup-node@main
with:
node-version: 14.x
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache@v2
id: yarn-cache
with:
path: |
${{ steps.yarn-cache-dir-path.outputs.dir }}
node_modules
key: ${{ runner.os }}-yarn-v4-${{ hashFiles('yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-v4-
- name: Install Dependencies
run: yarn
- name: Unit tests
run: cd examples/testing; yarn test
examples_smoke_tests:
name: Smoke Tests For Examples
runs-on: ubuntu-latest
needs: should_run_tests
env:
DATABASE_URL: 'file:./test.db'
strategy:
matrix:
test:
[
'auth.test.ts',
'basic.test.ts',
'blog.test.ts',
'document-field.test.ts',
'default-values.test.ts',
'extend-graphql-schema.test.ts',
'json.test.ts',
'roles.test.ts',
'task-manager.test.ts',
'testing.test.ts',
'with-auth.test.ts',
'custom-field-view.test.ts',
'custom-field.test.ts',
'custom-admin-ui-pages.test.ts',
'custom-admin-ui-logo.test.ts',
'custom-admin-ui-navigation.test.ts',
]
fail-fast: false
steps:
- name: Checkout Repo
if: needs.should_run_tests.outputs.shouldRunTests == 'true'
uses: actions/checkout@v2
- name: Setup Node.js 14.x
if: needs.should_run_tests.outputs.shouldRunTests == 'true'
uses: actions/setup-node@main
with:
node-version: 14.x
- name: Get yarn cache directory path
if: needs.should_run_tests.outputs.shouldRunTests == 'true'
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache@v2
if: needs.should_run_tests.outputs.shouldRunTests == 'true'
id: yarn-cache
with:
path: |
${{ steps.yarn-cache-dir-path.outputs.dir }}
node_modules
key: ${{ runner.os }}-yarn-v4-${{ hashFiles('yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-v4-
- name: Install Dependencies
if: needs.should_run_tests.outputs.shouldRunTests == 'true'
run: yarn
- name: Install Dependencies of Browsers
if: needs.should_run_tests.outputs.shouldRunTests == 'true'
uses: microsoft/playwright-github-action@v1
- name: Install Browsers for Playwright
if: needs.should_run_tests.outputs.shouldRunTests == 'true'
run: node ./node_modules/playwright/install.js
- name: Unit tests
if: needs.should_run_tests.outputs.shouldRunTests == 'true'
run: yarn jest --ci --runInBand tests/examples-smoke-tests/${{ matrix.test }}
admin_ui_integration_tests:
name: Integration tests for Admin UI
runs-on: ubuntu-latest
needs: should_run_tests
env:
DATABASE_URL: 'file:./test.db'
strategy:
matrix:
test: ['init.test.ts']
fail-fast: false
steps:
- name: Checkout Repo
if: needs.should_run_tests.outputs.shouldRunTests == 'true'
uses: actions/checkout@v2
- name: Setup Node.js 14.x
if: needs.should_run_tests.outputs.shouldRunTests == 'true'
uses: actions/setup-node@main
with:
node-version: 14.x
- name: Get yarn cache directory path
if: needs.should_run_tests.outputs.shouldRunTests == 'true'
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache@v2
if: needs.should_run_tests.outputs.shouldRunTests == 'true'
id: yarn-cache
with:
path: |
${{ steps.yarn-cache-dir-path.outputs.dir }}
node_modules
key: ${{ runner.os }}-yarn-v4-${{ hashFiles('yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-v4-
- name: Install Dependencies
if: needs.should_run_tests.outputs.shouldRunTests == 'true'
run: yarn
- name: Install Dependencies of Browsers
if: needs.should_run_tests.outputs.shouldRunTests == 'true'
uses: microsoft/playwright-github-action@v1
- name: Install Browsers for Playwright
if: needs.should_run_tests.outputs.shouldRunTests == 'true'
run: node ./node_modules/playwright/install.js
- name: Unit tests
if: needs.should_run_tests.outputs.shouldRunTests == 'true'
run: yarn jest --ci --runInBand tests/admin-ui-tests/${{ matrix.test }}
linting:
name: Linting
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v2
- name: Setup Node.js 14.x
uses: actions/setup-node@main
with:
node-version: 14.x
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache@v2
id: yarn-cache
with:
path: |
${{ steps.yarn-cache-dir-path.outputs.dir }}
node_modules
key: ${{ runner.os }}-yarn-v4-${{ hashFiles('yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-v4-
- name: Install Dependencies
run: yarn
- name: Prettier
run: yarn lint:prettier
- name: TypeScript
run: yarn lint:types
- name: ESLint
run: yarn lint:eslint
- name: Preconstruct
run: yarn build
- name: Remark
run: yarn lint:markdown
- name: Example schemas
run: yarn lint:examples