language: r
r: bioc-release
cache: 
  packages: true
sudo: required
warnings_are_errors: true


bioc_packages: 
  - xcms 
  - msPurityData

# Based on XCMS travis yml created by johannes.rainer https://github.com/sneumann/xcms/blob/master/.travis.yml  
addons:
  apt:
    packages:
      - libnetcdf-dev
      - netcdf-bin # libnetcdf-dev doesn't contain nc-config in ubuntu 12.04 (in 16.04 [xerus] it is part of libnetcdf-dev)
      - libhdf5-dev
      - libgit2-dev # git2r
      - texlive-latex-recommended
      - texlive-fonts-extra

# Set CXX1X for R-devel, as R-devel does not detect CXX1X support for gcc 4.6.3,
# this was causing mzR installation to fail
# see https://bugs.r-project.org/bugzilla3/show_bug.cgi?id=17189
# workaround stolen from https://github.com/hadley/devtools/blob/1ce84b04568ff7846c3da754f28e7e22a23c8737/.travis.yml#L23-L26
before_install:
  - if [[ "$TRAVIS_R_VERSION_STRING" = 'bioc-devel' ]]; then mkdir ~/.R && echo 'CXX1X=g++ -std=c++0x -g -O2 -fPIC' > ~/.R/Makevars; fi

 

jobs:
  include:
    - stage: "Build"
      r_packages:
        - covr
        - testthat
        - knitr
        - roxygen2
      before_install:
        - mkdir -p ~/.R
        - echo -e 'MAKEFLAGS = -j2' > ~/.R/Makevars
        - echo 'options(Ncpus = 2)' > ~/.Rprofile
        - echo 'options(repos = c(CRAN = "https://cran.rstudio.com"))' > ~/.Rprofile
        - echo 'utils::chooseCRANmirror(ind = 1)' > ~/.Rprofile
      script: true
      name: "Build dependencies and cache"
    - stage: "Check"
      r_build_args: --no-build-vignettes --no-manual
      r_check_args: --as-cran --no-build-vignettes --no-vignettes --no-manual --no-tests
      before_script: rm -rf vignettes
      install: skip
      name: "examples"
    - r_build_args: --no-build-vignettes --no-manual
      r_check_args: --as-cran --no-build-vignettes --no-vignettes --no-manual --no-codoc --no-examples
      install: skip
      before_script: rm -rf vignettes
      name: "tests"
    - r_build_args:
      r_check_args: --as-cran --no-build-vignettes --no-codoc --no-examples --no-tests
      install: skip
      name: "vignettes"
    - stage: "CodeCov"
      install: skip
      script:
        - travis_wait 20 Rscript -e 'covr::codecov()'
      name: "codecov and pkgdown (on master)"

# In general the r-travis script automatically dump the logs after failure but
# because of a bug in travis the output is often truncated. See
# https://github.com/travis-ci/travis-ci/issues/6018
after_failure: sleep 10


before_install:
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then curl -O http://r.research.att.com/libs/netcdf-4.1.3-darwin9-bin3.tar.gz && sudo tar fvxz netcdf-4.1.3-darwin9-bin3.tar.gz -C /; fi


branches:
  except:
    - RELEASE_3_4
    - RELEASE_3_5
    - RELEASE_3_6
