From 97965096ee1b880cff784c2bf87208a02f330395 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] [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..8b312be6d 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: R{{ 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