Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GitLab CI with r testthat package

Tags:

r

gitlab

testthat

Can anyone run testthat tests for a minimal R package using GitLab.com continuous integration tools? My attempt:
https://gitlab.com/djchapman/CI_example
This is the .gitlab-CI.yml text I am using,

image: rocker/rstudio
test:
   script:
    - R -e 'install.packages(c("devtools", "testthat"))'
    - 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
    - R -e 'devtools::test()'

It is adapted from this website. I realize that devtools has dependencies which may need to be included as packages are installed, and I tried that, but the libraries for git2r didn't seem to install correctly, and now I wonder if I'm going about it wrong. Thanks.

like image 256
djchapman Avatar asked Aug 15 '18 21:08

djchapman


1 Answers

You do not need to run the tests via devtools since R CMD check does that already. The following should work:

image: rocker/rstudio
test:
   script:
    - R -e 'install.packages(c("testthat"))'
    - 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

Alternatively you could use an image that allows for binary installs:

image: rocker/r-base
test:
   script:
    - apt-get update
    - apt-get install --yes --no-install-recommends r-cran-testthat r-cran-devtools
    - R -e "devtools::install_deps()"
    - 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

This is useful if you have dependencies that have not been packaged for Debian, or if you don't want to update your CI script when you add a new dependency.

like image 194
Ralf Stubner Avatar answered Oct 02 '22 08:10

Ralf Stubner