forked from koii-network/koii-node
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy path.gitlab-ci.yml
More file actions
338 lines (310 loc) · 9.47 KB
/
.gitlab-ci.yml
File metadata and controls
338 lines (310 loc) · 9.47 KB
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
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
variables:
USE_HARD_LINKS: 'false'
FF_USE_FASTZIP: 'true'
TRANSFER_METER_FREQUENCY: 2s
ARTIFACT_COMPRESSION_LEVEL: 'fastest'
CACHE_COMPRESSION_LEVEL: 'fastest'
DOCKER_DRIVER: overlay2
# Windows runners
.rbst-windows-runner:
tags:
- rbst-windows-runner
stages:
- prepare
- checks
- package
- mirror
##################################################################################################
######################################## TEMPLATES ################################################
###################################################################################################
.npm_ci_template: &npm_ci
stage: prepare
interruptible: true
rules:
- if: '$CI_COMMIT_TAG'
when: always
- if: '$CI_MERGE_REQUEST_ID'
when: always
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
when: always
- if: '$CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH'
when: always
script:
- npm config set -- //gitlab.com/api/v4/packages/npm/:_authToken=$GITLAB_ACCESS_TOKEN
- npm config set @koii-network:registry https://gitlab.com/api/v4/packages/npm/
# Configure GitHub Package Registry
- npm config set -- //npm.pkg.github.com/:_authToken=$GITHUB_TOKEN
- npm config set "@orca-compute:registry" "https://npm.pkg.github.com/"
- npm config set -- //registry.npmjs.org/:_authToken=$ORCA_NPM_TOKEN
- npm config set "@orcacompute:registry" "https://registry.npmjs.org/"
- npm ci --cache npm_cache --prefer-offline --no-audit --progress=false
cache:
- key: npm-${CI_COMMIT_REF_SLUG}-12-protected
policy: push
paths:
- npm_cache/
- key: node_modules-${CI_COMMIT_REF_SLUG}-12-protected
policy: push
paths:
- node_modules/
- release/app/node_modules/
- src/node_modules/
.lint_template: &lint
stage: checks
interruptible: true
rules:
- if: '$CI_COMMIT_TAG'
when: never
- if: '$CI_MERGE_REQUEST_ID'
when: always
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
when: always
- if: '$CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH'
when: always
script:
# Ensure cross-env is available locally even if cache fails
- npm run lint
cache:
- key: npm-${CI_COMMIT_REF_SLUG}-12-protected
policy: pull
paths:
- npm_cache/
- key: node_modules-${CI_COMMIT_REF_SLUG}-12-protected
policy: pull
paths:
- node_modules/
- release/app/node_modules/
- src/node_modules/
.test_template: &test
stage: checks
interruptible: true
rules:
- if: '$CI_COMMIT_TAG'
when: never
- if: '$CI_MERGE_REQUEST_ID'
when: always
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
when: always
- if: '$CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH'
when: always
script:
- npm run test
cache:
- key: npm-${CI_COMMIT_REF_SLUG}-12-protected
policy: pull
paths:
- npm_cache/
- key: node_modules-${CI_COMMIT_REF_SLUG}-12-protected
policy: pull
paths:
- node_modules/
- release/app/node_modules/
- src/node_modules/
.package_template: &package
interruptible: false
rules:
- if: '$CI_COMMIT_BRANCH =~ /^RELEASE_/'
when: manual
stage: package
cache:
- key: npm-${CI_COMMIT_REF_SLUG}-12-protected
policy: pull
paths:
- npm_cache/
- key: node_modules-${CI_COMMIT_REF_SLUG}-12-protected
policy: pull
paths:
- node_modules/
- release/app/node_modules/
- src/node_modules/
variables:
AWS_ACCESS_KEY_ID: ${AWS_ACCESS_KEY_ID}
AWS_SECRET_ACCESS_KEY: ${AWS_SECRET_ACCESS_KEY}
APTABASE_INT: ${APTABASE_INT}
VIP_SECRET_KEY: ${VIP_SECRET_KEY}
TEST_VAR: ${TEST_VAR}
###################################################################################################
######################################## PREPARE ##################################################
###################################################################################################
install_win:
extends:
- .rbst-windows-runner
<<: *npm_ci
install_linux:
image: $LINUX_IMAGE
<<: *npm_ci
tags:
- rbst-ubuntu-runner
install_macos:
<<: *npm_ci
before_script:
- export PATH="/opt/homebrew/opt/node@18/bin:$PATH" || export PATH="/usr/local/opt/node@18/bin:$PATH"
- node --version # Verify we're using Node.js 18
tags:
- rbst-mac-runner
# install_macos_intel:
# <<: *npm_ci
# tags:
# - koii-macos-intel
###################################################################################################
######################################## TEST #####################################################
###################################################################################################
lint_win:
extends:
- .rbst-windows-runner
needs: ['install_win']
dependencies:
- install_win
stage: checks
script:
- npm ci # Install dependencies again in this job
- npm run lint
lint_linux:
image: $LINUX_IMAGE
needs: ['install_linux']
dependencies:
- install_linux
<<: *lint
tags:
- rbst-ubuntu-runner
lint_macos:
image: $MACOS_IMAGE
needs: ['install_macos']
dependencies:
- install_macos
before_script:
- export PATH="/opt/homebrew/opt/node@18/bin:$PATH" || export PATH="/usr/local/opt/node@18/bin:$PATH"
- node --version # Verify we're using Node.js 18
<<: *lint
tags:
- rbst-mac-runner
test_win:
extends:
- .rbst-windows-runner
stage: checks
needs: ['install_win', 'lint_win']
dependencies:
- install_win
- lint_win
script:
- npm ci # Reinstall dependencies
- npm run test
cache:
- key: node_modules-${CI_COMMIT_REF_SLUG}-12-protected
policy: pull
paths:
- node_modules/
- release/app/node_modules/
- src/node_modules/
test_linux:
image: $LINUX_IMAGE
needs: ['install_linux', 'lint_linux']
dependencies:
- install_linux
- lint_linux
<<: *test
tags:
- rbst-ubuntu-runner
test_macos:
needs: ['install_macos', 'lint_macos']
dependencies:
- install_macos
- lint_macos
before_script:
- export PATH="/opt/homebrew/opt/node@18/bin:$PATH" || export PATH="/usr/local/opt/node@18/bin:$PATH"
- node --version # Verify we're using Node.js 18
- chmod +x node_modules/.bin/*
<<: *test
tags:
- rbst-mac-runner
###################################################################################################
######################################## PACKAGE ##################################################
###################################################################################################
package_win:
extends:
- .rbst-windows-runner
<<: *package
needs: ['lint_win', 'test_win']
script:
- npm ci # Reinstall dependencies to ensure everything is available
- npm run release -- -w
package_linux:
image: $LINUX_IMAGE
<<: *package
needs: ['lint_linux', 'test_linux']
script:
- npm ci # Reinstall dependencies to ensure everything is available
- npm run release
tags:
- rbst-ubuntu-runner
package_macos:
<<: *package
needs: ['lint_macos', 'test_macos']
before_script:
- chmod +x node_modules/.bin/*
script:
- npm ci
- export NODE_OPTIONS="--max-old-space-size=6144"
- npm run release
tags:
- rbst-mac-runner
###################################################################################################
######################################## MIRROR ##################################################
###################################################################################################
mirror_to_github:
stage: mirror
image: $LINUX_IMAGE
needs:
- install_win
- install_linux
- install_macos
- lint_win
- lint_linux
- lint_macos
- test_win
- test_linux
- test_macos
rules:
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
when: always
- when: never
variables:
GIT_STRATEGY: none
script:
# Start fresh
- cd ~
- rm -rf temp-mirror-repo
- mkdir temp-mirror-repo && cd temp-mirror-repo
# Clone the Gitlab repository
- git clone --single-branch --branch="$CI_DEFAULT_BRANCH" --depth=1 "https://oauth2:${GITLAB_MIRRORING_ACCESS_TOKEN}@gitlab.com/koii-network/dev-green/desktop-node.git" original
- cd original
- git lfs fetch --all
- COMMIT_MSG=$(git log -1 --pretty=%B)
- COMMIT_AUTHOR=$(git log -1 --pretty="%an <%ae>")
- COMMIT_DATE=$(git log -1 --pretty=%ad)
# Create new repo
- cd ..
- git init temp-repo
- cd temp-repo
- git lfs install
# Copy content
- cp -r ../original/. .
- rm -rf ../original
# Commit with simple metadata
- git add .
- git config user.name "$(echo $COMMIT_AUTHOR | cut -d '<' -f1)"
- git config user.email "$(echo $COMMIT_AUTHOR | cut -d '<' -f2 | tr -d '>')"
- GIT_COMMITTER_DATE="$COMMIT_DATE" git commit --date="$COMMIT_DATE" -m "$COMMIT_MSG"
# Create and switch to main branch
- git branch -M $CI_DEFAULT_BRANCH
# Configure git pull strategy
- git config pull.rebase false
# Add GitHub remote and fetch
- git remote add github https://${GITHUB_MIRRORING_USERNAME}:${GITHUB_MIRRORING_TOKEN}@github.com/${GITHUB_MIRRORING_REPO_PATH}.git
- git fetch github $CI_DEFAULT_BRANCH
# Merge preserving GitLab files
- git merge --strategy=ours github/$CI_DEFAULT_BRANCH -m "Merge branch 'github/$CI_DEFAULT_BRANCH'"
# Push to GitHub
- git push github $CI_DEFAULT_BRANCH
tags:
- rbst-ubuntu-runner