-
Notifications
You must be signed in to change notification settings - Fork 2
172 lines (166 loc) · 4.86 KB
/
test-and-demo.yaml
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
# This workflow will do
# - a clean install of node dependencies
# - run tests
# - build and upload the storybook to a staging area
#
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
on:
push:
branches:
- master
- next
pull_request:
name: Test and Deploy
jobs:
setup:
runs-on: ubuntu-latest
outputs:
visual: ${{ steps.filter.outputs.visual }}
behavioral: ${{ steps.filter.outputs.behavioral }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0 # chromatic needs access to the history
- name: Check Paths
uses: dorny/paths-filter@v2
id: filter
with:
filters: |
visual:
- 'tokens/**'
- 'vue-components/**'
behavioral:
- 'vue-components/**'
- name: Set up node
uses: actions/setup-node@v3
with:
node-version: '16'
- name: Cache dependencies
uses: actions/cache@v3
id: cache
with:
path: |
node_modules
*/node_modules
key: ${{ runner.os }}-${{ hashFiles('**/package-lock.json', '**/package.json') }}
- name: Cache artifacts
uses: actions/cache@v3
id: dist
with:
path: |
*/dist
key: ${{ runner.os }}-${{ github.sha }}
- name: Install
if: steps.cache.outputs.cache-hit != 'true'
run: npm ci
- name: Build # only runs in case of cache hit, otherwise as part of npm ci
if: steps.cache.outputs.cache-hit == 'true'
run: npm run lerna bootstrap
test:
runs-on: ubuntu-latest
needs: setup
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0 # chromatic needs access to the history
- name: Set up node
uses: actions/setup-node@v3
with:
node-version: '16'
- name: Restore dependencies
uses: actions/cache@v3
with:
path: |
node_modules
*/node_modules
key: ${{ runner.os }}-${{ hashFiles('**/package-lock.json', '**/package.json') }}
- name: Test
run: npm run test
ui-review:
runs-on: ubuntu-latest
needs: setup
if: ${{ needs.setup.outputs.visual == 'true' || github.ref == 'refs/heads/master' }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0 # chromatic needs access to the history
- name: Set up node
uses: actions/setup-node@v3
with:
node-version: '16'
- name: Restore dependencies
uses: actions/cache@v3
with:
path: |
node_modules
*/node_modules
key: ${{ runner.os }}-${{ hashFiles('**/package-lock.json', '**/package.json') }}
- name: Restore artifacts
uses: actions/cache@v3
with:
path: |
*/dist
key: ${{ runner.os }}-${{ github.sha }}
- name: Build Storybooks
run: npm run build:storybook
- name: Deploy Storybook
run: npm run chromatic
deploy:
runs-on: ubuntu-latest
needs: setup
if: ${{ github.repository_owner == 'wmde' }}
outputs:
deploy_url: ${{ env.NETLIFY_DEPLOY_URL }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up node
uses: actions/setup-node@v3
with:
node-version: '16'
- name: Restore dependencies
uses: actions/cache@v3
with:
path: |
node_modules
*/node_modules
key: ${{ runner.os }}-${{ hashFiles('**/package-lock.json', '**/package.json') }}
- name: Build Project
run: npm run build:storybook
- name: Deploy to netlify
run: echo "NETLIFY_DEPLOY_URL=$(npx -p netlify-cli
netlify deploy --dir=docs/dist --json
--alias $(echo '${{ github.ref }}' | shasum | awk '{print $1}')
| jq '.deploy_url' --raw-output)" >> $GITHUB_ENV
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
- name: Print deploy URL
run: echo ${{ env.NETLIFY_DEPLOY_URL }}
browser-tests:
runs-on: ubuntu-latest
needs: [setup, deploy]
if: ${{ needs.setup.outputs.behavioral == 'true' || github.ref == 'refs/heads/master' }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up node
uses: actions/setup-node@v3
with:
node-version: '16'
- name: Restore dependencies
uses: actions/cache@v3
with:
path: |
node_modules
*/node_modules
key: ${{ runner.os }}-${{ hashFiles('**/package-lock.json', '**/package.json') }}
- name: Run e2e cross browser tests
env:
SAUCE_USERNAME: ${{ secrets.SAUCE_USERNAME }}
SAUCE_ACCESS_KEY: ${{ secrets.SAUCE_ACCESS_KEY }}
DEPLOY_URL: ${{ needs.deploy.outputs.deploy_url }}
run: npm run test:e2e