<%------------------------------------------------------------------------ Usage: yml <- R.rsp::rfile(".travis.yml.rsp") ------------------------------------------------------------------------%> <% pd <- local({ pd <- NULL function() { if (is.null(pd)) { pd <<- as.list(as.data.frame(read.dcf("DESCRIPTION"), stringsAsFactors=FALSE)) } pd } }) pkg <- function() pd()$Package deps <- function(what=c("Depends", "Imports", "Suggests", "SuggestsNote")) { deps <- unlist(pd()[what], use.names=FALSE) if (length(deps) == 0) return("") deps <- unlist(strsplit(deps, split="[,:]"), use.names=FALSE) deps <- gsub("[ \n\t]", "", deps) deps <- gsub("[(].*[)]", "", deps) deps <- setdiff(deps, c("R", "base", "datasets", "graphics", "grDevices", "methods", "parallel", "splines", "stats", "tcltk", "tools", "utils", "Recommended")) sort(deps) } deps_on_R <- function() { deps <- unlist(pd(), use.names=FALSE) if (length(deps) == 0) return("") deps <- unlist(strsplit(deps, split="[,:]"), use.names=FALSE) deps <- gsub("^([ \n\t]+|[ \n\t]+$)", "", deps) deps <- grep("^R[ ]*[(].*[)]$", deps, value=TRUE) if (length(deps) == 0) { op <- ">=" ver <- "0.0" } else { pattern <- ".*[(][ ]*([^0-9 ]*)[ ]*(.*)[)]$" op <- gsub(pattern, "\\1", deps) if (nchar(op) == 0L) op <- "==" ver <- gsub(pattern, "\\2", deps) } comp <- eval(parse(text=sprintf("function(ver) { package_version(ver) %s package_version('%s') }", op, ver))) list(op=op, ver=ver, comp=comp) } support_R <- function(ver) { deps_on_R()$comp(ver) } cran <- local({ pkgs <- NULL function() { if (is.null(pkgs)) { repos <- "http://cran.r-project.org" data <- available.packages(contriburl=contrib.url(repos, "source")) pkgs <<- rownames(data) } pkgs } }) bioc <- local({ pkgs <- NULL function() { if (is.null(pkgs)) { repos <- "http://www.bioconductor.org/packages/devel/bioc/" data <- available.packages(contriburl=contrib.url(repos, "source")) pkgsA <- rownames(data) repos <- "http://www.bioconductor.org/packages/devel/data/annotation/" data <- available.packages(contriburl=contrib.url(repos, "source")) pkgsB <- rownames(data) repos <- "http://www.bioconductor.org/packages/devel/data/experiment/" data <- available.packages(contriburl=contrib.url(repos, "source")) pkgsC <- rownames(data) pkgs <<- c(pkgsA, pkgsB, pkgsC) } pkgs } }) deps_on_cran <- function(...) { deps <- deps(...) deps[deps %in% cran()] } deps_on_bioc <- function(...) { deps <- deps(...) deps[deps %in% bioc()] } deps_elsewhere <- function(...) { deps <- deps(...) deps[!deps %in% c(cran(), bioc())] } install_cran <- function(...) { pkgs <- deps_on_cran(...) if (length(pkgs) > 0L) { sprintf(" - $RENV install_r %s", paste(pkgs, collapse=" ")) } else "" } install_bioc <- function(...) { pkgs <- deps_on_bioc(...) if (length(pkgs) > 0L) { sprintf(" - $RENV install_bioc %s", paste(pkgs, collapse=" ")) } else "" } %> #---------------------------------------------------------------- # Travis-CI configuration for R packages # # REFERENCES: # * Travis CI: https://travis-ci.org/ # * r-builder: https://github.com/metacran/r-builder # * covr: https://github.com/jimhester/covr # # Validate your .travis.yml file at http://lint.travis-ci.org/ #---------------------------------------------------------------- language: c env: global: - RENV="./pkg-build.sh" # r-builder - R_BUILD_ARGS="--no-manual" - R_CHECK_ARGS="--no-manual --as-cran" - _R_CHECK_CRAN_INCOMING_=TRUE - _R_CHECK_FORCE_SUGGESTS_=false # Need LaTeX? (very time consuming!) - BOOTSTRAP_LATEX="" # Skip building vignettes, which iff LaTeX-based are very # time consuming because LaTeX needs to be installed # - R_BUILD_ARGS="--no-build-vignettes ${R_BUILD_ARGS}" # - R_CHECK_ARGS="--no-build-vignettes ${R_CHECK_ARGS}" # R versions r-builder should test on (ignored by r-travis) matrix: <% rversion <- c( "3.1.3" = "3.1.3", "3.2.4" = "3.2.4", "3.4.0" = "devel _R_COVR_=TRUE _R_CHECK_FULL_=TRUE" ) ## Check native code for memory leaks? if (file_test("-d", "src")) { rversion <- c(rversion, "3.4.0" = "devel _R_CHECK_USE_VALGRIND_=TRUE _R_CHECK_FULL_=TRUE" ) } for (kk in seq_along(rversion)) if (support_R(names(rversion)[kk])) cat(sprintf(" - RVERSION=%s\n", rversion[kk])) %> before_install: - echo RENV=$RENV - curl -OL https://raw.githubusercontent.com/metacran/r-builder/master/pkg-build.sh; - chmod 755 $RENV - $RENV bootstrap - if [ "BOOTSTRAP_LATEX" == "true" ]; then (cd /tmp && curl -OL http://mirrors.ctan.org/macros/latex/contrib/xcolor.zip && cd /usr/share/texmf/tex/latex && sudo unzip /tmp/xcolor.zip && cd xcolor && sudo latex xcolor.ins && sudo texhash); else export R_RSP_COMPILELATEX_FALLBACK="copy-force"; fi - if [[ "$_R_CHECK_USE_VALGRIND_" == "TRUE" ]]; then export R_BUILD_ARGS="--no-manual --no-build-vignettes"; export R_CHECK_ARGS="--no-manual --no-build-vignettes --no-codoc --no-examples --use-valgrind"; export _R_CHECK_TIMINGS_=10; sudo apt-get install valgrind; valgrind --version; fi install: - $RENV install_deps <%= install_bioc(c("SuggestsNote")) %> <%= install_cran(c("SuggestsNote")) %> <%--- ONLY IF NEEDED <%= install_bioc(c("VignetteBuilder")) %> <%= install_cran(c("VignetteBuilder")) %> <%= install_bioc(c("Depends", "Imports")) %> <%= install_cran(c("Depends", "Imports")) %> <%= install_bioc(c("Suggests")) %> <%= install_cran(c("Suggests")) %> ---%> script: - $RENV run_build - $RENV run_check after_success: - $RENV dump_logs_by_extension out - if [[ "$_R_COVR_" == "TRUE" && -f ".covr.R" ]]; then $RENV install_devtools; $RENV install_github jimhester/covr; curl -OL https://raw.githubusercontent.com/HenrikBengtsson/covr-utils/master/covr-utils.R; fi - if [[ "$_R_COVR_" == "TRUE" && -f ".covr.R" ]]; then $RENV run_script .covr.R; fi after_failure: - $RENV dump_logs notifications: email: on_success: change on_failure: change branches: except: - /-expt$/