  
language: r
r: bioc-release

install:
  - sudo apt-get update

cache:
  directories:
    - ~/Rlib

# install the package and dependencies:
# - create directory for R libraries (if not already exists)
# - create .Renviron with location of R libraries
# - define R repository in .Rprofile
# - add .travis.yml to .Rbuildignore
# - install devtools if not already installed
# - install covr if not already installed
# - update all installed packages
# - install package with dependencies
install:
  - mkdir -p ~/Rlib
  - echo 'R_LIBS=~/Rlib' > .Renviron
  - echo 'options(repos = "http://cran.rstudio.com")' > .Rprofile
  - echo '.travis.yml' > .Rbuildignore
  - Rscript -e 'if(!"devtools" %in% rownames(installed.packages())) { install.packages("devtools", dependencies = TRUE) }'
  - Rscript -e 'update.packages(ask = FALSE, instlib = "~/Rlib")'
  #- Rscript -e 'install.packages("testthat", dependencies = TRUE)'
  - Rscript -e 'library(devtools); devtools::install_deps(pkg = ".", dependencies = TRUE)'
  - Rscript -e 'library(devtools); devtools::install_github("r-lib/testthat")'

script:
  - R CMD build . --no-build-vignettes --no-manual
  - PKG_FILE_NAME=$(ls -1t *.tar.gz | head -n 1)
  - R CMD check "${PKG_FILE_NAME}" --no-build-vignettes --no-manual
