-
Notifications
You must be signed in to change notification settings - Fork 45
251 lines (216 loc) · 7.19 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
248
249
250
251
name: CI
on:
pull_request:
branches:
- master
paths:
- '**.js'
- '**.ts'
- '**.tsx'
- '**.css'
- '**.json'
- '**.html'
- '**.nvmrc'
- '!package.json'
- '!public/manifest.json'
- '!release-notes.json'
env:
BLOCK_WALLET_URL: url.txt
BLOCK_WALLET_FOLDER: blockwallet-build
S3_PATH: s3://releases.blockwallet.io/tmp/
CYPRESS_CACHE_FOLDER: cypress/cache
jobs:
lint:
runs-on: ubuntu-latest
if: startsWith(github.head_ref, 'dependabot/') == false
steps:
- name: Checkout monorepo
uses: actions/checkout@v3
- name: Install node
uses: actions/setup-node@v3
with:
node-version-file: .nvmrc
registry-url: https://npm.pkg.github.com
- name: Install yarn
run: |
npm install --global yarn
- name: Dependency UI cache
uses: actions/cache@v3
with:
path: 'packages/ui/node_modules'
key: ${{ runner.os }}-modules-v1-${{ hashFiles('packages/ui/yarn.lock') }}
- name: Dependency Background cache
uses: actions/cache@v3
with:
path: 'packages/background/node_modules'
key: ${{ runner.os }}-modules-v1-${{ hashFiles('packages/background/yarn.lock') }}
- name: Dependency Provider cache
uses: actions/cache@v3
with:
path: 'packages/provider/node_modules'
key: ${{ runner.os }}-modules-v1-${{ hashFiles('packages/provider/yarn.lock') }}
- name: Install packages dependencies
run: |
make install/ci
env:
GITHUB_TOKEN: ${{ secrets.PAT }}
- name: Check lint in all the packages
run: |
echo "::group::UI"
cd packages/ui/
if yarn lint; then
echo "::notice:: UI lint OK"
lint_ui=0
else
echo '::error:: UI lint failed. Run "yarn lint:fix" in the folder "packages/ui/" to fix it and commit your changes.'
lint_ui=1
fi
echo "::endgroup::"
echo "::group::Background"
cd ..
cd background/
if yarn lint; then
echo "::notice:: Background lint OK"
lint_background=0
else
echo '::error:: Background lint failed. Run "yarn lint:fix" in the folder "packages/background/" to fix it and commit your changes.'
lint_background=1
fi
echo "::endgroup::"
echo "::group::Provider"
cd ..
cd provider/
if yarn lint; then
echo "::notice:: Provider lint OK"
lint_provider=0
else
echo '::error:: Provider lint failed. Run "yarn lint:fix" in the folder "packages/provider/" to fix it and commit your changes.'
lint_provider=1
fi
echo "::endgroup::"
if [[ "$lint_ui" -ne "0" || "$lint_background" -ne "0" || "$lint_provider" -ne "0" ]]; then
exit 1
fi
test:
runs-on: ubuntu-latest
if: startsWith(github.head_ref, 'dependabot/') == false
steps:
- name: Checkout monorepo
uses: actions/checkout@v3
- name: Install node
uses: actions/setup-node@v3
with:
node-version-file: .nvmrc
registry-url: https://npm.pkg.github.com
- name: Install yarn
run: |
npm install --global yarn
- name: Dependency UI cache
uses: actions/cache@v3
with:
path: 'packages/ui/node_modules'
key: ${{ runner.os }}-modules-v1-${{ hashFiles('packages/ui/yarn.lock') }}
- name: Dependency Background cache
uses: actions/cache@v3
with:
path: 'packages/background/node_modules'
key: ${{ runner.os }}-modules-v1-${{ hashFiles('packages/background/yarn.lock') }}
- name: Dependency Provider cache
uses: actions/cache@v3
with:
path: 'packages/provider/node_modules'
key: ${{ runner.os }}-modules-v1-${{ hashFiles('packages/provider/yarn.lock') }}
- name: Install packages dependencies
run: |
make install/ci
env:
GITHUB_TOKEN: ${{ secrets.PAT }}
- name: Build tailwind
run: |
cd packages/ui
yarn build:tailwind
- name: Test ui
run: |
cd packages/ui
make test/ui
env:
INFURA_PROJECT_ID: ${{ secrets.INFURA_PROJECT_ID }}
ETHERSCAN_API_KEY: ${{ secrets.ETHERSCAN_API_KEY }}
- name: Test provider
run: |
cd packages/provider
make test/provider
- name: Test background
run: |
cd packages/background
make test/background
build:
needs: [test, lint]
env:
ENVIRONMENT: prod
runs-on: ubuntu-latest
steps:
- name: Checkout monorepo
uses: actions/checkout@v3
- name: Install node
uses: actions/setup-node@v3
with:
node-version-file: .nvmrc
registry-url: https://npm.pkg.github.com
- name: Install yarn
run: |
npm install --global yarn
- name: Dependency UI cache
uses: actions/cache@v3
with:
path: 'packages/ui/node_modules'
key: ${{ runner.os }}-modules-v1-${{ hashFiles('packages/ui/yarn.lock') }}
- name: Dependency Background cache
uses: actions/cache@v3
with:
path: 'packages/background/node_modules'
key: ${{ runner.os }}-modules-v1-${{ hashFiles('packages/background/yarn.lock') }}
- name: Dependency Provider cache
uses: actions/cache@v3
with:
path: 'packages/provider/node_modules'
key: ${{ runner.os }}-modules-v1-${{ hashFiles('packages/provider/yarn.lock') }}
- name: Install packages dependencies
run: |
make install/ci
env:
GITHUB_TOKEN: ${{ secrets.PAT }}
- name: Build extension
env:
CI: false
run: |
make build/prod
- name: Zip build
if: startsWith(github.head_ref, 'dependabot/') == false
id: zip
run: |
file=block-wallet-${GITHUB_SHA::7}
zip -r -D $file dist/
echo "::set-output name=file::$file.zip"
- name: Configure AWS credentials
if: startsWith(github.head_ref, 'dependabot/') == false
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID_RELEASE_BUCKET }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY_RELEASE_BUCKET }}
aws-region: us-east-2
- name: Upload zip to S3
if: startsWith(github.head_ref, 'dependabot/') == false
run: |
zip=${{ steps.zip.outputs.file }}
aws s3 cp $zip $S3_PATH
s3_url_https=$(echo "${S3_PATH/s3/https}")
echo "$s3_url_https""$zip" > $BLOCK_WALLET_URL
cat $BLOCK_WALLET_URL
- name: Save extension url
if: startsWith(github.head_ref, 'dependabot/') == false
uses: actions/upload-artifact@v3
with:
name: ${{ env.BLOCK_WALLET_FOLDER }}
if-no-files-found: error
path: ${{ env.BLOCK_WALLET_URL }}