This repository has been archived by the owner on Aug 14, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
534 lines (515 loc) · 18.5 KB
/
node.js.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
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
name: Node.js CI
on:
push:
paths-ignore:
- "**/*.md"
pull_request_target:
paths-ignore:
- "**/*.md"
jobs:
build:
runs-on: ubuntu-20.04
container:
image: "corejam/ci:node14.0.0.2"
if: (github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository) && !contains(github.event.head_commit.message, 'Merge master into next')
steps:
- name: Cancel Previous Run preventing duplicate pipelines
uses: styfle/cancel-workflow-action@0.6.0
with:
access_token: ${{ github.token }}
- name: Get PR git sha
id: gitRef
run: |
if [ "${{ github.event_name }}" == 'pull_request_target' ]; then
echo "::set-output name=sha::${{ github.event.pull_request.head.sha }}"
else
echo "::set-output name=sha::${{ github.sha }}"
fi
- name: Checkout code
uses: actions/checkout@v2
with:
ref: ${{ steps.gitRef.outputs.sha }}
- name: Cache node_modules
id: cache-node-modules
uses: actions/cache@v2
with:
path: node_modules
key: ${{ runner.os }}-${{ matrix.node-version }}-nodemodules-${{ hashFiles('**/yarn.lock') }}
- run: |
rm -rf node_modules/@corejam node_modules/.bin/corejam
yarn --frozen-lockfile
yarn lint
yarn build
yarn bs
node ./utils/hoistPackagesForDeployment.js
env: # Or as an environment variable
GITHUB_SHA: ${{ github.sha }}
- run: tar -czf artifact.tar node_modules packages examples/nextjs
- uses: actions/upload-artifact@v2
with:
name: dist
path: artifact.tar
core-components-test:
runs-on: ubuntu-20.04
container:
image: "corejam/ci:node14.0.0.2"
needs: build
steps:
- name: Get PR git sha
id: gitRef
run: |
if [ "${{ github.event_name }}" == 'pull_request_target' ]; then
echo "::set-output name=sha::${{ github.event.pull_request.head.sha }}"
else
echo "::set-output name=sha::${{ github.sha }}"
fi
- name: Checkout code
uses: actions/checkout@v2
with:
ref: ${{ steps.gitRef.outputs.sha }}
- uses: actions/download-artifact@v2
with:
name: dist
- run: tar -xzf artifact.tar
- run: chmod +x node_modules/.bin/corejam
- run: |
cd packages/core-components/
yarn test
- uses: codecov/codecov-action@v1
with:
directory: packages # optional
integration-tests:
runs-on: ubuntu-20.04
container:
image: "corejam/ci:node14.0.0.2"
needs: build
steps:
- name: Get PR git sha
id: gitRef
run: |
if [ "${{ github.event_name }}" == 'pull_request_target' ]; then
echo "::set-output name=sha::${{ github.event.pull_request.head.sha }}"
else
echo "::set-output name=sha::${{ github.sha }}"
fi
- name: Checkout code
uses: actions/checkout@v2
with:
ref: ${{ steps.gitRef.outputs.sha }}
- uses: actions/download-artifact@v2
with:
name: dist
- run: tar -xzf artifact.tar
- run: chmod +x node_modules/.bin/corejam
- run: cd packages/base && yarn corejam init && yarn test
- run: cd packages/notify && yarn corejam init && yarn test
- run: |
cd packages/auth && yarn corejam generateSchema
yarn test
export SECRET=$(COMMIT_ID=auth_$GITHUB_SHA node ./tests/bootstrap.js | grep 'secret'|cut -f2 -d ":")
SECRET_KEY=$SECRET DB_DRIVER=DB_FAUNA yarn test
env: # Or as an environment variable
SECRET_KEY: ${{ secrets.SECRET }}
GITHUB_SHA: ${{ github.sha }}
- run: |
cd packages/dershop && yarn corejam generateSchema
yarn test
export SECRET_SHOP=$(COMMIT_ID=dershop_$GITHUB_SHA node ./tests/bootstrap.js | grep 'secret'|cut -f2 -d ":")
SECRET_KEY=$SECRET_SHOP DB_DRIVER=DB_FAUNA yarn test
env: # Or as an environment variable
SECRET_KEY: ${{ secrets.SECRET }}
GITHUB_SHA: ${{ github.sha }}
- uses: codecov/codecov-action@v1
with:
directory: packages # optional
cypress-static-plugin-auth:
runs-on: ubuntu-20.04
container:
image: "corejam/cypress:6.6.0"
options: --ipc=host
needs: build
steps:
- name: Get PR git sha
id: gitRef
run: |
if [ "${{ github.event_name }}" == 'pull_request_target' ]; then
echo "::set-output name=sha::${{ github.event.pull_request.head.sha }}"
else
echo "::set-output name=sha::${{ github.sha }}"
fi
- name: Checkout code
uses: actions/checkout@v2
with:
ref: ${{ steps.gitRef.outputs.sha }}
path: ""
- uses: actions/download-artifact@v2
with:
name: dist
- run: tar -xzf artifact.tar
- run: chmod +x node_modules/.bin/corejam
- name: Cache Cypress
id: cache-cypress
uses: actions/cache@v2
with:
path: test/cypress/node_modules
key: ${{ runner.os }}-${{ matrix.node-version }}-cache-cypress-${{ hashFiles('test/cypress/yarn.lock') }}
- run: yarn --cwd test/cypress --frozen-lockfile
if: |
steps.cache-cypress.outputs.cache-hit != 'true'
- run: |
cd packages/auth
cp .env.sample .env
yarn static -l
nohup yarn static:serve & cd ../../test/cypress
cypress run --spec "./cypress/integration/plugins/auth/**/*"
env:
CYPRESS_baseUrl: "http://localhost:3001"
CYPRESS_CACHE_FOLDER: "/root/.cache/Cypress"
- uses: actions/upload-artifact@v1
if: failure()
with:
name: cypress-screenshots
path: test/cypress/cypress/screenshots
cypress-static-plugin-dershop:
runs-on: ubuntu-20.04
container:
image: "corejam/cypress:6.6.0"
options: --ipc=host
needs: build
steps:
- name: Get PR git sha
id: gitRef
run: |
if [ "${{ github.event_name }}" == 'pull_request_target' ]; then
echo "::set-output name=sha::${{ github.event.pull_request.head.sha }}"
else
echo "::set-output name=sha::${{ github.sha }}"
fi
- name: Checkout code
uses: actions/checkout@v2
with:
ref: ${{ steps.gitRef.outputs.sha }}
path: ""
- uses: actions/download-artifact@v2
with:
name: dist
- run: tar -xzf artifact.tar
- run: chmod +x node_modules/.bin/corejam
- name: Cache Cypress
id: cache-cypress
uses: actions/cache@v2
with:
path: test/cypress/node_modules
key: ${{ runner.os }}-${{ matrix.node-version }}-cache-cypress-${{ hashFiles('test/cypress/yarn.lock') }}
- run: yarn --cwd test/cypress --frozen-lockfile
if: |
steps.cache-cypress.outputs.cache-hit != 'true'
- run: |
cd packages/dershop
cp .env.sample .env
yarn corejam generateSchema && yarn corejam bootstrap
yarn static -l
JWT_HASH=test FAKER_MODULE=auth DEPLOYMENT_URL=http://localhost:3000 nohup yarn static:serve & cd ../../test/cypress
cypress run --spec "./cypress/integration/plugins/dershop/**/*"
env:
CYPRESS_baseUrl: "http://localhost:3001"
CYPRESS_CACHE_FOLDER: "/root/.cache/Cypress"
- uses: actions/upload-artifact@v1
if: failure()
with:
name: cypress-screenshots
path: test/cypress/cypress/screenshots
cypress-generateApp-monorepo:
runs-on: ubuntu-20.04
container:
image: "corejam/cypress:6.6.0"
options: --ipc=host
needs: build
steps:
- name: Get PR git sha
id: gitRef
run: |
if [ "${{ github.event_name }}" == 'pull_request_target' ]; then
echo "::set-output name=sha::${{ github.event.pull_request.head.sha }}"
else
echo "::set-output name=sha::${{ github.sha }}"
fi
- name: Checkout code
uses: actions/checkout@v2
with:
ref: ${{ steps.gitRef.outputs.sha }}
path: ""
- uses: actions/download-artifact@v2
with:
name: dist
- run: tar -xzf artifact.tar
- run: chmod +x node_modules/.bin/corejam
- name: Cache Cypress
id: cache-cypress
uses: actions/cache@v2
with:
path: test/cypress/node_modules
key: ${{ runner.os }}-${{ matrix.node-version }}-cache-cypress-${{ hashFiles('test/cypress/yarn.lock') }}
- run: yarn --cwd test/cypress --frozen-lockfile
if: |
steps.cache-cypress.outputs.cache-hit != 'true'
- run: |
yarn bs
cd examples
yarn corejam createApp test
cd test
cp .env.sample .env
yarn static -l
nohup yarn static:serve & cd ../../test/cypress
cypress run --spec "./cypress/integration/generateApp/**/*"
env:
CYPRESS_baseUrl: "http://localhost:3001"
CYPRESS_CACHE_FOLDER: "/root/.cache/Cypress"
- uses: actions/upload-artifact@v1
if: failure()
with:
name: cypress-screenshots
path: test/cypress/cypress/screenshots
cypress-generateApp-standalone:
runs-on: ubuntu-20.04
container:
image: "corejam/cypress:6.6.0"
options: --ipc=host
needs: build
steps:
- name: Get PR git sha
id: gitRef
run: |
if [ "${{ github.event_name }}" == 'pull_request_target' ]; then
echo "::set-output name=sha::${{ github.event.pull_request.head.sha }}"
else
echo "::set-output name=sha::${{ github.sha }}"
fi
- name: Checkout code
uses: actions/checkout@v2
with:
ref: ${{ steps.gitRef.outputs.sha }}
path: ""
- uses: actions/download-artifact@v2
with:
name: dist
- run: tar -xzf artifact.tar
- run: chmod +x node_modules/.bin/corejam
- name: Cache Cypress
id: cache-cypress
uses: actions/cache@v2
with:
path: test/cypress/node_modules
key: ${{ runner.os }}-${{ matrix.node-version }}-cache-cypress-${{ hashFiles('test/cypress/yarn.lock') }}
- run: yarn --cwd test/cypress --frozen-lockfile
if: |
steps.cache-cypress.outputs.cache-hit != 'true'
- run: |
yarn bs
cd packages/base && yarn link
cd ../cli && yarn link
cd ../run && yarn link
cd ../rollup-plugin && yarn link
cd ../core-components && yarn link
cd /github/home && corejam createApp test
cd test
yarn link @corejam/base @corejam/cli @corejam/core-components @corejam/run @corejam/rollup-plugin
yarn
cp .env.sample .env
yarn static
nohup yarn static:serve &
cd /__w/corejam/corejam/test/cypress
cypress run --spec "./cypress/integration/generateApp/**/*"
env:
CYPRESS_baseUrl: "http://localhost:3001"
CYPRESS_CACHE_FOLDER: "/root/.cache/Cypress"
- uses: actions/upload-artifact@v1
if: failure()
with:
name: cypress-screenshots
path: test/cypress/cypress/screenshots
cypress-generateApp-standaloneCLI:
runs-on: ubuntu-20.04
container:
image: "corejam/cypress:6.6.0"
options: --ipc=host
needs: build
steps:
- name: Get PR git sha
id: gitRef
run: |
if [ "${{ github.event_name }}" == 'pull_request_target' ]; then
echo "::set-output name=sha::${{ github.event.pull_request.head.sha }}"
else
echo "::set-output name=sha::${{ github.sha }}"
fi
- name: Checkout code
uses: actions/checkout@v2
with:
ref: ${{ steps.gitRef.outputs.sha }}
path: ""
- uses: actions/download-artifact@v2
with:
name: dist
- run: tar -xzf artifact.tar
- run: chmod +x node_modules/.bin/corejam
- name: Cache Cypress
id: cache-cypress
uses: actions/cache@v2
with:
path: test/cypress/node_modules
key: ${{ runner.os }}-${{ matrix.node-version }}-cache-cypress-${{ hashFiles('test/cypress/yarn.lock') }}
- run: yarn --cwd test/cypress --frozen-lockfile
if: |
steps.cache-cypress.outputs.cache-hit != 'true'
- run: |
yarn bs
cd packages/base && yarn link
cd ../cli && export CLI_PATH=$(pwd) && yarn link
cd ../run && yarn link
cd ../rollup-plugin && yarn link
cd ../core-components && yarn link
cd /github/home && cp -r $CLI_PATH . && cd cli && yarn link @corejam/base --ignore-scripts && yarn --ignore-scripts
cd /github/home && /github/home/cli/dist/index.js createApp test
cd test && yarn link @corejam/base @corejam/cli @corejam/core-components @corejam/run @corejam/rollup-plugin
yarn
cp .env.sample .env
yarn static
nohup yarn static:serve &
cd /__w/corejam/corejam/test/cypress
cypress run --spec "./cypress/integration/generateApp/**/*"
env:
CYPRESS_baseUrl: "http://localhost:3001"
CYPRESS_CACHE_FOLDER: "/root/.cache/Cypress"
- uses: actions/upload-artifact@v1
if: failure()
with:
name: cypress-screenshots
path: test/cypress/cypress/screenshots
cypress:
runs-on: ubuntu-20.04
container:
image: "corejam/cypress:6.6.0"
options: --ipc=host
needs:
- integration-tests
- cypress-static-plugin-auth
- core-components-test
- cypress-generateApp-monorepo
- cypress-generateApp-standalone
- cypress-generateApp-standaloneCLI
steps:
- name: Get PR git sha
id: gitRef
run: |
if [ "${{ github.event_name }}" == 'pull_request_target' ]; then
echo "::set-output name=sha::${{ github.event.pull_request.head.sha }}"
else
echo "::set-output name=sha::${{ github.sha }}"
fi
- name: Checkout code
uses: actions/checkout@v2
with:
ref: ${{ steps.gitRef.outputs.sha }}
path: ""
- uses: actions/download-artifact@v2
with:
name: dist
- run: tar -xzf artifact.tar
- run: chmod +x node_modules/.bin/corejam
- name: Cache Cypress
id: cache-cypress
uses: actions/cache@v2
with:
path: test/cypress/node_modules
key: ${{ runner.os }}-${{ matrix.node-version }}-cache-cypress-${{ hashFiles('test/cypress/yarn.lock') }}
- run: yarn --cwd test/cypress --frozen-lockfile
if: |
steps.cache-cypress.outputs.cache-hit != 'true'
- run: |
if [ $GITHUB_REF = 'refs/heads/master' ]; then export DEPLOYED_URL="demo.dershop.dev"; else export DEPLOYED_URL="$GITHUB_SHA.pipeline.dershop.dev"; fi
cd packages/dershop && yarn corejam generateSchema
export SECRET=$(COMMIT_ID=cypress_$GITHUB_SHA node ./tests/bootstrap.js | grep 'secret'|cut -f2 -d ":")
cd ../../examples/nextjs
export DEPLOYMENT=$(vercel --confirm --token $ZEIT_TOKEN --scope=dershop -e JWT_HASH=gitlab -e SECRET_KEY=$SECRET -e DB_DRIVER="DB_FAUNA" --build-env SECRET_KEY=$SECRET --build-env DB_DRIVER="DB_FAUNA" -e DEPLOYMENT_URL=https://$DEPLOYED_URL)
vercel alias $DEPLOYMENT $DEPLOYED_URL --token $ZEIT_TOKEN --scope dershop
wget $DEPLOYED_URL
cd ../../test/cypress
CYPRESS_baseUrl=https://$DEPLOYED_URL cypress run --spec "./cypress/integration/plugins/dershop/**/*"
env: # Or as an environment variable
SECRET_KEY: ${{ secrets.SECRET }}
GITHUB_SHA: ${{ github.sha }}
ZEIT_TOKEN: ${{ secrets.ZEIT_TOKEN }}
CYPRESS_CACHE_FOLDER: "/root/.cache/Cypress"
- uses: actions/upload-artifact@v1
if: failure()
with:
name: cypress-screenshots
path: test/cypress/cypress/screenshots
publish:
name: Publish packages
runs-on: ubuntu-20.04
needs:
- integration-tests
- cypress-static-plugin-auth
- core-components-test
- cypress-generateApp-monorepo
- cypress-generateApp-standalone
- cypress-generateApp-standaloneCLI
- cypress
if: github.ref == 'refs/heads/next' || github.ref == 'refs/heads/master'
steps:
- name: 📚 Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*
- name: 🟢 Setup Node ${{ matrix.node_version }}
uses: actions/setup-node@v1
with:
node-version: 14
- name: ⏳ Install
run: |
yarn --frozen-lockfile
yarn lint
yarn bs
- name: 🗝 Configure git credentials
uses: OleksiyRudenko/gha-git-credentials@v2
with:
token: ${{ secrets.GH }}
- name: 🐒 Authenticate with NPM
run: |
yarn logout
echo "registry=https://registry.npmjs.org/" >> .npmrc
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> .npmrc
npm whoami
env:
NPM_TOKEN: ${{ secrets.NPM }}
- name: 🚽 Publish package
run: |
yarn logout
npm whoami
yarn lerna publish --yes $LERNA_TAG --no-verify-access $CANARY
env:
GH_TOKEN: ${{ secrets.GH }}
GITHUB_TOKEN: ${{ secrets.GH }}
NPM_TOKEN: NODE_AUTH_TOKEN
NODE_AUTH_TOKEN: NODE_AUTH_TOKEN
CANARY: ${{ github.ref == 'refs/heads/next' && '--canary' || ''}}
LERNA_TAG: ${{ github.ref == 'refs/heads/next' && '--dist-tag next' || ''}}
sync-branch:
if: github.ref == 'refs/heads/master'
needs:
- publish
runs-on: ubuntu-20.04
name: Merge master -> next
steps:
- name: "Merge"
uses: devmasx/merge-branch@v1.3.1
with:
type: now
from_branch: master
target_branch: next
github_token: ${{ secrets.GH}}