Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
111 changes: 91 additions & 20 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,52 +1,123 @@
language: c
# Configuration file for TravisCI

# Use the container builds so we don't need sudo priviledges
sudo: false

sudo: required
language: c

# Only build pushes to select branches and tags. This avoids the double
# builds than happen when working on a branch instead of a fork.
branches:
only:
- master
- 5.4
# Regex to build tagged commits with version numbers
- /\d+\.\d+(\.\d+)?(\S*)?$/

os:
- linux
#- osx
# Set the Ubuntu version for the Linux builds
dist: xenial

# Dependencies for the Linux and OSX builds
addons:
apt:
packages:
- cmake
- build-essential
- libcurl4-gnutls-dev
- libnetcdf-dev
- libgdal1-dev
- libfftw3-dev
- libpcre3-dev
- liblapack-dev
- ghostscript
- curl
- graphicsmagick
- python
- python-pip
homebrew:
packages:
- cmake
- curl
- netcdf
- gdal
- fftw
- pcre2
- ghostscript
- curl
- graphicsmagick
- python

# Define environment variables and set build actions
env:
global:
- INSTALLDIR="$HOME/gmt-install-dir"
- COASTLINEDIR="$HOME/gmt-install-dir/coast"
- PATH="$INSTALLDIR/bin:$PATH"
- LD_LIBRARY_PATH="$INSTALLDIR/lib:$LD_LIBRARY_PATH"
- if [ "$TRAVIS_EVENT_TYPE" == "cron" ]; then
export PYTHON=3.6
export CONDA_INSTALL_EXTRA="sphinx"
export COVERAGE=true
fi
- BUILD_DOCS=false
- TEST=false

# Create the build matrix with different jobs for each platform and cron jobs
matrix:
include:
- name: "Linux (compile only)"
os: linux
if: type != cron
- name: "Linux (cron)"
os: linux
if: type = cron
env:
- TEST="true"
- name: "Mac (compile only)"
os: osx
if: type != cron
- name: "Mac (cron)"
os: osx
if: type = cron
env:
- TEST="true"
# Only build the docs on Linux cron jobs
- name: "Linux (cron - build docs)"
os: linux
if: type = cron
env:
- BUILD_DOCS=true

# Setup the build environment
before_install:
# Install GMT dependencies
- bash ci/travis-setup.sh
- mkdir "$INSTALLDIR"
- mkdir "$COASTLINEDIR"
- bash ci/download-coastlines.sh
# Install GMT documentation dependencies
- if [ "$TRAVIS_EVENT_TYPE" == "cron" ]; then
git clone https://github.com/fatiando/continuous-integration.git;
source continuous-integration/travis/setup-miniconda.sh;
- if [ "$BUILD_DOCS" == "true" ]; then
pip install --user sphinx;
fi

# Install the package that we want to test
install:
# Build and install GMT
- bash ci/travis-build.sh;
- bash ci/build-gmt.sh;

# Run the actual tests and checks
script:
- cd build
- gmt defaults -Vd
- gmt pscoast -R0/10/0/10 -JM6i -Ba -Ggray -P -Vd > test.ps
# Build documentations, tests and coverage reports
- if [ "$TRAVIS_EVENT_TYPE" == "cron" ]; then
cd build; make -j docs_html; cd ..;
cd build; make -j check; cd ..;
- if [ "$TEST" == "true" ]; then
make -j check;
fi
# Upload test coverage even if build fails. Keep separate to make sure this task
# fails if the tests fail.
- if [ "$TEST" == "true" ]; then
bash <(curl -s https://codecov.io/bash);
fi
- if [ "$BUILD_DOCS" == "true" ]; then
make -j docs_html;
fi
- cd ..

# Things to do if the build is successful
#after_success:

notifications:
email: false
53 changes: 53 additions & 0 deletions ci/build-gmt.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/usr/bin/env bash
# Build and install GMT

# To return a failure if any commands inside fail
set -e

cat > cmake/ConfigUser.cmake << 'EOF'
set (CMAKE_INSTALL_PREFIX "$ENV{INSTALLDIR}")
set (GMT_LIBDIR "$ENV{INSTALLDIR}/lib")
set (DCW_ROOT "$ENV{COASTLINEDIR}")
set (GSHHG_ROOT "$ENV{COASTLINEDIR}")
EOF

if [ "$TEST" == "true" ]; then
cat >> cmake/ConfigUser.cmake << 'EOF'
set (CMAKE_BUILD_TYPE Debug)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicate CMAKE_BUILD_TYPE if "COVERAGE" == "true".

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 removed the one inside the if block

enable_testing()
set (DO_EXAMPLES TRUE)
set (DO_TESTS TRUE)
set (DO_ANIMATIONS TRUE)
set (N_TEST_JOBS 2)
set (CMAKE_C_FLAGS "-Wall -Wdeclaration-after-statement -coverage -O0")
EOF
fi
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need to enable the tests in compile-only jobs, so we can change it to:

if [ "$TEST" == "all"]; then
    cat >> cmake/ConfigUser.cmake << 'EOF'
set (CMAKE_BUILD_TYPE Debug)
enable_testing()
set (DO_EXAMPLES TRUE)
set (DO_TESTS TRUE)
set (DO_ANIMATIONS TRUE)
set (N_TEST_JOBS 2)
set (CMAKE_C_FLAGS "-Wall -Wdeclaration-after-statement -coverage -O0")
EOF
fi   

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are any of those required for building the docs?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Never mind, already found it.


echo ""
echo "Using the following cmake configuration:"
cat cmake/ConfigUser.cmake
echo ""

mkdir build && cd build

cmake ..

make -j
make install

# We are fixing the paths to dynamic library files inside library and binary
# files because something in 'make install' is doubling up the path to the
# library files. This only happens on OSX. Anyone who knows how to solve that
# problem is free to contact the maintainers.
if [[ "$TRAVIS_OS_NAME" == "osx" ]];then
install_name_tool -id $INSTALLDIR/lib/libgmt.6.dylib $INSTALLDIR/lib/libgmt.6.dylib
install_name_tool -id $INSTALLDIR/lib/libpostscriptlight.6.dylib $INSTALLDIR/lib/libpostscriptlight.6.dylib
install_name_tool -change $INSTALLDIR/$INSTALLDIR/lib/libgmt.6.dylib $INSTALLDIR/lib/libgmt.6.dylib $INSTALLDIR/lib/gmt/plugins/supplements.so
install_name_tool -change $INSTALLDIR/$INSTALLDIR/lib/libpostscriptlight.6.dylib $INSTALLDIR/lib/libpostscriptlight.6.dylib $INSTALLDIR/lib/gmt/plugins/supplements.so
install_name_tool -change $INSTALLDIR/$INSTALLDIR/lib/libgmt.6.dylib $INSTALLDIR/lib/libgmt.6.dylib $INSTALLDIR/bin/gmt
install_name_tool -change $INSTALLDIR/$INSTALLDIR/lib/libpostscriptlight.6.dylib $INSTALLDIR/lib/libpostscriptlight.6.dylib $INSTALLDIR/bin/gmt
install_name_tool -change $INSTALLDIR/$INSTALLDIR/lib/libpostscriptlight.6.dylib $INSTALLDIR/lib/libpostscriptlight.6.dylib $INSTALLDIR/lib/libgmt.6.dylib
fi

# Turn off exit on failure.
set +e
15 changes: 1 addition & 14 deletions ci/travis-setup.sh → ci/download-coastlines.sh
Original file line number Diff line number Diff line change
@@ -1,27 +1,14 @@
#!/usr/bin/env bash
# Setup TravisCI to be able to build and test GMT
# Download and install the coastlines and boundaries datasets

# To return a failure if any commands inside fail
set -e

# Install dependencies
if [ "$TRAVIS_OS_NAME" == "linux" ]; then
sudo apt-get update
sudo apt-get install -y build-essential cmake libcurl4-gnutls-dev libnetcdf-dev \
libgdal1-dev libfftw3-dev libpcre3-dev liblapack-dev ghostscript curl \
graphicsmagick
else
echo "OSX not supported yet";
fi

# Get the coastlines and country polygons
EXT="tar.gz"
GSHHG="gshhg-gmt-2.3.7"
DCW="dcw-gmt-1.1.4"

mkdir $INSTALLDIR
mkdir $COASTLINEDIR

# GSHHG (coastlines, rivers, and political boundaries):
echo ""
echo "Downloading and unpacking GSHHG"
Expand Down
38 changes: 0 additions & 38 deletions ci/travis-build.sh

This file was deleted.