From 747e41f093c9d0ba9e5943f62ee0552999cd9415 Mon Sep 17 00:00:00 2001
From: Giovanni Bussi <giovanni.bussi@gmail.com>
Date: Sat, 10 Mar 2018 11:05:04 +0100
Subject: [PATCH] Separate repo for coverage scan

Coverage scan is now stored in a separate repository. This allows
generating the manual and the coverage scan in two different travis jobs.

Since this introduces a new travis job (for coverage scan), I removed another
job that was redundant (build with mpi and -O3; notice that we always use -O3
since v2.4). System lapack are now tested on the first job.

Fixes #348
---
 .travis.yml               | 26 +++++++--------
 .travis/{pushdoc => push} | 66 +++++++++++++++++++++++++++++++++------
 2 files changed, 69 insertions(+), 23 deletions(-)
 rename .travis/{pushdoc => push} (67%)

diff --git a/.travis.yml b/.travis.yml
index 0f3e4556d..20ee9d858 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -10,7 +10,12 @@ matrix:
   - os: linux
     dist: trusty
     sudo: required
-    env: PLUMED_CC=mpicc PLUMED_CXX=mpic++ MAKEDOC=yes PLUMED_ALL_TESTS=yes
+    env: PLUMED_CC=mpicc PLUMED_CXX=mpic++ MAKEDOC=yes PLUMED_ALL_TESTS=yes LAPACK=yes
+# coverage scan
+  - os: linux
+    dist: trusty
+    sudo: required
+    env: PLUMED_CC=mpicc PLUMED_CXX=mpic++ MAKECOVERAGE=yes PLUMED_ALL_TESTS=yes
 # the following are with debug flags
   - os: linux
     dist: trusty
@@ -20,17 +25,11 @@ matrix:
     dist: trusty
     sudo: required
     env: PLUMED_CC=mpicc PLUMED_CXX=mpic++ CONFIG_FLAGS="--enable-debug --enable-debug-glibcxx"
-# cppcheck - takes a lot of time to compile the code, so I place it closer
-# to the beginning of the list
+# cppcheck
   - os: linux
     dist: trusty
     sudo: required
     env: CPPCHECK=yes CPPCHECK_VERSION=1.81
-# then check with different optimization flags
-  - os: linux
-    dist: trusty
-    sudo: required
-    env: PLUMED_CC=mpicc   PLUMED_CXX=mpic++     PLUMED_CXXFLAGS=-O3 LAPACK=yes
 # test using external blas with internal lapack
   - os: linux
     if: branch =~ ^test- OR type IN(pull_request)
@@ -130,7 +129,7 @@ install:
 # install doxygen-latex
   - if test "$MAKEDOC" == yes ; then sudo apt-get install -y doxygen-latex ; fi
 # install lcov
-  - if test "$MAKEDOC" == yes ; then ./.travis/install.lcov v1.13 ; fi
+  - if test "$MAKECOVERAGE" == yes ; then ./.travis/install.lcov v1.13 ; fi
 # install numpy and cython for python interface
 # only for linux and homebrew (no macports)
   - if test "$PLUMED_CXX" ; then
@@ -169,9 +168,9 @@ script:
 # enable boost_serialization to test drr module
   - CONFIG_FLAGS="$CONFIG_FLAGS --enable-boost_serialization"
   - if test "$MAKEDOC" == yes ; then CONFIG_FLAGS="$CONFIG_FLAGS --enable-pdfdoc" ; fi
-  - if test "$MAKEDOC" == yes ; then CONFIG_FLAGS="$CONFIG_FLAGS --enable-gcov" ; fi
+  - if test "$MAKECOVERAGE" == yes ; then CONFIG_FLAGS="$CONFIG_FLAGS --enable-gcov" ; fi
 # when running lcov plumed should be compiled with -O0
-  - if test "$MAKEDOC" == yes ; then PLUMED_CXXFLAGS=-O0 ; fi
+  - if test "$MAKECOVERAGE" == yes ; then PLUMED_CXXFLAGS=-O0 ; fi
 
 # BUILD:
 # this is done only if PLUMED_CXX is defined
@@ -203,7 +202,7 @@ script:
 # currently, gcc6 fails for numerical reasons. Once this is fixed we can add the "make -C regtest checkfail" command below
 
   - if test "$MAKEDOC" == yes ; then make -C regtest copytodoc ; fi
-  - if test "$MAKEDOC" == yes ; then make -C developer-doc coverage ; fi
+  - if test "$MAKECOVERAGE" == yes ; then make -C developer-doc coverage ; fi
   - if test "$MAKEDOC" == yes ; then make doc >/dev/null ; fi
   - if test "$PLUMED_CXX" ; then make -C regtest checkfail ; fi
   - if test -n "$PLUMED_MACPORTS" ; then sudo port -N -d test $PLUMED_MACPORTS ; fi
@@ -217,4 +216,5 @@ script:
 # script which check if coding policies are satisfied
   - if test "$CPPCHECK" == yes ; then make codecheck ; fi
 after_success:
-  - if test "$MAKEDOC" == yes ; then ./.travis/pushdoc ; fi 
+  - if test "$MAKEDOC" == yes ; then ./.travis/push doc ; fi 
+  - if test "$MAKECOVERAGE" == yes ; then ./.travis/push coverage ; fi 
diff --git a/.travis/pushdoc b/.travis/push
similarity index 67%
rename from .travis/pushdoc
rename to .travis/push
index d79400680..38b7454fa 100755
--- a/.travis/pushdoc
+++ b/.travis/push
@@ -1,5 +1,14 @@
 #! /bin/bash
 
+WHAT=$1
+
+case "$WHAT" in
+(doc) echo "Pushing documentation" ;;
+(coverage) echo "Pushing coverage" ;;
+(*) echo "ERROR!!"
+    exit 1
+esac
+
 set -e
 set -x
 
@@ -28,24 +37,40 @@ root="$PWD"
 mkdir -p tmp/$$
 cd tmp/$$
 
+
+case "$WHAT" in
+(doc)
 # grab doc
-mkdir user-doc
-cp -R $root/user-doc/{html,manual.pdf} user-doc/
-test -d $root/user-doc/regtests && cp -R $root/user-doc/regtests user-doc/ || true
-mkdir developer-doc
-cp -R $root/developer-doc/html developer-doc/
-test -d $root/developer-doc/coverage && cp -R $root/developer-doc/coverage developer-doc || true
+  mkdir user-doc
+  cp -R $root/user-doc/{html,manual.pdf} user-doc/
+  test -d $root/user-doc/regtests && cp -R $root/user-doc/regtests user-doc/ || true
+  mkdir developer-doc
+  cp -R $root/developer-doc/html developer-doc/
+;;
+(coverage)
+  cp -R $root/developer-doc/coverage .
+esac
+
 
 # This file should be here, it is needed otherwise
 # files beginning with _ are skipped
 touch .nojekyll
 
+case "$WHAT" in
+(doc)
+  home="user-doc/html/index.html"
+  ;;
+(coverage)
+  home="coverage/index.html"
+  ;;
+esac
+
 cat > index.html << EOF
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
 <html>
 <head>
 <title>Page Auto Redirect</title>
-<meta http-equiv="refresh" content ="0; user-doc/html/index.html">
+<meta http-equiv="refresh" content ="0; $home">
 </head>
 <body>
 This is an auto redirect page.
@@ -69,8 +94,11 @@ git config user.name "${GIT_BOT}"
 git checkout -b gh-pages
 # this is not to show the GIT_TOKEN on Travis log
 set +x
-git remote add doc https://${GIT_BOT}:$GIT_TOKEN@github.com/$GIT_OWNER/doc-${TRAVIS_BRANCH}.git
+git remote add doc https://${GIT_BOT}:$GIT_TOKEN@github.com/$GIT_OWNER/${WHAT}-${TRAVIS_BRANCH}.git
 set -x
+
+case "$WHAT" in
+(doc)
 cat > README.md << EOF
 Precompiled manual for PLUMED ${TRAVIS_BRANCH}
 -----------------------------
@@ -80,10 +108,10 @@ git revision [$hash](https://github.com/${GIT_OWNER}/${GIT_REPO}/commit/$hash).
 
 This manual has been compiled on [travis](http://travis-ci.org/${GIT_OWNER}/${GIT_REPO}) on $(date).
 
-To browse the manual you should go [here](http://${GIT_OWNER}.github.io/doc-${TRAVIS_BRANCH}).
+To browse the manual you should go [here](http://${GIT_OWNER}.github.io/${WHAT}-${TRAVIS_BRANCH}).
 
 You can also download a full copy of the manual for offline access
-at [this link](http://github.com/${GIT_OWNER}/doc-${TRAVIS_BRANCH}/archive/gh-pages.zip).
+at [this link](http://github.com/${GIT_OWNER}/${WHAT}-${TRAVIS_BRANCH}/archive/gh-pages.zip).
 
 EOF
 
@@ -93,6 +121,24 @@ case "$branchtype" in
 (master)      echo "This is the manual for the development PLUMED branch." >> README.md ;;
 (unofficial)  echo "This is the manual for an unofficial PLUMED branch. It will not appear on search engines." >> README.md ;;
 esac
+;;
+
+(coverage)
+cat > README.md << EOF
+Coverage scan for PLUMED ${TRAVIS_BRANCH}
+-----------------------------
+
+This repository hosts the coverage scan for [PLUMED](http://www.plumed.org) ${TRAVIS_BRANCH},
+git revision [$hash](https://github.com/${GIT_OWNER}/${GIT_REPO}/commit/$hash).
+
+Coverage scan done on [travis](http://travis-ci.org/${GIT_OWNER}/${GIT_REPO}) on $(date).
+
+To browse the scan you should go [here](http://${GIT_OWNER}.github.io/${WHAT}-${TRAVIS_BRANCH}).
+
+You can also download a full copy of the scan for offline access
+at [this link](http://github.com/${GIT_OWNER}/${WHAT}-${TRAVIS_BRANCH}/archive/gh-pages.zip).
+EOF
+esac
 
 case "$branchtype" in
 (unsupported|unofficial)
-- 
GitLab