Skip to content
Snippets Groups Projects
.gitlab-ci.yml 2.60 KiB
image: rocker/geospatial:latest

variables:
  GIT_DEPTH: 10
  REPO_NAME: "https://packagemanager.rstudio.com/all/__linux__/focal/latest"
  R_LIBS: "ci/lib"

cache:
  key: global-cache
  paths:
      - ${R_LIBS}

stages:
  - build
  - test
  - pkgdown
  - pkgdown-move
  - deploy

building:
  stage: build
  script:
    - apt-get update -qq && apt-get install -y libharfbuzz-dev libfribidi-dev
    - echo "Library path for packages :" $R_LIBS
    - mkdir -p $R_LIBS
    - Rscript -e 'install.packages("remotes")'
    - Rscript -e 'install.packages("rcmdcheck")'
    - Rscript -e 'remotes::install_local(upgrade = "never")'
    - R -e 'rcmdcheck::rcmdcheck(args = c("--no-manual"), error_on = "warning", check_dir = "check")'

# To have the coverage percentage appear as a gitlab badge follow these
# instructions:
# https://docs.gitlab.com/ee/user/project/pipelines/settings.html#test-coverage-parsing
# The coverage parsing string is
# Coverage: \d+\.\d+

coverage:
    stage: test
    allow_failure: true
    when: on_success
    only:
        - master
        - production
    script:
        - Rscript -e 'remotes::install_local(upgrade = "never")'
        - Rscript -e 'remotes::install_cran(c("covr", "DT"), upgrade = "never")'
        - Rscript -e 'covr::gitlab(quiet = FALSE)'
    artifacts:
        paths:
            - public
        expire_in: 30 days

# To produce a code coverage report as a GitLab page see
# https://about.gitlab.com/2016/11/03/publish-code-coverage-report-with-gitlab-pages/

integration:
    stage: pkgdown
    allow_failure: true
    when: on_success
    only:
        - master
        - production
        - test-ci
    script:
        - Rscript -e 'remotes::install_cran(c("pkgdown"), upgrade = "never")'
        - Rscript -e 'pkgdown::build_site()'
    artifacts:
        paths:
            - docs
        expire_in: 30 days


integration-master:
    stage: pkgdown-move
    dependencies:
        - integration
    only:
        - master
    script:
        - mkdir -p public
        - 'curl --location --output artifacts.zip --header "JOB-TOKEN: $CI_JOB_TOKEN" "https://gitlab.com/api/v4/projects/$CI_PROJECT_ID/jobs/artifacts/production/download?job=pages" &&
          unzip artifacts.zip &&
          rm artifacts.zip &&
          echo "copied production artifacts" ||
          echo "copied production artifacts failed"'
        - cp -r docs/* public
    artifacts:
        paths:
            - public
        expire_in: 30 days

pages:
    stage: deploy
    script:
        - echo "deployment with cache"
    artifacts:
        paths:
            - public
    only:
        - master
        - production
        - test-ci