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 diff --git a/NEWS.md b/NEWS.md index 16ece5059..b3c55978a 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). + * `[setup-r]` now avoids spurious warnings from Homebrew (#864). * `[setup-r-dependencies]` now accepts `pak-version: none` to skip pak 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/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 2d2cc36f2..372a9d4a6 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: @@ -156,20 +170,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' } } @@ -184,6 +203,38 @@ runs: with: pandoc-version: ${{ inputs.pandoc-version }} + - name: Check whether quarto if needed + id: check-quarto + run: | + # Quarto check + cat("::group::Check if package needs quarto\n") + 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") + 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 diff --git a/vignettes/quarto-test.qmd b/vignettes/quarto-test.qmd new file mode 100644 index 000000000..3bd9ba05a --- /dev/null +++ b/vignettes/quarto-test.qmd @@ -0,0 +1,19 @@ +--- +title: "Quarto HTML Vignettes" +vignette: > + %\VignetteIndexEntry{Quarto HTML Vignettes} + %\VignetteEngine{quarto::html} + %\VignetteEncoding{UTF-8} +--- + +## 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) ``` -