# these are the different stages for our pipelines
# jobs in the same stage run in parallel 
# next stage doesn't start until previous stage finishes with 'OK'
# by now we only do build and test, we could add another stage "deploy" if
# needed
stages:
  - test

# CentOS7 STAGE
test:centos7.3:
  stage: test
  image: centos:7.3.1611
  before_script:
    - echo "Running centos7.3 'before_script'..."
    - yum -y -q -e 0 install tcl
    - yum -y -q -e 0 install glibc-common
    - yum -y -q -e 0 install glibc-devel
    - yum -y -q -e 0 install make
    - yum -y -q -e 0 install libicu
    - yum -y -q -e 0 install libjpeg-turbo
    - yum -y -q -e 0 install freetype
    - yum -y -q -e 0 install openssl
    - mkdir -p /scicore/soft/modules
    - ln -s /export/soft/apps/centos7/generic /scicore/soft/apps
    - ln -s /export/soft/modules/centos7/generic/all /scicore/soft/modules
    - source /export/soft/lua_lmod/centos7/lmod/lmod/init/bash
    - module use /scicore/soft/modules/all
    - module load foss/2021a
    - module load CMake/3.23.1-GCCcore-10.3.0
    - module load Python/3.9.5-GCCcore-10.3.0
    - module load Eigen/3.4.0-GCCcore-10.3.0
    - module load Boost.Python/1.76.0-GCC-10.3.0
    - module load LibTIFF/.4.2.0-GCCcore-10.3.0
    - module load libpng/.1.6.37-GCCcore-10.3.0
    - module load HH-suite/3.2.0-gompi-2021a
    - *module load Perl/5.28.0-GCCcore-7.3.0
    - module load OpenMM/7.7.0-foss-2021a
    - module load SQLite/3.35.4-GCCcore-10.3.0
    - module load dssp/2.2.1-foss-2021a
    - module load msms/2.6.1-linux-x86_64 
    - module load ClustalW2/2.1-foss-2021a
    - module load networkx/2.5.1-foss-2021a
    - echo "... done running centos7.3 'before_script'."
  script:
  - echo "Testing on CentOS 7..."
  - echo "    Building OST..."
  - mkdir build-ci
  - cd build-ci
  - cmake .. -DENABLE_MM=1
             -DOPEN_MM_LIBRARY=$EBROOTOPENMM/lib/libOpenMM.so
             -DOPEN_MM_PLUGIN_DIR=$EBROOTOPENMM/lib/plugins
             -DOPEN_MM_INCLUDE_DIR=$EBROOTOPENMM/include
             -DCOMPILE_TMTOOLS=1
             -DENABLE_INFO=OFF
             -DENABLE_GFX=OFF
             -DENABLE_GUI=OFF
             -DUSE_NUMPY=1
             -DUSE_RPATH=1
             -DPython_ROOT_DIR=$EBROOTPYTHON
             -DEIGEN3_INCLUDE_DIR=$EBROOTEIGEN/include
             -DFFTW_LIBRARY=$EBROOTFFTW/lib/libfftw3f.a
             -DFFTW_INCLUDE_DIR=$EBROOTFFTW/include
             -DSQLITE3_LIBRARY=$EBROOTSQLITE/lib/libsqlite3.so
             -DSQLITE3_INCLUDE_DIR=$EBROOTSQLITE/include
             -DBOOST_ROOT=$EBROOTBOOST
             -DPNG_LIBRARY=$EBROOTLIBPNG/lib/libpng.so
             -DPNG_PNG_INCLUDE_DIR=$EBROOTLIBPNG/include
             -DZLIB_LIBRARY=$EBROOTZLIB/lib/libz.so
             -DZLIB_INCLUDE_DIR=$EBROOTZLIB/include
             -DTIFF_INCLUDE_DIR=$EBROOTLIBTIFF/include
             -DTIFF_LIBRARY=$EBROOTLIBTIFF/lib/libtiff.so
             -DZLIB_INCLUDE_DIR=$EBROOTZLIB/include
             -DZLIB_LIBRARY=$EBROOTZLIB/lib/libz.so
             -DOPTIMIZE=1
             -DCMAKE_C_FLAGS='-L${EBROOTLIBPNG}/lib/ -L${EBROOTLIBTIFF}/lib/ -L${EBROOTZLIB}/lib/ -isystem ${EBROOTBOOST}/include -isystem ${EBROOTOPENMM}/include'
             -DCMAKE_CXX_FLAGS='-L${EBROOTLIBPNG}/lib/ -L${EBROOTLIBTIFF}/lib/ -L${EBROOTZLIB}/lib/ -isystem ${EBROOTBOOST}/include -isystem ${EBROOTOPENMM}/include'
             -DCMAKE_EXE_LINKER_FLAGS=" -pthread"
  - make -j 2
  - echo "    ... done building OST."
  - echo "    Running unit tests for OST..."  
  - make check
  - echo "    ... done running unit tests for OST..." 
  - echo "... done testing on CentOS 7."
