From 79c970c4a4a6aa957a9a7c8b23d78e56a869a998 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Cs=C3=A1rdi?= Date: Thu, 1 Aug 2024 11:30:48 +0200 Subject: [PATCH 1/8] [setup-r-dependencies]: install quarto if needed --- setup-r-dependencies/README.md | 16 +++++++++++---- setup-r-dependencies/action.yaml | 34 ++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 4 deletions(-) diff --git a/setup-r-dependencies/README.md b/setup-r-dependencies/README.md index db4800395..0ee96160a 100644 --- a/setup-r-dependencies/README.md +++ b/setup-r-dependencies/README.md @@ -32,7 +32,11 @@ Inputs available - `extra-packages` - One or more extra package references to install. Separate each reference by newlines or commas for more than one package. - `install-pandoc` - Whether to install pandoc. By default it is installed - if it is not already on the PATH and the R package depends in rmarkdown. + if it is not already on the PATH and the R package depends on rmarkdown. +- `install-quarto` - Whether to install quarto. If it is 'auto' (the + default), it is installed if there is at least one `.qmd` file in the + repository, inside `working-directory`. Set to 'true' to always install + it. Set to 'false' to never install it. - `needs` - `Config/Needs` fields to install from the DESCRIPTION, the `Config/Needs/` prefix will be automatically included. - `lockfile-create-lib` - The package library to consider when creating @@ -44,11 +48,15 @@ Inputs available install. The default installs the dependencies of the package in the working directory and the sessioninfo package. Separate multiple packages by newlines or commas. -- `pak-version`: Which pak version to use. Possible values are +- `pak-version` - Which pak version to use. Possible values are `stable`, `rc` and `devel`. Defaults to `stable`. -- `pandoc-version`: Which pandoc version to install (see the +- `pandoc-version` - Which pandoc version to install (see the `r-lib/actions/setup-pandoc` action), if pandoc is installed. -- `upgrade`: Whether to install the latest available versions of the +- `quarto-version` - Version of quarto to install, if quarto is installed. + It is passed to the `quarto-dev/quarto-actions/setup@v2` action. The + default is 'release' to install the latest release. Other possible values + are a version number number (without the `v` prefix), and 'pre-release'. +- `upgrade` - Whether to install the latest available versions of the dependencies. Must be an R expression. See the README for details if you need quoting. Defaults to `FALSE`. - `working-directory` - default `'.'`. If the DESCRIPTION file is not in the diff --git a/setup-r-dependencies/action.yaml b/setup-r-dependencies/action.yaml index 282de0f96..37983f0d6 100644 --- a/setup-r-dependencies/action.yaml +++ b/setup-r-dependencies/action.yaml @@ -38,6 +38,20 @@ s.' pandoc-version: description: 'Pandoc version to install.' default: '3.1.11' + install-quarto: + description: | + Whether to install quarto. If it is 'auto' (the default), it is + installed if there is at least one `.qmd` file in the repository, + inside `working-directory`. Set to 'true' to always install it. + Set to 'false' to never install it. + default: 'auto' + quarto-version: + description: | + Version of quarto to install, if quarto is installed. It is passed + to the `quarto-dev/quarto-actions/setup@v2` action. The default is + 'release' to install the latest release. Other possible values are + a version number number (without the `v` prefix), and 'pre-release'. + default: 'release' runs: using: "composite" steps: @@ -183,6 +197,26 @@ runs: with: pandoc-version: ${{ inputs.pandoc-version }} + - name: Check whether quarto if needed + id: check-quarto + run: | + cat("::group::Check if package needs quarto\n") + if (length(dir(recursive = TRUE, pattern = "[.]qmd$")) > 0) { + o <- "true" + } else { + o <- "false" + } + cat("install=", o, "\n", file = Sys.getenv("GITHUB_OUTPUT"), sep = "", append = TRUE) + cat("::endgroup::\n") + shell: Rscript {0} + working-directory: ${{ inputs.working-directory }} + + - name: Install quarto if needed + if: ${{ steps.check-quarto.outputs.install == 'true' }} + uses: quarto-dev/quarto-actions/setup@v2 + with: + version: ${{ inputs.quarto-version }} + - name: Session info run: | # Session info From 6c58e1a7b9566cc3921ece7fb6b1972b03dfe824 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Cs=C3=A1rdi?= Date: Thu, 1 Aug 2024 11:42:58 +0200 Subject: [PATCH 2/8] Add a .qmd vignette to test quarto install --- vignettes/test.qmd | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 vignettes/test.qmd diff --git a/vignettes/test.qmd b/vignettes/test.qmd new file mode 100644 index 000000000..3b1fadfd2 --- /dev/null +++ b/vignettes/test.qmd @@ -0,0 +1,22 @@ +--- +title: "Test vignette for GH Actions" +output: rmarkdown::html_vignette +vignette: > + %\VignetteIndexEntry{Test vignette for GH Actopns} + %\VignetteEngine{knitr::rmarkdown} + %\VignetteEncoding{UTF-8} +--- + +```{r, include = FALSE} +knitr::opts_chunk$set( + collapse = TRUE, + comment = "#>" +) +``` + +Irure ad excepteur aliqua esse id sint ex aliquip laborum. Officia laborum ex cupidatat exercitation velit. Nisi elit incididunt nisi ullamco. Ut Lorem eiusmod anim ipsum dolore cupidatat officia non. Culpa voluptate consectetur in ullamco minim sit sunt. Ad aute laborum laborum cillum qui consequat proident sit ad incididunt. Enim nisi nulla aliquip anim fugiat deserunt aliqua aliqua sunt nisi commodo magna reprehenderit. Reprehenderit dolor sunt nulla mollit est magna exercitation dolore magna. Mollit qui labore tempor commodo veniam cupidatat esse irure nisi eiusmod qui dolore nisi. + +```{r} +summary(mtcars) +``` + From 62aa52f04712392540418f74995ac2e9302e078f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Cs=C3=A1rdi?= Date: Thu, 1 Aug 2024 11:57:02 +0200 Subject: [PATCH 3/8] Implement install-querto properly Plus better install-pandoc messaging. --- setup-r-dependencies/action.yaml | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/setup-r-dependencies/action.yaml b/setup-r-dependencies/action.yaml index 37983f0d6..98ef9cce0 100644 --- a/setup-r-dependencies/action.yaml +++ b/setup-r-dependencies/action.yaml @@ -169,20 +169,25 @@ runs: - name: Check whether pandoc needs to be installed id: check-pandoc run: | + # Pandoc check cat("::group::Check if package needs pandoc\n") o <- '${{ inputs.install-pandoc }}' if (! o %in% c('true', 'false')) { if (Sys.which("pandoc") != "") { + cat("Pandoc is already installed at", Sys.which("pandoc"), "\n") o <- 'false' } else if (file.exists("DESCRIPTION")) { deptypes <- list(direct = "all", indirect = character()) deps <- pak::pkg_deps(".", dependencies = deptypes) if ("rmarkdown" %in% deps$package) { + cat("Pandoc is needed for rmarkdown\n") o <- 'true' } else { + cat("Pandoc is not needed\n") o <- 'false' } } else { + cat("Pandoc is not needed, no R package found\n") o <- 'false' } } @@ -200,11 +205,23 @@ runs: - name: Check whether quarto if needed id: check-quarto run: | + # Quarto check cat("::group::Check if package needs quarto\n") - if (length(dir(recursive = TRUE, pattern = "[.]qmd$")) > 0) { - o <- "true" - } else { - o <- "false" + o <- '${{ inputs.install-quarto }}' + if (! o %in% c('true', 'false')) { + if (Sys.which("quarto") != "") { + cat("Quarto is already installed at", Sys.which("quarto"), "\n") + o <- "false" + } else { + qmd <- dir(recursive = TRUE, pattern = "[.]qmd$") + if (length(qmd) > 0) { + cat("Quarto is needed for qmd file(s):", qmd[1], "...\n") + o <- "true" + } else { + cat("No qmd files found, Quarto is not needed.\n") + o <- "false" + } + } } cat("install=", o, "\n", file = Sys.getenv("GITHUB_OUTPUT"), sep = "", append = TRUE) cat("::endgroup::\n") From 72b8f5632dcfcd54567ce40a31a25d6520e42a69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Cs=C3=A1rdi?= Date: Thu, 1 Aug 2024 12:04:46 +0200 Subject: [PATCH 4/8] Add quarto dep to test package --- DESCRIPTION | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index d2ec169b4..7eefd8e9c 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,13 +1,13 @@ Package: testpackage Title: A Simple Test Description File to Test Packages Version: 1.0.0 -Authors@R: +Authors@R: c(person(given = "Jim", family = "Hester", role = c("aut", "cre"), email = "james.hester@rstudio.com")) Description: This is a simple package used to test the workflow files. Imports: xml2, curl -Suggests: covr, knitr, rmarkdown, testthat +Suggests: covr, knitr, rmarkdown, testthat, quarto License: GPL (>= 2) -VignetteBuilder: knitr, rmarkdown +VignetteBuilder: knitr, rmarkdown, quarto From 157098a9b88c897769f08c416a451e5bb95d68cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Cs=C3=A1rdi?= Date: Thu, 1 Aug 2024 12:17:12 +0200 Subject: [PATCH 5/8] Proper quarto test vignette --- vignettes/{test.qmd => quarto-test.qmd} | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) rename vignettes/{test.qmd => quarto-test.qmd} (88%) diff --git a/vignettes/test.qmd b/vignettes/quarto-test.qmd similarity index 88% rename from vignettes/test.qmd rename to vignettes/quarto-test.qmd index 3b1fadfd2..afbc6cabe 100644 --- a/vignettes/test.qmd +++ b/vignettes/quarto-test.qmd @@ -1,9 +1,11 @@ --- -title: "Test vignette for GH Actions" -output: rmarkdown::html_vignette +title: "Test Quarto vignette for GH Actions" +format: + html: + theme: none vignette: > %\VignetteIndexEntry{Test vignette for GH Actopns} - %\VignetteEngine{knitr::rmarkdown} + %\VignetteEngine{quarto::html} %\VignetteEncoding{UTF-8} --- From c01fc539bdbc0a2d1d7cb20a5f8ae13f66e4c495 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Cs=C3=A1rdi?= Date: Thu, 1 Aug 2024 12:24:07 +0200 Subject: [PATCH 6/8] More quarto vignette fixes --- vignettes/quarto-test.qmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vignettes/quarto-test.qmd b/vignettes/quarto-test.qmd index afbc6cabe..a315e15e8 100644 --- a/vignettes/quarto-test.qmd +++ b/vignettes/quarto-test.qmd @@ -4,7 +4,7 @@ format: html: theme: none vignette: > - %\VignetteIndexEntry{Test vignette for GH Actopns} + %\VignetteIndexEntry{Test Quarto vignette for GH Actions} %\VignetteEngine{quarto::html} %\VignetteEncoding{UTF-8} --- From 42f38f4b6ab614a817ba306b5ae8b9bb688e8acd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Cs=C3=A1rdi?= Date: Thu, 1 Aug 2024 13:35:10 +0200 Subject: [PATCH 7/8] Need explicit Bootstrap 5 for quarto vignette --- _pkgdown.yml | 2 ++ vignettes/quarto-test.qmd | 19 +++++++------------ vignettes/test.Rmd | 3 +-- 3 files changed, 10 insertions(+), 14 deletions(-) create mode 100644 _pkgdown.yml diff --git a/_pkgdown.yml b/_pkgdown.yml new file mode 100644 index 000000000..ec0a74054 --- /dev/null +++ b/_pkgdown.yml @@ -0,0 +1,2 @@ +template: + bootstrap: 5 diff --git a/vignettes/quarto-test.qmd b/vignettes/quarto-test.qmd index a315e15e8..3bd9ba05a 100644 --- a/vignettes/quarto-test.qmd +++ b/vignettes/quarto-test.qmd @@ -1,24 +1,19 @@ --- -title: "Test Quarto vignette for GH Actions" -format: - html: - theme: none +title: "Quarto HTML Vignettes" vignette: > - %\VignetteIndexEntry{Test Quarto vignette for GH Actions} + %\VignetteIndexEntry{Quarto HTML Vignettes} %\VignetteEngine{quarto::html} %\VignetteEncoding{UTF-8} --- -```{r, include = FALSE} -knitr::opts_chunk$set( - collapse = TRUE, - comment = "#>" -) -``` +## HTML Vignette Engines + +The **quarto** R package registers vignette engines that can be used in `%\VignetteEngine{}` directives in vignette headers. + +To learn more about how vignettes engine works, and how to write vignette engines, see the [Writing R Extensions](https://cran.r-project.org/doc/manuals/r-release/R-exts.html#Non_002dSweave-vignettes) manual and the [R Packages (2e)](https://r-pkgs.org/vignettes.html) book. Irure ad excepteur aliqua esse id sint ex aliquip laborum. Officia laborum ex cupidatat exercitation velit. Nisi elit incididunt nisi ullamco. Ut Lorem eiusmod anim ipsum dolore cupidatat officia non. Culpa voluptate consectetur in ullamco minim sit sunt. Ad aute laborum laborum cillum qui consequat proident sit ad incididunt. Enim nisi nulla aliquip anim fugiat deserunt aliqua aliqua sunt nisi commodo magna reprehenderit. Reprehenderit dolor sunt nulla mollit est magna exercitation dolore magna. Mollit qui labore tempor commodo veniam cupidatat esse irure nisi eiusmod qui dolore nisi. ```{r} summary(mtcars) ``` - diff --git a/vignettes/test.Rmd b/vignettes/test.Rmd index 3b1fadfd2..94875bdcc 100644 --- a/vignettes/test.Rmd +++ b/vignettes/test.Rmd @@ -2,7 +2,7 @@ title: "Test vignette for GH Actions" output: rmarkdown::html_vignette vignette: > - %\VignetteIndexEntry{Test vignette for GH Actopns} + %\VignetteIndexEntry{Test vignette for GH Actions} %\VignetteEngine{knitr::rmarkdown} %\VignetteEncoding{UTF-8} --- @@ -19,4 +19,3 @@ Irure ad excepteur aliqua esse id sint ex aliquip laborum. Officia laborum ex cu ```{r} summary(mtcars) ``` - From 5879f0c9388bae5dbb5f4161a46e6f8857e4c831 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Cs=C3=A1rdi?= Date: Fri, 2 Aug 2024 09:21:16 +0200 Subject: [PATCH 8/8] Add NEWS for `install-quarto` --- NEWS.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/NEWS.md b/NEWS.md index fb31bd763..dbe1ac457 100644 --- a/NEWS.md +++ b/NEWS.md @@ -14,6 +14,10 @@ unchanged, on all R versions. To avoid using a P3M snapshot on R 3.6.x, set the `RSPM_PIN_3_6` environment variable to `false`. +* `[setup-r-dependencies]` now automatically installs Quarto if the repo + has a qmd file, and it isn't installed. See the `install-quarto` and + `quarto-version` input parameters (#866). + # `v2.9.0` (2024-05-09) * The `test-coverage.yaml` example workflow now handles global Codecov