Coder Social home page Coder Social logo

maxheld83 / r-ci Goto Github PK

View Code? Open in Web Editor NEW

This project forked from colinfay/r-ci

0.0 2.0 0.0 33 KB

Docker images for Continous Integration / Continuous Delivery for R Projects

Dockerfile 64.15% HCL 23.40% R 12.44%
docker rstats cicd ci cd development developer-tools

r-ci's Introduction

r-ci

Docker images for Continuous Integration / Continuous Delivery of R Projects.

This image was created in order to be used in a CI/CD environment like Gitlab CI or Travis, so that you don't have to reinstall testing and dev packages.

Available on docker hub at https://hub.docker.com/r/maxheld83/r-ci.

Images are tagged by all GitHub refs (commit hash, branch, release).

docker pull maxheld83/r-ci:master

Packages Installed

Dockerfiles are based on a rhub/debian-gcc-release image, with these packages and their respective system dependencies installed on top:

Isolation

(This is an opinionated suggestion.)

CI/CD should run an in-development R package in a computing environment defined by, and only by its DESCRIPTION. For example, when a CI/CD script calls a function from the development package, say, as part of running tests, that function and all its dependencies should run in the versions specified in the Imports and Suggests fields of the DESCRIPTION.

This seemingly straightforward reproducibility is easily broken when the CI/CD scripts alter the computing environment by bringing their own system and R dependencies. Problems can arise, when the CI/CD scripts and the development package have overlapping dependencies in different versions. For example, when a CI/CD script uses, say, devtools, which depends on the CRAN-version of httr, but the development package depends on a development version of httr off of GitHub, there can be a conflict. These problems may seem unlikely, though when they do occur, they can be very hard to reason about and debug. Problems of this sort may also become more widespread, as CI/CD scripts rely on more (sometimes dependency-heavy) development helpers.

It is therefore a good idea to strictly isolate the changes to the computing environment brought by the development helpers from those brought by the development package. This may not be possible to achieve in the absolute, but is a worthy design goal.

This image implements several practices to strengthen this isolation.

.libPaths()

The development helpers in this image are all installed to /usr/lib/R/dev-helpers-library (stored in R_LIBS_DEV_HELPERS), a directory that is not usually on the .libPaths() search tree.

To make the R_LIBS_DEV_HELPERS available, you can:

  1. You can wrap your call with withr:

    withr::with_libpaths(
      new = Sys.getenv("R_LIBS_DEV_HELPERS"),
      action = "suffix", 
      code = pkgdown::build_site()
    )
    

    This method will put all development helpers on the library search tree, not just some as in the above method. The the changed .libPaths() also appears to persist across R sessions.

  2. You can prefix or suffix your .libPaths() by setting an R_LIBS environment variable.

    In the command line:

    export R_LIBS="$R_LIBS_DEV_HELPERS"
    

    Or set it your Dockerfile:

    ENV R_LIBS="$R_LIBS_DEV_HELPERS"
    

    This method will put all development helpers on the library search tree and let them persist until R_LIBS is un/reset.

Call Tree

TODO: It would also be nice to isolate the dependencies down the call tree, where say, rcmdcheck::check() would use the R_LIBS_DEV_HELPERS until the call tree "passes over" into the development package, and call whatever is in DESCRIPTION there (#212)

System Dependencies

Isolating system dependencies may be less urgent, but can also avoid thorny problems. In particular, not having frequently used system dependencies available on the PATH in a CI/CD image may be beneficial, because it forces to developers to explicitly declare those up front.

TODO: should also be stored in a separate directory and only prepended to the PATH as necessary. (#2))

Benefits

Adhering to this separation between run-time dependencies and "CI/CD-time" (more than just build-time) dependencies of an R package also frees up the Suggests field for actual optional dependencies. It is currently often (ab)used to store "CI/CD-time" dependencies, though these development helpers typically do not enhance or otherwise alter the package for a user at run-time.

Should a development package really need a particular version of a development helper, the developer can always list it in the DESCRIPTION This should be exceedingly rare and only necessary for the development of development helpers. TODO: how this would then take precedence in the lib tree is not yet implemented (#3).

r-ci's People

Contributors

colinfay avatar maxheld83 avatar

Watchers

James Cloos avatar  avatar

r-ci's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.