forked from Pyomo/pyomo
-
Notifications
You must be signed in to change notification settings - Fork 1
/
.travis.yml
128 lines (122 loc) · 5.11 KB
/
.travis.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
branches:
only:
- master
cache: false
language: generic
services:
- docker
env:
global:
- DOCKERHUB_REPOSITORY=pyomo/linux-test-images
# Configure Pyomo to put the configuration directory here (so that it
# is both writable, and will be cleared between test runs
- PYOMO_CONFIG_DIR=${TRAVIS_BUILD_DIR}/config
- COVERAGE_PROCESS_START=${TRAVIS_BUILD_DIR}/coveragerc
- DOCKERENV="-e TAG -e COVERAGE_PROCESS_START -e PYOMO_CONFIG_DIR"
matrix:
- TAG=python_3.8 CATEGORY="nightly"
- TAG=python_3.7 CATEGORY="nightly"
- TAG=python_3.7 CATEGORY="nightly" SLIM=1
- TAG=python_3.7 CATEGORY="smoke" SETUP_OPTIONS="--with-cython"
- TAG=python_3.6 CATEGORY="nightly"
- TAG=python_3.5 CATEGORY="nightly"
- TAG=python_2.7 CATEGORY="nightly" KEY_JOB=1
- TAG=pypy_3 CATEGORY="nightly" DISABLE_COVERAGE=1
- TAG=pypy_2 CATEGORY="nightly" DISABLE_COVERAGE=1
- TAG=anaconda_3 CATEGORY="nightly"
- TAG=anaconda_2 CATEGORY="nightly"
- TAG=python_3.6 CATEGORY="parallel"
- TAG=python_2.7 CATEGORY="parallel"
before_install:
- IMAGE=${DOCKERHUB_REPOSITORY}:${TAG}
- docker pull ${IMAGE}
# (1) We are mounting the current directory onto the
# docker container and giving it a mount location with
# an identical name, which avoids issues with file
# paths in coverage reports.
# (2) We are starting a container in detached mode that
# runs a semi-infinite sleep call. This allows us to
# run separate docker exec commands that keep the state
# of the container between calls.
- export DOC_ID=`docker run -d -v $(pwd):$(pwd) -w $(pwd) ${IMAGE} sleep 10000000000`
# used by codecov when uploading the coverage report
- export CI_ENV=`bash <(curl -s https://codecov.io/env)`
# enable tracking of coverage for subprocesses launched
# during tests
- cp ${TRAVIS_BUILD_DIR}/.coveragerc ${COVERAGE_PROCESS_START}
- echo "data_file=${TRAVIS_BUILD_DIR}/.coverage" >> ${COVERAGE_PROCESS_START}
# commands prefixed by ${DOC} will execute inside the
# running docker container
- export DOC="docker exec ${CI_ENV} ${DOCKERENV} ${DOC_ID}"
install:
# NOTE: pip, setuptools, wheel, coverage, and codecov are all built
# into the docker container. We will upgrade the critical package
# management packages here to reduce the volume of PIP warnings
- ${DOC} pip install -U pip setuptools wheel
- |
if [ -n "$SLIM" ]
then
${DOC} bash -c 'echo ${DOCKER_PYTHON_CORE}; \
for PKG in `pip list --format freeze | cut -d= -f1`; do \
_core=`echo " ${DOCKER_PYTHON_CORE} "|grep " ${PKG} "|wc -l`; \
if test ${_core} -eq 0; then \
pip uninstall -y ${PKG}; \
else \
echo "Preserving ${PKG}; part of DOCKER_PYTHON_CORE"; \
fi; \
done'
fi
# Clone but don't install pyomo-model-libraries
- ${DOC} git clone --quiet https://github.com/Pyomo/pyomo-model-libraries.git
# Install PyUtilib (master branch)
- ${DOC} pip install --quiet git+https://github.com/PyUtilib/pyutilib
# Install this package
- ${DOC} python setup.py develop ${SETUP_OPTIONS}
# Finish setting up coverage tracking for subprocesses
- DOCKER_SITE_PACKAGES=`${DOC} python -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())"`
- |
if [ -z "$DISABLE_COVERAGE" ]
then
${DOC} bash -c "echo 'import coverage; coverage.process_startup()' > ${DOCKER_SITE_PACKAGES}/run_coverage_at_startup.pth"
fi
- ${DOC} pyomo download-extensions
- ${DOC} pyomo build-extensions
script:
- ${DOC} python --version
- ${DOC} pip --version
- ${DOC} pip list
- ${DOC} env | grep -vi SECRET | sort
- ${DOC} test.pyomo -v --cat=$CATEGORY pyomo `pwd`/pyomo-model-libraries
# Run documentation tests
- |
if [ -z "$SLIM" ]; then
${DOC} make -C doc/OnlineDocs doctest -d
fi
after_script:
# Kill the docker container
- docker kill ${DOC_ID}
after_success:
# Combine coverage reports over all subprocesses and upload
- ${DOC} find . -maxdepth 10 -name ".cov*"
- ${DOC} coverage combine
- ${DOC} coverage report -i
- ${DOC} coverage xml -i
- |
i=0
while : ; do
((i+=1))
echo "Uploading coverage to codecov (attempt $i)"
${DOC} codecov --env TAG -X gcov -X s3
if test $? == 0; then
break
elif test $i -ge 4; then
exit 1
fi
DELAY=$(( RANDOM % 30 + 30))
echo "Pausing $DELAY seconds before re-attempting upload"
sleep $DELAY
done
# Trigger PyomoGallery build, but only when building the master branch
# Note: this is disabled unless a token is injected through an
# environment variable
- "if [ -n \"${SECRET_TRAVIS_TOKEN}\" -a -n \"${KEY_JOB}\" -a \"${TRAVIS_PULL_REQUEST}\" == false ]; then curl -s -X POST -H 'Content-Type: application/json' -H 'Accept: application/json' -H 'Travis-API-Version: 3' -H 'Authorization: token ${SECRET_TRAVIS_TOKEN}' -d '{\"request\": {\"branch\": \"master\"}}' https://api.travis-ci.org/repo/Pyomo%2FPyomoGallery/requests; fi"