Skip to content
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
12 changes: 6 additions & 6 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
Type: Package
Package: audit.workbench
Title: RStudio/Workbench User Acceptance Tests
Version: 0.6.5
Authors@R:
Version: 0.6.6
Authors@R:
person("Jumping", "Rivers", , "info@jumpingrivers.com", role = c("aut", "cre"))
Description: Testing whether data scientists can do what they expect in
Posit Workbench.
License: file LICENSE
URL: https://jumpingrivers.github.io/audit.workbench/
Imports:
audit.base (>= 0.6.20),
BiocManager,
Expand All @@ -28,15 +29,14 @@ Imports:
yaml
Suggests:
reticulate,
rvest,
rstudioapi,
rvest,
testthat (>= 3.0.0)
Remotes:
jumpingrivers/audit.base,
jumpingrivers/serverheaders
Config/testthat/edition: 3
Encoding: UTF-8
LazyData: false
Language: en-GB
RoxygenNote: 7.3.2
URL: https://jumpingrivers.github.io/audit.workbench/
LazyData: false
RoxygenNote: 7.3.3
1 change: 0 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,4 @@ export(check_rmd_html)
export(check_rmd_pdf)
export(check_rmd_word)
export(create_config)
importFrom(dplyr,"%>%")
importFrom(rlang,.data)
6 changes: 5 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# audit.workbench 0.6.6 *2026-01-22*
- fix: Parsing Posit versions #20
- chore: Linting and air'ing

# audit.workbench 0.6.5 *2025-02-22*
- feat: The {rstudioapi} package is now optional

Expand All @@ -19,7 +23,7 @@
# audit.workbench 0.5.0 *2023-06-21*
- feat: Use %>% instead of |>
- feat: Add initial report
- feat: Standardise function names with
- feat: Standardise function names with

# audit.workbench 0.4.0 *2023-06-11*
- feat: Initial version
10 changes: 6 additions & 4 deletions R/audit_details.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
audit_details = function(server) {
list(user = Sys.info()[["user"]],
server = server,
time = Sys.time(),
version = utils::packageVersion("audit.workbench"))
list(
user = Sys.info()[["user"]],
server = server,
time = Sys.time(),
version = utils::packageVersion("audit.workbench")
)
}
16 changes: 8 additions & 8 deletions R/check.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@
#' * 2: No clean-up and display build steps
#' @importFrom rlang .data
#' @export
check = function(server,
dir = ".",
debug_level = 0:2) {
check = function(server, dir = ".", debug_level = 0:2) {
debug_level = audit.base::get_debug_level(force(debug_level))

check_list = list()
Expand All @@ -28,12 +26,14 @@ check = function(server,
check_list$sys_deps = check_sys_libs(debug_level)
check_list$versions = check_versions(debug_level)
cli::cli_h2("Starting checks")
r6_inits = audit.base::init_r6_checks(dir = dir,
file = "config-uat-psw.yml",
pkg_name = "audit.workbench")
r6_inits = audit.base::init_r6_checks(
dir = dir,
file = "config-uat-psw.yml",
pkg_name = "audit.workbench"
)
lapply(r6_inits, function(r6) r6$check(debug_level = debug_level))
results = purrr::map_dfr(r6_inits, ~.x$get_log())
results = purrr::map_dfr(r6_inits, ~ .x$get_log())
check_list$results = dplyr::arrange(results, .data$group, .data$short)
cli::cli_h1("All checks complete")
return(invisible(check_list))
invisible(check_list)
}
10 changes: 6 additions & 4 deletions R/check_core_r_pkgs.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ check_core_r_pkgs = R6::R6Class(
#' @param debug_level See check() for details
check = function(debug_level) {
private$checker(testing_core_r_pkgs(debug_level))
return(invisible(NULL))
invisible(NULL)
}
),
private = list(
Expand All @@ -30,14 +30,16 @@ testing_core_r_pkgs = function(debug_level) {
if (length(missing_r_pkgs) > 0L) {
cli::cli_abort("Core R packages are missing: {missing_r_pkgs}")
}
return(TRUE)
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
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(
Expand All @@ -49,5 +51,5 @@ get_core_r_packages = function() {
} else {
stop("Install either rstudioapi or rvest to check core packages ")
}
return(sort(core))
sort(core)
}
7 changes: 3 additions & 4 deletions R/check_file_permissions.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ check_file_permissions = R6::R6Class(
#' @param debug_level See check() for details
check = function(debug_level) {
private$checker(testing_file_permissions(debug_level))
return(invisible(NULL))
invisible(NULL)
}
),
private = list(
Expand All @@ -31,7 +31,6 @@ testing_file_permissions = function(debug_level) {
# Convert the string to an integer, so that we can use it to make comparisons:
file_permissions = strtoi(permissions_on_file)
stopifnot("File permissions incorrect" = file_permissions >= 600)
}
)
return(invisible(TRUE))
})
invisible(TRUE)
}
9 changes: 6 additions & 3 deletions R/check_git_cloning.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ check_git_cloning = R6::R6Class(
#' @param debug_level See `check()` for details
check = function(debug_level) {
private$checker(git_cloning(debug_level))
return(invisible(NULL))
invisible(NULL)
}
),
private = list(
Expand All @@ -25,8 +25,11 @@ git_cloning = function(debug_level) {
git_clone_url = "https://github.com/jumpingrivers/diffify.git"
git_local_folder = file.path(tempdir(), "diffify")

system2("git", args = c("clone", "--depth", "1", git_clone_url, git_local_folder))
system2(
"git",
args = c("clone", "--depth", "1", git_clone_url, git_local_folder)
)
withr::defer(unlink(git_local_folder, recursive = TRUE))
success = dir.exists(git_local_folder)
return(success)
success
}
24 changes: 15 additions & 9 deletions R/check_package.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ check_cran = R6::R6Class(
#' @param debug_level See check() for details
check = function(debug_level) {
private$checker(testing_cran(debug_level))
return(invisible(NULL))
rinvisible(NULL)
}
),
private = list(
Expand All @@ -37,7 +37,7 @@ check_bioconductor = R6::R6Class(
#' @param debug_level See check() for details
check = function(debug_level) {
private$checker(testing_bioconductor(debug_level))
return(invisible(NULL))
invisible(NULL)
}
),
private = list(
Expand All @@ -60,7 +60,7 @@ check_github = R6::R6Class(
#' @param debug_level See check() for details
check = function(debug_level) {
private$checker(testing_github(debug_level))
return(invisible(NULL))
invisible(NULL)
}
),
private = list(
Expand All @@ -76,14 +76,17 @@ testing_cran = function(debug_level) {
pkg_name = "drat"
is_installed = install_packages(pkg_name, quiet = TRUE)
stopifnot("pkg unable to be installed" = is_installed)
return(invisible(TRUE))
invisible(TRUE)
}

testing_github = function(debug_level) {
installed_pkg = remotes::install_github("jumpingrivers/datasauRus",
quiet = TRUE, force = TRUE)
installed_pkg = remotes::install_github(
"jumpingrivers/datasauRus",
quiet = TRUE,
force = TRUE
)
stopifnot(installed_pkg == "datasauRus")
return(invisible(TRUE))
invisible(TRUE)
}

testing_bioconductor = function(debug_level) {
Expand All @@ -94,7 +97,7 @@ testing_bioconductor = function(debug_level) {
lapply(repos, function(repo) {
stopifnot("Unable to access bioconductor repo" = !httr::http_error(repo))
})
return(invisible(TRUE))
invisible(TRUE)
}

install_packages = function(pkgs, quiet = FALSE) {
Expand All @@ -104,7 +107,10 @@ install_packages = function(pkgs, quiet = FALSE) {
# install.packages() doesn't throw an error if the pkg install fails
# instead we capture the warning using capture() - that then changes the value of `e`
# Hence: if e isn't null, something bad has happened.
withCallingHandlers(utils::install.packages(pkgs, quiet = quiet), warning = capture)
withCallingHandlers(
utils::install.packages(pkgs, quiet = quiet),
warning = capture
)
# If pkg not installed, return FALSE
is.null(e)
}
13 changes: 9 additions & 4 deletions R/check_posit_drivers.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,26 @@ check_posit_drivers = function(debug_level) {
software = "Posit pro-drivers",
installed_version = installed_version,
upgrade = upgrade,
version = latest_version)
version = latest_version
)
audit.base::print_colour_versions(installed)
return(installed)
installed
}

get_installed_posit_driver = function() {
fname = "/opt/rstudio-drivers/odbcinst.ini.sample"
if (file.exists(fname)) {
odbc = readLines(fname, warn = FALSE)
versions = odbc[stringr::str_starts(odbc, "#", negate = TRUE)]
versions = stringr::str_extract(versions, "RStudioVersion = (.*)", group = TRUE)
versions = stringr::str_extract(
versions,
"RStudioVersion = (.*)",
group = TRUE
)
versions = versions[!is.na(versions)]
installed_version = unique(versions)
} else {
installed_version = NA_character_
}
return(installed_version)
installed_version
}
10 changes: 7 additions & 3 deletions R/check_posit_version.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@ check_posit_version = function() {
} else {
cmd = system2("rstudio-server", args = "version", stdout = TRUE)
posit_version = stringr::str_remove(cmd, " .*")

}
posit_version = stringr::str_remove(posit_version, "\\+[0-9]*")
posit_version = stringr::str_squish(posit_version)

posit_version = stringr::str_extract(
posit_version,
"^20[0-9][0-9]\\.[0-9]?[0-9]\\.[0-9]?[0-9]"
)
audit.base::audit_posit_version(posit_version, type = "workbench")
return(posit_version)
posit_version
}
20 changes: 13 additions & 7 deletions R/check_python.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ check_python_pip = R6::R6Class(
#' @param debug_level See check() for details
check = function(debug_level) {
private$checker(python_pip_tests(debug_level))
return(invisible(NULL))
invisible(NULL)
}
),
private = list(
Expand All @@ -33,7 +33,7 @@ check_python_reticulate = R6::R6Class(
#' @param debug_level See check() for details
check = function(debug_level) {
private$checker(python_reticulate_tests(debug_level))
return(invisible(NULL))
invisible(NULL)
}
),
private = list(
Expand All @@ -51,21 +51,27 @@ python_pip_tests = function(debug_level) {
min_version = grepl("pip [2-3][0-9]", pip_version)
stopifnot("Pip failed to install " = min_version)

numpy = processx::run("pip", args = c("install", "numpy", "--force-reinstall"))
numpy = processx::run(
"pip",
args = c("install", "numpy", "--force-reinstall")
)
withr::defer(processx::run("pip", args = c("uninstall", "numpy", "--yes")))
has_installed = grepl(numpy$stdout, pattern = "Successfully installed")
has_installed = grepl(
numpy$stdout,
pattern = "Successfully installed",
fixed = TRUE
)
stopifnot("Pip failed to install " = has_installed)
return(invisible(TRUE))
invisible(TRUE)
}

python_reticulate_tests = function(debug_level) {

if (!requireNamespace("reticulate", quietly = TRUE)) {
utils::install.packages("reticulate")
withr::defer(utils::remove.packages("reticulate"))
}

reticulate::py_run_string("x=2+2")
stopifnot("Reticulate error " = reticulate::py$x == 4)
return(invisible(TRUE))
invisible(TRUE)
}
Loading