forked from opensim-org/opensim-core
-
Notifications
You must be signed in to change notification settings - Fork 1
/
.travis.yml
329 lines (287 loc) · 17.5 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
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
# 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=2 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
branches:
except:
# Branches containing Development Proposals do not need to be tested.
# Exclude any branch whose name starts with devprop (case-insensitive).
# For example, devprop-feature and DEVPROP_feature are ignored.
- /^(?i:devprop).*$/
env:
global:
# The python tests look for OPENSIM_HOME.
- OPENSIM_HOME=~/opensim-core
- OPENSIM_DEPENDENCIES_BUILD_DIR=~/opensim_dependencies-build
- OPENSIM_DEPENDENCIES_INSTALL_DIR=~/opensim_dependencies-install
- SWIG_VER=3.0.6
- PATH="$PATH:$TRAVIS_BUILD_DIR/.github"
- USE_CACHE=false
cache: false
addons:
# Dependencies on linux.
apt:
sources:
# For gcc >= 4.8
- ubuntu-toolchain-r-test
# for clang
#- llvm-toolchain-precise-3.5
# For cmake >= 2.8.8 (for CMakePackageConfigHelpers)
- kubuntu-backports
- george-edison55-precise-backports # cmake 3.2.3 / doxygen 1.8.3
packages:
# Must explicitly list cmake-data, otherwise the incorrect
# version of cmake-data will be sought to satisfy the dependencies
# of cmake.
- cmake-data
- cmake
# For Simbody.
- liblapack-dev
- g++-4.9
#- clang-3.5
# 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 avoid being prompted when ssh'ing into sourceforge.
ssh_known_hosts:
# For uploading doxygen.
- web.sourceforge.net
# For deleting old doxygen.
- shell.sourceforge.net
# For uploading binaries.
- frs.sourceforge.net
before_install:
- cd $TRAVIS_BUILD_DIR
# Stop build if comment contains [skip travis].
- if $(git log -n1 --format="%B" | grep --quiet '\[skip travis\]'); then exit; fi
- cmake --version # To help debug any cmake-related issues.
## Avoid bug on OSX (https://github.com/travis-ci/travis-ci/issues/6307)
# This prevents the build from failing with:
# `/Users/travis/build.sh: line 109: shell_session_update: command not found`
- if [ "$TRAVIS_OS_NAME" = "osx" ]; then rvm get head; fi
###########################################################################################################
# Temporary fix until llvm.org/apt is back up. Manually download clang binaries and use them.
- if [[ "$TRAVIS_OS_NAME" = "linux" && $CC = *clang* ]]; then cd && wget http://llvm.org/releases/3.5.0/clang+llvm-3.5.0-x86_64-linux-gnu-ubuntu-14.04.tar.xz; fi
- if [[ "$TRAVIS_OS_NAME" = "linux" && $CC = *clang* ]]; then tar -xJf clang+llvm-3.5.0-x86_64-linux-gnu-ubuntu-14.04.tar.xz; fi
- if [[ "$TRAVIS_OS_NAME" = "linux" && $CC = *clang* ]]; then export CC="$HOME/clang+llvm-3.5.0-x86_64-linux-gnu/bin/clang"; fi
- if [[ "$TRAVIS_OS_NAME" = "linux" && $CXX = *clang* ]]; then export CXX="$HOME/clang+llvm-3.5.0-x86_64-linux-gnu/bin/clang++"; fi
###########################################################################################################
## Ensure that there are no tabs in source code.
# 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).
- cd $TRAVIS_BUILD_DIR
- if grep --line-num --recursive --exclude-dir="*dependencies*" --include={CMakeLists.txt,*.cpp,*.c,*.h} -P "\t" . ; then echo "Tabs found in the lines shown above. See CONTRIBUTING.md about tabs."; false; fi
## 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.9" CC="gcc-4.9"; fi
# Temporary fix until llvm.org/apt is up again. See above.
# - if [[ "$TRAVIS_OS_NAME" = "linux" && "$CXX" = "clang++" ]]; then export CXX="clang++-3.5" CC="clang-3.5"; fi
## Temporary hack to find libblas and liblapack.
# TODO. Currently Simbody is using Travis CI's Ubuntu 14.04 VMs, which link with
# liblapack.so.3 and libblas.so.3. These files don't exist on the 12.04 machines.
- if [ "$TRAVIS_OS_NAME" = "linux" ]; then mkdir ~/lib; fi
- if [ "$TRAVIS_OS_NAME" = "linux" ]; then ln -s /usr/lib/liblapack.so ~/lib/liblapack.so.3; fi
- if [ "$TRAVIS_OS_NAME" = "linux" ]; then ln -s /usr/lib/libblas.so ~/lib/libblas.so.3; fi
- if [ "$TRAVIS_OS_NAME" = "linux" ]; then export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:~/lib; 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 simbody binaries to sourceforge.
- SIMBODYZIP=simbody-latest_${TRAVIS_OS_NAME}_${BTYPE}.zip
- wget https://prdownloads.sourceforge.net/myosin/simbody/$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, based on platform, configuration, etc.
# Initialize environment variable.
- export TESTS_TO_EXCLUDE="unmatched" # This is just for the regex.
## If we are building in debug, there are some tests to ignore.
- if [ "$BTYPE" = "Debug" ]; then export TESTS_TO_EXCLUDE="$TESTS_TO_EXCLUDE|testOptimizationExample|testCMCGait10dof18musc"; fi
## Set compiler flags.
- export CXX_FLAGS="-Werror -Wno-tautological-undefined-compare -Wno-undefined-bool-conversion"
- if [ "$TRAVIS_OS_NAME" = "osx" ]; then export CXX_FLAGS="$CXX_FLAGS -Wno-inconsistent-missing-override"; fi;
# Run superbuild to download, configure, build and install dependencies.
- mkdir $OPENSIM_DEPENDENCIES_BUILD_DIR
- cd $OPENSIM_DEPENDENCIES_BUILD_DIR
- cmake $TRAVIS_BUILD_DIR/dependencies -DCMAKE_INSTALL_PREFIX=$OPENSIM_DEPENDENCIES_INSTALL_DIR -DCMAKE_BUILD_TYPE=$BTYPE -DSUPERBUILD_simbody=OFF
#######################################################################################################################
# Download the cached build directory, if one exists.
#######################################################################################################################
- BTK_SOURCE_DIR="${TRAVIS_BUILD_DIR}/dependencies/BTK"
- BTK_BUILD_DIR="${OPENSIM_DEPENDENCIES_BUILD_DIR}/BTK"
- source DownloadDepBuildFromCache.sh BTKCore $BTK_SOURCE_DIR $BTK_BUILD_DIR
- make -j8
#######################################################################################################################
# Cache BTK build directory.
#######################################################################################################################
- source UploadBuildToCache.sh BTKCore $BTK_SOURCE_DIR $BTK_BUILD_DIR
# Force some cleanup of homebrew cache so we do not exceed availabe disk space
- if [ "$TRAVIS_OS_NAME" = "osx" ]; then brew cleanup; rm -rf "`brew cache`"; fi
install:
#######################################################################################################################
# Download the cached build directory, if one exists.
#######################################################################################################################
- source DownloadBuildFromCache.sh opensim-core $TRAVIS_BUILD_DIR ~/opensim-core-build
#######################################################################################################################
# Configure OpenSim.
#######################################################################################################################
- cd ~/opensim-core-build
- cmake $TRAVIS_BUILD_DIR -DBUILD_JAVA_WRAPPING=$WRAP -DBUILD_PYTHON_WRAPPING=$WRAP -DSWIG_EXECUTABLE=$HOME/swig/bin/swig -DSIMBODY_HOME=~/simbody -DOPENSIM_DEPENDENCIES_DIR=$OPENSIM_DEPENDENCIES_INSTALL_DIR -DCMAKE_INSTALL_PREFIX=$OPENSIM_HOME -DCMAKE_BUILD_TYPE=$BTYPE -DCMAKE_CXX_FLAGS="$CXX_FLAGS" -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/" -DWITH_BTK:BOOL=ON
#######################################################################################################################
# Build OpenSim.
#######################################################################################################################
- BUILD_START_TIMESTAMP=$(date +%s)
# 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;
#######################################################################################################################
# Cache OpenSim build directory if current branch is master.
#######################################################################################################################
- source UploadBuildToCache.sh opensim-core $TRAVIS_BUILD_DIR ~/opensim-core-build
- cd ~/opensim-core-build
script:
#######################################################################################################################
# Find tests to exclude. Add them to TESTS_TO_EXCLUDE.
#######################################################################################################################
- source FindTestsToExclude.sh
# 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.
# Since we use OPENSIM_COPY_DEPENDENCIES=ON, ensure the Python bindings are
# not relying on the original Simbody/BTK libraries but rather the copied
# ones. This should make sure we have the correct RPATH for Simbody/BTK on
# macOS.
- rm -r ~/simbody
# Go to the python wrapping package directory.
- if [ "$WRAP" = "on" ]; then cd $OPENSIM_HOME/lib/python2.7/site-packages; fi
# Run the python tests, verbosely.
- if [ "$WRAP" = "on" ]; then nosetests -v; fi
## Set up ssh for sourceforge.
- if [[ "$DEPLOY" = "yes" || ("$DOXY" = "on" && "$TRAVIS_PULL_REQUEST" != "false") ]]; then PREP_SOURCEFORGE_SSH=0; else PREP_SOURCEFORGE_SSH=1; fi
# Decrypt the private key stored in the repository to the tmp dir.
- if [ $PREP_SOURCEFORGE_SSH = "0" ]; then openssl aes-256-cbc -K $encrypted_b368d71b8a89_key -iv $encrypted_b368d71b8a89_iv -in $TRAVIS_BUILD_DIR/.github/.deploy_myosin_sourceforge_rsa.enc -out /tmp/deploy_myosin_sourceforge_rsa -d; fi
# Start the ssh agent.
- if [ $PREP_SOURCEFORGE_SSH = "0" ]; then eval "$(ssh-agent -s)"; fi
# Register this private key with this client (the travis machine).
- if [ $PREP_SOURCEFORGE_SSH = "0" ]; then chmod 600 /tmp/deploy_myosin_sourceforge_rsa; fi
- if [ $PREP_SOURCEFORGE_SSH = "0" ]; then ssh-add /tmp/deploy_myosin_sourceforge_rsa; fi
## Upload doxygen to server for viewing.
# View resulting doxygen at myosin.sourceforge.net/<pull-request-number>
# https://sourceforge.net/p/forge/documentation/Project%20Web%20Services/
- if [ "$DOXY" = "on" ]; then if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then rsync -az $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 ssh 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 ssh opensim-bot,[email protected] 'cd /home/project-web/myosin/htdocs && find . -mindepth 1 -maxdepth 1 -type d -mtime +30 | xargs rm -rf && shutdown'; fi
before_deploy:
# Zip up the installation using a file name that identifies where
# the binaries were built.
- mkdir ~/to_deploy
- ZIPNAME=opensim-core-latest_${TRAVIS_OS_NAME}_${BTYPE}.zip
# Zip up opensim relative to where it's installed.
- cd $OPENSIM_HOME/../
# Leave symlinks intact.
- zip --symlinks --recurse-paths --quiet ~/to_deploy/$ZIPNAME opensim-core
# SSH for sourceforge is already set up, in the `script:` section.
deploy:
# Uploads to sourceforge.net/projects/myosin
# See https://docs.travis-ci.com/user/deployment/custom/
# '--archive' preserves symlinks.
provider: script
skip_cleanup: true
script: rsync --archive --compress --verbose ~/to_deploy/$ZIPNAME [email protected]:/home/frs/project/myosin/opensim-core/
on:
branch: master
# Upload for both linux (once) and OSX. Might need to modify the condition
# if we change the build matrix.
condition: "$DEPLOY = yes"
# Below is a description of the process for securely uploading files to
# Sourceforge, taken from https://oncletom.io/2016/travis-ssh-deploy/.
#
# The following link is a great page to learn about SSH.
# https://www.digitalocean.com/community/tutorials/understanding-the-ssh-encryption-and-connection-process
#
# Contact chrisdembia if you need the login information for opensim-bot at
# sourceforge, to manage myosin.sourceforge.net.
#
# You must install the travis command-line tool: `gem install travis`
# Locally, from the root of the opensim-core repository:
# Create a 4096-bit RSA key, providing a comment.
# $ ssh-keygen -t rsa -b 4096 -C '[email protected]' -f .github/.deploy_myosin_sourceforge_rsa
# When prompted for a passphrase, just hit enter (twice).
# First make a backup copy of .travis.yml.
# $ cp .travis-ci.yml travis-ci-backup.yml
# Encrypt the private key, add decryption line to .travis.yml.
# $ travis encrypt-file .github/.deploy_myosin_sourceforge_rsa --add
# Manually edit the .travis.yml file to clean up the added lines and restore
# comments to the file; move the decryption line to the before_deploy step.
# Remove the unencrypted private key. DO NOT commmit the unencrypted private
# key.
# $ rm -f .github/.deploy_myosin_sourceforge_rsa
# Move the encrypted key to the .github folder.
# $ mv .deploy_myosin_sourceforge_rsa.enc .github/
# Manually, log into the sourceforge website (user opensim-bot) and add the
# public key (contents of .github/.deploy_myosin_sourceforge_rsa.pub) in
# Profile > SSH Settings.
# Now you can delete the public key file from your local machine.
# Commit the encrypted private key and the changes to .travis.yml.
# $ git commit .travis.yml .github/.deploy_myosin_sourceforge_rsa.enc