-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
515 lines (489 loc) · 16.3 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
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
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
stages:
- images
- lint
- doc
- download
- octave:build
- octave:test
- matlab:build
- matlab:test
- package
- deploy
variables:
GIT_SUBMODULE_STRATEGY: recursive
PACKAGE_REGISTRY_URL: "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/gams_transfer_matlab/${CI_COMMIT_TAG}/"
image_linux:
stage: images
tags:
- linux
image:
name: docker:20.10
services:
- docker:20.10-dind
variables:
DOCKER_TLS_CERTDIR: "/certs"
before_script:
- mkdir -p $HOME/.docker
- echo $DOCKER_AUTH_CONFIG > $HOME/.docker/config.json
script:
- sed -i "s/_matlab_username_/$MATLAB_USERNAME/g" images/linux/runmatlab.sh
- sed -i "s/_matlab_password_/$MATLAB_PASSWORD/g" images/linux/runmatlab.sh
- docker build -t linux/builder images/linux
- docker tag linux/builder $CI_REGISTRY_IMAGE/linux/builder:latest
- docker push $CI_REGISTRY_IMAGE/linux/builder:latest
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
changes:
- images/linux/Dockerfile
when: manual
allow_failure: true
lint:
stage: lint
tags:
- windows-shell
script:
- matlab.exe -batch "addpath('test'); code_issues('exit_on_fail', true)"
only:
- merge_requests
- master
- tags
doc:build:
stage: doc
tags:
- linux
image:
name: $CI_REGISTRY_IMAGE/linux/builder
script:
- mkdir -p build
- doxygen doc/Doxyfile
only:
- merge_requests
- master
- tags
artifacts:
name: doc
paths:
- build/doc/html
expire_in: 30 min
download:linux:
stage: download
tags:
- linux
image:
name: $CI_REGISTRY_IMAGE/linux/builder
script:
- mkdir -p linux/gdx
- curl -o gdx.zip $URL_GDX_LINUX
- unzip gdx.zip -d linux/gdx
only:
- merge_requests
- master
- tags
artifacts:
name: linux:gdx
paths:
- linux/gdx
expire_in: 30 min
download:macos:
stage: download
tags:
- macos
script:
- mkdir -p macos/gdx
- curl -o gdx.zip $URL_GDX_MACOS
- tar -xf gdx.zip -C macos/gdx
only:
- merge_requests
- master
- tags
artifacts:
name: macos:gdx
paths:
- macos/gdx
expire_in: 30 min
download:macos_arm:
stage: download
tags:
- macos-arm64
script:
- mkdir -p macos_arm/gdx
- curl -o gdx.zip $URL_GDX_MACOS_ARM
- tar -xf gdx.zip -C macos_arm/gdx
only:
- merge_requests
- master
- tags
artifacts:
name: macos_arm:gdx
paths:
- macos_arm/gdx
expire_in: 30 min
download:windows:
stage: download
tags:
- windows-shell
script:
- mkdir -p windows/gdx
- curl -o gdx.zip $URL_GDX_WINDOWS
- tar -xf gdx.zip -C windows/gdx
only:
- merge_requests
- master
- tags
artifacts:
name: windows:gdx
paths:
- windows/gdx
expire_in: 30 min
octave:build:linux:
stage: octave:build
tags:
- linux
image:
name: $CI_REGISTRY_IMAGE/linux/builder
needs: [download:linux]
script:
- mkdir -p linux/octave
- cp -r +gams linux/octave
- cd linux/octave
- octave --no-gui --no-window-system --eval "gams.transfer.setup('../../ext/gdx', '../../ext/zlib', 'verbose', $BUILD_VERBOSITY)"
- nm -o `find -name "*mex"` | grep -F GLIBC_2. | grep -v -F 2.2.5 | grep -v -F 2.3.4
only:
- merge_requests
- master
artifacts:
name: linux:octave
paths:
- linux/octave/+gams
expire_in: 30 min
octave:build:macos:
stage: octave:build
tags:
- macos
needs: [download:macos]
script:
- mkdir -p macos/octave
- cp -r +gams macos/octave
- cd macos/octave
- octave --no-gui --no-window-system --eval "gams.transfer.setup('../../ext/gdx', '../../ext/zlib', 'verbose', $BUILD_VERBOSITY)"
only:
- merge_requests
- master
artifacts:
name: macos:octave
paths:
- macos/octave/+gams
expire_in: 30 min
octave:build:macos_arm:
stage: octave:build
tags:
- macos-arm64
needs: [download:macos_arm]
script:
- mkdir -p macos_arm/octave
- cp -r +gams macos_arm/octave
- cd macos_arm/octave
- octave --no-gui --no-window-system --eval "gams.transfer.setup('../../ext/gdx', '../../ext/zlib', 'verbose', $BUILD_VERBOSITY)"
only:
- merge_requests
- master
artifacts:
name: macos_arm:octave
paths:
- macos_arm/octave/+gams
expire_in: 30 min
matlab:build:linux:
stage: matlab:build
tags:
- linux
image:
name: $CI_REGISTRY_IMAGE/linux/builder
needs: [download:linux]
script:
- mkdir -p linux/matlab
- cp -r +gams linux/matlab
- cd linux/matlab
- ~/Documents/MATLAB/runmatlab.sh "mex -setup C -v; mex -setup C++ -v; gams.transfer.setup('../../ext/gdx', '../../ext/zlib', 'verbose', $BUILD_VERBOSITY)"
- nm -o `find -name "*mexa64"` | grep -F GLIBC_2. | grep -v -F 2.2.5 | grep -v -F 2.3.4
only:
- merge_requests
- master
- tags
artifacts:
name: linux:matlab
paths:
- linux/matlab/+gams
expire_in: 30 min
matlab:build:macos:
stage: matlab:build
tags:
- macos
- clarus
needs: [download:macos]
script:
- mkdir -p macos/matlab
- cp -r +gams macos/matlab
- cd macos/matlab
- matlab -nodisplay -nosplash -nodesktop -r "mex -setup C -v; mex -setup C++ -v; gams.transfer.setup('../../ext/gdx', '../../ext/zlib', 'verbose', $BUILD_VERBOSITY)"
only:
- merge_requests
- master
- tags
artifacts:
name: macos:matlab
paths:
- macos/matlab/+gams
expire_in: 30 min
matlab:build:macos_arm:
stage: matlab:build
tags:
- macos-arm64
- stan
needs: [download:macos_arm]
script:
- mkdir -p macos_arm/matlab
- cp -r +gams macos_arm/matlab
- cd macos_arm/matlab
- matlab -nodisplay -nosplash -nodesktop -r "mex -setup C -v; mex -setup C++ -v; gams.transfer.setup('../../ext/gdx', '../../ext/zlib', 'verbose', $BUILD_VERBOSITY)"
only:
- merge_requests
- master
- tags
artifacts:
name: macos_arm:matlab
paths:
- macos_arm/matlab/+gams
expire_in: 30 min
matlab:build:windows:
stage: matlab:build
tags:
- windows-shell
needs: [download:windows]
script:
- mkdir -p windows/matlab
- cp -r +gams windows/matlab
- cd windows/matlab
- matlab.exe -batch "mex -setup C -v; mex -setup C++ -v; gams.transfer.setup('../../ext/gdx', '../../ext/zlib', 'verbose', $BUILD_VERBOSITY)"
only:
- merge_requests
- master
- tags
artifacts:
name: windows:matlab
paths:
- windows/matlab/+gams
expire_in: 30 min
octave:test:linux:
stage: octave:test
tags:
- linux
image:
name: $CI_REGISTRY_IMAGE/linux/builder
needs: [download:linux, octave:build:linux]
before_script:
- PATH=$PWD/linux/gdx:$PATH
script:
- octave --no-gui --no-window-system --path $PWD/test --eval "run_tests('linux/octave', 'working_dir', 'unittest', 'exit_on_fail', true)"
only:
- merge_requests
- master
octave:test:macos:
stage: octave:test
tags:
- macos
needs: [download:macos, octave:build:macos]
before_script:
- PATH=$PWD/macos/gdx:$PATH
script:
- octave --no-gui --no-window-system --path $PWD/test --eval "run_tests('macos/octave', 'working_dir', 'unittest', 'exit_on_fail', true)"
only:
- merge_requests
- master
octave:test:macos_arm:
stage: octave:test
tags:
- macos-arm64
needs: [download:macos_arm, octave:build:macos_arm]
before_script:
- PATH=$PWD/macos_arm/gdx:$PATH
script:
- octave --no-gui --no-window-system --path $PWD/test --eval "run_tests('macos_arm/octave', 'working_dir', 'unittest', 'exit_on_fail', true)"
only:
- merge_requests
- master
matlab:test:linux:
stage: matlab:test
tags:
- linux
image:
name: $CI_REGISTRY_IMAGE/linux/builder
needs: [download:linux, matlab:build:linux]
before_script:
- PATH=$PWD/linux/gdx:$PATH
script:
- ~/Documents/MATLAB/runmatlab.sh "addpath('test'); run_tests('linux/matlab', 'working_dir', 'unittest', 'exit_on_fail', true)"
# - export GAMS_TRANSFER_MATLAB_SUPPORTS_CATEGORICAL=false
# - export GAMS_TRANSFER_MATLAB_SUPPORTS_TABLE=true
# - ~/Documents/MATLAB/runmatlab.sh "addpath('test'); run_tests('linux/matlab', 'working_dir', 'unittest', 'exit_on_fail', true)"
# - export GAMS_TRANSFER_MATLAB_SUPPORTS_CATEGORICAL=true
# - export GAMS_TRANSFER_MATLAB_SUPPORTS_TABLE=false
# - ~/Documents/MATLAB/runmatlab.sh "addpath('test'); run_tests('linux/matlab', 'working_dir', 'unittest', 'exit_on_fail', true)"
# - export GAMS_TRANSFER_MATLAB_SUPPORTS_CATEGORICAL=false
# - export GAMS_TRANSFER_MATLAB_SUPPORTS_TABLE=false
# - ~/Documents/MATLAB/runmatlab.sh "addpath('test'); run_tests('linux/matlab', 'working_dir', 'unittest', 'exit_on_fail', true)"
only:
- merge_requests
- master
matlab:test:macos:
stage: matlab:test
tags:
- macos
- clarus
needs: [download:macos, matlab:build:macos]
before_script:
- PATH=$PWD/macos/gdx:$PATH
script:
- matlab -batch "addpath('test'); run_tests('macos/matlab', 'working_dir', 'unittest', 'exit_on_fail', true)"
- export GAMS_TRANSFER_MATLAB_SUPPORTS_CATEGORICAL=false
- export GAMS_TRANSFER_MATLAB_SUPPORTS_TABLE=true
- matlab -batch "addpath('test'); run_tests('macos/matlab', 'working_dir', 'unittest', 'exit_on_fail', true)"
- export GAMS_TRANSFER_MATLAB_SUPPORTS_CATEGORICAL=true
- export GAMS_TRANSFER_MATLAB_SUPPORTS_TABLE=false
- matlab -batch "addpath('test'); run_tests('macos/matlab', 'working_dir', 'unittest', 'exit_on_fail', true)"
- export GAMS_TRANSFER_MATLAB_SUPPORTS_CATEGORICAL=false
- export GAMS_TRANSFER_MATLAB_SUPPORTS_TABLE=false
- matlab -batch "addpath('test'); run_tests('macos/matlab', 'working_dir', 'unittest', 'exit_on_fail', true)"
only:
- merge_requests
- master
matlab:test:macos_arm:
stage: matlab:test
tags:
- macos-arm64
- stan
needs: [download:macos_arm, matlab:build:macos_arm]
before_script:
- PATH=$PWD/macos_arm/gdx:$PATH
script:
- matlab -batch "addpath('test'); run_tests('macos_arm/matlab', 'working_dir', 'unittest', 'exit_on_fail', true)"
- export GAMS_TRANSFER_MATLAB_SUPPORTS_CATEGORICAL=false
- export GAMS_TRANSFER_MATLAB_SUPPORTS_TABLE=true
- matlab -batch "addpath('test'); run_tests('macos_arm/matlab', 'working_dir', 'unittest', 'exit_on_fail', true)"
- export GAMS_TRANSFER_MATLAB_SUPPORTS_CATEGORICAL=true
- export GAMS_TRANSFER_MATLAB_SUPPORTS_TABLE=false
- matlab -batch "addpath('test'); run_tests('macos_arm/matlab', 'working_dir', 'unittest', 'exit_on_fail', true)"
- export GAMS_TRANSFER_MATLAB_SUPPORTS_CATEGORICAL=false
- export GAMS_TRANSFER_MATLAB_SUPPORTS_TABLE=false
- matlab -batch "addpath('test'); run_tests('macos_arm/matlab', 'working_dir', 'unittest', 'exit_on_fail', true)"
only:
- merge_requests
- master
matlab:test:windows:
stage: matlab:test
tags:
- windows-shell
needs: [download:windows, matlab:build:windows]
before_script:
- $env:Path = "$pwd/windows/gdx;" + $env:Path
script:
- matlab.exe -batch "addpath('test'); run_tests('windows/matlab', 'working_dir', 'unittest', 'exit_on_fail', true)"
- $env:GAMS_TRANSFER_MATLAB_SUPPORTS_CATEGORICAL = 'false'
- $env:GAMS_TRANSFER_MATLAB_SUPPORTS_TABLE = 'true'
- matlab.exe -batch "addpath('test'); run_tests('windows/matlab', 'working_dir', 'unittest', 'exit_on_fail', true)"
- $env:GAMS_TRANSFER_MATLAB_SUPPORTS_CATEGORICAL = 'true'
- $env:GAMS_TRANSFER_MATLAB_SUPPORTS_TABLE = 'false'
- matlab.exe -batch "addpath('test'); run_tests('windows/matlab', 'working_dir', 'unittest', 'exit_on_fail', true)"
- $env:GAMS_TRANSFER_MATLAB_SUPPORTS_CATEGORICAL = 'false'
- $env:GAMS_TRANSFER_MATLAB_SUPPORTS_TABLE = 'false'
- matlab.exe -batch "addpath('test'); run_tests('windows/matlab', 'working_dir', 'unittest', 'exit_on_fail', true)"
only:
- merge_requests
- master
package:
stage: package
tags:
- linux
image:
name: $CI_REGISTRY_IMAGE/linux/builder
script:
- |
for d in linux macos macos_arm windows
do
cd $d/matlab
sudo zip -r gams_transfer_matlab_$d.zip +gams
cd ../..
mv $d/matlab/gams_transfer_matlab_$d.zip .
done
artifacts:
name: release
paths:
- gams_transfer_matlab_linux.zip
- gams_transfer_matlab_macos.zip
- gams_transfer_matlab_macos_arm.zip
- gams_transfer_matlab_windows.zip
expire_in: 30 min
only:
- tags
deploy:gitlab:
stage: deploy
tags:
- linux
image:
name: $CI_REGISTRY_IMAGE/linux/builder
script:
- |
for fn in gams_transfer_matlab_linux.zip gams_transfer_matlab_macos.zip gams_transfer_matlab_macos_arm.zip gams_transfer_matlab_windows.zip
do
curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file $fn ${PACKAGE_REGISTRY_URL}
done
- DESCR=$(grep -Pzo "(?s)GAMS Transfer Matlab $CI_COMMIT_TAG.*?((?=\nGAMS Transfer Matlab v)|$)" CHANGELOG.md | tr -d '\0')
- DESCR=$(sed 1,2d <<< "$DESCR")
- |
release-cli create \
--name "Release $CI_COMMIT_TAG" \
--tag-name $CI_COMMIT_TAG \
--description "$DESCR" \
--assets-link "{\"name\":\"gams_transfer_matlab_linux.zip\",\"url\":\"${PACKAGE_REGISTRY_URL}gams_transfer_matlab_linux.zip\"}" \
--assets-link "{\"name\":\"gams_transfer_matlab_macos.zip\",\"url\":\"${PACKAGE_REGISTRY_URL}gams_transfer_matlab_macos.zip\"}" \
--assets-link "{\"name\":\"gams_transfer_matlab_macos_arm.zip\",\"url\":\"${PACKAGE_REGISTRY_URL}gams_transfer_matlab_macos_arm.zip\"}" \
--assets-link "{\"name\":\"gams_transfer_matlab_windows.zip\",\"url\":\"${PACKAGE_REGISTRY_URL}gams_transfer_matlab_windows.zip\"}"
- mv build/doc/html public/
artifacts:
paths:
- public
only:
- tags
deploy:github:
stage: deploy
tags:
- linux
image:
name: $CI_REGISTRY_IMAGE/linux/builder
before_script:
- PATH="/opt/github-release:${PATH}"
script:
- DESCR=$(grep -Pzo "(?s)GAMS Transfer Matlab $CI_COMMIT_TAG.*?((?=\nGAMS Transfer Matlab v)|$)" CHANGELOG.md | tr -d '\0')
- DESCR=$(sed 1,2d <<< "$DESCR")
- |
GITHUB_TOKEN=${GITHUB_TOKEN} \
github-release \
-v release \
-u GAMS-dev \
-r transfer-matlab \
-t "${CI_COMMIT_TAG}" \
-d "${DESCR}" \
-n "GAMS Transfer Matlab ${CI_COMMIT_TAG}"
- sleep 10s # make sure the release is available to reference
- |
for fn in gams_transfer_matlab_linux.zip gams_transfer_matlab_macos.zip gams_transfer_matlab_macos_arm.zip gams_transfer_matlab_windows.zip
do
GITHUB_TOKEN=${GITHUB_TOKEN} \
github-release \
-v upload -R \
-u GAMS-dev \
-r transfer-matlab \
-t "${CI_COMMIT_TAG}" \
-n $fn -f $fn
done
only:
- tags