forked from Pyomo/pyomo
-
Notifications
You must be signed in to change notification settings - Fork 0
749 lines (687 loc) · 25.2 KB
/
test_branches.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
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
name: GitHub Branch CI
on:
push:
branches-ignore:
- main
workflow_dispatch:
inputs:
git-ref:
description: Git Hash (Optional)
required: false
defaults:
run:
shell: bash -l {0}
env:
PYTHONWARNINGS: ignore::UserWarning
PYTHON_CORE_PKGS: wheel
PYPI_ONLY: z3-solver
CACHE_VER: v210812.0
NEOS_EMAIL: [email protected]
jobs:
build:
name: ${{ matrix.TARGET }}/${{ matrix.python }}${{ matrix.other }}
runs-on: ${{ matrix.os }}
timeout-minutes: 120
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
python: ['3.10']
other: [""]
category: [""]
include:
- os: ubuntu-latest
python: '3.10'
TARGET: linux
PYENV: pip
- os: macos-latest
python: 3.8
TARGET: osx
PYENV: pip
- os: windows-latest
python: 3.7
TARGET: win
PYENV: conda
PACKAGES: glpk
- os: ubuntu-latest
python: 3.9
other: /conda
skip_doctest: 1
TARGET: linux
PYENV: conda
PACKAGES: mpi4py openmpi
- os: ubuntu-latest
python: 3.8
other: /mpi
mpi: 3
skip_doctest: 1
TARGET: linux
PYENV: conda
PACKAGES: mpi4py openmpi
- os: ubuntu-latest
python: 3.7
other: /slim
slim: 1
skip_doctest: 1
TARGET: linux
PYENV: pip
- os: ubuntu-latest
python: 3.8
other: /cython
setup_options: --with-cython
skip_doctest: 1
TARGET: linux
PYENV: pip
PACKAGES: cython
- os: windows-latest
python: 3.8
other: /pip
skip_doctest: 1
TARGET: win
PYENV: pip
steps:
- name: Checkout Pyomo source
uses: actions/checkout@v2
- name: Configure job parameters
run: |
JOB="${{matrix.TARGET}}/${{matrix.python}}${{matrix.other}}"
echo "GHA_JOBNAME=$JOB" | sed 's|/|_|g' >> $GITHUB_ENV
if test -z "${{matrix.other}}"; then
echo "GHA_JOBGROUP=${{matrix.TARGET}}" >> $GITHUB_ENV
else
echo "GHA_JOBGROUP=other" >> $GITHUB_ENV
fi
# Note: pandas 1.0.3 causes gams 29.1.0 import to fail in python 3.8
EXTRAS=tests
if test -z "${{matrix.slim}}"; then
EXTRAS="$EXTRAS,docs,optional"
fi
echo "EXTRAS=$EXTRAS" >> $GITHUB_ENV
PYTHON_PACKAGES="${{matrix.PACKAGES}}"
echo "PYTHON_PACKAGES=$PYTHON_PACKAGES" \
| tr '\n' ' ' | sed 's/ \+/ /g' >> $GITHUB_ENV
# Ideally we would cache the conda downloads; however, each cache is
# over 850MB, and with 5 python versions, that would consume 4.2 of
# the 5 GB GitHub allows.
#
#- name: Conda package cache
# uses: actions/cache@v2
# if: matrix.PYENV == 'conda'
# id: conda-cache
# with:
# path: cache/conda
# key: conda-${{env.CACHE_VER}}.0-${{runner.os}}-${{matrix.python}}
- name: Pip package cache
uses: actions/cache@v2
if: matrix.PYENV == 'pip'
id: pip-cache
with:
path: cache/pip
key: pip-${{env.CACHE_VER}}.0-${{runner.os}}-${{matrix.python}}
- name: OS package cache
uses: actions/cache@v2
if: matrix.TARGET != 'osx'
id: os-cache
with:
path: cache/os
key: pkg-${{env.CACHE_VER}}.0-${{runner.os}}
- name: TPL package download cache
uses: actions/cache@v2
id: download-cache
with:
path: cache/download
key: download-${{env.CACHE_VER}}.0-${{runner.os}}
- name: Configure curl
run: |
CURLRC="$(cat <<EOF
retry = 0
max-time = 30
EOF
)"
echo "$CURLRC" > ${GITHUB_WORKSPACE}/.curlrc
echo "$CURLRC" > ${GITHUB_WORKSPACE}/_curlrc
echo "CURL_HOME=$GITHUB_WORKSPACE" >> $GITHUB_ENV
- name: Update OSX
if: matrix.TARGET == 'osx'
run: |
mkdir -p ${GITHUB_WORKSPACE}/cache/os
export HOMEBREW_CACHE=${GITHUB_WORKSPACE}/cache/os
# Be cautious running brew update: it can break
# setup-python on OSX
# brew update
#
# Notes:
# - install glpk
# - pyodbc needs: gcc pkg-config unixodbc freetds
for pkg in bash pkg-config unixodbc freetds glpk; do
brew list $pkg || brew install $pkg
done
- name: Update Linux
if: matrix.TARGET == 'linux'
run: |
mkdir -p ${GITHUB_WORKSPACE}/cache/os
# Notes:
# - install glpk
# - ipopt needs: libopenblas-dev gfortran liblapack-dev
sudo apt-get -o Dir::Cache=${GITHUB_WORKSPACE}/cache/os \
install libopenblas-dev gfortran liblapack-dev glpk-utils
sudo chmod -R 777 ${GITHUB_WORKSPACE}/cache/os
- name: Update Windows
if: matrix.TARGET == 'win'
run: |
echo "SETUPTOOLS_USE_DISTUTILS=local" >> $GITHUB_ENV
- name: Set up Python ${{ matrix.python }}
if: matrix.PYENV == 'pip'
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python }}
- name: Set up Miniconda Python ${{ matrix.python }}
if: matrix.PYENV == 'conda'
uses: conda-incubator/setup-miniconda@v2
with:
auto-update-conda: true
python-version: ${{ matrix.python }}
# GitHub actions is very fragile when it comes to setting up various
# Python interpreters, expecially the setup-miniconda interface.
# Per the setup-miniconda documentation, it is important to always
# invoke bash as a login shell ('shell: bash -l {0}') so that the
# conda environment is properly activated. However, running within
# a login shell appears to foul up the link to python from
# setup-python. Further, we have anecdotal evidence that
# subprocesses invoked through $(python -c ...) and `python -c ...`
# will not pick up the python activated by setup-python on OSX.
#
# Our solution is to define a PYTHON_EXE environment variable that
# can be explicitly called within subprocess calls to reach the
# correct interpreter. Note that we must explicitly run in a *non*
# login shell to set up the environment variable for the
# setup-python environments.
- name: Install Python Packages (pip)
if: matrix.PYENV == 'pip'
shell: bash # DO NOT REMOVE: see note above
run: |
python -c 'import sys;print(sys.executable)'
python -m pip install --cache-dir cache/pip --upgrade pip
PYOMO_DEPENDENCIES=`python setup.py dependencies \
--extras "$EXTRAS" | tail -1`
python -m pip install --cache-dir cache/pip \
${PYTHON_CORE_PKGS} ${PYTHON_PACKAGES} ${PYOMO_DEPENDENCIES}
python -m pip install --cache-dir cache/pip pymysql || \
python -m pip install --cache-dir cache/pip pymysql
if test -z "${{matrix.slim}}"; then
python -m pip install --cache-dir cache/pip cplex \
|| echo "WARNING: CPLEX Community Edition is not available"
python -m pip install --cache-dir cache/pip \
-i https://pypi.gurobi.com gurobipy \
|| echo "WARNING: Gurobi is not available"
python -m pip install --cache-dir cache/pip xpress \
|| echo "WARNING: Xpress Community Edition is not available"
fi
python -c 'import sys; print("PYTHON_EXE=%s" \
% (sys.executable,))' >> $GITHUB_ENV
- name: Install Python packages (conda)
if: matrix.PYENV == 'conda'
run: |
mkdir -p $GITHUB_WORKSPACE/cache/conda
conda config --set always_yes yes
conda config --set auto_update_conda false
conda config --prepend pkgs_dirs $GITHUB_WORKSPACE/cache/conda
conda info
conda config --show-sources
conda list --show-channel-urls
# Note: some pypi packages are not available through conda
PYOMO_DEPENDENCIES=`python setup.py dependencies \
--extras "$EXTRAS" | tail -1`
CONDA_DEPENDENCIES=`echo $PYOMO_DEPENDENCIES | tr ' ' '\n' \
| grep -Ev ${PYPI_ONLY} | tr '\n' ' '`
PYPI_DEPENDENCIES=`echo $PYOMO_DEPENDENCIES | tr ' ' '\n' \
| grep -E ${PYPI_ONLY} | tr '\n' ' '`
conda install -q -y -c conda-forge \
${PYTHON_CORE_PKGS} ${PYTHON_PACKAGES} ${CONDA_DEPENDENCIES}
if test -z "${{matrix.slim}}"; then
conda install -q -y -c ibmdecisionoptimization 'cplex>=12.10' \
|| echo "WARNING: CPLEX Community Edition is not available"
conda install -q -y -c gurobi gurobi \
|| echo "WARNING: Gurobi is not available"
conda install -q -y -c fico-xpress xpress \
|| echo "WARNING: Xpress Community Edition is not available"
for PKG in cyipopt pymumps; do
conda install -q -y -c conda-forge $PKG \
|| echo "WARNING: $PKG is not available"
done
# TODO: This is a hack to stop test_qt.py from running until we
# can better troubleshoot why it fails on GHA
conda remove qt pyqt
fi
# Re-try Pyomo (optional) dependencies with pip
if test -n "$PYPI_DEPENDENCIES"; then
python -m pip install --cache-dir cache/pip $PYPI_DEPENDENCIES
fi
# remember this python interpreter
python -c 'import sys; print("PYTHON_EXE=%s" \
% (sys.executable,))' >> $GITHUB_ENV
#
# conda activate puts itself first in the PATH, which overrides
# any paths we add through GITHUB_PATH. We will update .profile
# to move the local runner paths back to the front (before conda).
for profile in $HOME/.profile $HOME/.bash_profile; do
if test ! -e $profile; then
continue
fi
echo '' >> $profile
echo 'export PATH=`echo "$PATH" \
| tr ":" "\\n" | grep runner | tr "\n" ":"`:`echo "$PATH" \
| tr ":" "\\n" | grep -v runner | tr "\n" ":"`' >> $profile
done
- name: Setup TPL package directories
run: |
TPL_DIR="${GITHUB_WORKSPACE}/cache/tpl"
mkdir -p "$TPL_DIR"
DOWNLOAD_DIR="${GITHUB_WORKSPACE}/cache/download"
mkdir -p "$DOWNLOAD_DIR"
echo "TPL_DIR=$TPL_DIR" >> $GITHUB_ENV
echo "DOWNLOAD_DIR=$DOWNLOAD_DIR" >> $GITHUB_ENV
- name: Install Ipopt
if: ${{ ! matrix.slim }}
run: |
IPOPT_DIR=$TPL_DIR/ipopt
echo "$IPOPT_DIR" >> $GITHUB_PATH
echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$IPOPT_DIR" >> $GITHUB_ENV
mkdir -p $IPOPT_DIR
IPOPT_TAR=${DOWNLOAD_DIR}/ipopt.tar.gz
if test ! -e $IPOPT_TAR; then
echo "...downloading Ipopt"
if test "${{matrix.TARGET}}" == osx; then
echo "IDAES Ipopt not available on OSX"
exit 0
fi
URL=https://github.com/IDAES/idaes-ext
RELEASE=$(curl --max-time 150 --retry 8 \
-L -s -H 'Accept: application/json' ${URL}/releases/latest)
VER=$(echo $RELEASE | sed -e 's/.*"tag_name":"\([^"]*\)".*/\1/')
URL=${URL}/releases/download/$VER
if test "${{matrix.TARGET}}" == linux; then
curl --max-time 150 --retry 8 \
-L $URL/idaes-solvers-ubuntu2004-64.tar.gz \
> $IPOPT_TAR
else
curl --max-time 150 --retry 8 \
-L $URL/idaes-solvers-windows-64.tar.gz \
$URL/idaes-lib-windows-64.tar.gz > $IPOPT_TAR
fi
fi
cd $IPOPT_DIR
tar -xzi < $IPOPT_TAR
echo ""
echo "$IPOPT_DIR"
ls -l $IPOPT_DIR
- name: Install GAMS
if: ${{ ! matrix.slim }}
# We install using Powershell because the GAMS installer hangs
# when launched from bash on Windows
shell: pwsh
run: |
$GAMS_DIR = "${env:TPL_DIR}/gams"
echo "$GAMS_DIR" | `
Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
echo "LD_LIBRARY_PATH=${env:LD_LIBRARY_PATH}:$GAMS_DIR" `
Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
echo "DYLD_LIBRARY_PATH=${env:DYLD_LIBRARY_PATH}:$GAMS_DIR" `
Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
$INSTALLER = "${env:DOWNLOAD_DIR}/gams_install.exe"
$URL = "https://d37drm4t2jghv5.cloudfront.net/distributions/29.1.0"
if ( "${{matrix.TARGET}}" -eq "win" ) {
$URL = "$URL/windows/windows_x64_64.exe"
} elseif ( "${{matrix.TARGET}}" -eq "osx" ) {
$URL = "$URL/macosx/osx_x64_64_sfx.exe"
} else {
$URL = "$URL/linux/linux_x64_64_sfx.exe"
}
if (-not (Test-Path "$INSTALLER" -PathType Leaf)) {
echo "...downloading GAMS"
Invoke-WebRequest -Uri "$URL" -OutFile "$INSTALLER" `
-RetryIntervalSec 30 -MaximumRetryCount 8 -TimeoutSec 150
}
echo "...installing GAMS"
if ( "${{matrix.TARGET}}" -eq "win" ) {
Start-Process -FilePath "$INSTALLER" -ArgumentList `
"/SP- /NORESTART /VERYSILENT /DIR=$GAMS_DIR /NOICONS" `
-Wait
} else {
chmod 777 $INSTALLER
Start-Process -FilePath "$INSTALLER" -ArgumentList `
"-q -d $GAMS_DIR" -Wait
mv $GAMS_DIR/*/* $GAMS_DIR/.
}
echo ""
echo "$GAMS_DIR"
ls -l $GAMS_DIR
- name: Install GAMS Python bindings
if: ${{ ! matrix.slim }}
run: |
GAMS_DIR="${env:TPL_DIR}/gams"
py_ver=$($PYTHON_EXE -c 'import sys;v="_%s%s" % sys.version_info[:2] \
;print(v if v != "_27" else "")')
if test -e $GAMS_DIR/apifiles/Python/api$py_ver; then
echo "Installing GAMS Python bindings"
pushd $GAMS_DIR/apifiles/Python/api$py_ver
$PYTHON_EXE setup.py install
popd
fi
- name: Install BARON
if: ${{ ! matrix.slim }}
shell: pwsh
run: |
$BARON_DIR = "${env:TPL_DIR}/baron"
echo "$BARON_DIR" | `
Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
$URL = "https://www.minlp.com/downloads/xecs/baron/current/"
if ( "${{matrix.TARGET}}" -eq "win" ) {
$INSTALLER = "${env:DOWNLOAD_DIR}/baron_install.exe"
$URL += "baron-win64.exe"
} elseif ( "${{matrix.TARGET}}" -eq "osx" ) {
$INSTALLER = "${env:DOWNLOAD_DIR}/baron_install.zip"
$URL += "baron-osx64.zip"
} else {
$INSTALLER = "${env:DOWNLOAD_DIR}/baron_install.zip"
$URL += "baron-lin64.zip"
}
if (-not (Test-Path "$INSTALLER" -PathType Leaf)) {
echo "...downloading BARON ($URL)"
Invoke-WebRequest -Uri "$URL" -OutFile "$INSTALLER" `
-RetryIntervalSec 30 -MaximumRetryCount 8 -TimeoutSec 150
}
echo "...installing BARON"
if ( "${{matrix.TARGET}}" -eq "win" ) {
Start-Process -FilePath "$INSTALLER" -ArgumentList `
"/SP- /NORESTART /VERYSILENT /DIR=$BARON_DIR /NOICONS" `
-Wait
} else {
unzip -q $INSTALLER
mv baron-* $BARON_DIR
}
echo ""
echo "$BARON_DIR"
ls -l $BARON_DIR
- name: Install GJH_ASL_JSON
if: ${{ ! matrix.slim && matrix.TARGET != 'win' }}
run: |
GJH_DIR="$TPL_DIR/gjh"
echo "${GJH_DIR}" >> $GITHUB_PATH
INSTALL_DIR="${DOWNLOAD_DIR}/gjh"
if test ! -e "$INSTALL_DIR/bin"; then
mkdir -p "$INSTALL_DIR"
INSTALLER="$INSTALL_DIR/gjh_asl_json.zip"
URL="https://codeload.github.com/ghackebeil/gjh_asl_json/zip/master"
curl --max-time 150 --retry 8 -L $URL > $INSTALLER
cd $INSTALL_DIR
unzip -q $INSTALLER
cd gjh_asl_json-master/Thirdparty
./get.ASL
cd ..
make
mv bin "$INSTALL_DIR/bin"
fi
cp -rp "$INSTALL_DIR/bin" "$GJH_DIR"
echo ""
echo "$GJH_DIR"
ls -l $GJH_DIR
- name: Install Pyomo
run: |
echo ""
echo "Clone Pyomo-model-libraries..."
git clone -b main https://github.com/Pyomo/pyomo-model-libraries.git
echo ""
echo "Install Pyomo..."
echo ""
$PYTHON_EXE setup.py develop ${{matrix.setup_options}}
echo ""
echo "Set custom PYOMO_CONFIG_DIR"
echo ""
echo "PYOMO_CONFIG_DIR=${GITHUB_WORKSPACE}/config" >> $GITHUB_ENV
- name: Set up coverage tracking
run: |
if test "${{matrix.TARGET}}" == win; then
COVERAGE_BASE=${GITHUB_WORKSPACE}\\.cover
else
COVERAGE_BASE=${GITHUB_WORKSPACE}/.cover
fi
COVERAGE_RC=${COVERAGE_BASE}_rc
echo "COVERAGE_RCFILE=$COVERAGE_RC" >> $GITHUB_ENV
echo "COVERAGE_PROCESS_START=$COVERAGE_RC" >> $GITHUB_ENV
cp ${GITHUB_WORKSPACE}/.coveragerc ${COVERAGE_RC}
echo "data_file=${COVERAGE_BASE}age" >> ${COVERAGE_RC}
SITE_PACKAGES=$($PYTHON_EXE -c "from distutils.sysconfig import \
get_python_lib; print(get_python_lib())")
echo "Python site-packages: $SITE_PACKAGES"
echo 'import coverage; coverage.process_startup()' \
> ${SITE_PACKAGES}/run_coverage_at_startup.pth
- name: Download and install extensions
if: ${{ ! matrix.slim }}
run: |
echo ""
echo "Pyomo download-extensions"
echo ""
pyomo download-extensions
echo ""
echo "Pyomo build-extensions"
echo ""
pyomo build-extensions --parallel 2
- name: Report pyomo plugin information
run: |
echo "$PATH"
pyomo help --solvers || exit 1
pyomo help --transformations || exit 1
pyomo help --writers || exit 1
- name: Run Pyomo tests
if: matrix.mpi == 0
run: |
CATEGORY=
for cat in ${{matrix.category}}; do
CATEGORY+=" -m $cat"
done
$PYTHON_EXE -m pytest -v \
-W ignore::Warning $CATEGORY \
pyomo `pwd`/pyomo-model-libraries \
`pwd`/examples/pyomobook --junitxml="TEST-pyomo.xml"
- name: Run Pyomo MPI tests
if: matrix.mpi != 0
run: |
# Manually invoke the DAT parser so that parse_table_datacmds.py
# is fully generated by a single process before invoking MPI
$PYTHON_EXE -c "from pyomo.dataportal.parse_datacmds import \
parse_data_commands; parse_data_commands(data='')"
mpirun -np ${{matrix.mpi}} --oversubscribe pytest -v \
--junit-xml=TEST-pyomo-mpi.xml \
-m "mpi" -W ignore::Warning \
pyomo `pwd`/pyomo-model-libraries
- name: Run documentation tests
if: matrix.skip_doctest == 0
run: |
make -C doc/OnlineDocs doctest -d
- name: Process code coverage report
run: |
coverage combine
coverage report -i
coverage xml -i
- name: Record build artifacts
uses: actions/upload-artifact@v2
with:
name: ${{github.job}}_${{env.GHA_JOBGROUP}}-${{env.GHA_JOBNAME}}
path: |
.coverage
coverage.xml
# In general, do not record test results as artifacts to
# manage total artifact storage
# TEST-*.xml
bare-python-env:
name: linux/3.8/bare-env
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout Pyomo source
uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install Pyomo
run: |
echo ""
echo "Install Pyomo..."
echo ""
python setup.py develop
echo ""
echo "Set custom PYOMO_CONFIG_DIR"
echo ""
echo "PYOMO_CONFIG_DIR=${GITHUB_WORKSPACE}/config" >> $GITHUB_ENV
- name: Report pyomo plugin information
run: |
echo "$PATH"
pyomo help --solvers || exit 1
pyomo help --transformations || exit 1
pyomo help --writers || exit 1
- name: Run Pyomo standalone test
run: |
echo ""
echo "Running standalone Pyomo test"
echo ""
python `pwd`/pyomo/environ/tests/standalone_minimal_pyomo_driver.py \
|| exit 1
cover:
name: process-coverage-${{ matrix.TARGET }}
needs: build
if: always() # run even if a build job fails
runs-on: ${{ matrix.os }}
timeout-minutes: 10
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
include:
- os: ubuntu-latest
TARGET: linux
- os: macos-latest
TARGET: osx
- os: windows-latest
TARGET: win
steps:
- name: Checkout Pyomo source
uses: actions/checkout@v2
# We need the source for .codecov.yml and running "coverage xml"
- name: Pip package cache
uses: actions/cache@v2
id: pip-cache
with:
path: cache/pip
key: pip-${{env.CACHE_VER}}.0-${{runner.os}}-3.8
- name: Download build artifacts
uses: actions/download-artifact@v2
with:
path: artifacts
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install Python Packages (pip)
shell: bash # DO NOT REMOVE: see note above
run: |
python -c 'import sys;print(sys.executable)'
python -m pip install --cache-dir cache/pip --upgrade pip
PYOMO_DEPENDENCIES=`python setup.py dependencies \
--extras "tests" | tail -1`
python -m pip install --cache-dir cache/pip \
${PYTHON_CORE_PKGS} ${PYOMO_DEPENDENCIES}
python -c 'import sys; print("PYTHON_EXE=%s" \
% (sys.executable,))' >> $GITHUB_ENV
- name: Install Pyomo
run: |
echo ""
echo "Clone Pyomo-model-libraries..."
git clone https://github.com/Pyomo/pyomo-model-libraries.git
echo ""
echo "Install Pyomo..."
echo ""
$PYTHON_EXE setup.py develop ${{matrix.setup_options}}
echo ""
echo "Set custom PYOMO_CONFIG_DIR"
echo ""
echo "PYOMO_CONFIG_DIR=${GITHUB_WORKSPACE}/config" >> $GITHUB_ENV
- name: Generate parse_table_datacmds
run: |
# Manually invoke the DAT parser so that parse_table_datacmds.py
# is generated before running "coverage xml"
$PYTHON_EXE -c "from pyomo.dataportal.parse_datacmds import \
parse_data_commands; parse_data_commands(data='')"
- name: Update codecov uploader
run: |
set +e
CODECOV="${GITHUB_WORKSPACE}/codecov.sh"
echo "CODECOV=$CODECOV" >> $GITHUB_ENV
for i in `seq 3`; do
echo "Downloading current codecov script (attempt ${i})"
curl -L https://codecov.io/bash -o $CODECOV
if test $? == 0; then
break
fi
DELAY=$(( RANDOM % 30 + 30))
echo "Pausing $DELAY seconds before re-attempting download"
sleep $DELAY
done
if test ! -e $CODECOV; then
echo "Failed to download codecov.sh"
exit 1
fi
- name: Combine coverage reports
if: github.repository_owner == 'Pyomo' || github.ref != 'refs/heads/main'
run: |
set +e
if [ "$GITHUB_EVENT_NAME" == "pull_request" ]; then
SHA=$(jq --raw-output .pull_request.head.sha "$GITHUB_EVENT_PATH")
else
SHA=$GITHUB_SHA
fi
for ARTIFACT in artifacts/*_*${{matrix.TARGET}}_*; do
NAME=`echo $ARTIFACT | cut -d/ -f2`
cp -v $ARTIFACT/.coverage .coverage-$NAME
done
rm -vf .coverage coverage.xml
echo "Build: ${{ matrix.TARGET }}/other"
echo ""
FILES=.coverage-*_other-*
coverage combine --debug=dataio $FILES
if test ! -e .coverage; then
echo "No coverage to upload."
else
coverage xml || coverage xml -i
mv -v coverage.xml coverage-other.xml
fi
echo ""
echo "Build: ${{ matrix.TARGET }}"
echo ""
FILES=.coverage-*_${{matrix.TARGET}}-*
coverage combine --debug=dataio $FILES
rm -vf artifacts/*/*.xml
if test ! -e .coverage; then
echo "No coverage to upload."
else
coverage xml || coverage xml -i
fi
- name: Upload codecov reports
if: github.repository_owner == 'Pyomo' || github.ref != 'refs/heads/main'
uses: codecov/codecov-action@v2
with:
files: coverage.xml
name: ${{ matrix.TARGET }}
flags: ${{ matrix.TARGET }}
fail_ci_if_error: true
- name: Upload other coverage reports
if: |
hashFiles('coverage-other.xml') != '' &&
(github.repository_owner == 'Pyomo' || github.ref != 'refs/heads/main')
uses: codecov/codecov-action@v2
with:
files: coverage-other.xml
name: ${{ matrix.TARGET }}/other
flags: ${{ matrix.TARGET }},other
fail_ci_if_error: true