Skip to content

Commit

Permalink
Added travis build
Browse files Browse the repository at this point in the history
  • Loading branch information
omodei committed Oct 25, 2019
1 parent bfed239 commit 657b4ce
Show file tree
Hide file tree
Showing 5 changed files with 166 additions and 74 deletions.
34 changes: 34 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
sudo: required

language: generic

matrix:

include:
- os: linux
python: 2.7
env: TRAVIS_PYTHON_VERSION=2.7

- os: osx
python: 2.7
env: TRAVIS_PYTHON_VERSION=2.7

before_install:
- |
if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh
bash miniconda.sh -b -p $HOME/miniconda
export PATH="$HOME/miniconda/bin:$PATH"
conda install -y conda-build
else
# Install Miniconda
wget https://repo.continuum.io/miniconda/Miniconda3-latest-MacOSX-x86_64.sh -O miniconda.sh
bash miniconda.sh -b -p $HOME/miniconda
export PATH="$HOME/miniconda/bin:$PATH"
conda install -y conda-build
fi
script:
- chmod u+x ci/build_and_test.sh
- ./ci/build_and_test.sh

60 changes: 24 additions & 36 deletions build_local.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
#!/usr/bin/env bash
# Make sure we fail in case of errors
set -e

# FLAGS AND ENVIRONMENT:

TRAVIS_OS_NAME="unknown"
UPDATE_CONDA=false
TRAVIS_PYTHON_VERSION=2.7
TRAVIS_BUILD_NUMBER=1

LIBGFORTRAN_VERSION="3.0"
READLINE_VERSION="6.2"

ENVNAME=xsmodelsonly_test_$TRAVIS_PYTHON_VERSION


conda_channel=conda-forge/label/cf201901

if [[ "$OSTYPE" == "linux-gnu" ]]; then

Expand Down Expand Up @@ -32,43 +48,16 @@ else
fi

echo "Running on ${TRAVIS_OS_NAME}"

TRAVIS_PYTHON_VERSION=2.7
TRAVIS_BUILD_NUMBER=0

ENVNAME=xsmodelsonly_test_$TRAVIS_PYTHON_VERSION

echo "Python version: ${TRAVIS_PYTHON_VERSION}"

# Make sure we fail in case of errors
set -e

# Environment
libgfortranver="3.0"

UPDATE_CONDA=false

#if [[ ${TRAVIS_OS_NAME} == linux ]];
#then
# miniconda_os=Linux
# compilers="gcc_linux-64 gxx_linux-64 gfortran_linux-64"
#else # osx
# miniconda_os=MacOSX
# compilers="clang_osx-64 clangxx_osx-64 gfortran_osx-64"
# # On macOS we also need the conda libx11 libraries used to build xspec
# # We also need to pin down ncurses, for now only on macos.
# xorg="xorg-libx11 ncurses=5"
#fi


#conda config --remove channels conda-forge
#conda config --remove channels default

conda_channel=conda-forge/label/cf201901

if $UPDATE_CONDA ; then
# Update conda
echo "Update conda..."
# Updating conda
echo "======================> Updating conda..."
conda update --yes -q conda conda-build
fi

Expand All @@ -84,18 +73,18 @@ conda config --set always_yes true
conda config --set anaconda_upload no

# Create test environment
echo "Create test environment..."
echo " ======================> Creating the test environment..."

conda create --yes --name $ENVNAME -c $conda_channel python=$TRAVIS_PYTHON_VERSION
#libgfortran=${libgfortranver}
conda create --yes --name $ENVNAME -c $conda_channel python=$TRAVIS_PYTHON_VERSION readline=${READLINE_VERSION}
#libgfortran=${LIBGFORTRAN_VERSION}

# Make sure conda-forge is the first channel
conda config --add channels $conda_channel

#conda config --add channels defaults

# Activate test environment
echo "Activate test environment..."
echo "=====================> Activate test environment..."

source $CONDA_PREFIX/etc/profile.d/conda.sh
conda activate $ENVNAME
Expand All @@ -105,12 +94,11 @@ conda activate $ENVNAME
echo "Build package..."
if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
conda build --python=$TRAVIS_PYTHON_VERSION conda_recipe/xspec-modelsonly
#conda index $HOME/work/fermi/miniconda3/conda-bld
conda index $HOME/miniconda/conda-bld
#conda index $HOME/miniconda/conda-bld
else
# there is some strange error about the prefix length
conda build --no-build-id --python=$TRAVIS_PYTHON_VERSION conda_recipe/xspec-modelsonly
conda index $HOME/miniconda/conda-bld
#conda index $HOME/miniconda/conda-bld
fi
echo "======> installing..."
conda install --use-local -c $conda_channel xspec-modelsonly
Expand Down
89 changes: 89 additions & 0 deletions ci/build_and_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
#!/usr/bin/env bash
# Make sure we fail in case of errors
set -e

# FLAGS AND ENVIRONMENT:
LIBGFORTRAN_VERSION="3.0"
READLINE_VERSION="6.2"
UPDATE_CONDA=false

ENVNAME=xsmodelsonly_test_$TRAVIS_PYTHON_VERSION

conda_channel=conda-forge/label/cf201901

if [[ ${TRAVIS_OS_NAME} == linux ]];
then
miniconda_os=Linux
else # osx
miniconda_os=MacOSX
fi

echo "Running on ${TRAVIS_OS_NAME}"
echo "Python version: ${TRAVIS_PYTHON_VERSION}"

if $UPDATE_CONDA ; then
# Updating conda
echo "======================> Updating conda..."
conda update --yes -q conda conda-build
fi

if [[ ${TRAVIS_OS_NAME} == osx ]];
then
conda config --add channels $conda_channel
fi

# Answer yes to all questions (non-interactive)
conda config --set always_yes true

# We will upload explicitly at the end, if successful
conda config --set anaconda_upload no

# Create test environment
echo " ======================> Creating the test environment..."

conda create --yes --name $ENVNAME -c $conda_channel python=$TRAVIS_PYTHON_VERSION readline=${READLINE_VERSION}
#libgfortran=${LIBGFORTRAN_VERSION}

# Make sure conda-forge is the first channel
conda config --add channels $conda_channel

#conda config --add channels defaults

# Activate test environment
echo "=====================> Activate test environment..."

source $CONDA_PREFIX/etc/profile.d/conda.sh
conda activate $ENVNAME

# Build package
echo "Build package..."
if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
conda build --python=$TRAVIS_PYTHON_VERSION conda_recipe/xspec-modelsonly
#conda index $HOME/miniconda/conda-bld
else
# there is some strange error about the prefix length
conda build --no-build-id --python=$TRAVIS_PYTHON_VERSION conda_recipe/xspec-modelsonly
#conda index $HOME/miniconda/conda-bld
fi
echo "======> installing..."
conda install --use-local -c $conda_channel xspec-modelsonly


# UPLOAD TO CONDA:
# If we are on the master branch upload to the channel
if [[ "${TRAVIS_EVENT_TYPE}" == "pull_request" ]]; then
echo "This is a pull request, not uploading to Conda channel"
else
if [[ "${TRAVIS_EVENT_TYPE}" == "push" ]]; then
echo "This is a push to TRAVIS_BRANCH=${TRAVIS_BRANCH}"
if [[ "${TRAVIS_BRANCH}" == "master" ]]; then
conda install -c conda-forge anaconda-client
echo "Uploading ${CONDA_BUILD_PATH}"
if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
anaconda -t $CONDA_UPLOAD_TOKEN upload -u threeml /home/travis/miniconda/conda-bld/linux-64/*.tar.bz2 --force
else
anaconda -t $CONDA_UPLOAD_TOKEN upload -u threeml /Users/travis/miniconda/conda-bld/*/*.tar.bz2 --force
fi
fi
fi
fi
19 changes: 0 additions & 19 deletions conda_recipe/xspec-modelsonly/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,19 @@ cd BUILD_DIR
# We need a custom include and library path to use the packages installed
# in the build environment

echo SRC_DIR="${SRC_DIR}"
echo BUILD_PREFIX=$"{BUILD_PREFIX}"

export CFLAGS="-I$CONDA_PREFIX/include"
export CXXFLAGS="-std=c++11 -Wno-c++11-narrowing -I$CONDA_PREFIX/include"
export LDFLAGS="$LDFLAGS -L$CONDA_PREFIX/lib -L${PREFIX}/lib"

#export CFLAGS="${CFLAGS} -I${PREFIX}/include -O2 -Wall --pedantic -Wno-comment -Wno-long-long -g -ffloat-store -fPIC"
#export CXXFLAGS="${CXXFLAGS} -I${PREFIX}/include -O2 -std=c++11 -Wno-c++11-narrowing -Wall --pedantic -Wno-comment -Wno-long-long -g -ffloat-store -fPIC"
#export CPPFLAGS="${CXXFLAGS} -I${PREFIX}/include"

if [ "$(uname)" == "Linux" ]; then

./configure --prefix=${SRC_DIR}/xspec-modelsonly-build

./hmake 'XSLM_USER_FLAGS="-I${PREFIX}/include"' 'XSLM_USER_LIBS="-L${PREFIX}/lib -lCCfits -lcfitsio -lwcslib -lgfortran"'


fi

if [ "$(uname)" == "Darwin" ]; then

# Build for a fairly old mac to ensure portability

./configure --prefix=${SRC_DIR}/xspec-modelsonly-build
#./hmake 'LDFLAGS_CXX=-lcfitsio -lCCfits -lccfits -lwcs -lgfortran' 'XSLM_USER_FLAGS="-I${PREFIX}/include"' 'XSLM_USER_LIBS="-L${PREFIX}/lib -lCCfits -lcfitsio -lwcslib -lgfortran"'
./hmake 'LDFLAGS_CXX=-headerpad_max_install_names -lcfitsio -lCCfits -lccfits -lwcs -lgfortran' 'XSLM_USER_LIBS="-L${PREFIX}/lib -lCCfits -lcfitsio -lwcslib -lgfortran"'

#make HD_ADD_SHLIB_LIBS=yes
#make install
#./hmake 'LDFLAGS_CXX=-headerpad_max_install_names -lcfitsio -lCCfits -lccfits -lwcs -lgfortran' 'XSLM_USER_LIBS="-L${PREFIX}/lib -lCCfits -lcfitsio -lwcslib -lgfortran"'

fi

make install
Expand Down
38 changes: 19 additions & 19 deletions conda_recipe/xspec-modelsonly/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,29 @@ build:

requirements:
build:
- ccfits 2.5 0
- cfitsio 3.410 2
- gfortran_osx-64 4.8.5 h22b1bf0_3
- libgfortran 3.0.1 h93005f0_2
- libpng 1.6.34 0
- libxcb 1.12 1
- ncurses 5.9 10
- perl 5.20.3.1 2
- pgplot 5.2.2 2
- readline 6.2 0
- toolchain 2.1.2 0
- wcslib 5.18 2
- xorg-kbproto 1.0.7 1
- xorg-libx11 1.6.4 6
- xorg-libxau 1.0.8 3
- xorg-libxdmcp 1.1.2 3
- xorg-xproto 7.0.31 6
- zlib 1.2.11 0
- ccfits 2.5
- cfitsio 3.410
- gfortran_osx-64 # [osx]
- libgfortran 3.0
#- libpng 1.6.34
#- libxcb 1.12
- ncurses 5.9
#- perl 5.20.3.1
#- pgplot 5.2.2
- readline 6.2
- toolchain 2.1.2
- wcslib 5.18
#- xorg-kbproto 1.0.7 1
#- xorg-libx11 1.6.4 6
#- xorg-libxau 1.0.8 3
#- xorg-libxdmcp 1.1.2 3
#- xorg-xproto 7.0.31 6
#- zlib 1.2.11
run:
- cfitsio
- ccfits
- wcslib
- readline 6.2
#- readline 6.2
- libgfortran
- ncurses

Expand Down

0 comments on commit 657b4ce

Please sign in to comment.