Skip to content

Commit

Permalink
Merge branch 'main' into improve-render
Browse files Browse the repository at this point in the history
  • Loading branch information
salim-b committed Sep 23, 2024
2 parents 193bc46 + 0fcb998 commit 497d895
Show file tree
Hide file tree
Showing 32 changed files with 308 additions and 101 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
^doc$
^Meta$

^vignettes/.quarto$
^vignettes/*_files$
^revdep$
^cran-comments\.md$
Expand Down
8 changes: 6 additions & 2 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@
# check-standard.yaml is likely a better choice.
# usethis::use_github_action("check-standard") will install it.
on:
workflow_dispatch:
push:
branches: [main, master]
pull_request:
branches: [main, master]

name: R-CMD-check

permissions: read-all

jobs:
R-CMD-check:
runs-on: ${{ matrix.config.os }}
Expand All @@ -27,8 +30,6 @@ jobs:

- {os: windows-latest, r: 'release'}
- {os: windows-latest, r: 'release', quarto: 'pre-release'}
# Use 3.6 to trigger usage of RTools35
- {os: windows-latest, r: '3.6'}
# use 4.1 to check with rtools40's older compiler
- {os: windows-latest, r: '4.1'}

Expand All @@ -48,6 +49,8 @@ jobs:
- uses: actions/checkout@v4

- uses: quarto-dev/quarto-actions/setup@v2
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
version: ${{ matrix.config.quarto || 'release' }}
tinytex: true
Expand All @@ -71,3 +74,4 @@ jobs:
- uses: r-lib/actions/check-r-package@v2
with:
upload-snapshots: true
build_args: 'c("--no-manual","--compact-vignettes=gs+qpdf")'
9 changes: 9 additions & 0 deletions .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ on:

name: pkgdown

permissions: read-all

jobs:
pkgdown:
runs-on: ubuntu-latest
Expand All @@ -24,6 +26,13 @@ jobs:
steps:
- uses: actions/checkout@v4

- uses: quarto-dev/quarto-actions/setup@v2
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
version: pre-release
tinytex: true

- uses: r-lib/actions/setup-pandoc@v2

- uses: r-lib/actions/setup-r@v2
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/pr-commands.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ on:

name: Commands

permissions: read-all

jobs:
document:
if: ${{ github.event.issue.pull_request && (github.event.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'OWNER') && startsWith(github.event.comment.body, '/document') }}
Expand Down
95 changes: 95 additions & 0 deletions .github/workflows/rhub.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# R-hub's generic GitHub Actions workflow file. It's canonical location is at
# https://github.com/r-hub/actions/blob/v1/workflows/rhub.yaml
# You can update this file to a newer version using the rhub2 package:
#
# rhub::rhub_setup()
#
# It is unlikely that you need to modify this file manually.

name: R-hub
run-name: "${{ github.event.inputs.id }}: ${{ github.event.inputs.name || format('Manually run by {0}', github.triggering_actor) }}"

on:
workflow_dispatch:
inputs:
config:
description: 'A comma separated list of R-hub platforms to use.'
type: string
default: 'linux,windows,macos'
name:
description: 'Run name. You can leave this empty now.'
type: string
id:
description: 'Unique ID. You can leave this empty now.'
type: string

jobs:

setup:
runs-on: ubuntu-latest
outputs:
containers: ${{ steps.rhub-setup.outputs.containers }}
platforms: ${{ steps.rhub-setup.outputs.platforms }}

steps:
# NO NEED TO CHECKOUT HERE
- uses: r-hub/actions/setup@v1
with:
config: ${{ github.event.inputs.config }}
id: rhub-setup

linux-containers:
needs: setup
if: ${{ needs.setup.outputs.containers != '[]' }}
runs-on: ubuntu-latest
name: ${{ matrix.config.label }}
strategy:
fail-fast: false
matrix:
config: ${{ fromJson(needs.setup.outputs.containers) }}
container:
image: ${{ matrix.config.container }}

steps:
- uses: r-hub/actions/checkout@v1
- uses: r-hub/actions/platform-info@v1
with:
token: ${{ secrets.RHUB_TOKEN }}
job-config: ${{ matrix.config.job-config }}
- uses: r-hub/actions/setup-deps@v1
with:
token: ${{ secrets.RHUB_TOKEN }}
job-config: ${{ matrix.config.job-config }}
- uses: r-hub/actions/run-check@v1
with:
token: ${{ secrets.RHUB_TOKEN }}
job-config: ${{ matrix.config.job-config }}

other-platforms:
needs: setup
if: ${{ needs.setup.outputs.platforms != '[]' }}
runs-on: ${{ matrix.config.os }}
name: ${{ matrix.config.label }}
strategy:
fail-fast: false
matrix:
config: ${{ fromJson(needs.setup.outputs.platforms) }}

steps:
- uses: r-hub/actions/checkout@v1
- uses: r-hub/actions/setup-r@v1
with:
job-config: ${{ matrix.config.job-config }}
token: ${{ secrets.RHUB_TOKEN }}
- uses: r-hub/actions/platform-info@v1
with:
token: ${{ secrets.RHUB_TOKEN }}
job-config: ${{ matrix.config.job-config }}
- uses: r-hub/actions/setup-deps@v1
with:
job-config: ${{ matrix.config.job-config }}
token: ${{ secrets.RHUB_TOKEN }}
- uses: r-hub/actions/run-check@v1
with:
job-config: ${{ matrix.config.job-config }}
token: ${{ secrets.RHUB_TOKEN }}
17 changes: 14 additions & 3 deletions .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ on:

name: test-coverage

permissions: read-all

jobs:
test-coverage:
runs-on: ubuntu-latest
Expand All @@ -28,23 +30,32 @@ jobs:

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::covr
extra-packages: any::covr, any::xml2
needs: coverage

- name: Test coverage
run: |
covr::codecov(
cov <- covr::package_coverage(
quiet = FALSE,
clean = FALSE,
install_path = file.path(normalizePath(Sys.getenv("RUNNER_TEMP"), winslash = "/"), "package")
)
covr::to_cobertura(cov)
shell: Rscript {0}

- uses: codecov/codecov-action@v4
with:
fail_ci_if_error: ${{ github.event_name != 'pull_request' && true || false }}
file: ./cobertura.xml
plugin: noop
disable_search: true
token: ${{ secrets.CODECOV_TOKEN }}

- name: Show testthat output
if: always()
run: |
## --------------------------------------------------------------------
find ${{ runner.temp }}/package -name 'testthat.Rout*' -exec cat '{}' \; || true
find '${{ runner.temp }}/package' -name 'testthat.Rout*' -exec cat '{}' \; || true
shell: bash

- name: Upload test results
Expand Down
8 changes: 4 additions & 4 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: quarto
Title: R Interface to 'Quarto' Markdown Publishing System
Version: 1.4.1
Version: 1.4.4.9003
Authors@R: c(
person("JJ", "Allaire", , "[email protected]", role = "aut",
comment = c(ORCID = "0000-0003-0174-9868")),
Expand Down Expand Up @@ -39,6 +39,6 @@ VignetteBuilder:
Config/testthat/edition: 3
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.1
SystemRequirements: Quarto command line tools
(https://github.com/quarto-dev/quarto-cli).
RoxygenNote: 7.3.2
SystemRequirements: Quarto command line tool
(<https://github.com/quarto-dev/quarto-cli>).
20 changes: 19 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,31 @@
# quarto (development version)

- Add `quarto.quiet` options to allow more verbose error message when `quarto_*` function are used inside other package.
For example, inside **pkgdown** for building Quarto vignettes. **pkgdown** sets `quiet = TRUE` internally for its call to `quarto_render()`,
and setting `options(quarto.quiet = TRUE)` allows to overwrite this.

- `quarto_path()` now returns a normalized path with potential symlink resolved, for less confusion with `quarto_binary_sitrep()` (thanks, @jennybc).

- Fix an error with interactive prompt for extension approval (thanks, @wjschne, #212).

# quarto 1.4.4

- `quarto_preview()` now looks at `quarto preview` log to browse to the correct url when inside RStudio viewer (thanks, @aronatkins, #167).

- This package now uses the x.y.z.dev versionning scheme to indicate development, patch, minor and major versions. This follows [Tidyverse package version conventions](https://r-pkgs.org/lifecycle.html#sec-lifecycle-version-number-tidyverse).

- Adapt tests for CRAN checks issues due to Quarto v1.5.54 regression (though it is fixed upstream).

- Approval check in `quarto_add_extension()` and `quarto_use_template()` now works correctly (thanks, @eveyp, #172).

# quarto 1.4

- This version is now adapted to Quarto 1.4 latest stable release.

- Add registration of vignette engine to use `quarto` as a vignette builder, and use `.qmd` file as vignette. See `vignette("hello", package = "quarto")`. (thanks, @dcnorris, #57).

- New `quarto_binary_sitrep()` checks possible difference in Quarto binary used by this package, and the one used by RStudio IDE (thanks, @jthomasmock, #12).

- New `is_using_quarto()` to check if a directory requires using Quarto (i.e. it has a `_quarto.yml` or at least one `*.qmd` file) (thanks, @hadley, #103).

- New `quarto_create_project()` calls `quarto create project <type> <name>` (thanks, @maelle, #87).
Expand Down
9 changes: 5 additions & 4 deletions R/add.R
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,12 @@ quarto_add_extension <- function(extension = NULL, no_prompt = FALSE, quiet = FA
quarto_bin <- find_quarto()

# This will ask for approval or stop installation
check_extension_approval(no_prompt, "Quarto extensions", "https://quarto.org/docs/extensions/managing.html")
approval <- check_extension_approval(no_prompt, "Quarto extensions", "https://quarto.org/docs/extensions/managing.html")

args <- c(extension, "--no-prompt", if (quiet) cli_arg_quiet(), quarto_args)

quarto_add(args, quarto_bin = quarto_bin, echo = TRUE)
if (approval) {
args <- c(extension, "--no-prompt", if (is_quiet(quiet)) cli_arg_quiet(), quarto_args)
quarto_add(args, quarto_bin = quarto_bin, echo = TRUE)
}

invisible()
}
Expand Down
2 changes: 1 addition & 1 deletion R/create.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ quarto_create_project <- function(name, type = "default", dir = ".", no_prompt =

quarto_bin <- find_quarto()

args <- c("project", type, name, "--no-prompt", "--no-open", if (quiet) cli_arg_quiet(), quarto_args = NULL)
args <- c("project", type, name, "--no-prompt", "--no-open", if (is_quiet(quiet)) cli_arg_quiet(), quarto_args = NULL)

owd <- setwd(dir)
on.exit(setwd(owd), add = TRUE, after = FALSE)
Expand Down
17 changes: 15 additions & 2 deletions R/daemon.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,14 @@ run_serve_daemon <- function(command, target, wd, extra_args, render, port, host
# calculate keys
ps_key <- paste0(command, "_ps")
port_key <- paste0(command, "_port")
url_key <- paste0(command, "_url")
# We don't need to keep previous url
quarto[[url_key]] <- NULL

# manage existing server instances
stop_serve_daemon(command)
# we don't need to keep previous url
quarto[[url_key]] <- NULL

# if the last server had a port then re-use it for "auto"
if (port == "auto") {
Expand Down Expand Up @@ -86,12 +91,20 @@ run_serve_daemon <- function(command, target, wd, extra_args, render, port, host
}
quarto[[port_key]] <- port



# monitor the process for abnormal exit
poll_process <- function() {
if (is.null(quarto[[ps_key]])) {
return()
}
cat(quarto[[ps_key]]$read_output())
ro <- quarto[[ps_key]]$read_output()
cat(ro)
# Look at url to browse too in `quarto preview log`
if (!isFALSE(browse) && is.null(quarto[[url_key]]) && grepl("Browse at https?://", ro)) {
m <- regexec("Browse at (https?://[^ ]+)\n", ro)
quarto[[url_key]] <- regmatches(ro, m)[[1]][2]
}
if (!quarto[[ps_key]]$is_alive()) {
status <- quarto[[ps_key]]$get_exit_status()
quarto[[ps_key]] <- NULL
Expand All @@ -116,7 +129,7 @@ run_serve_daemon <- function(command, target, wd, extra_args, render, port, host
utils::browseURL
)
}
serve_url <- paste0("http://localhost:", port)
serve_url <- quarto[[url_key]] %||% paste0("http://localhost:", port)
browse(serve_url)
}

Expand Down
2 changes: 1 addition & 1 deletion R/inspect.R
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ quarto_inspect <- function(input = ".",
args <- c(args, c("--profile", paste0(profile, collapse = ",")))
}

if (isTRUE(quiet)) args <- cli_arg_quiet(args)
if (is_quiet(quiet)) args <- cli_arg_quiet(args)

args <- c(args, quarto_args)

Expand Down
7 changes: 7 additions & 0 deletions R/quarto-args.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@ cli_arg_profile <- function(profile, ...) {
append_cli_args(arg, ...)
}

is_quiet <- function(quiet) {
# this option takes precedence
quiet_options <- getOption("quarto.quiet", NA)
if (!is.na(quiet_options)) return(quiet_options)
isTRUE(quiet)
}

cli_arg_quiet <- function(...) {
append_cli_args("--quiet", ...)
}
Expand Down
3 changes: 2 additions & 1 deletion R/quarto.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@
#' @export
quarto_path <- function() {
path_env <- get_quarto_path_env()
if (is.na(path_env)) {
quarto_path <- if (is.na(path_env)) {
path <- unname(Sys.which("quarto"))
if (nzchar(path)) path else NULL
} else {
path_env
}
normalizePath(quarto_path, winslash = "/", mustWork = FALSE)
}

get_quarto_path_env <- function() {
Expand Down
Loading

0 comments on commit 497d895

Please sign in to comment.