0

I am building an R Package on GitLab and I am trying to get the GitLab CI to work, the issues are

  • devtools::check fails if there is an error, warning or note. I only want it to fail on errors
  • Deploy pkgdown to GitLab pages, it doesn't seem to work?

Below is the .gitlab-ci-yml I am using. I used the R package template from R Studio to test it.

# .gitlab-ci.yml

image: methodsconsultants/r-packaging

variables:
  DOCKER_DRIVER: overlay2
  PKGNAME: "test"
  R_LIBS_USER: "$CI_PROJECT_DIR/ci/lib"
  CHECK_DIR: "$CI_PROJECT_DIR/ci/logs"
  BUILD_LOGS_DIR: "$CI_PROJECT_DIR/ci/logs/$PKGNAME.Rcheck"

cache:
    paths:
    - $R_LIBS_USER
    - vendor/apt

stages:
  - build
  - check
  - test
  - pages

before_script:
  - mkdir -p vendor/apt
  - apt-get --allow-releaseinfo-change update -qq
  - apt-get remove -y libgcc-8-dev
  - apt-get -o dir::cache::archives="vendor/apt" install -y libcairo2-dev -qq

buildbinary:
  stage: build
  script:
    - r -e 'devtools::build(binary = TRUE)'

 checkErrors:
   stage: check
   script:
     - r -e 'if (!identical(devtools::check(document = FALSE, args = "--no-tests")[["errors"]], character(0))) stop("Check with Errors")'

unittests:
  stage: test
  script:
    - r -e 'if (any(as.data.frame(devtools::test())[["failed"]] > 0)) stop("Some tests failed.")'

pages:
  script:
    - R -e "pkgdown::build_site()"
  artifacts:
    paths:
      - public
  only:
    - master 

Note

  • Everything works locally, devtools::check() produces warnings and notes but no errors. pkgdown builds fine. tests pass fine.
  • Gitlab CI is working, the build step and test stages pass fine, then fails on devtools::check() error message
  • I tried gitlab pages by removing the check() phrase, the pipeline finishes fine but under setting > Pages I can't see anything?
Joshua
  • 184
  • 1
  • 11

1 Answers1

0

Worked it out:

  • devtools::check seems to raise an error on warnings on gitlab CI BUT not locally? Don't understand it, but you can set it explicitly which works devtools::check(error_on = "error")
  • GitLab pages I think needs to be in a deploy stage? Anyway it works now :) I did change the output folder of pkgdown to public to match gitlab pages (shown below)

Hope this helps anyone who stumbles upon this!

# .gitlab-ci.yml

image: rocker/tidyverse

variables:
  DOCKER_DRIVER: overlay2
  PKGNAME: "test"
  R_LIBS_USER: "$CI_PROJECT_DIR/ci/lib"
  CHECK_DIR: "$CI_PROJECT_DIR/ci/logs"
  BUILD_LOGS_DIR: "$CI_PROJECT_DIR/ci/logs/$PKGNAME.Rcheck"

cache:
    paths:
    - $R_LIBS_USER
    - vendor/apt

stages:
  - build
  - test
  - deploy

before_script:
  - R -e 'devtools::install_deps(dep = T)'

buildbinary:
  stage: build
  script:
    - R -e 'devtools::check(vignettes = FALSE, error_on = "error")'

unittests:
  stage: test
  script:
    - r -e 'if (any(as.data.frame(devtools::test())[["failed"]] > 0)) stop("Some tests failed.")'

pages:
  stage: deploy
  script:
  - R -e "install.packages('pkgdown')"
  - R -e "pkgdown::build_site()"
  artifacts:
    paths:
    - public
    expire_in: 1 day
  rules:
    - if: $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH

# _pkgdown.yml
url: ~
template:
  bootstrap: 5
destination: public/

Joshua
  • 184
  • 1
  • 11