Reputation: 546163
I would like to set up Travis CI for an R project hosted on Github that isn’t a package. Unfortunately, the official R Travis support seems to be pretty hard-wired to packages (which, to be fair, makes sense).
Is there any chance to get this working for non-package code, or is my only recourse to branch r-travis and patch it according to my specifications? I don’t feel competent enough to do this easily.
Here’s my failing Travis configuration:
language: R
r_github_packages:
- klmr/modules
r_binary_packages:
- testthat
script: make test
This fails with the following error:
The command
"Rscript -e 'deps <- devtools::install_deps(dependencies = TRUE);if (!all(deps %in% installed.packages())) { message("missing: ", paste(setdiff(deps, installed.packages()), collapse=", ")); q(status = 1, save = "no")}'"
failed and exited with 1 during .
This makes sense: devtools::install_deps
only works in the context of a package.
I’ve tried suppressing the installation step, by adding install: true
to my configuration. However, now the dependencies are no longer installed, and the build consequently fails with
Error in loadNamespace(name) : there is no package called ‘modules’
Upvotes: 8
Views: 373
Reputation: 779
I was looking for an even more basic setup to get started. Here is what worked well for me.
.travis.yml
:
language: r
install:
- Rscript install_packages.R
script:
- Rscript testthat.R
install_packages.R
:
install.packages('testthat')
testthat.R
:
library(testthat)
test_that('blabla', {
expect_equal(1+2, 3)
})
Upvotes: 2
Reputation: 546163
It turns out that a naïve approach is fairly easy; the following (complete .travis.yml
) works for my purposes:
language: R
install:
- Rscript -e 'install.packages(c("devtools", "testthat"))'
- Rscript -e 'devtools::install_github("klmr/modules")'
script: make test
However, I’d still prefer a solution that can actually use the Travis declarations (r_binary_packages
, etc.) instead of having to install dependencies manually.
Upvotes: 4