# The Docker image that will be used to build your app
image: rocker/tidyverse:4.3.2

before_script:
  - apt-get update
  - apt-get install -y --no-install-recommends libcurl4-openssl-dev libxext6 libxtst6 libxt6
  - apt-get install -y --no-install-recommends qpdf pandoc pandoc-citeproc
  - R -e 'install.packages(c("testthat", "rmarkdown"));'
  - R -e "install.packages(c('rsconnect', 'matrix', 'parallel', 'data.table', 'ggplot2', 'gridExtra', 'glmmTMB', 'magrittr', 'MASS', 'reshape2', 'rlang', 'stats', 'utils', 'BiocManager', 'car'))" 
  - R -e "BiocManager::install('S4Vectors', update = FALSE)"
  - R -e "BiocManager::install('DESeq2', update = FALSE)" 
  - R -e 'install.packages(setdiff(desc::desc()$get_deps()$package, c(installed.packages(), "R")));'
  - R -e 'update.packages(ask = FALSE, checkBuilt = TRUE)' 

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

unit_test_coverage:
    stage: test
    allow_failure: true
    when: on_success
    only:
        - master
    script:
        - Rscript -e 'install.packages("covr")'
        - Rscript -e 'install.packages("DT")'
        - Rscript -e 'covr::gitlab(quiet = FALSE)'
    coverage: '/HTRfit Coverage: \d+(?:\.d+)?/' # regex to extract coverage percentage
    artifacts:
      paths:
        - public/


pages:
  stage: build
  script:
  - R -e "devtools::document(); pkgdown::build_site(override = list(destination = 'public/'))"
  artifacts:
    paths:
    - public/
  only:
    variables:
    - $CI_COMMIT_REF_NAME == "master"
