-
Notifications
You must be signed in to change notification settings - Fork 80
/
.gitlab-ci.yml
356 lines (319 loc) · 10.6 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
stages:
- build
- test
- trigger
- bench
.download_bundle: &download_bundle
- curl --location --header "PRIVATE-TOKEN:$ACCESS_TOKEN" --silent https://gitlab.com/api/v4/snippets/1796163/raw | tr -d '\r' > download.sh
- sh download.sh minizinc-vendor master bundle:${MZNARCH} vendor.zip
- unzip -q vendor.zip
.download_bundle_win: &download_bundle_win
- curl -o download.sh --location --header "PRIVATE-TOKEN:%ACCESS_TOKEN%" --silent https://gitlab.com/api/v4/snippets/1796163/raw
- dos2unix download.sh
- sh download.sh minizinc-vendor master bundle:%MZNARCH% vendor.zip
- unzip -q vendor.zip
variables:
# CCache settings
CCACHE_DIR: "$CI_PROJECT_DIR/.ccache"
CCACHE_MAXSIZE: "100M"
# MacOS deployment settings
MACOSX_DEPLOYMENT_TARGET: "10.9"
CMAKE_OSX_ARCHITECTURES: "x86_64;arm64"
default:
interruptible: true
# ----------- Build MiniZinc -----------
.build:
stage: build
before_script:
- bash download_vendor
script:
- cmake -S . -B build -G"$CMAKE_ARCH" -DCMAKE_BUILD_TYPE=Release -DBUILD_REF=$CI_PIPELINE_ID -DGecode_ROOT="$CI_PROJECT_DIR/vendor/gecode" -DOsiCBC_ROOT="$CI_PROJECT_DIR/vendor/cbc" -DCMAKE_INSTALL_PREFIX="$CI_PROJECT_DIR/minizinc"
- cmake --build build --config Release --target install
artifacts:
paths: [minizinc/]
cache:
key: "$CI_JOB_STAGE:$CI_JOB_NAME"
paths: [.ccache, vendor/]
variables:
CMAKE_C_COMPILER_LAUNCHER: "ccache"
CMAKE_CXX_COMPILER_LAUNCHER: "ccache"
only: [tags, merge_requests, pipelines, develop, master]
build:linux:
extends: .build
image: ghcr.io/minizinc/docker-build-environment:cpp
variables:
MZNARCH: "linux"
CMAKE_ARCH: "Ninja"
tags: [linux, docker]
build:linux-arm64:
extends: .build
image: ghcr.io/minizinc/docker-build-environment:cpp
variables:
MZNARCH: "linux-arm64"
CMAKE_ARCH: "Ninja"
tags: [linux-arm64]
build:musl:
extends: .build
image: ghcr.io/minizinc/docker-build-environment:alpine
variables:
MZNARCH: "musl"
CMAKE_ARCH: "Ninja"
tags: [linux, docker]
build:musl-arm64:
extends: .build
image: ghcr.io/minizinc/docker-build-environment:alpine
variables:
MZNARCH: "musl-arm64"
CMAKE_ARCH: "Ninja"
tags: [linux-arm64]
build:osx:
extends: .build
variables:
MZNARCH: "osx"
CMAKE_ARCH: "Ninja"
tags: [osx, cmake, cpp]
build:win64:
extends: .build
variables:
MZNARCH: "win64"
CMAKE_ARCH: "Ninja"
CMAKE_C_COMPILER_LAUNCHER: "buildcache"
CMAKE_CXX_COMPILER_LAUNCHER: "buildcache"
BUILDCACHE_DIR: "$CI_PROJECT_DIR/.ccache"
BUILDCACHE_MAX_CACHE_SIZE: "104857600"
script:
- cmake -S . -B build -G"%CMAKE_ARCH%" -DCMAKE_BUILD_TYPE=Release -DBUILD_REF=%CI_PIPELINE_ID% -DGecode_ROOT="%CI_PROJECT_DIR%/vendor/gecode" -DOsiCBC_ROOT="%CI_PROJECT_DIR%/vendor/cbc" -DCMAKE_INSTALL_PREFIX="%CI_PROJECT_DIR%/minizinc"
- cmake --build build --config Release --target install
cache:
key: "build_win64"
tags: [win64, cmake, cpp, ninja, buildcache]
# ----------- Test Suite -----------
test:format:
stage: test
image: ghcr.io/minizinc/docker-build-environment:clang-tools
script:
- cmake -S . -B build -GNinja -DCLANG_FORMAT_EXECUTABLE="run-clang-format" -DCLANG_FORMAT_FLAGS="--color always"
- cmake --build build --target format
tags: [linux, docker]
only:
changes:
- "**/*.{cpp,c,h,hh,hpp}"
- .clang-format
refs:
- merge_requests
needs: []
test:analyse:
extends: .build
stage: test
image: ghcr.io/minizinc/docker-build-environment:clang-tools
variables:
MZNARCH: "musl"
CMAKE_ARCH: "Ninja"
script:
- cmake -S . -B build -G"$CMAKE_ARCH" -DCMAKE_CXX_CLANG_TIDY="clang-tidy" -DCMAKE_BUILD_TYPE="Debug" -DGecode_ROOT="$CI_PROJECT_DIR/vendor/gecode" -DOsiCBC_ROOT="$CI_PROJECT_DIR/vendor/cbc"
- cmake --build build --config Debug
tags: [linux, docker]
only:
changes:
- "**/*.{cpp,c,h,hh,hpp}"
- .clang-tidy
refs:
- merge_requests
needs: []
.tests:
stage: test
variables:
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
MZN_SOLVER_PATH: "$CI_PROJECT_DIR/vendor/chuffed/share/minizinc/solvers/:$CI_PROJECT_DIR/vendor/gecode/share/minizinc/solvers/"
MZN_TEST_TAGS_PRESENT: gecode_presolver,cbc,cplex,highs,scip,gurobi,xpress
before_script:
- *download_bundle
- export PATH=$CI_PROJECT_DIR/minizinc/bin:$PATH
- minizinc --solvers
- cd tests
- python3 -m venv env
- source env/bin/activate
- pip install -r requirements.txt
after_script:
- echo "Test results at https://minizinc.gitlab.io/-/minizinc/-/jobs/${CI_JOB_ID}/artifacts/tests/output/report.html"
artifacts:
when: always
paths:
- tests/output/
reports:
junit: tests/output/junit*.xml
cache:
key: "$CI_JOB_STAGE:$CI_JOB_NAME"
paths: [.cache/pip, vendor.zip*]
only: [merge_requests, pipelines, master]
# Linux specific config
.tests_linux:
extends: .tests
image: python:3.11
variables:
MZNARCH: "linux"
LD_LIBRARY_PATH: "$CI_PROJECT_DIR/vendor/highs/lib64"
tags: [linux, docker]
dependencies: ["build:linux"]
needs: ["build:linux"]
# OSX specific config
.tests_osx:
extends: .tests
variables:
MZNARCH: "osx"
DYLD_LIBRARY_PATH: "$CI_PROJECT_DIR/vendor/highs/lib"
tags: [osx]
dependencies: ["build:osx"]
needs: ["build:osx"]
# Windows specific config
.tests_win64:
extends: .tests
variables:
MZNARCH: "win64"
MZN_SOLVER_PATH: "$CI_PROJECT_DIR/vendor/chuffed/share/minizinc/solvers/;$CI_PROJECT_DIR/vendor/gecode/share/minizinc/solvers/"
before_script:
- *download_bundle_win
- set PATH=%CI_PROJECT_DIR%/minizinc/bin;%CI_PROJECT_DIR%/vendor/highs/bin;%PATH%
- cd tests
- python -m venv env
- call env\Scripts\activate.bat
- pip install -r requirements.txt
after_script:
- "echo Test results at https://minizinc.gitlab.io/-/minizinc/-/jobs/%CI_JOB_ID%/artifacts/tests/output/report.html"
tags: [win64]
dependencies: ["build:win64"]
needs: ["build:win64"]
cache:
key: test_win64
.tests_fast:
script:
- pytest
.tests_full:
script:
- pytest --all-suites
when: manual
test:linux:fast:
extends: [.tests_linux, .tests_fast]
artifacts:
expose_as: test-linux
test:linux:full:
extends: [.tests_linux, .tests_full]
test:osx:fast:
extends: [.tests_osx, .tests_fast]
artifacts:
expose_as: test-osx
test:osx:full:
extends: [.tests_osx, .tests_full]
test:win64:fast:
extends: [.tests_win64, .tests_fast]
cache:
key: test_win64_fast
artifacts:
expose_as: test-win64
test:win64:full:
extends: [.tests_win64, .tests_full]
cache:
key: test_win64_full
# ------------ Benchmarking -----------
.flatten_benchmark:
stage: bench
variables:
MZNARCH: linux
# Run on SLURM using srun
FLATTEN_PREFIX: srun -w critical001 --nice --mem=8192 -t 10
PARALLEL_JOBS: "-1" # All in parallel, SLURM manages queue
tags: [slurm]
dependencies: ["build:linux"]
needs: ["build:linux"]
before_script:
- cd tests/flattening
- mkdir -p results
# Download instances to benchmark
- curl --location --silent https://gitlab.com/-/snippets/2095682/raw/master/instances.csv | tr -d '\r' > instances.csv
- git clone https://github.com/minizinc/minizinc-benchmarks.git
script:
# Run benchmarks
- python3 flatten.py --minizinc="$CI_PROJECT_DIR/minizinc/bin/minizinc" --prefix-args="$FLATTEN_PREFIX" --args="-G $MZNLIB" --parallel="$PARALLEL_JOBS" instances.csv results/stats.csv
artifacts:
paths:
- tests/flattening/results/
expose_as: $CI_JOB_NAME
cache:
key: "$CI_JOB_STAGE:$CI_JOB_NAME"
paths: [.cache/pip]
# bench:std:
# extends: .flatten_benchmark
# variables:
# MZNLIB: std
# artifacts:
# expose_as: bench-std
# only: [tags, master, develop]
# allow_failure: true
# bench:linear:
# extends: .flatten_benchmark
# variables:
# MZNLIB: linear
# artifacts:
# expose_as: bench-linear
# only: [tags, master, develop]
# allow_failure: true
bench:std:manual:
extends: .flatten_benchmark
variables:
MZNLIB: std
artifacts:
expose_as: bench-std-manual
# only: [merge_requests, pipelines]
only: [merge_requests, pipelines, tags, master, develop]
when: manual
bench:linear:manual:
extends: .flatten_benchmark
variables:
MZNLIB: linear
artifacts:
expose_as: bench-linear-manual
# only: [merge_requests, pipelines]
only: [merge_requests, pipelines, tags, master, develop]
when: manual
# ----------- Documentation -----------
documentation:
stage: test
image: ghcr.io/minizinc/docker-build-environment:sphinx
variables:
MZNARCH: "linux"
before_script:
- *download_bundle
script:
- cp $CI_PROJECT_DIR/vendor/gecode/share/minizinc/gecode/gecode.mzn $CI_PROJECT_DIR/share/minizinc/std/
- cp $CI_PROJECT_DIR/vendor/chuffed/share/minizinc/chuffed/chuffed.mzn $CI_PROJECT_DIR/share/minizinc/std/
- echo 'include "globals.mzn"; include "gecode.mzn"; include "chuffed.mzn"; include "ide/vis.mzn"; include "experimental/all.mzn";' > $CI_PROJECT_DIR/share/minizinc/std/all.mzn
- ./minizinc/bin/mzn2doc --rst-output --include-stdlib --output-base $CI_PROJECT_DIR/docs/en/lib $CI_PROJECT_DIR/share/minizinc/std/all.mzn
- ./minizinc/bin/mzn2doc --rst-output --include-stdlib --output-base $CI_PROJECT_DIR/docs/chi/lib $CI_PROJECT_DIR/share/minizinc/std/all.mzn
- cd $CI_PROJECT_DIR/docs
- make BUILDDIR="en/_build" html latexpdf
- make SPHINXOPTS="-D language=zh_CN" BUILDDIR="chi/_build" html latexpdf
- MZNVERSION=$(python3 "$CI_PROJECT_DIR/docs/utils/minizinc_version.py")
- mkdir -p $CI_PROJECT_DIR/docs-deploy/doc-${MZNVERSION}/en
- mkdir -p $CI_PROJECT_DIR/docs-deploy/doc-${MZNVERSION}/chi
- cp -r $CI_PROJECT_DIR/docs/en/_build/html/* $CI_PROJECT_DIR/docs-deploy/doc-${MZNVERSION}/en/
- cp $CI_PROJECT_DIR/docs/en/_build/latex/MiniZinc.pdf $CI_PROJECT_DIR/docs-deploy/doc-${MZNVERSION}/en/MiniZinc\ Handbook.pdf
- cp -r $CI_PROJECT_DIR/docs/chi/_build/html/* $CI_PROJECT_DIR/docs-deploy/doc-${MZNVERSION}/chi/
- cp $CI_PROJECT_DIR/docs/chi/_build/latex/MiniZinc.pdf $CI_PROJECT_DIR/docs-deploy/doc-${MZNVERSION}/chi/MiniZinc\ Handbook.pdf
- python3 "$CI_PROJECT_DIR/docs/utils/gen_redirects.py" "$CI_PROJECT_DIR/docs-deploy/doc-${MZNVERSION}" "$CI_PROJECT_DIR/docs-deploy/doc-latest"
artifacts:
paths:
- docs-deploy/
expose_as: documentation
tags:
- linux
- docker
only: [tags, merge_requests, pipelines, develop, master]
dependencies: ["build:linux"]
needs: ["build:linux"]
# ----------- Trigger FindMUS pipeline -----------
trigger:findmus:
stage: trigger
trigger:
project: minizinc/FindMUS
branch: develop
only: [develop]