Skip to content

Commit

Permalink
nosuggests (#1075)
Browse files Browse the repository at this point in the history
* nosuggests workflow

* skip tests on missing suggests

* skip quarto tests on cran, as quarto leaves residue in ~/.cache

* NEWS

* link news to issue
  • Loading branch information
aronatkins authored May 23, 2024
1 parent f3b1993 commit 4c30b1c
Show file tree
Hide file tree
Showing 15 changed files with 118 additions and 0 deletions.
60 changes: 60 additions & 0 deletions .github/workflows/check-no-suggests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
#
# NOTE: This workflow only directly installs "hard" dependencies, i.e. Depends,
# Imports, and LinkingTo dependencies. Notably, Suggests dependencies are never
# installed, with the exception of testthat, knitr, and rmarkdown. The cache is
# never used to avoid accidentally restoring a cache containing a suggested
# dependency.
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]

name: R-CMD-check-hard

permissions: read-all

jobs:
R-CMD-check:
runs-on: ${{ matrix.config.os }}

name: ${{ matrix.config.os }} (${{ matrix.config.r }})

strategy:
fail-fast: false
matrix:
config:
- {os: ubuntu-latest, r: 'release'}

env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
R_KEEP_PKG_SOURCE: yes

steps:
- uses: actions/checkout@v4

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

- uses: r-lib/actions/setup-r@v2
with:
r-version: ${{ matrix.config.r }}
http-user-agent: ${{ matrix.config.http-user-agent }}
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v2
with:
dependencies: '"hard"'
cache: false
extra-packages: |
any::rcmdcheck
any::testthat
any::knitr
any::rmarkdown
needs: check

- uses: r-lib/actions/check-r-package@v2
with:
upload-snapshots: true
build_args: 'c("--no-manual","--compact-vignettes=gs+qpdf")'
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
* `deployTF()` can deploy a TensorFlow model to Posit Connect. Requires Posit
Connect 2024.05.0 or higher.

* Skip tests when suggested packages are not available. Skip Quarto tests when
run by CRAN. (#1074)

# rsconnect 1.2.2

* Use internally computed SHA1 sums and PKI signing when SHA1 is disabled
Expand Down
3 changes: 3 additions & 0 deletions tests/testthat/test-appDependencies.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ test_that("appDependencies includes implicit deps", {

test_that("appDependencies includes implicit deps when appMode forced", {
skip_on_cran()
skip_if_not_installed("plumber")
skip_if_not_installed("shiny")
skip_if_not_installed("rmarkdown")

withr::local_options(renv.verbose = TRUE)

Expand Down
7 changes: 7 additions & 0 deletions tests/testthat/test-appMetadata-quarto.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ fakeQuartoMetadata <- function(version, engines) {
}

test_that("inferQuartoInfo correctly detects info when quarto is provided alone", {
skip_on_cran()
skip_if_no_quarto()

quartoInfo <- inferQuartoInfo(
Expand Down Expand Up @@ -51,6 +52,7 @@ test_that("quartoInspect requires quarto", {
})

test_that("quartoInspect identifies Quarto projects", {
skip_on_cran()
skip_if_no_quarto()

inspect <- quartoInspect(test_path("quarto-website-r"))
Expand All @@ -61,6 +63,7 @@ test_that("quartoInspect identifies Quarto projects", {
})

test_that("quartoInspect identifies Quarto documents", {
skip_on_cran()
skip_if_no_quarto()

inspect <- quartoInspect(
Expand All @@ -71,6 +74,7 @@ test_that("quartoInspect identifies Quarto documents", {
})

test_that("quartoInspect processes content within paths containing spaces", {
skip_on_cran()
skip_if_no_quarto()

parent <- withr::local_tempdir()
Expand All @@ -87,6 +91,7 @@ test_that("quartoInspect processes content within paths containing spaces", {
})

test_that("quartoInspect processes content with filenames containing spaces", {
skip_on_cran()
skip_if_no_quarto()

dir <- local_temp_app(list("space file.qmd" = c(
Expand All @@ -112,6 +117,7 @@ strip_quarto_trace <- function(lines) {
}

test_that("quartoInspect produces an error when a document cannot be inspected", {
skip_on_cran()
skip_if_no_quarto()

# Suppress colors from Quarto errors.
Expand All @@ -131,6 +137,7 @@ test_that("quartoInspect produces an error when a document cannot be inspected",
})

test_that("quartoInspect produces an error when a project cannot be inspected", {
skip_on_cran()
skip_if_no_quarto()

# Suppress colors from Quarto errors.
Expand Down
6 changes: 6 additions & 0 deletions tests/testthat/test-appMetadata.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# appMetadata -------------------------------------------------------------

test_that("quarto affects mode inference", {
skip_on_cran()

dir <- local_temp_app(list("foo.Rmd" = ""))

metadata <- appMetadata(dir, c("foo.Rmd"))
Expand All @@ -11,12 +13,16 @@ test_that("quarto affects mode inference", {
})

test_that("quarto path is deprecated", {
skip_on_cran()
skip_if_no_quarto()

dir <- local_temp_app(list("foo.Rmd" = ""))
expect_snapshot(. <- appMetadata(dir, c("foo.Rmd"), quarto = "abc"))
})

test_that("validates quarto argument", {
skip_on_cran()

dir <- local_temp_app(list("foo.Rmd" = ""))
expect_snapshot(appMetadata(dir, c("foo.Rmd"), quarto = 1), error = TRUE)
})
Expand Down
3 changes: 3 additions & 0 deletions tests/testthat/test-client-cloud.R
Original file line number Diff line number Diff line change
Expand Up @@ -898,6 +898,9 @@ test_that("deployApp() for shiny results in correct Cloud API calls", {
})

test_that("deployDoc() results in correct Cloud API calls", {
skip_on_cran()
skip_if_not_installed("rmarkdown")

local_temp_config()

mock <- deployAppMockServerFactory(expectedAppType = "static", outputState = "active")
Expand Down
2 changes: 2 additions & 0 deletions tests/testthat/test-client-connect.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ test_that("messages without recognized timestamps are unmodified", {
})

test_that("waitForTask", {
skip_if_not_installed("webfakes")

task_app <- webfakes::new_app()
task_app$use(webfakes::mw_json())
task_app$get("/tasks/:id", function(req, res) {
Expand Down
6 changes: 6 additions & 0 deletions tests/testthat/test-deploySite.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
test_that("can extract quarto metadata", {
skip_on_cran()
skip_if_no_quarto()
skip_if_not_installed("quarto")

app <- local_temp_app(list(`_quarto.yaml` = c(
"project:",
" type: website",
Expand All @@ -14,6 +17,9 @@ test_that("can extract quarto metadata", {
})

test_that("can extract rmarkdown metadata", {
skip_on_cran()
skip_if_not_installed("rmarkdown")

app <- local_temp_app(list(
`_site.yml` = 'name: "my-website"'
))
Expand Down
2 changes: 2 additions & 0 deletions tests/testthat/test-http-curl.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
test_that("basic HTTP methods work", {
skip_if(Sys.which("curl") == "")
skip_if_not_installed("webfakes")

withr::local_options(rsconnect.http = "curl", lifecycle_verbosity = "quiet")

test_http_GET()
Expand Down
2 changes: 2 additions & 0 deletions tests/testthat/test-http-internal.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
test_that("basic HTTP methods work", {
skip_if_not_installed("webfakes")

withr::local_options(rsconnect.http = "internal", lifecycle_verbosity = "quiet")

test_http_GET()
Expand Down
6 changes: 6 additions & 0 deletions tests/testthat/test-http-libcurl.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
test_that("basic HTTP methods work", {
skip_if_not_installed("webfakes")

withr::local_options(rsconnect.http = "libcurl")

test_http_GET()
Expand All @@ -9,6 +11,8 @@ test_that("basic HTTP methods work", {
})

test_that("can trace JSON", {
skip_if_not_installed("webfakes")

withr::local_options(rsconnect.http.trace.json = TRUE)
service <- httpbin_service()

Expand All @@ -27,6 +31,8 @@ test_that("can trace JSON", {

test_that("can get and set cookies", {
skip_on_cran()
skip_if_not_installed("webfakes")

# uses live httpbin since webfakes doesn't support cookie endpoints
service <- parseHttpUrl("http://httpbin.org/")

Expand Down
2 changes: 2 additions & 0 deletions tests/testthat/test-http-rcurl.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
test_that("basic HTTP methods work", {
skip_if_not_installed("RCurl")
skip_if_not_installed("webfakes")

withr::local_options(rsconnect.http = "rcurl", lifecycle_verbosity = "quiet")

test_http_GET()
Expand Down
10 changes: 10 additions & 0 deletions tests/testthat/test-http.R
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ a3hEFijsjg/+FDMr+iAVzjry
})

test_that("can add user specific headers", {
skip_if_not_installed("webfakes")

withr::local_options(rsconnect.http.headers = c(a = "1", b = "2"))

service <- httpbin_service()
Expand All @@ -88,6 +90,8 @@ test_that("can add user specific headers", {

test_that("can add user specific cookies", {
skip_on_cran()
skip_if_not_installed("webfakes")

# uses live httpbin since webfakes doesn't support cookie endpoints
withr::local_options(rsconnect.http.cookies = c("a=1", "b=2"))
service <- parseHttpUrl("http://httpbin.org/")
Expand Down Expand Up @@ -163,6 +167,8 @@ test_that("but still gives got error if no body", {
})

test_that("errors contain method", {
skip_if_not_installed("webfakes")

service <- httpbin_service()
expect_snapshot(error = TRUE, {
GET(service, list(), path = "status/404")
Expand All @@ -171,6 +177,8 @@ test_that("errors contain method", {
})

test_that("http error includes status in error class", {
skip_if_not_installed("webfakes")

service <- httpbin_service()
expect_error(
GET(service, list(), path = "status/404"),
Expand All @@ -183,6 +191,8 @@ test_that("http error includes status in error class", {
})

test_that("handles redirects", {
skip_if_not_installed("webfakes")

service <- httpbin_service()
out <- GET(service, list(), "absolute-redirect/3")
expect_equal(out$url, paste0(buildHttpUrl(service), "get"))
Expand Down
4 changes: 4 additions & 0 deletions tests/testthat/test-ide.R
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ current_user_service <- function() {
}

test_that("getUserFromRawToken having a single matching server", {
skip_if_not_installed("webfakes")

local_temp_config()

service <- current_user_service()
Expand All @@ -82,6 +84,8 @@ test_that("getUserFromRawToken having a single matching server", {
})

test_that("getUserFromRawToken having multiple matching servers", {
skip_if_not_installed("webfakes")

local_temp_config()

service <- current_user_service()
Expand Down
2 changes: 2 additions & 0 deletions tests/testthat/test-servers.R
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ test_that("addServer() normalises url", {
})

test_that("addServer() errors if url not a connect server", {
skip_if_not_installed("webfakes")

local_temp_config()

service <- httpbin_service()
Expand Down

0 comments on commit 4c30b1c

Please sign in to comment.