-
Notifications
You must be signed in to change notification settings - Fork 56
221 lines (185 loc) · 5.74 KB
/
pull-request.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
name: Pull Request CI
on:
pull_request_target:
branches:
- master
types: [opened, labeled, reopened, synchronize]
env:
rid: ${{ github.run_id }}-${{ github.run_number }}
jobs:
check-validation:
name: Check - Validation
runs-on: ubuntu-20.04
steps:
- name: Check Validation
run: |
HEAD_REPO=${{ github.event.pull_request.head.repo.full_name }}
BASE_REPO=${{ github.event.pull_request.base.repo.full_name }}
FROM_BASE=0; [ "$HEAD_REPO" == "$BASE_REPO" ] && FROM_BASE=1
HAS_VALIDATED_LABEL=${{ contains(github.event.pull_request.labels.*.name, 'validated') }}
VALIDATED=0; [ "$HAS_VALIDATED_LABEL" == "true" ] && VALIDATED=1
echo from base $FROM_BASE
echo validated $VALIDATED
if [[ $FROM_BASE == 1 || $VALIDATED == 1 ]]
then
echo 'pull request is validated, running tests'
exit 0
else
echo 'pull request is not validated, exiting'
exit 1
fi
initialize:
name: Initialize
needs: check-validation
runs-on: ubuntu-20.04
steps:
- name: Checkout Project
uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Setup Environment
uses: actions/setup-node@v2
with:
node-version: 14.x
check-latest: true
- name: Validate Dependencies
id: validate-dependencies
uses: actions/cache@v2
with:
path: node_modules/
key: node-modules-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}
- name: Install Dependencies
if: steps.validate-dependencies.outputs.cache-hit != 'true'
run: yarn
- name: Cache Dependencies
uses: actions/cache@v2
if: steps.validate-dependencies.outputs.cache-hit != 'true'
with:
path: node_modules/
key: node-modules-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}
- name: Cache Cypress
uses: actions/cache@v2
if: steps.validate-dependencies.outputs.cache-hit != 'true'
with:
path: /home/runner/.cache/Cypress
key: cypress-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}
test-source:
name: Test - Source
needs: initialize
runs-on: ubuntu-20.04
steps:
- name: Checkout Project
uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Setup Environment
uses: actions/setup-node@v2
with:
node-version: 14.x
check-latest: true
- name: Uncache Dependencies
uses: actions/cache@v2
with:
path: node_modules/
key: node-modules-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}
- name: Test Source
run: yarn ci:test:src
test-static:
name: Test - static
needs: initialize
runs-on: ubuntu-20.04
steps:
- name: Checkout Project
uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Setup Environment
uses: actions/setup-node@v2
with:
node-version: 14.x
check-latest: true
- name: Uncache Dependencies
uses: actions/cache@v2
with:
path: node_modules/
key: node-modules-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}
- name: test-static
run: yarn ci:test:lint
- name: test-tokens
run: yarn ci:test:tokens
build-source:
name: Build - Source
needs: initialize
runs-on: ubuntu-20.04
steps:
- name: Checkout Project
uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Setup Environment
uses: actions/setup-node@v2
with:
node-version: 14.x
check-latest: true
- name: Uncache Dependencies
uses: actions/cache@v2
with:
path: node_modules/
key: node-modules-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}
- name: Build Source
run: yarn ci:build
- name: Cache Dist
uses: actions/cache@v2
with:
path: dist/
key: dist-${{ runner.os }}-${{ env.rid }}
- name: Cache Docs
uses: actions/cache@v2
with:
path: docs/
key: docs-${{ runner.os }}-${{ env.rid }}
- name: Cache Styles
uses: actions/cache@v2
with:
path: scss/
key: scss-${{ runner.os }}-${{ env.rid }}
test-storybook:
name: Test - Storybook
needs: build-source
runs-on: ubuntu-20.04
steps:
- name: Checkout Project
uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Setup Environment
uses: actions/setup-node@v2
with:
node-version: 14.x
check-latest: true
- name: Uncache Dependencies
uses: actions/cache@v2
with:
path: node_modules/
key: node-modules-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}
- name: Uncache Dist
uses: actions/cache@v2
with:
path: dist/
key: dist-${{ runner.os }}-${{ env.rid }}
- name: Uncache Docs
uses: actions/cache@v2
with:
path: docs/
key: docs-${{ runner.os }}-${{ env.rid }}
- name: Uncache Styles
uses: actions/cache@v2
with:
path: scss/
key: scss-${{ runner.os }}-${{ env.rid }}
- name: Test - Storybook
uses: percy/[email protected]
with:
custom-command: 'yarn ci:test:storybook'
env:
PERCY_TOKEN: ${{ secrets.PERCY_TOKEN }}