-
Notifications
You must be signed in to change notification settings - Fork 2
247 lines (211 loc) · 6.87 KB
/
ci.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
name: Node CI
concurrency:
group: ci-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on:
pull_request:
workflow_dispatch:
push:
branches: main
schedule:
- cron: "0 0 * * *"
env:
CI: true
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_TOKEN }}
COVERALLS_GIT_BRANCH: main
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# - name: Setup kernel for react native, increase watchers
# run: echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
# used to centralize the node version across workflows
# refs https://arinco.com.au/blog/github-actions-share-environment-variables-across-workflows
# refs https://github.com/marketplace/actions/set-environment-variables
- name: Set Environment Variables
uses: tw3lveparsecs/[email protected]
with:
envFilePath: ./envvars.for.actions
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
- name: Attempt to restore the cache
uses: actions/cache@v3
id: cache
with:
path: |
./node_modules
~/.cache/Cypress
key: ${{ hashFiles('**/package-lock.json') }}
restore-keys: ${{ hashFiles('**/package-lock.json') }}
- name: install
if: steps.cache.outputs.cache-hit != 'true'
run: npm install --legacy-peer-deps
test:
runs-on: ubuntu-latest
needs: [build]
steps:
- uses: actions/checkout@v4
- name: Set Environment Variables
uses: tw3lveparsecs/[email protected]
with:
envFilePath: ./envvars.for.actions
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
- name: Attempt to restore the cache
uses: actions/cache@v3
id: cache_restore
with:
fail-on-cache-miss: true
path: |
./node_modules
~/.cache/Cypress
key: ${{ hashFiles('**/package-lock.json') }}
- name: coverage
if: github.ref == 'refs/heads/main'
run: npm run coverage
- uses: actions/upload-artifact@v3
if: github.ref == 'refs/heads/main'
with:
name: jest-lcov
path: coverage/lcov.info
- name: coverage (no coveralls)
if: github.ref != 'refs/heads/main'
run: npm run coverage
acceptance:
runs-on: ubuntu-latest
needs: [build]
steps:
- uses: actions/checkout@v4
- name: Set Environment Variables
uses: tw3lveparsecs/[email protected]
with:
envFilePath: ./envvars.for.actions
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
- name: Attempt to restore the cache
uses: actions/cache@v3
id: cache_restore
with:
fail-on-cache-miss: true
path: |
./node_modules
~/.cache/Cypress
key: ${{ hashFiles('**/package-lock.json') }}
- name: export display
run: |
/usr/bin/Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &
echo ">>> Started xvfb"
- name: delete coverage folder
run: rm -rf coverage/
- name: lint
run: npm run lint
- name: build application
run: npm run build
- name: instrument application
run: |
npx nyc instrument src/ instrumented
cp -R instrumented/ src/
rm -rf instrumented
- name: Run cypress (acceptance tests)
uses: cypress-io/github-action@v6
env:
CYPRESS_INSTRUMENT_PRODUCTION: false
DISABLE_ESLINT_PLUGIN: true
CYPRESS_BASE_URL: 'http://localhost:3000'
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
with:
record: true
wait-on: 'http://localhost:3000'
start: npm run start-instrumented
browser: chrome
headed: true
install-command: npm install --legacy-peer-deps
- name: Generate lcov
run: npx nyc report --reporter=lcov
- uses: actions/upload-artifact@v3
if: github.ref == 'refs/heads/main'
with:
name: cypress-lcov
path: coverage/lcov.info
coverage:
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
needs: [build, test, acceptance]
steps:
- uses: actions/checkout@v4
- name: Set Environment Variables
uses: tw3lveparsecs/[email protected]
with:
envFilePath: ./envvars.for.actions
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
- name: Attempt to restore the cache
uses: actions/cache@v3
with:
fail-on-cache-miss: true
path: |
./node_modules
~/.cache/Cypress
key: ${{ hashFiles('**/package-lock.json') }}
- uses: actions/download-artifact@v3
with:
path: coverage/
pattern: "*-lcov"
merge-multiple: false
- run: |
mkdir merged_coverage
mv coverage/cypress-lcov/lcov.info merged_coverage/cypress.info
mv coverage/jest-lcov/lcov.info merged_coverage/jest.info
./node_modules/.bin/lcov-result-merger './merged_coverage/*' merged_coverage.info
npm run coveralls
- uses: actions/upload-artifact@v3
with:
name: merged-lcov
path: merged_coverage.info
delivery:
runs-on: ubuntu-latest
needs: [test, acceptance]
if: github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v4
- name: Set Environment Variables
uses: tw3lveparsecs/[email protected]
with:
envFilePath: ./envvars.for.actions
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
- name: Attempt to restore the cache
uses: actions/cache@v3
id: cache_restore
with:
fail-on-cache-miss: true
path: |
./node_modules
~/.cache/Cypress
key: ${{ hashFiles('**/package-lock.json') }}
- name: package
run: npm run package
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
- name: fetch snap file
id: snap_file
run: echo "::set-output name=name::$(ls dist/*.snap | sed "s/dist\///g" | sed "s/\.snap//g")"
- name: publish snap edge channel
uses: snapcore/action-publish@v1
env:
SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.STORE_LOGIN }}
with:
store_login: ${{ secrets.STORE_LOGIN }}
snap: "dist/${{ steps.snap_file.outputs.name }}.snap"
release: edge