-
Notifications
You must be signed in to change notification settings - Fork 1
389 lines (389 loc) · 15.1 KB
/
unit-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
name: Unit Tests
on: [push]
jobs:
test-server:
name: Test GraphQL API Server
runs-on: ubuntu-latest
services:
postgres:
image: underbluewaters/seasketch_db_base
ports:
- "5432:5432"
env:
POSTGRES_PASSWORD: password
redis:
image: "redis:alpine"
ports:
- "6379:6379"
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v3
with:
node-version: "18.6"
cache: "npm"
- name: Install lerna
run: |
npm install
- name: Install dependencies
run: |
npx lerna bootstrap --ci
- name: Init docker db
working-directory: ./packages/api
env:
TEST_DB: postgres://postgres:password@localhost:5432/
run: |
node tests/init_dockerdb.js
- name: Run Tests
working-directory: ./packages/api
run: |
npx jest --ci --reporters=default --reporters=jest-junit
env:
TEST_DB: postgres://postgres:password@localhost:5432/
SES_EMAIL_SOURCE: [email protected]
- uses: IgnusG/[email protected]
if: always()
with:
access-token: ${{ secrets.GITHUB_TOKEN }}
working-directory: ./packages/api
check-name: API Test Output
run-name: Test GraphQL API Server
database-drift:
name: Check for schema and generated code drift
runs-on: ubuntu-latest
services:
postgres:
image: underbluewaters/seasketch_db_base
ports:
- "54321:5432"
env:
POSTGRES_PASSWORD: password
redis:
image: "redis:alpine"
ports:
- "6379:6379"
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v3
with:
node-version: "18.6"
cache: "npm"
- name: Install lerna
run: |
npm install
- name: Install dependencies
run: |
npx lerna bootstrap --ci
- name: Initialize database
working-directory: ./packages/api
env:
TEST_DB: postgres://postgres:password@localhost:54321/
DATABASE_URL: postgres://postgres:password@localhost:54321/seasketch
ADMIN_DATABASE_URL: postgres://postgres:password@localhost:54321/seasketch
AUTH0_CLIENT_ID: ${{ secrets.AUTH0_CLIENT_ID }}
AUTH0_CLIENT_SECRET: ${{ secrets.AUTH0_CLIENT_SECRET }}
AUTH0_DOMAIN: ${{ secrets.AUTH0_DOMAIN }}
GM_DBURL: postgres://postgres:password@localhost:54321/seasketch_shadow
MAPBOX_ACCESS_TOKEN: ${{ secrets.MAPBOX_ACCESS_TOKEN }}
run: |
node tests/init_dockerdb.js
IN_TESTS=1 npm run db:migrate -- --shadow
node dist/src/createCleanGraphqlSchema.js
- name: Check for graphql schema drift
working-directory: ./packages/api
run: |
ls -lh generated-schema*
npm run db:drift
- name: Check for drift in hooks
working-directory: ./packages/client
run: |
npx graphql-codegen --config codegen.yml
git diff --exit-code ./src/generated/graphql.ts
test-client:
name: Test React Client
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v3
with:
node-version: "18.6"
cache: "npm"
- name: Install lerna
run: |
npm install
- name: Install dependencies
run: |
npx lerna bootstrap --ci
- name: Test client
working-directory: ./packages/client
env:
SKIP_PREFLIGHT_CHECK: true
REACT_APP_GRAPHQL_ENDPOINT: http://localhost:3857/graphql
run: |
npm run test -- --ci --testResultsProcessor="jest-junit" --watchAll=false
- uses: IgnusG/[email protected]
if: always()
with:
access-token: ${{ secrets.GITHUB_TOKEN }}
working-directory: ./packages/client
check-name: React Client Test Output
run-name: Test React Client
build-client:
name: Build React Client
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v3
with:
node-version: "18.6"
cache: "npm"
- id: short_sha
run: |
echo `git rev-parse HEAD`
echo "::set-output name=sha::`git rev-parse --short HEAD`"
- name: Install lerna
run: |
npm install
- name: Install dependencies
run: |
npx lerna bootstrap --ci
- name: Build client
working-directory: ./packages/client
env:
SKIP_PREFLIGHT_CHECK: true
REACT_APP_AUTH0_CLIENT_ID: ${{ secrets.REACT_APP_AUTH0_CLIENT_ID }}
REACT_APP_AUTH0_DOMAIN: ${{ secrets.REACT_APP_AUTH0_DOMAIN }}
REACT_APP_AUTH0_SCOPE: ${{ secrets.REACT_APP_AUTH0_SCOPE }}
REACT_APP_AUTH0_AUDIENCE: ${{ secrets.REACT_APP_AUTH0_AUDIENCE }}
REACT_APP_MAPBOX_ACCESS_TOKEN: abc123
REACT_APP_GRAPHQL_ENDPOINT: https://example.com/graphql
REACT_APP_BUILD: ${{ steps.short_sha.outputs.sha }}
run: |
NODE_OPTIONS=--openssl-legacy-provider CI=false npm run build
# integration-tests:
# name: Cypress Integration Tests
# runs-on: ubuntu-latest
# timeout-minutes: 60
# # container: cypress/browsers:node16.5.0-chrome94-ff93
# services:
# postgres:
# image: underbluewaters/seasketch_db_base
# ports:
# - "5432:5432"
# env:
# POSTGRES_PASSWORD: password
# redis:
# image: "redis:alpine"
# ports:
# - "6379:6379"
# steps:
# - uses: actions/checkout@v2
# - uses: actions/setup-node@v2
# with:
# node-version: "18.6"
# - id: short_sha
# run: |
# echo `git rev-parse HEAD`
# echo "::set-output name=sha::`git rev-parse --short HEAD`"
# - name: Cache node modules
# uses: actions/cache@v2
# env:
# cache-name: cache-integration-node-modules
# with:
# # npm cache files are stored in `~/.npm` on Linux/macOS
# path: |
# node_modules
# */*/node_modules
# ~/.npm
# ~/.cache/Cypress
# key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
# restore-keys: |
# ${{ runner.os }}-build-${{ env.cache-name }}-
# ${{ runner.os }}-build-
# ${{ runner.os }}-
# - name: Install
# run: |
# npm install
# npm install -g lerna
# npm install serve -g
# lerna bootstrap
# - name: Init docker db
# working-directory: ./packages/api
# env:
# TEST_DB: postgres://postgres:password@localhost:5432/
# DATABASE_URL: postgres://postgres:password@localhost:5432/seasketch
# run: |
# node tests/init_dockerdb.js
# npm run db:migrate
# - name: Start API Server
# working-directory: ./packages/api
# env:
# DATABASE_URL: postgres://graphile:password@localhost:5432/seasketch
# ADMIN_DATABASE_URL: postgres://postgres:password@localhost:5432/seasketch
# AUTH0_CLIENT_ID: ${{ secrets.AUTH0_CLIENT_ID }}
# AUTH0_CLIENT_SECRET: ${{ secrets.AUTH0_CLIENT_SECRET }}
# AUTH0_DOMAIN: ${{ secrets.AUTH0_DOMAIN }}
# JWKS_URI: ${{ secrets.JWKS_URI }}
# JWT_AUD: ${{ secrets.JWT_AUD }}
# JWT_ISS: ${{ secrets.JWT_ISS }}
# PUBLIC_S3_BUCKET: ${{ secrets.PUBLIC_S3_BUCKET }}
# PUBLIC_UPLOADS_DOMAIN: ${{ secrets.PUBLIC_UPLOADS_DOMAIN }}
# S3_REGION: ${{ secrets.S3_REGION }}
# SES_EMAIL_SOURCE: ${{ secrets.SES_EMAIL_SOURCE }}
# UNSPLASH_KEY: ${{ secrets.UNSPLASH_KEY }}
# NODE_ENV: staging
# GRAPHILE_WORKER_CONCURRENCY: 5
# AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
# AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
# IS_CYPRESS_TEST_ENV: "true"
# run: |
# npm run build
# npm start &
# - name: Start client
# working-directory: ./packages/client
# run: |
# NODE_OPTIONS=--openssl-legacy-provider CI=false npm run build
# serve -s build &
# env:
# SKIP_PREFLIGHT_CHECK: true
# REACT_APP_AUTH0_CLIENT_ID: ${{ secrets.REACT_APP_AUTH0_CLIENT_ID }}
# REACT_APP_AUTH0_DOMAIN: ${{ secrets.REACT_APP_AUTH0_DOMAIN }}
# REACT_APP_AUTH0_SCOPE: ${{ secrets.REACT_APP_AUTH0_SCOPE }}
# REACT_APP_AUTH0_AUDIENCE: ${{ secrets.REACT_APP_AUTH0_AUDIENCE }}
# REACT_APP_MAPBOX_ACCESS_TOKEN: ${{ secrets.REACT_APP_MAPBOX_ACCESS_TOKEN }}
# REACT_APP_GRAPHQL_ENDPOINT: http://localhost:3857/graphql
# CYPRESS_BASE_URL: http://localhost:3000
# REACT_APP_BUILD: e2e-tests-${{ steps.short_sha.outputs.sha }}
# - name: Cypress run
# uses: cypress-io/github-action@v2
# with:
# record: true
# browser: chrome
# wait-on: "http://localhost:3000"
# install-command: "true"
# working-directory: ./packages/client
# wait-on-timeout: 240
# config: baseUrl=http://localhost:3000
# env:
# CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORDING_KEY }}
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# CYPRESS_AUTH0_CLIENT_SECRET: ${{ secrets.CYPRESS_AUTH0_CLIENT_SECRET }}
# REACT_APP_AUTH0_CLIENT_ID: ${{ secrets.REACT_APP_AUTH0_CLIENT_ID }}
# REACT_APP_AUTH0_DOMAIN: ${{ secrets.REACT_APP_AUTH0_DOMAIN }}
# REACT_APP_AUTH0_SCOPE: ${{ secrets.REACT_APP_AUTH0_SCOPE }}
# REACT_APP_AUTH0_AUDIENCE: ${{ secrets.REACT_APP_AUTH0_AUDIENCE }}
# REACT_APP_GRAPHQL_ENDPOINT: http://localhost:3857/graphql
# CYPRESS_TEST_DB: postgres://postgres:password@localhost:5432/seasketch
# AUTH0_MANAGEMENT_API_CLIENT_ID: ${{ secrets.AUTH0_MANAGEMENT_API_CLIENT_ID }}
# AUTH0_MANAGEMENT_API_CLIENT_SECRET: ${{ secrets.AUTH0_MANAGEMENT_API_CLIENT_SECRET }}
# percy-visual-tests:
# name: Percy Visual Testing
# runs-on: ubuntu-latest
# timeout-minutes: 60
# # container: cypress/browsers:node16.5.0-chrome94-ff93
# services:
# postgres:
# image: underbluewaters/seasketch_db_base
# ports:
# - "5432:5432"
# env:
# POSTGRES_PASSWORD: password
# redis:
# image: "redis:alpine"
# ports:
# - "6379:6379"
# steps:
# - uses: actions/checkout@v2
# - uses: actions/setup-node@v2
# with:
# node-version: "18.6"
# - id: short_sha
# run: |
# echo `git rev-parse HEAD`
# echo "::set-output name=sha::`git rev-parse --short HEAD`"
# - name: Cache node modules
# uses: actions/cache@v2
# env:
# cache-name: cache-integration-node-modules
# with:
# # npm cache files are stored in `~/.npm` on Linux/macOS
# path: |
# node_modules
# */*/node_modules
# ~/.npm
# ~/.cache/Cypress
# key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
# restore-keys: |
# ${{ runner.os }}-build-${{ env.cache-name }}-
# ${{ runner.os }}-build-
# ${{ runner.os }}-
# - name: Install
# run: |
# npm install
# npm install -g lerna
# npm install serve -g
# lerna bootstrap
# - name: Init docker db
# working-directory: ./packages/api
# env:
# TEST_DB: postgres://postgres:password@localhost:5432/
# DATABASE_URL: postgres://postgres:password@localhost:5432/seasketch
# run: |
# node tests/init_dockerdb.js
# npm run db:migrate
# - name: Start API Server
# working-directory: ./packages/api
# env:
# DATABASE_URL: postgres://graphile:password@localhost:5432/seasketch
# ADMIN_DATABASE_URL: postgres://postgres:password@localhost:5432/seasketch
# AUTH0_CLIENT_ID: ${{ secrets.AUTH0_CLIENT_ID }}
# AUTH0_CLIENT_SECRET: ${{ secrets.AUTH0_CLIENT_SECRET }}
# AUTH0_DOMAIN: ${{ secrets.AUTH0_DOMAIN }}
# HOST: ${{ secrets.HOST }}
# JWKS_URI: ${{ secrets.JWKS_URI }}
# JWT_AUD: ${{ secrets.JWT_AUD }}
# JWT_ISS: ${{ secrets.JWT_ISS }}
# PUBLIC_S3_BUCKET: ${{ secrets.PUBLIC_S3_BUCKET }}
# PUBLIC_UPLOADS_DOMAIN: ${{ secrets.PUBLIC_UPLOADS_DOMAIN }}
# S3_REGION: ${{ secrets.S3_REGION }}
# SES_EMAIL_SOURCE: ${{ secrets.SES_EMAIL_SOURCE }}
# UNSPLASH_KEY: ${{ secrets.UNSPLASH_KEY }}
# NODE_ENV: staging
# GRAPHILE_WORKER_CONCURRENCY: 5
# AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
# AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
# IS_CYPRESS_TEST_ENV: "true"
# run: |
# npm run build
# npm start &
# - name: Start client
# working-directory: ./packages/client
# run: |
# NODE_OPTIONS=--openssl-legacy-provider CI=false npm run build
# serve -s build &
# env:
# SKIP_PREFLIGHT_CHECK: true
# REACT_APP_AUTH0_CLIENT_ID: ${{ secrets.REACT_APP_AUTH0_CLIENT_ID }}
# REACT_APP_AUTH0_DOMAIN: ${{ secrets.REACT_APP_AUTH0_DOMAIN }}
# REACT_APP_AUTH0_SCOPE: ${{ secrets.REACT_APP_AUTH0_SCOPE }}
# REACT_APP_AUTH0_AUDIENCE: ${{ secrets.REACT_APP_AUTH0_AUDIENCE }}
# REACT_APP_MAPBOX_ACCESS_TOKEN: ${{ secrets.REACT_APP_MAPBOX_ACCESS_TOKEN }}
# REACT_APP_GRAPHQL_ENDPOINT: http://localhost:3857/graphql
# CYPRESS_BASE_URL: http://localhost:3000
# REACT_APP_BUILD: e2e-tests-${{ steps.short_sha.outputs.sha }}
# - name: Percy/Cypress Run
# working-directory: ./packages/client
# run: npx @percy/cli exec -- cypress run --record false
# env:
# CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORDING_KEY }}
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# CYPRESS_AUTH0_CLIENT_SECRET: ${{ secrets.CYPRESS_AUTH0_CLIENT_SECRET }}
# REACT_APP_AUTH0_CLIENT_ID: ${{ secrets.REACT_APP_AUTH0_CLIENT_ID }}
# REACT_APP_AUTH0_DOMAIN: ${{ secrets.REACT_APP_AUTH0_DOMAIN }}
# REACT_APP_AUTH0_SCOPE: ${{ secrets.REACT_APP_AUTH0_SCOPE }}
# REACT_APP_AUTH0_AUDIENCE: ${{ secrets.REACT_APP_AUTH0_AUDIENCE }}
# REACT_APP_GRAPHQL_ENDPOINT: http://localhost:3857/graphql
# CYPRESS_TEST_DB: postgres://postgres:password@localhost:5432/seasketch
# PERCY_TOKEN: ${{ secrets.PERCY_TOKEN }}
# ACTIONS_ALLOW_UNSECURE_COMMANDS: true
# AUTH0_MANAGEMENT_API_CLIENT_ID: ${{ secrets.AUTH0_MANAGEMENT_API_CLIENT_ID }}
# AUTH0_MANAGEMENT_API_CLIENT_SECRET: ${{ secrets.AUTH0_MANAGEMENT_API_CLIENT_SECRET }}