-
Notifications
You must be signed in to change notification settings - Fork 24
380 lines (338 loc) · 14.8 KB
/
build-workflow.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
name: Build and Test
on:
workflow_call:
inputs:
build_type:
description: 'The CMake build type, can be either: Release, Debug, RelWithDebInfo, etc.'
default: Release
required: false
type: string
build_args:
description: 'Additional build parameters'
default: '-DHAS_GAMS=off -DHAS_CPLEX=off -DHAS_GUROBI=off -DCOMPILE_TESTS=on -DSPDLOG_STATIC=on'
required: false
type: string
job_count:
description: 'The amount of jobs to use when building the program and dependencies.'
default: 1
required: false
type: number
# Map the workflow outputs to job outputs
version:
description: 'The version to build SHOT as.'
default: ${{ github.sha }}
required: false
type: string
retention:
description: 'The artifact retention period (in days)'
default: 60
required: false
type: number
upload_artifacts:
description: 'Should the artifacts be uploaded'
default: true
required: false
type: boolean
enable_gurobi:
description: 'Is this a Gurobi build (this will install Gurobi)'
default: false
required: false
type: boolean
enable_gams:
description: 'Is this a GAMS build (this will install GAMS)'
default: false
required: false
type: boolean
artifact_suffix:
description: 'The suffix to add to the artifact name'
default: ''
required: false
type: string
gurobi_version:
description: 'The version of Gurobi to use'
default: '11.0.1'
required: false
type: string
gams_version:
description: 'The version of GAMS to use'
default: '42.3.0'
required: false
type: string
run_benchmarks:
description: 'Should the benchmarks be run'
default: false
required: false
type: boolean
secrets:
gurobi_license:
description: 'Gurobi license file secret'
required: false
gams_license:
description: 'GAMS license file secret'
required: false
OS_USERNAME:
description: 'OpenStack username'
required: false
OS_PASSWORD:
description: 'OpenStack password'
required: false
outputs:
test-artifact:
description: "Test artifact ID"
value: ${{ jobs.build.outputs.test-artifact }}
options-artifact:
description: "SHOT Optionsfile artifact ID"
value: ${{ jobs.build.outputs.options-artifact }}
binary-artifact:
description: "SHOT Binary artifact ID"
value: ${{ jobs.build.outputs.binary-artifact }}
package-artifact:
description: "SHOT Package artifact ID"
value: ${{ jobs.build.outputs.package-artifact }}
library-artifact:
description: "SHOT Libraries artifact ID"
value: ${{ jobs.build.outputs.library-artifact }}
env:
BUILD_TYPE: ${{ inputs.build_type }}
JOB_COUNT: ${{ inputs.job_count }}
VERSION: ${{ inputs.version }}
ARTIFACT_SUFFIX: ${{ inputs.artifact_suffix }}
EXTRA_BUILD_ARGS: ${{ inputs.build_args }}
GRB_LICENSE_FILE: ${{ github.workspace }}/gurobi.lic
GUROBI_VERSION: ${{ inputs.gurobi_version }}
GAMS_VERSION: ${{ inputs.gams_version }}
jobs:
build:
outputs:
test-artifact: ${{ steps.output-artifacts.test }}
options-artifact: ${{ steps.output-artifacts.options }}
binary-artifact: ${{ steps.output-artifacts.binary }}
package-artifact: ${{ steps.output-artifacts.package }}
library-artifact: ${{ steps.output-artifacts.library }}
name: Build SHOT
runs-on: [ self-hosted, linux, cmake ]
env:
GAMS_OPTIONS: -DHAS_GAMS=off
GUROBI_OPTIONS: -DHAS_GUROBI=off
steps:
- name: Cleanup workspace
run: |
sudo rm -rf ./* || true
sudo rm -rf ./.??* || true
- uses: actions/checkout@v3
- name: Checkout submodules
run: git submodule update --init --recursive
- name: Create Build Environment
# Some projects don't allow in-source building, so create a separate build directory
# We'll use this as our working directory for all subsequent commands
run: cmake -E make_directory ${{github.workspace}}/build
- name: Install dependencies
shell: bash
run: sudo apt-get update ; sudo apt-get install -y libc6-dev libbz2-dev zlib1g-dev liblapack-dev libnauty2-dev libopenblas-base libopenblas-dev libmumps-dev pkgconf
- name: Cache Cbc
id: cache-cbc
uses: actions/cache@v3
with:
path: ${{github.workspace}}/ThirdParty/Cbc
key: ${{ runner.os }}-cbc
- name: Cache Ipopt
id: cache-ipopt
uses: actions/cache@v3
with:
path: ${{github.workspace}}/ThirdParty/Ipopt
key: ${{ runner.os }}-ipopt
- name: Setup Coinbrew
if: steps.cache-ipopt.outputs.cache-hit != 'true' || steps.cache-cbc.outputs.cache-hit != 'true'
shell: bash
working-directory: ${{github.workspace}}/build
run: git -C "coinbrew" pull || git clone https://github.com/coin-or/coinbrew
- name: Download and build Ipopt
if: steps.cache-ipopt.outputs.cache-hit != 'true'
shell: bash
working-directory: ${{github.workspace}}/build/coinbrew
run: ./coinbrew build Ipopt --verbosity 2 --prefix=${{github.workspace}}/ThirdParty/Ipopt -j $JOB_COUNT --no-prompt --tests none
- name: Download and build Cbc
if: steps.cache-cbc.outputs.cache-hit != 'true'
shell: bash
working-directory: ${{github.workspace}}/build/coinbrew
run: rm -rf build dist ; ./coinbrew build Cbc@stable/2.10 --verbosity 2 -j $JOB_COUNT --prefix=${{github.workspace}}/ThirdParty/Cbc --no-prompt --tests none --no-third-party
# Proprietary software setup happens here (GAMS and Gurobi)
# First we create the license files from the base64 encoded secrets.
- name: Setup Gurobi License file
if: ${{ inputs.enable_gurobi }}
shell: bash
working-directory: ${{github.workspace}}
run: echo ${{ secrets.gurobi_license }} | base64 -d > $GRB_LICENSE_FILE
- name: Extract Version
id: get_version
run: |
version=${{ env.GUROBI_VERSION }}
major_minor=$(echo $version | awk -F '.' '{print $1 "." $2}')
version_without_dot=$(echo $version | tr -d .)
echo "GUROBI_SHORT_VERSION=$major_minor" >> $GITHUB_ENV
echo "GUROBI_VERSION_WITHOUT_DOT=$version_without_dot" >> $GITHUB_ENV
echo "GRB_INSTALL_PATH=${{ github.workspace }}/ThirdParty/gurobi${version_without_dot}" >> $GITHUB_ENV
# Then we download and install Gurobi
- name: Download Gurobi
if: ${{ inputs.enable_gurobi }}
shell: bash
working-directory: ${{github.workspace}}/ThirdParty
run: wget -q https://packages.gurobi.com/${{ env.GUROBI_SHORT_VERSION }}/gurobi${{ env.GUROBI_VERSION }}_linux64.tar.gz ; tar -xvf gurobi${{ env.GUROBI_VERSION }}_linux64.tar.gz ; rm gurobi${{ env.GUROBI_VERSION }}_linux64.tar.gz
# Finally, we set the environment variables needed for Gurobi to work.
- name: Setup Gurobi environment variables
if: ${{ inputs.enable_gurobi }}
shell: bash
working-directory: ${{github.workspace}}/ThirdParty
run: |
echo "${{ github.workspace }}/ThirdParty/gurobi${{ env.GUROBI_VERSION_WITHOUT_DOT }}/linux64/bin" >> $GITHUB_PATH
echo "GUROBI_HOME=${{ github.workspace }}/ThirdParty/gurobi${{ env.GUROBI_VERSION_WITHOUT_DOT }}/linux64" >> $GITHUB_ENV
echo "LD_LIBRARY_PATH=${{ github.workspace }}/ThirdParty/gurobi${{ env.GUROBI_VERSION_WITHOUT_DOT }}/linux64/lib:$LD_LIBRARY_PATH" >> $GITHUB_ENV
- name: Set Gurobi options
if: ${{ inputs.enable_gurobi }}
shell: bash
run: echo "GUROBI_OPTIONS=-DHAS_GUROBI=on" >> $GITHUB_ENV
- name: Get GAMS short version
id: get_gams_short_version
run: |
version=${{ env.GAMS_VERSION }}
major_minor=$(echo $version | awk -F '.' '{print $1 "." $2}')
echo "GAMS_SHORT_VERSION=$major_minor" >> $GITHUB_ENV
echo "GAMS_INSTALL_PATH=${{ github.workspace }}/ThirdParty/gams${major_minor}_linux_x64_64_sfx" >> $GITHUB_ENV
echo "GAMS_LICENSE_FILE=${{ github.workspace }}/ThirdParty/gams${major_minor}_linux_x64_64_sfx/gamslice.txt" >> $GITHUB_ENV
# Next, we set up GAMS
# Download GAMS
- name: Download GAMS
if: ${{ inputs.enable_gams }}
shell: bash
working-directory: ${{github.workspace}}/ThirdParty
run: wget -q https://d37drm4t2jghv5.cloudfront.net/distributions/${{ env.GAMS_VERSION }}/linux/linux_x64_64_sfx.exe ; chmod +x linux_x64_64_sfx.exe ; ./linux_x64_64_sfx.exe ; rm linux_x64_64_sfx.exe
# Add the license file to the GAMS installation directory
- name: Setup GAMS License file
if: ${{ inputs.enable_gams }}
shell: bash
working-directory: ${{github.workspace}}
run: echo ${{ secrets.gams_license }} | base64 -d > $GAMS_LICENSE_FILE
- name: Install GAMS
if: ${{ inputs.enable_gams }}
shell: bash
working-directory: ${{ github.workspace }}/ThirdParty/gams${{ env.GAMS_SHORT_VERSION }}_linux_x64_64_sfx/
run: ./gamsinst -a
- name: Add GAMS to the path
if: ${{ inputs.enable_gams }}
shell: bash
run: echo "$GAMS_INSTALL_PATH" >> $GITHUB_PATH
- name: Set GAMS options
if: ${{ inputs.enable_gams }}
shell: bash
run: echo "GAMS_OPTIONS=-DHAS_GAMS=on" >> $GITHUB_ENV
- name: Configure CMake
# Uses bash shell, so we can use the same syntax for environment variable
# access regardless of the host operating system
shell: bash
working-directory: ${{github.workspace}}/build
# Here we configure the build, we set the build type,
# enable the tests and set the path to the external libraries.
run: cmake -S $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DHAS_CBC=on -DCBC_DIR=${{github.workspace}}/ThirdParty/Cbc -DHAS_IPOPT=ON -DIPOPT_DIR=${{github.workspace}}/ThirdParty/Ipopt -DGAMS_DIR=$GAMS_INSTALL_PATH -DGUROBI_DIR=$GRB_INSTALL_PATH -DCOMPILE_TESTS=on -DSPDLOG_STATIC=on $GAMS_OPTIONS $GUROBI_OPTIONS -DHAS_CPLEX=off
- name: Build
working-directory: ${{github.workspace}}/build
shell: bash
# We build the job, $BUILD_TYPE can be Release, Debug, RelWithDebInfo.
# $JOB_COUNT is the amount of jobs to use when building the program and dependencies,
# this can be set as an input.
run: cmake --build . --config $BUILD_TYPE -j $JOB_COUNT
- name: Generate Optionsfile
working-directory: ${{github.workspace}}/build
shell: bash
run: ./SHOT --opt
- name: Test
id: test
working-directory: ${{github.workspace}}/build
shell: bash
run: ctest -C $BUILD_TYPE --output-on-failure --output-junit test-output/ctest-junit-output.xml --output-log test-output/ctest-test.log
- name: Construct package
working-directory: ${{github.workspace}}/build
shell: bash
run: make package
- name: Show linked libraries
working-directory: ${{github.workspace}}/build
shell: bash
run: ldd SHOT
# This will always run as we always want the test output, however if the files are not found, we just warn the user.
- uses: actions/upload-artifact@v4
if: ${{ always() }}
name: Upload test results
with:
name: test-logs-${{ env.VERSION }}${{ env.ARTIFACT_SUFFIX }}
path: |
${{github.workspace}}/build/test-output/*.log
${{github.workspace}}/build/test-output/*.xml
retention-days: ${{ inputs.retention }}
- uses: actions/upload-artifact@v4
if: ${{ inputs.upload_artifacts }}
name: Upload SHOT Optionsfile
with:
name: shot-optsfile-${{ env.VERSION }}${{ env.ARTIFACT_SUFFIX }}
path: ${{github.workspace}}/build/SHOT.opt
retention-days: ${{ inputs.retention }}
- uses: actions/upload-artifact@v4
if: ${{ inputs.upload_artifacts }}
name: Upload SHOT File
with:
name: shot-binary-${{ env.VERSION }}${{ env.ARTIFACT_SUFFIX }}
path: ${{github.workspace}}/build/SHOT
retention-days: ${{ inputs.retention }}
- uses: actions/upload-artifact@v4
if: ${{ inputs.upload_artifacts }}
name: Upload SHOT Package file
with:
name: shot-package-${{ env.VERSION }}${{ env.ARTIFACT_SUFFIX }}
path: ${{github.workspace}}/build/SHOT-*-Linux.zip
retention-days: ${{ inputs.retention }}
- uses: actions/upload-artifact@v4
if: ${{ inputs.upload_artifacts }}
name: Upload SHOT Libraries
with:
name: shot-libraries-${{ env.VERSION }}${{ env.ARTIFACT_SUFFIX }}
path: |
${{github.workspace}}/build/*.so
${{github.workspace}}/build/*.a
retention-days: ${{ inputs.retention }}
- name: Output artifact names
id: output-artifacts
if: ${{ inputs.upload_artifacts }}
shell: bash
run: |
echo "test=test-logs-${{ env.VERSION }}${{ env.ARTIFACT_SUFFIX }}" >> $GITHUB_OUTPUT
echo "options=shot-optsfile-${{ env.VERSION }}${{ env.ARTIFACT_SUFFIX }}" >> $GITHUB_OUTPUT
echo "binary=shot-binary-${{ env.VERSION }}${{ env.ARTIFACT_SUFFIX }}" >> $GITHUB_OUTPUT
echo "package=shot-package-${{ env.VERSION }}${{ env.ARTIFACT_SUFFIX }}" >> $GITHUB_OUTPUT
echo "library=shot-libraries-${{ env.VERSION }}${{ env.ARTIFACT_SUFFIX }}" >> $GITHUB_OUTPUT
- name: Output test artifacts
if: ${{ inputs.upload_artifacts }} != true && steps.output-artifacts.outcome != 'success'
shell: bash
run: echo "test=test-logs-${{ env.VERSION }}" >> $GITHUB_OUTPUT
- name: Cleanup license files
if: ${{ success() || failure() }}
shell: bash
run: |
rm -f $GRB_LICENSE_FILE
rm -f $GAMS_LICENSE_FILE
# Finally, we run some simple benchmarks
benchmark:
if: ${{ inputs.run_benchmarks }}
name: Benchmark
uses: ./.github/workflows/benchmarker.yml
needs: [ build ]
with:
shot_executable_path: build
benchmark_folder: "MINLP-convex-small"
benchmark_type: "nl"
enable_gurobi: ${{ inputs.enable_gurobi }}
enable_gams: ${{ inputs.enable_gams }}
gurobi_license_file: ${{ env.GUROBI_LICENSE_FILE }}
gams_license_file: ${{ env.GAMS_LICENSE_FILE }}
secrets:
gurobi_license: ${{ secrets.gurobi_license }}
gams_license: ${{ secrets.gams_license }}
OS_USERNAME: ${{ secrets.OS_USERNAME }}
OS_PASSWORD: ${{ secrets.OS_PASSWORD }}