This repository has been archived by the owner on Nov 23, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 260
/
.gitlab-ci.yml
301 lines (272 loc) · 7.79 KB
/
.gitlab-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
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
stages:
- setup
- build
- test
- test extended
- examples
- deploy
variables:
GIT_STRATEGY: clone
GIT_SUBMODULE_STRATEGY: recursive
TEST_PATTERN: "methods"
setup environment:
stage: setup
script:
- git submodule update --init --recursive
- nix-shell --run "yarn"
artifacts:
expire_in: 1 week
paths:
- submodules
- node_modules
tags:
- deploy
verify:
stage: build
dependencies:
- "setup environment"
script:
- nix-shell --run "yarn test:health"
- nix-shell --run "yarn flow"
- nix-shell --run "yarn typescript"
- nix-shell --run "yarn lint"
- nix-shell --run "yarn test:unit"
tags:
- deploy
build:
stage: build
dependencies:
- "setup environment"
script:
- nix-shell --run "yarn build:connect"
artifacts:
expire_in: 1 week
paths:
- build
tags:
- deploy
# Deploy to testing environment
deploy test:
stage: deploy
except:
- v8
variables:
GIT_STRATEGY: none
when: manual
dependencies:
- build
environment:
name: $CI_BUILD_REF_NAME
url: $BASE_REVIEW_URL/$CI_BUILD_REF_NAME
before_script: []
script:
- echo "Deploy a review app"
- '[ -z "${DEPLOY_BASE_DIR}" ] && echo "Deploy base dir cannot be empty" && exit 255'
- env
- mkdir -p "${DEPLOY_BASE_DIR}/${CI_BUILD_REF_NAME}"
- echo "Copy dev build to web server ${DEPLOY_BASE_DIR}/${CI_BUILD_REF_NAME}..."
- rsync --delete -va build/ "${DEPLOY_BASE_DIR}/${CI_BUILD_REF_NAME}/"
only:
- branches
tags:
- deploy
# Create rollback copy of connect.trezo.io
rollback production copy:
stage: deploy
only:
refs:
- v8
when: manual
variables:
GIT_STRATEGY: none
before_script: []
script:
- aws s3 sync s3://connect.trezor.io s3://rollback-connect.trezor.io
tags:
- deploy
# Deploy release to connect.trezor.io
deploy production:
stage: deploy
only:
refs:
- v8
when: manual
dependencies:
- build
variables:
GIT_STRATEGY: none
before_script: []
script:
- ./scripts/s3sync.sh 8
tags:
- deploy
# Publish release to npm registry
publish release to npm:
stage: deploy
only:
refs:
- v8
when: manual
dependencies:
- "setup environment"
before_script:
- echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc
- nix-shell --run "yarn"
script:
- nix-shell --run "yarn build:npm && cd ./npm && npm publish"
- nix-shell --run "yarn build:npm-extended && cd ./npm-extended && npm publish --tag extended"
after_script:
- rm ~/.npmrc
tags:
- deploy
# Publish beta release to npm registry
publish beta release to npm:
stage: deploy
except:
- v8
when: manual
dependencies:
- "setup environment"
before_script:
- echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc
- nix-shell --run "yarn"
- nix-shell --run "REMOTE_VERSION=\$(npm show trezor-connect version --tag beta) && node ./scripts/ci-check-version \$REMOTE_VERSION $CI_COMMIT_BRANCH"
script:
- nix-shell --run "yarn build:npm-extended && cd ./npm-extended && npm publish --tag beta"
after_script:
- rm ~/.npmrc
tags:
- deploy
# Test
.jobs:
parallel:
matrix:
- TESTS_INCLUDED_METHODS: "applySettings,applyFlags,getFeatures"
- TESTS_INCLUDED_METHODS: "signTransaction"
- TESTS_INCLUDED_METHODS: "getAccountInfo,getAddress,getPublicKey,signMessage,verifyMessage,composeTransaction"
- TESTS_INCLUDED_METHODS: "stellarGetAddress,stellarSignTransaction"
- TESTS_INCLUDED_METHODS: "cardanoGetAddress,cardanoGetNativeScriptHash,cardanoGetPublicKey,cardanoSignTransaction"
- TESTS_INCLUDED_METHODS: "eosGetPublicKey,eosSignTransaction"
- TESTS_INCLUDED_METHODS: "ethereumGetAddress,ethereumGetPublicKey,ethereumSignMessage,ethereumSignTransaction,ethereumVerifyMessage,ethereumSignTypedData"
- TESTS_INCLUDED_METHODS: "nemGetAddress,nemSignTransaction"
- TESTS_INCLUDED_METHODS: "rippleGetAddress,rippleSignTransaction"
- TESTS_INCLUDED_METHODS: "tezosGetAddress,tezosGetPublicKey"
- TESTS_INCLUDED_METHODS: "binanceSignTransaction"
.jobs-t1:
parallel:
matrix:
- TESTS_INCLUDED_METHODS: "applySettings,applyFlags,getFeatures"
- TESTS_INCLUDED_METHODS: "signTransaction"
- TESTS_INCLUDED_METHODS: "getAccountInfo,getAddress,getPublicKey,signMessage,verifyMessage,composeTransaction"
- TESTS_INCLUDED_METHODS: "ethereumGetAddress,ethereumGetPublicKey,ethereumSignMessage,ethereumSignTransaction,ethereumVerifyMessage,ethereumSignTypedData"
.jobs-api:
parallel:
matrix:
- TEST_PATTERN: "init"
.test:
extends: .jobs
image: ghcr.io/trezor/trezor-user-env:1d12b626fdd4aab4b5c8e148e42a81c269e7e5b5
dependencies:
- "setup environment"
variables:
SDL_VIDEODRIVER: "dummy"
TESTS_USE_TX_CACHE: "false"
TESTS_USE_WS_CACHE: "false"
before_script:
- nix-shell --run "yarn"
script:
- "echo Firmware version: $TESTS_FIRMWARE"
- /trezor-user-env/run-nix.sh &
- nix-shell --run "export TESTS_FIRMWARE=\$(node ./tests/get-latest-firmware.js) && yarn test:integration ${TEST_PATTERN} --coverage true"
after_script:
- cp /trezor-user-env/logs/debugging.log trezor-user-env-debugging.log
- cp /trezor-user-env/logs/emulator_bridge.log tenv-emulator-bridge-debugging.log
artifacts:
paths:
- trezor-user-env-debugging.log
- tenv-emulator-bridge-debugging.log
expire_in: 1 week
when: always
TT latest:
extends: .test
stage: test
API:
extends: .test
stage: test
parallel: !reference [.jobs-api,parallel]
.test-nightly:
extends: .test
stage: test extended
only:
- schedules
variables:
TESTS_USE_TX_CACHE: "true"
TESTS_USE_WS_CACHE: "true"
# todo: resolve tests flakiness and remove retry option
retry: 2
.test-manual:
extends: .test
stage: test extended
when: manual
# out of stages order, needs makes jobs available along with "base tests"
needs: ["setup environment", "verify", "build"]
TT master:
extends: .test-nightly
variables:
TESTS_FIRMWARE: "2-master"
TT master:
extends: .test-manual
variables:
TESTS_FIRMWARE: "2-master"
TT 2.2.0:
extends: .test-nightly
# todo: remove delay. according to my observation, the higher number of jobs running concurrently, the higher chance of test failing. are we sure jobs are isolated from each other
when: delayed
start_in: 5 minutes
variables:
TESTS_FIRMWARE: "2.2.0"
TT 2.2.0:
extends: .test-manual
variables:
TESTS_FIRMWARE: "2.2.0"
T1 latest:
extends: .test-nightly
# todo: remove delay. according to my observation, the higher number of jobs running concurrently, the higher chance of test failing. are we sure jobs are isolated from each other
when: delayed
start_in: 10 minutes
variables:
TESTS_FIRMWARE: "1-latest"
parallel: !reference [.jobs-t1,parallel]
T1 latest:
extends: .test-manual
variables:
TESTS_FIRMWARE: "1-latest"
parallel: !reference [.jobs-t1,parallel]
T1 master:
extends: .test-nightly
# todo: remove delay. according to my observation, the higher number of jobs running concurrently, the higher chance of test failing. are we sure jobs are isolated from each other
when: delayed
start_in: 15 minutes
variables:
TESTS_FIRMWARE: "1-master"
parallel: !reference [.jobs-t1,parallel]
T1 master:
extends: .test-manual
variables:
TESTS_FIRMWARE: "1-master"
parallel: !reference [.jobs-t1,parallel]
# Examples
node:
image: ghcr.io/trezor/trezor-user-env:1d12b626fdd4aab4b5c8e148e42a81c269e7e5b5
stage: examples
dependencies:
- "setup environment"
variables:
SDL_VIDEODRIVER: "dummy"
before_script:
- nix-shell --run "yarn"
- nix-shell --run "yarn build:npm-extended"
script:
- /trezor-user-env/run-nix.sh &
- sleep 10
- nix-shell --run "yarn babel-node ./examples/node/index.js"