stages:
    - update_packages
    - build
    - checks

default:
  tags: [docker]

image: r-base:latest

cache:
  paths:
    - R_LIBS/

before_script:
  - echo "R_LIBS='$(pwd)/R_LIBS'" > .Renviron

update_packages:
  stage: update_packages
  script:
    - mkdir -p R_LIBS
    - Rscript -e 'if(!dir.exists("R_LIBS/remotes")) install.packages("remotes", lib = "R_LIBS")'
    - Rscript -e 'remotes::update.packages(c("dplyr", "rmarkdown", "readr", "lubridate", "zoo"), lib = "R_LIBS")'
    - Rscript -e 'remotes::install_gitlab("HYCAR-Hydro/airgr@sd", host = "gitlab.irstea.fr", lib = "R_LIBS")'

build:
  stage: build
  script:
    - R CMD build ../griwrm

check_not_cran:
  stage: checks
  variables:
    NOT_CRAN: "true"
  script:
    - R CMD check griwrm_*.tar.gz
