Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add R CMD check without packages in Suggests #267

Merged
merged 7 commits into from
Nov 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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: check-no-suggests.yaml

permissions: read-all

jobs:
check-no-suggests:
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")'
2 changes: 2 additions & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ Suggests:
Matrix,
methods,
modeldata (>= 1.0.0),
probably,
recipes (>= 1.0.10.9000),
rmarkdown,
testthat (>= 3.0.0)
Expand All @@ -56,6 +57,7 @@ Remotes:
tidymodels/dials,
tidymodels/recipes,
tidymodels/parsnip,
tidymodels/probably,
tidymodels/tailor,
r-lib/sparsevctrs
Config/testthat/edition: 3
Expand Down
2 changes: 1 addition & 1 deletion R/broom.R
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ tidy.workflow <- function(x, what = "model", ...) {
#'
#' @export
#' @examples
#' if (rlang::is_installed("broom")) {
#' if (rlang::is_installed(c("broom", "modeldata"))) {
#'
#' library(parsnip)
#' library(magrittr)
Expand Down
2 changes: 1 addition & 1 deletion R/extract.R
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
#' section.
#'
#' @name extract-workflow
#' @examples
#' @examplesIf rlang::is_installed("recipes")
#' library(parsnip)
#' library(recipes)
#' library(magrittr)
Expand Down
6 changes: 3 additions & 3 deletions R/fit.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#'
#' @name fit-workflow
#' @export
#' @examples
#' @examplesIf rlang::is_installed("recipes")
#' library(parsnip)
#' library(recipes)
#' library(magrittr)
Expand Down Expand Up @@ -66,7 +66,7 @@ fit.workflow <- function(object, data, ..., calibration = NULL, control = contro

if (is_sparse_matrix(data)) {
data <- sparsevctrs::coerce_to_sparse_tibble(
data,
data,
call = rlang::caller_env(0)
)
}
Expand Down Expand Up @@ -125,7 +125,7 @@ fit.workflow <- function(object, data, ..., calibration = NULL, control = contro
#' @name workflows-internals
#' @keywords internal
#' @export
#' @examples
#' @examplesIf rlang::is_installed("recipes")
#' library(parsnip)
#' library(recipes)
#' library(magrittr)
Expand Down
2 changes: 1 addition & 1 deletion R/post-action-tailor.R
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
#' `x`, updated with either a new or removed tailor postprocessor.
#'
#' @export
#' @examples
#' @examplesIf rlang::is_installed(c("tailor", "probably"))
#' library(tailor)
#' library(magrittr)
#'
Expand Down
2 changes: 1 addition & 1 deletion R/pre-action-recipe.R
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
#' `x`, updated with either a new or removed recipe preprocessor.
#'
#' @export
#' @examples
#' @examplesIf rlang::is_installed("recipes")
#' library(recipes)
#' library(magrittr)
#'
Expand Down
4 changes: 2 additions & 2 deletions R/predict.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#'
#' @name predict-workflow
#' @export
#' @examples
#' @examplesIf rlang::is_installed("recipes")
#' library(parsnip)
#' library(recipes)
#' library(magrittr)
Expand Down Expand Up @@ -61,7 +61,7 @@ predict.workflow <- function(object, new_data, type = NULL, opts = list(), ...)

if (is_sparse_matrix(new_data)) {
new_data <- sparsevctrs::coerce_to_sparse_tibble(
new_data,
new_data,
call = rlang::caller_env(0)
)
}
Expand Down
2 changes: 1 addition & 1 deletion R/pull.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#'
#' @name workflow-extractors
#' @keywords internal
#' @examples
#' @examplesIf rlang::is_installed("recipes")
#' library(parsnip)
#' library(recipes)
#' library(magrittr)
Expand Down
4 changes: 2 additions & 2 deletions R/workflow.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#'
#' @includeRmd man/rmd/indicators.Rmd details
#'
#' @examples
#' @examplesIf rlang::is_installed(c("recipes", "modeldata"))
#' library(parsnip)
#' library(recipes)
#' library(magrittr)
Expand Down Expand Up @@ -166,7 +166,7 @@ is_workflow <- function(x) {
#' @return A single logical indicating if the workflow has been trained or not.
#'
#' @export
#' @examples
#' @examplesIf rlang::is_installed("recipes")
#' library(parsnip)
#' library(recipes)
#' library(magrittr)
Expand Down
2 changes: 2 additions & 0 deletions man/add_recipe.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions man/add_tailor.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions man/extract-workflow.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions man/fit-workflow.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/glance.workflow.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions man/is_trained_workflow.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions man/predict-workflow.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions man/workflow-extractors.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions man/workflow.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions man/workflows-internals.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions tests/testthat/helper-sparsevctrs.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
# For sparse tibble testing

sparse_hotel_rates <- function(tibble = FALSE) {
if (!rlang::is_installed("modeldata")) {
return()
}

# 99.2 sparsity
hotel_rates <- modeldata::hotel_rates

Expand Down
2 changes: 2 additions & 0 deletions tests/testthat/test-broom.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
skip_if_not_installed("recipes")

# ------------------------------------------------------------------------------
# tidy()

Expand Down
2 changes: 2 additions & 0 deletions tests/testthat/test-butcher.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
skip_if_not_installed("recipes")

test_that("attaches the butcher class", {
skip_if_not_installed("butcher")

Expand Down
5 changes: 5 additions & 0 deletions tests/testthat/test-extract.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
skip_if_not_installed("recipes")
skip_if_not_installed("modeldata")
skip_if_not_installed("probably")
skip_if_not_installed("tailor")

data(Chicago, package = "modeldata")

# ------------------------------------------------------------------------------
Expand Down
2 changes: 2 additions & 0 deletions tests/testthat/test-fit-action-model.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ test_that("prompt on spec without a loaded implementation (#174)", {
expect_snapshot(error = TRUE, workflow(spec = mod))
})

skip_if_not_installed("recipes")

test_that("cannot add two models", {
mod <- parsnip::linear_reg()
mod <- parsnip::set_engine(mod, "lm")
Expand Down
4 changes: 4 additions & 0 deletions tests/testthat/test-fit.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
skip_if_not_installed("recipes")

data("hardhat-example-data", package = "hardhat")

test_that("can `fit()` a workflow with a recipe", {
Expand Down Expand Up @@ -87,6 +89,7 @@ test_that("cannot fit without a fit stage", {

test_that("fit.workflow confirms compatibility of object and calibration", {
skip_if_not_installed("tailor")
skip_if_not_installed("probably")

mod <- parsnip::linear_reg()
mod <- parsnip::set_engine(mod, "lm")
Expand Down Expand Up @@ -199,6 +202,7 @@ test_that("`.fit_pre()` doesn't modify user supplied recipe blueprint", {
# .fit_post()
test_that(".workflow_includes_calibration works", {
skip_if_not_installed("tailor")
skip_if_not_installed("probably")

expect_false(.workflow_includes_calibration(workflow()))
expect_false(.workflow_includes_calibration(workflow() %>% add_model(parsnip::linear_reg())))
Expand Down
2 changes: 2 additions & 0 deletions tests/testthat/test-generics.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
skip_if_not_installed("recipes")

test_that("can compute required packages of a workflow - formula", {
mod <- parsnip::linear_reg()
mod <- parsnip::set_engine(mod, "lm")
Expand Down
3 changes: 3 additions & 0 deletions tests/testthat/test-post-action-tailor.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
skip_if_not_installed("probably")
skip_if_not_installed("tailor")

test_that("can add a postprocessor to a workflow", {
post <- tailor::tailor()

Expand Down
Loading
Loading