Skip to content

Commit

Permalink
add R CMD check without packages in Suggests (#170)
Browse files Browse the repository at this point in the history
* add R CMD check without packages in Suggests
* skip vignette eval without packages in Suggests
* skip tests and examples needing Suggests
* another test skip
  • Loading branch information
simonpcouch authored Oct 24, 2024
1 parent 3f36252 commit 444ae2a
Show file tree
Hide file tree
Showing 11 changed files with 79 additions and 3 deletions.
60 changes: 60 additions & 0 deletions .github/workflows/R-CMD-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-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: 1 addition & 1 deletion R/leave_var_out_formulas.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#'
#' Factor predictors are left as-is (i.e., no indicator variables are created).
#'
#' @examples
#' @examplesIf rlang::is_installed("modeldata")
#' data(penguins, package = "modeldata")
#'
#' leave_var_out_formulas(
Expand Down
1 change: 1 addition & 0 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ knitr::opts_chunk$set(

<!-- badges: start -->
[![R-CMD-check](https://github.com/tidymodels/workflowsets/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/tidymodels/workflowsets/actions/workflows/R-CMD-check.yaml)
[![R-CMD-check-no-suggests](https://github.com/tidymodels/workflowsets/actions/workflows/R-CMD-check-no-suggests.yaml/badge.svg)](https://github.com/tidymodels/workflowsets/actions/workflows/R-CMD-check-no-suggests.yaml)
[![Codecov test coverage](https://codecov.io/gh/tidymodels/workflowsets/branch/main/graph/badge.svg)](https://app.codecov.io/gh/tidymodels/workflowsets?branch=main)
[![Lifecycle](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html)
<!-- badges: end -->
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<!-- badges: start -->

[![R-CMD-check](https://github.com/tidymodels/workflowsets/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/tidymodels/workflowsets/actions/workflows/R-CMD-check.yaml)
[![R-CMD-check-no-suggests](https://github.com/tidymodels/workflowsets/actions/workflows/R-CMD-check-no-suggests.yaml/badge.svg)](https://github.com/tidymodels/workflowsets/actions/workflows/R-CMD-check-no-suggests.yaml)
[![Codecov test
coverage](https://codecov.io/gh/tidymodels/workflowsets/branch/main/graph/badge.svg)](https://app.codecov.io/gh/tidymodels/workflowsets?branch=main)
[![Lifecycle](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html)
Expand Down
2 changes: 2 additions & 0 deletions man/leave_var_out_formulas.Rd

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

2 changes: 2 additions & 0 deletions tests/testthat/test-collect-predictions.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
skip_on_cran()
skip_if_not_installed("kknn")
skip_if_not_installed("modeldata")

# ------------------------------------------------------------------------------

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

library(parsnip)
library(rsample)
library(recipes)
Expand Down
3 changes: 3 additions & 0 deletions tests/testthat/test-fit_best.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
skip_if_not_installed("kknn")
skip_if_not_installed("modeldata")

test_that("fit_best fits with correct hyperparameters", {
skip_on_cran()

Expand Down
3 changes: 3 additions & 0 deletions tests/testthat/test-updates.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
skip_if_not_installed("kknn")
skip_if_not_installed("modeldata")

library(parsnip)
library(recipes)
library(hardhat)
Expand Down
5 changes: 3 additions & 2 deletions tests/testthat/test-workflow-map.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
skip_if_not_installed("kknn")
skip_if_not_installed("modeldata")

library(parsnip)
suppressPackageStartupMessages(library(rsample))
suppressPackageStartupMessages(library(tune))
Expand Down Expand Up @@ -81,8 +84,6 @@ test_that("map logging", {
)
})



test_that("missing packages", {
skip_if(rlang::is_installed("glmnet"))
car_set_2 <-
Expand Down
1 change: 1 addition & 0 deletions vignettes/evaluating-different-predictor-sets.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ vignette: >
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
eval = rlang::is_installed(c("modeldata", "recipes")),
comment = "#>"
)
library(parsnip)
Expand Down

0 comments on commit 444ae2a

Please sign in to comment.