gitlabr icon indicating copy to clipboard operation
gitlabr copied to clipboard

gitlab-ci template: fix bookdown templates

Open statnmap opened this issue 4 years ago • 2 comments

and maybe check too...

For REPO_NAME and/or CRAN to be used, options() must be set up over .Rprofile.site already modified by "r/r-verse"

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

book-production:
    stage: book-create
    only:
        - production
    script:
        - echo "options(repos = c(CRAN = '${REPO_NAME}'), download.file.method = 'libcurl')" >> ${R_HOME}/etc/Rprofile.site

statnmap avatar Sep 21 '21 10:09 statnmap

Add bs4_book along with gitbook

        - Rscript -e 'bookdown::render_book("index.Rmd", output_format = "bookdown::bs4_book", clean = FALSE, output_dir = "public")'
        # - Rscript -e 'bookdown::render_book("index.Rmd", output_format = "bookdown::pdf_book", clean = FALSE, output_dir = "public")'

Add deps for bs4_book: install bookdown with suggests.

    script:
        - echo "options(repos = c(CRAN = '${REPO_NAME}'), download.file.method = 'libcurl')" >> ${R_HOME}/etc/Rprofile.site
        - echo "Library path for packages :" $R_LIBS
        - mkdir -p $R_LIBS
        - Rscript -e 'install.packages(c("remotes", "attachment", "tinytex", "usethis"))'
        - Rscript -e 'remotes::install_cran("bookdown", dependencies = TRUE)'        
        - Rscript -e 'if (!file.exists("DESCRIPTION")) {usethis::use_description()}'
        - Rscript -e 'imports <- unique(c("knitr", attachment::att_from_rmds(".", recursive = FALSE)));attachment::att_to_desc_from_is(path.d = "DESCRIPTION", imports = imports)'
        - Rscript -e 'remotes::install_deps(dependencies = TRUE)'

statnmap avatar Sep 21 '21 13:09 statnmap

Bookdown templates do not always match CRAN-compliant package name requirements. I would recommend to add check_name = FALSE in usethis::use_description() when DESCRIPTION does not exist.

marionlouveaux avatar Sep 27 '21 17:09 marionlouveaux