Skip to content

Commit

Permalink
feat: Make rstudioapi optional (#18)
Browse files Browse the repository at this point in the history
* feat: Make rstudioapi optional

* feat: Adding package down
  • Loading branch information
csgillespie authored Feb 22, 2025
1 parent b1248bf commit 5ccb029
Show file tree
Hide file tree
Showing 15 changed files with 106 additions and 19 deletions.
3 changes: 3 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@ docs
^config-uat-psw\.yml$
^\.github$
^README\.Rmd$
^_pkgdown\.yml$
^docs$
^pkgdown$
2 changes: 0 additions & 2 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ jobs:
fail-fast: false
matrix:
config:
- {os: macos-latest, r: 'release'}
- {os: windows-latest, r: 'release'}
- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
- {os: ubuntu-latest, r: 'release'}
- {os: ubuntu-latest, r: 'oldrel-1'}
Expand Down
49 changes: 49 additions & 0 deletions .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# 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
on:
push:
branches: [main, master]
pull_request:
release:
types: [published]
workflow_dispatch:

name: pkgdown.yaml

permissions: read-all

jobs:
pkgdown:
runs-on: ubuntu-latest
# Only restrict concurrency for non-PR jobs
concurrency:
group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }}
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
permissions:
contents: write
steps:
- uses: actions/checkout@v4

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

- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::pkgdown, local::.
needs: website

- name: Build site
run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE)
shell: Rscript {0}

- name: Deploy to GitHub pages 🚀
if: github.event_name != 'pull_request'
uses: JamesIves/[email protected]
with:
clean: false
branch: gh-pages
folder: docs
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,4 @@ inst/doc
*.env
*.swp
config-uat-psw.yml
docs
13 changes: 8 additions & 5 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
Type: Package
Package: audit.workbench
Title: RStudio/Workbench User Acceptance Tests
Version: 0.6.4
Version: 0.6.5
Authors@R:
person("Jumping", "Rivers", , "[email protected]", role = c("aut", "cre"))
Description: Testing whether data scientists can do what they expect in
RStudio Workbench.
Posit Workbench.
License: file LICENSE
Imports:
audit.base (>= 0.6.9),
audit.base (>= 0.6.20),
BiocManager,
cli,
dplyr,
Expand All @@ -20,7 +20,6 @@ Imports:
remotes,
rlang,
rmarkdown,
rstudioapi,
serverHeaders,
stringr,
tibble,
Expand All @@ -29,11 +28,15 @@ Imports:
yaml
Suggests:
reticulate,
rvest,
rstudioapi,
testthat (>= 3.0.0)
Remotes:
jumpingrivers/audit.base,
jumpingrivers/serverheaders
Config/testthat/edition: 3
Encoding: UTF-8
LazyData: false
RoxygenNote: 7.2.3
Language: en-GB
RoxygenNote: 7.3.2
URL: https://jumpingrivers.github.io/audit.workbench/
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# audit.workbench 0.6.5 *2025-02-22*
- feat: The {rstudioapi} package is now optional

# audit.workbench 0.6.4 *2023-01-11*
- fix: Return `TRUE`, when `testing_core_r_pkgs()` passes

Expand Down
21 changes: 20 additions & 1 deletion R/check_core_r_pkgs.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,30 @@ check_core_r_pkgs = R6::R6Class(
)

testing_core_r_pkgs = function(debug_level) {
core_r_pkgs = rstudioapi::getRStudioPackageDependencies()$name
core_r_pkgs = get_core_r_packages()
in_pkgs = utils::installed.packages()
missing_r_pkgs = core_r_pkgs[!(core_r_pkgs %in% rownames(in_pkgs))]
if (length(missing_r_pkgs) > 0L) {
cli::cli_abort("Core R packages are missing: {missing_r_pkgs}")
}
return(TRUE)
}

get_core_r_packages = function() {
if (requireNamespace("rstudioapi", quietly = TRUE)) {
core = rstudioapi::getRStudioPackageDependencies()$name
} else if (requireNamespace("rstudioapi", quietly = TRUE)) {
html = rvest::read_html("https://docs.posit.co/ide/server-pro/reference/r_package_dependencies.html") #nolint
cells = rvest::html_nodes(html, "td")
values = purrr::map_chr(cells, rvest::html_text2)
all = tibble::tibble(
"name" = values[seq.int(1L, length(values), 3L)],
"version" = values[seq.int(1L, length(values), 3L) + 1],
"features" = values[seq.int(1L, length(values), 3L) + 2]
)
core = all$name
} else {
stop("Install either rstudioapi or rvest to check core packages ")
}
return(sort(core))
}
2 changes: 1 addition & 1 deletion R/check_git_cloning.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ check_git_cloning = R6::R6Class(
inherit = audit.base::base_check,
public = list(
#' @description Checking that we can access and clone from github.com
#' @param debug_level See check() for details
#' @param debug_level See `check()` for details
check = function(debug_level) {
private$checker(git_cloning(debug_level))
return(invisible(NULL))
Expand Down
2 changes: 1 addition & 1 deletion R/check_package.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ check_bioconductor = R6::R6Class(
"check_bioconductor",
inherit = audit.base::base_check,
public = list(
#' @description Checks that bioconductor URLs are accessible
#' @description Checks that Bioconductor URLs are accessible
#' @param debug_level See check() for details
check = function(debug_level) {
private$checker(testing_bioconductor(debug_level))
Expand Down
8 changes: 7 additions & 1 deletion R/check_posit_version.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
check_posit_version = function() {
posit_version = rstudioapi::versionInfo()$long_version
if (requireNamespace("rstudioapi", quietly = TRUE)) {
posit_version = rstudioapi::versionInfo()$long_version
} else {
cmd = system2("rstudio-server", args = "version", stdout = TRUE)
posit_version = stringr::str_remove(cmd, " .*")

}
posit_version = stringr::str_remove(posit_version, "\\+[0-9]*")
audit.base::audit_posit_version(posit_version, type = "workbench")
return(posit_version)
Expand Down
4 changes: 4 additions & 0 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
url: https://jumpingrivers.github.io/audit.workbench/
template:
bootstrap: 5

1 change: 1 addition & 0 deletions audit.workbench.Rproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Version: 1.0
ProjectId: 40527578-1e74-4287-ac65-4e93cb15d8e4

RestoreWorkspace: Default
SaveWorkspace: Default
Expand Down
12 changes: 6 additions & 6 deletions inst/extdata/report/report.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ gt::gt(sys_deps) %>%
"pkg" = "R Package") %>%
gt::cols_align("left") %>%
gt::cols_hide("n") %>%
gt::tab_style(style = gt::cell_text(v_align = "top"),
gt::tab_style(style = gt::cell_text(v_align = "top"),
locations = gt::cells_body(columns = sys_libs))
```
Expand All @@ -111,12 +111,12 @@ gt::gt(software) %>%
gt::cols_align("right") %>%
gt::cols_hide(c("software", "upgrade")) %>%
gt::tab_row_group(label = "R", rows = which(.data$software == "r")) %>%
gt::tab_row_group(label = "Python", rows = which(.data$software == "python")) %>%
gt::tab_row_group(label = "Quarto", rows = which(.data$software == "quarto")) %>%
gt::tab_row_group(label = "R", rows = which(.data$software == "r")) %>%
gt::tab_row_group(label = "Python", rows = which(.data$software == "python")) %>%
gt::tab_row_group(label = "Quarto", rows = which(.data$software == "quarto")) %>%
gtExtras::gt_highlight_rows(rows = which(.data$upgrade), font_color = "white",
fill = severe)
fill = severe)
```

## Deployments
Expand All @@ -138,5 +138,5 @@ gt::gt(deploy) %>%
palette = c("grey10", "grey50"),
font_weight = c("normal", "normal"),
small_cap = FALSE
)
)
```
2 changes: 1 addition & 1 deletion man/check_bioconductor.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/check_git_cloning.Rd

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

0 comments on commit 5ccb029

Please sign in to comment.