forked from opensim-org/opensim-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.travis.yml
219 lines (193 loc) · 10.7 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
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
# This script is used by the Travis-CI (continuous integration) testing
# service to run opensim-core's tests with every GitHub push or pull-request.
# To learn about this file, go to http://docs.travis-ci.com/user/languages/c/
language: cpp
# Use container-based infrastructure to allow caching (for ccache).
sudo: false
matrix:
include:
- os: linux
compiler: clang
env: BTYPE=RelWithDebInfo WRAP=on DOXY=on NPROC=1 DEPLOY=yes
- os: linux
compiler: gcc
env: BTYPE=RelWithDebInfo WRAP=off DOXY=off NPROC=3 DEPLOY=no
- os: linux
compiler: clang
env: BTYPE=Debug WRAP=off DOXY=off NPROC=3 DEPLOY=yes
- os: osx
compiler: clang
env: BTYPE=RelWithDebInfo WRAP=off DOXY=off NPROC=3 DEPLOY=yes
env:
global:
# The python tests look for OPENSIM_HOME.
- OPENSIM_HOME=~/opensim-core
- SWIG_VER=3.0.5
- USE_CCACHE=1
- CCACHE_COMPRESS=1
# for Clang to work with ccache.
- CCACHE_CPP2=1
cache:
- directories: $HOME/.ccache
addons:
# Dependencies on linux.
apt:
sources:
# For gcc >= 4.8
- ubuntu-toolchain-r-test
# For cmake >= 2.8.8 (for CMakePackageConfigHelpers)
- kubuntu-backports
packages:
- cmake
# For Simbody.
- liblapack-dev
# C++11 on Ubuntu. Update to gcc 4.8, which provides full C++11 support. We
# use this script because if building Simbody with C++11, we need gcc-4.8,
# and the Travis Ubuntu 12.04 machines have an older version of gcc. Even if
# building with Clang, we need the newer libstdc++ that we get by updating to
# gcc-4.8. See https://github.com/travis-ci/travis-ci/issues/979.
- g++-4.8
# In case someone wants to check for memory leaks.
- valgrind
# To build doxygen documentation.
# TOO OLD; see below. - doxygen
# To run the python tests.
- python-nose
# To send a password to ssh.
- sshpass
before_install:
## Set up environment variables.
# Only if compiling with gcc, update environment variables
# to use the new gcc.
- if [ "$CXX" = "g++" ]; then export CXX="g++-4.8" CC="gcc-4.8"; fi
## Set up ccache.
# Lots of this is borrowed from https://github.com/weitjong/Urho3D/blob/master/.travis.yml.
# Put /usr/lib/ccache on the path.
- export PATH=$(whereis -b ccache |grep -o '\S*lib\S*'):$PATH
# For some reason the Travis CI clang compiler toolchain installation does not
# have a symlink in the ccache symlinks directory, so workaround it
- ln -s $(which ccache) $HOME/clang && ln -s $(which ccache) $HOME/clang++ && export PATH=$HOME:$PATH
# Without the following lines, ccache causes clang to not print in color.
- if [ "$CC" == "clang" ]; then export CC="clang -fcolor-diagnostics"; fi;
- if [ "$CXX" == "clang++" ]; then export CX="clang++ -fcolor-diagnostics"; fi;
## Doxygen.
# Need a doxygen that is more recent than that available through apt-get.
- if [ "$DOXY" = "on" ]; then mkdir ~/doxygen && cd ~/doxygen; fi
- if [ "$DOXY" = "on" ]; then wget http://ftp.stack.nl/pub/users/dimitri/doxygen-1.8.10.linux.bin.tar.gz; fi
- if [ "$DOXY" = "on" ]; then tar xzf doxygen-1.8.10.linux.bin.tar.gz; fi
## Install Simbody.
# The Simbody travis script uploads the latestsimbody binaries to bintray.
- SIMBODYZIP=simbody-latest_${TRAVIS_OS_NAME}_${BTYPE}.zip
- wget https://dl.bintray.com/chrisdembia/opensim-testing/$SIMBODYZIP
# Put Simbody in ~/simbody (-q: quiet).
- unzip -q $SIMBODYZIP -d ~
## Install SWIG to build Java/python wrapping.
- if [[ "$WRAP" = "on" ]]; then if [ "$TRAVIS_OS_NAME" = "osx" ]; then brew install pcre; fi; fi
- if [[ "$WRAP" = "on" ]]; then mkdir ~/swig-source && cd ~/swig-source; fi
- if [[ "$WRAP" = "on" ]]; then wget https://github.com/swig/swig/archive/rel-$SWIG_VER.tar.gz; fi
#- wget http://prdownloads.sourceforge.net/swig/$SWIG.tar.gz
- if [[ "$WRAP" = "on" ]]; then tar xzf rel-$SWIG_VER.tar.gz && cd swig-rel-$SWIG_VER; fi
- if [[ "$WRAP" = "on" ]]; then sh autogen.sh && ./configure --prefix=$HOME/swig --disable-ccache && make && make -j8 install; fi
#- ./configure --prefix=$HOME/swig && make && make -j8 install
## Detect if we should check memory leaks with valgrind.
- cd $TRAVIS_BUILD_DIR
- if [ "$TRAVIS_OS_NAME" = "linux" ]; then git log --format=%B --no-merges -n 1 | grep '\[ci valgrind\]'; export RUN_VALGRIND=$?; true; fi
- if [ $RUN_VALGRIND = "0" ]; then export CTEST_FLAGS="-D ExperimentalMemCheck"; fi
## Decide which tests to exclude.
# Initialize environment variable.
- export TESTS_TO_EXCLUDE="unmatched" # This is just for the regex.
## On OSX, we know that testInitState fails; exclude it.
- if [ "$TRAVIS_OS_NAME" = "osx" ]; then export TESTS_TO_EXCLUDE="$TESTS_TO_EXCLUDE|testInitState"; fi
## If we are building in debug, there are some tests to ignore.
- if [ "$BTYPE" = "Debug" ]; then export TESTS_TO_EXCLUDE="$TESTS_TO_EXCLUDE|testInitState|testPrescribedForce|testInducedAccelerations|testAssemblySolver|testCMC|testOptimizationExample|testComponents|testForward"; fi
install:
- mkdir ~/opensim-core-build && cd ~/opensim-core-build
# Configure OpenSim.
- cmake $TRAVIS_BUILD_DIR -DBUILD_JAVA_WRAPPING=$WRAP -DBUILD_PYTHON_WRAPPING=$WRAP -DSWIG_EXECUTABLE=$HOME/swig/bin/swig -DSIMBODY_HOME=~/simbody -DCMAKE_CXX_FLAGS="-Werror" -DCMAKE_INSTALL_PREFIX=$OPENSIM_HOME -DCMAKE_BUILD_TYPE=$BTYPE -DDOXYGEN_EXECUTABLE=$HOME/doxygen/doxygen-1.8.10/bin/doxygen -DOPENSIM_DOXYGEN_USE_MATHJAX=off -DOPENSIM_SIMBODY_DOXYGEN_LOCATION="https://simtk.org/api_docs/simbody/latest/"
# Build OpenSim.
# Build java and python C++ wrapper separately to avoid going over the memory limit.
- if [[ "$WRAP" = "on" ]]; then make -j$NPROC osimTools osimJavaJNI PythonBindings; fi
# Build whatever remains (at least _opensim, tests and examples).
- make -j$NPROC;
script:
# Test OpenSim.
# TODO On Debug, we need to tell travis not to timeout if it doesn't get
# any output for more than 10 minutes. We do this using "travis_wait".
#- if [ "$BTYPE" = "Debug" ]; export NO_TIMEOUT="travis_wait"; fi
- ctest -j8 --output-on-failure $CTEST_FLAGS --exclude-regex $TESTS_TO_EXCLUDE
## Print out valgrind output.
- if [ $RUN_VALGRIND ]; then find Testing/Temporary -name "MemoryCheck*" -print | xargs cat; fi
## Build doxygen documentation.
- if [ "$DOXY" = "on" ]; then make doxygen; fi
## Install OpenSim. Suppress output.
- make -j8 install > /dev/null
## Test python wrapping.
# Add OpenSim libraries to library path.
- if [ "$WRAP" = "on" ]; then export LD_LIBRARY_PATH=$OPENSIM_HOME/lib/x86_64-linux-gnu; fi
# Go to the python wrapping package directory.
- if [ "$WRAP" = "on" ]; then cd $OPENSIM_HOME/share/doc/OpenSim/python; fi
# Run the python tests, verbosely.
- if [ "$WRAP" = "on" ]; then nosetests -v; fi
## Upload doxygen to server for viewing.
# View resulting doxygen at myosin.sourceforge.net/<pull-request-number>
# The `-e "ssh...` is for providing the password andautomatically
# accepting the ssh key.
# https://sourceforge.net/p/forge/documentation/Project%20Web%20Services/
# MYOSIN_SOURCEFORGE_PASSWORD is a hidden environment variable that we set
# at https://travis-ci.org/opensim-org/opensim-core/settings.
- if [ "$DOXY" = "on" ]; then if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then rsync -az -e "sshpass -p rectusfemoris ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" $OPENSIM_HOME/share/doc/OpenSim/html_developer/ [email protected]:/home/project-web/myosin/htdocs/$TRAVIS_PULL_REQUEST; fi; fi
# If we're uploading doxygen, we also want to delete old
# doxygen files from the server so they don't build up indefinitely.
# However, ssh'ing into the server takes a while, so we only do this
# randomly (1% of the time).
- if [[ "$DOXY" = "on" && "$TRAVIS_PULL_REQUEST" != "false" && $(python -c "import random; print(random.random() < 0.01)") = "True" ]]; then CLEAN_UP_MYOSIN=0; else CLEAN_UP_MYOSIN=1; fi
- if [ $CLEAN_UP_MYOSIN = "0" ]; then echo "This build is randomly selected to delete old folders from myosin.sourceforge.net."; fi
# Creates an environment at sourceforge that we can ssh into.
- if [ $CLEAN_UP_MYOSIN = "0" ]; then sshpass -p rectusfemoris ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null opensim-bot,[email protected] create; fi
# Now that the environment is created, we can run a command on the server.
# mindepth and maxdepth makes sure that we only look to delete folders
# in the htdocs folder, and we don't look at subdirectories.
# We only look for folders (`-type d`).
# We delete folders older than 30 days (`-mtime +30`).
# The "shutdown" command shuts down the ssh environment.
- if [ $CLEAN_UP_MYOSIN = "0" ]; then sshpass -p rectusfemoris ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null opensim-bot,[email protected] 'cd /home/project-web/myosin/htdocs && find . -mindepth 1 -maxdepth 1 -type d -mtime +30 | xargs rm -rf && shutdown'; fi
## Ensure that there are no tabs in source code.
- cd $TRAVIS_BUILD_DIR
# GREP returns 0 (true) if there are any matches, and
# we don't want any matches. If there are matches,
# print a helpful message, and make the test fail by using "false".
# The GREP command here checks for any tab characters in the the files
# that match the specified pattern. GREP does not pick up explicit tabs
# (e.g., literally a \t in a source file).
- if grep --recursive --include={CMakeLists.txt,*.cpp,*.c,*.h} -P "\t" . ; then echo "Tabs found in the lines shown above. See CONTRIBUTING.md about tabs."; false; fi
# Maximum size of cache is 100 MB.
# TODO 100 MB is not big enough. Using default limit of 1 GB for now.
#- ccache --max-size 100M
before_cache:
# Show cache statistics.
- if [ "$TRAVIS_OS_NAME" = "linux" ]; then ccache --show-stats; fi
before_deploy:
# Zip up the installation using a file name that identifies where
# the binaries were built.
- mkdir ~/binstar-packages
- ZIPNAME=opensim-core-latest_${TRAVIS_OS_NAME}_${BTYPE}.zip
- # Zip up opensim relative to where it's installed.
- cd $OPENSIM_HOME/../
- zip --recurse-paths --quiet ~/binstar-packages/$ZIPNAME opensim-core
# Paths in the .bintray.json file are relative to the current directory.
- cd ~
deploy:
# Uploads to https://bintray.com/chrisdembia/opensim-testing/opensim-core/view
# https://dl.bintray.com/chrisdembia/opensim-testing/
# See http://docs.travis-ci.com/user/deployment/bintray/ for help.
provider: bintray
file: $TRAVIS_BUILD_DIR/doc/.bintray.json
user: chrisdembia
skip_cleanup: true
# API key is encrypted with travis.
key: $BINTRAY_API_KEY
on:
branch: bintray
# Upload for both linux (once) and OSX. Might need to modify the condition
# if we change the build matrix.
condition: "$DEPLOY = yes"