Skip to content
Snippets Groups Projects
.gitlab-ci.yml 2.26 KiB
Newer Older
  - deploy

default:
  tags: [stable]

image: rocker/geospatial:4.3.1

variables:
  CI_CACHE_DIR: "$CI_PROJECT_DIR/ci"
  R_LIBS_USER: "$CI_CACHE_DIR/lib"
  PKG_DATA_CACHE: "$CI_CACHE_DIR/data"

cache:
  key:
  paths:
    - $CI_CACHE_DIR

before_script:
  - mkdir -p $R_LIBS_USER
  - echo "R_LIBS='$R_LIBS_USER'" > .Renviron
  - R -q -e 'if (!require(remotes)) install.packages(c("remotes", "testthat"))'
  - R -q -e 'devtools::install_deps(dependencies = TRUE)'
  - R -q -e 'remotes::install_git("https://forgemia.inra.fr/umr-g-eau/fairify.git")'

check:
  variables:
    NOT_CRAN: "true"
  stage: checks
  script:
    - R -q -e 'remotes::update_packages("rcmdcheck")'
    - R -q -e 'rcmdcheck::rcmdcheck(args = "--no-manual", error_on = "error")'

    - if: $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH
    - R -q -e 'devtools::install()'
    - R -q -e 'remotes::update_packages("pkgdown")'
    - R -q -e 'rmarkdown::render("README.rmd", "md_document")'
    - R -q -e 'fairify::build_site()'
    - mv docs/* public/
  artifacts:
    paths:
      - public/

usrmanual:
  stage: usrmanual
    - echo "Checking the link to the Optirrig user manual..."
    - |
      if curl --output /dev/null --silent --head --fail "https://optirrigdev.pages.mia.inra.fr/OptirrigManual/reports/Advanced_Parametrization_of_the_Optirrig_for_Sugar_Beet_Cases/index.html"; then
        echo "The link is alive! The user manual is accessible."
      else
        echo "Alert! The link is dead or inaccessible. Please check the user manual."
        exit 1
      fi
    - echo "Checking and downloading the Optirrig user manual PDF..."
    - |
      if curl --output report.pdf --silent --fail "https://optirrigdev.pages.mia.inra.fr/OptirrigManual/reports/Advanced_Parametrization_of_the_Optirrig_for_Sugar_Beet_Cases/report.pdf"; then
        echo "The user manual PDF has been successfully downloaded."
      else
        echo "Downloading the PDF has failed. Is the file present?"
        exit 1
      fi
    - mv report.pdf public/
      - public/

pages:
  stage: deploy
  rules:
    - if: $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH
  script:
    - ls public/
  artifacts:
    paths:
      - public/