forked from opensim-org/opensim-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.travis.yml
369 lines (319 loc) · 18.2 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
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
# 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
dist: trusty
# For thread_local support on macOS, we require xcode8 or greater.
# Before 2018, xcode7 was the default. Now that xcode8.3 is the default,
# we no longer need to specify an osx_image.
# https://docs.travis-ci.com/user/reference/osx/#OS-X-Version
# osx_image: xcode8
matrix:
include:
# "cron" means periodic (e.g., daily) builds.
# see https://travis-ci.org/opensim-org/opensim-core/settings
# for our scheduled cron jobs.
- if: type != cron
os: linux
compiler: clang
env: BTYPE=Release WRAP=on DOXY=on NPROC=3 DEPLOY=yes
- if: type != cron
os: linux
compiler: gcc
env: BTYPE=Release WRAP=off DOXY=off NPROC=3 DEPLOY=no
- if: type = cron
os: linux
compiler: clang
env: BTYPE=Debug WRAP=off DOXY=off NPROC=3 DEPLOY=no
- if: type != cron
os: osx
compiler: clang
env: BTYPE=Release WRAP=on DOXY=off NPROC=2 DEPLOY=yes OSX_TARGET=10.10
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.8
- PATH="$PATH:$TRAVIS_BUILD_DIR/.github"
- USE_CCACHE=1
- CCACHE_COMPRESS=1
# For Clang to work with ccache.
- CCACHE_CPP2=1
cache: ccache
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
# python3 as linux and osx are still on python2
- python3
- python3-pip
- python3-numpy
# 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:
# If the Mac builds take too long when building bindings, then we can have the bindings
# (and doxygen) only build if we're going to deploy to sourceforge.
#- if [[ "$TRAVIS_BRANCH" != "master" || "$TRAVIS_PULL_REQUEST" != "false" ]]; then export WRAP=off; export DOXY=off; fi
- 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
# Avoid "Homebrew must be run under Ruby 2.3!"
# https://github.com/PowerShell/PowerShell/issues/5062
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update; 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
- if [[ "$TRAVIS_OS_NAME" = "linux" && "$CXX" = "clang++" ]]; then export CXX="clang++-3.5" CC="clang-3.5"; fi
## Set up ccache.
# Lots of this is borrowed from https://github.com/weitjong/Urho3D/blob/master/.travis.yml.
# Since we install our own Clang, it's not set up for ccache. Workaround:
- if [[ "$TRAVIS_OS_NAME" = "linux" && $CXX = *clang* ]]; then ln -s $(which ccache) $HOME/clang-3.5 && ln -s $(which ccache) $HOME/clang++-3.5 && export PATH=$HOME:$PATH; fi
# Without the following lines, ccache causes clang to not print in color.
- if [[ "$CC" = *clang* ]]; then export CC="$CC -fcolor-diagnostics"; fi;
- if [[ "$CXX" = *clang* ]]; then export CXX="$CXX -fcolor-diagnostics"; fi;
- if [ "$TRAVIS_OS_NAME" = "osx" ]; then brew install ccache; fi
- if [ "$TRAVIS_OS_NAME" = "osx" ]; then PATH=/usr/local/opt/ccache/libexec:$PATH; 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" && "$TRAVIS_OS_NAME" = "linux" ]]; then mkdir ~/doxygen && cd ~/doxygen; fi
- if [[ "$DOXY" = "on" && "$TRAVIS_OS_NAME" = "linux" ]]; then wget https://sourceforge.net/projects/doxygen/files/rel-1.8.10/doxygen-1.8.10.linux.bin.tar.gz; fi
- if [[ "$DOXY" = "on" && "$TRAVIS_OS_NAME" = "linux" ]]; then tar xzf doxygen-1.8.10.linux.bin.tar.gz; fi
- if [[ "$DOXY" = "on" && "$TRAVIS_OS_NAME" = "osx" ]]; then brew install doxygen; 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|testCMCWithControlConstraintsRunningModel"; 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
- DEP_CMAKE_ARGS=($TRAVIS_BUILD_DIR/dependencies -DCMAKE_INSTALL_PREFIX=$OPENSIM_DEPENDENCIES_INSTALL_DIR -DCMAKE_BUILD_TYPE=$BTYPE -DSUPERBUILD_simbody=OFF -DSUPERBUILD_ezc3d=ON)
- if [ "$TRAVIS_OS_NAME" = "osx" ]; then DEP_CMAKE_ARGS+=(-DCMAKE_OSX_DEPLOYMENT_TARGET=$OSX_TARGET); fi
- printf '%s\n' "${DEP_CMAKE_ARGS[@]}"
- cmake "${DEP_CMAKE_ARGS[@]}"
- make -j8
# 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:
#############################################################################
# Configure OpenSim.
#############################################################################
- mkdir ~/opensim-core-build && cd ~/opensim-core-build
## Store CMake arguments in bash array.
# https://stackoverflow.com/questions/1951506/add-a-new-element-to-an-array-without-specifying-the-index-in-bash
- OSIM_CMAKE_ARGS=($TRAVIS_BUILD_DIR -DCMAKE_INSTALL_PREFIX=$OPENSIM_HOME -DCMAKE_BUILD_TYPE=$BTYPE -DCMAKE_CXX_FLAGS="$CXX_FLAGS")
# The deployed binaries are used by the GUI, which requires the non-FHS
# layout.
- OSIM_CMAKE_ARGS+=(-DOPENSIM_INSTALL_UNIX_FHS=OFF)
# The minimum macOS/OSX version we support.
- if [ "$TRAVIS_OS_NAME" = "osx" ]; then OSIM_CMAKE_ARGS+=(-DCMAKE_OSX_DEPLOYMENT_TARGET=$OSX_TARGET); fi
# Dependencies.
- OSIM_CMAKE_ARGS+=(-DSIMBODY_HOME=~/simbody -DOPENSIM_DEPENDENCIES_DIR=$OPENSIM_DEPENDENCIES_INSTALL_DIR -DOPENSIM_C3D_PARSER=ezc3d)
# Build applications
- OSIM_CMAKE_ARGS+=(-DOPENSIM_BUILD_INDIVIDUAL_APPS=ON)
# Bindings.
- OSIM_CMAKE_ARGS+=(-DBUILD_PYTHON_WRAPPING=$WRAP -DBUILD_JAVA_WRAPPING=$WRAP -DSWIG_EXECUTABLE=$HOME/swig/bin/swig)
# On Mac, use system python instead of Homebrew python.
#- if [ "$TRAVIS_OS_NAME" = "osx" ]; then OSIM_CMAKE_ARGS+=(-DPYTHON_EXECUTABLE=/usr/bin/python3); fi
# Doxygen.
- OSIM_CMAKE_ARGS+=(-DOPENSIM_DOXYGEN_USE_MATHJAX=off -DOPENSIM_SIMBODY_DOXYGEN_LOCATION="https://simtk.org/api_docs/simbody/latest/")
- if [[ "$DOXY" = "on" && "$TRAVIS_OS_NAME" = "linux" ]]; then OSIM_CMAKE_ARGS+=(-DDOXYGEN_EXECUTABLE=$HOME/doxygen/doxygen-1.8.10/bin/doxygen); fi
- printf '%s\n' "${OSIM_CMAKE_ARGS[@]}"
- cmake "${OSIM_CMAKE_ARGS[@]}"
#############################################################################
# Build OpenSim.
#############################################################################
# Build java and python C++ wrapper separately to avoid going over the memory limit.
# On OSX, building the bindings separately slows down the build too much.
- if [[ "$WRAP" = "on" && "$TRAVIS_OS_NAME" = "linux" ]]; 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.
# 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/sdk/Python; fi
# Run the python tests, verbosely.
- if [ "$WRAP" = "on" ]; then python3 -m unittest discover --start-directory opensim/tests --verbose; fi
## Set up ssh for sourceforge.
- if [[ "$DEPLOY" = "yes" || ("$DOXY" = "on" && "$TRAVIS_OS_NAME" = "linux" && "$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" && "$TRAVIS_OS_NAME" = "linux" ]]; then if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then rsync -az $OPENSIM_HOME/sdk/doc/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_OS_NAME" = "linux" && "$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
# Set the maximum size of the cache.
# TODO 100 MB is not big enough. Using default limit of 1 GB for now.
#- ccache --max-size 100M
before_cache:
# Show cache statistics.
- ccache --show-stats
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