diff --git a/lib/gitlab/ci/templates/R.gitlab-ci.yml b/lib/gitlab/ci/templates/R.gitlab-ci.yml new file mode 100644 index 0000000000000000000000000000000000000000..e357fa2b879f243e239ad621167dc72cb207d453 --- /dev/null +++ b/lib/gitlab/ci/templates/R.gitlab-ci.yml @@ -0,0 +1,91 @@ +# R package developers can use this template to add CI to their R package +# repositories on GitLab. +# This template runs with valid R packages: +# - https://cran.r-project.org/doc/manuals/r-release/R-exts.html +# - http://r-pkgs.had.co.nz/ +# - https://support.rstudio.com/hc/en-us/articles/200486488-Developing-Packages-with-RStudio +# This template is generic and needs no special adjustments to run on a valid +# R package. In the deploy stage it uses pages to provide static html sites +# for code coverage and documentation. + +stages: + # Tests the package against R versions release, devel, and old R 3.4. + # all tests are ran for master and merge requests. + # Pipeline for merge requests: https://docs.gitlab.com/ee/ci/merge_request_pipelines/ + - test + # provide static html pages for coverage and pkgdown documentation + - deploy + +variables: + # https://cran.r-project.org/doc/manuals/r-release/R-exts.html + R_BUILD_ARGS: "--no-resave-data --no-manual" + R_CHECK_ARGS: "--as-cran --no-manual" + # supress warning: https://stackoverflow.com/a/50388556/2324028 + _R_CHECK_CRAN_INCOMING_: "FALSE" + +before_script: + - apt-get update + # install libxml, necessary for xml2 (deps of roxygen2) + - apt-get install -y libxml2-dev + # change CRAN mirror + - echo 'options(repos = c(CRAN = "https://cloud.r-project.org/"))' > ~/.Rprofile + # install dependency packages + - install2.r desc + - Rscript -e 'install.packages(desc::desc_get_deps()$package[-1])' + +# hidden job used by anchor in following jobs +# https://docs.gitlab.com/ee/ci/yaml/#hidden-keys-jobs +.test_template: + script: &test_script + - R CMD build ${R_BUILD_ARGS} . + - R CMD check ${R_CHECK_ARGS} $(ls -1t *.tar.gz | head -n 1) + +release: + # test against R version release + stage: test + image: rocker/r-ver:latest + only: + - master + - merge_request + script: *test_script + +devel: + # test against R version devel + stage: test + image: rocker/r-ver:devel + only: + - master + - merge_request + script: *test_script + +oldR34: + # test against old R version 3.4 + stage: test + image: rocker/r-ver:3.4 + only: + - master + - merge_request + script: *test_script + +pages: + stage: deploy + # r-ver not possible here: https://github.com/rocker-org/rocker/issues/327 + image: rocker/rstudio:latest + only: + - master + script: + # install curl and ssl for covr and pkgdown + - apt-get install -y libcurl4-openssl-dev libssl-dev + # DT is suggested by covr, but required here + - install2.r covr DT pkgdown + # install current package (mandatory for vignettes) + - R CMD INSTALL . + # coverage + - Rscript -e 'covr::gitlab(quiet = FALSE)' + # pkgdown + - Rscript -e 'pkgdown::build_site(preview = FALSE)' + - mv docs/ public/ + coverage: '/Coverage: \d+\.\d+\%/' + artifacts: + paths: + - public