From 11381eaf891b0d0975e4e85116803d7b72fb244a Mon Sep 17 00:00:00 2001 From: Karan Gathani Date: Thu, 26 Oct 2023 22:41:17 -0700 Subject: [PATCH] Revert "Replace repo_dir in other files as well" This reverts commit 527fdddac81ac8e63a3905431a0e4f75af1b8d52. --- R/accept_snaps.R | 4 ++-- R/apps.R | 8 ++++---- R/fix_snaps.R | 9 +++------ R/save-test-results.R | 2 +- R/test-in-local.R | 2 +- R/view-test-images.R | 2 +- man/accept_snaps.Rd | 2 +- man/fix_snaps.Rd | 2 +- man/test-results.Rd | 8 +------- man/test_in_local.Rd | 2 +- man/view_test_images.Rd | 2 +- 11 files changed, 17 insertions(+), 26 deletions(-) diff --git a/R/accept_snaps.R b/R/accept_snaps.R index 0350535afb..9aedc0dd5e 100644 --- a/R/accept_snaps.R +++ b/R/accept_snaps.R @@ -5,7 +5,7 @@ #' @inheritParams fix_snaps #' @export accept_snaps <- function( - repo_dir = rprojroot::find_package_root_file() + repo_dir = "." ) { app_paths <- repo_apps_paths(repo_dir) @@ -32,7 +32,7 @@ accept_snaps <- function( # Removes all snaps that are below the minimum R version -remove_snaps_cruft <- function(repo_dir = rprojroot::find_package_root_file(), min_r_version = "3.6") { +remove_snaps_cruft <- function(repo_dir = ".", min_r_version = "3.6") { app_paths <- repo_apps_paths(repo_dir) pb <- progress_bar( diff --git a/R/apps.R b/R/apps.R index 6eae5c7c74..a1fce9b4b6 100644 --- a/R/apps.R +++ b/R/apps.R @@ -46,16 +46,16 @@ is_manual_app <- function(app_dir) { ### Start GHA -apps_with_tests <- function(repo_dir = rprojroot::find_package_root_file()) { +apps_with_tests <- function(repo_dir = ".") { basename(Filter(x = repo_apps_paths(repo_dir), has_tests_folder)) } -repo_apps_path <- function(repo_dir = rprojroot::find_package_root_file()) { +repo_apps_path <- function(repo_dir = ".") { file.path(repo_dir, "inst", "apps") } -repo_apps_paths <- function(repo_dir = rprojroot::find_package_root_file()) { +repo_apps_paths <- function(repo_dir = ".") { dir(repo_apps_path(repo_dir), pattern = "^\\d\\d\\d-", full.names = TRUE) } -repo_app_path <- function(app_name, repo_dir = rprojroot::find_package_root_file()) { +repo_app_path <- function(app_name, repo_dir = ".") { file.path(repo_apps_path(repo_dir), app_name) } diff --git a/R/fix_snaps.R b/R/fix_snaps.R index 6c0fd3fcf1..b8682265ff 100644 --- a/R/fix_snaps.R +++ b/R/fix_snaps.R @@ -29,7 +29,7 @@ fix_snaps <- function( ask_apps = FALSE, ask_branches = TRUE, ask_if_not_main = TRUE, - repo_dir = rprojroot::find_package_root_file() + repo_dir = "." ) { original_sys_call <- sys.call() ask_apps <- as.logical(ask_apps) @@ -38,9 +38,6 @@ fix_snaps <- function( # validate_core_pkgs() apps_folder <- file.path(repo_dir, "inst", "apps") - if (!dir.exists(apps_folder)) { - stop("Apps folder does not exist: ", apps_folder) - } verify_if_not_main_branch(ask_if_not_main, repo_dir = repo_dir) verify_no_git_changes(repo_dir = repo_dir, apps_folder = apps_folder) @@ -278,7 +275,7 @@ fix_snaps <- function( f = function(app_name) { pb$tick(tokens = list(name = app_name)) # Use `.` as `git_cmd_` runs within `repo_dir` - app_path <- repo_app_path(repo_dir = rprojroot::find_package_root_file(), app_name = app_name) + app_path <- repo_app_path(repo_dir = ".", app_name = app_name) git_cmd_("git checkout -- ", app_path) git_cmd_("git clean -df -- ", app_path) } @@ -294,7 +291,7 @@ fix_snaps <- function( # Note: Logic should be duplicated in pre-check GHA workflow -verify_no_new_snaps <- function(repo_dir = rprojroot::find_package_root_file(), folder = "inst/apps") { +verify_no_new_snaps <- function(repo_dir = ".", folder = "inst/apps") { new_snaps <- dir(file.path(repo_dir, folder), pattern = "\\.new", recursive = TRUE, include.dirs = FALSE) if (length(new_snaps) > 0) { message("There should be no `.new` _snaps in `", folder, "`. Found: \n", paste0("* ", new_snaps, collapse = "\n")) diff --git a/R/save-test-results.R b/R/save-test-results.R index eae0d01336..85b4179b35 100644 --- a/R/save-test-results.R +++ b/R/save-test-results.R @@ -10,7 +10,7 @@ #' @inheritParams test_in_local #' @rdname test-results #' @export -save_test_results <- function(output, gha_branch_name, pr_number, username, repo_dir = rprojroot::find_package_root_file()) { +save_test_results <- function(output, gha_branch_name, pr_number, username, repo_dir = ".") { if (!inherits(output, "shinycoreci_test_output")) { stop("`output` must be an object returned by test_in_local()", call. = FALSE) } diff --git a/R/test-in-local.R b/R/test-in-local.R index f8662be20e..608f200942 100644 --- a/R/test-in-local.R +++ b/R/test-in-local.R @@ -23,7 +23,7 @@ test_in_local <- function( assert = TRUE, timeout = 10 * 60, retries = 2, - repo_dir = rprojroot::find_package_root_file() + repo_dir = "." ) { retries <- as.numeric(retries) repo_dir <- normalizePath(repo_dir, mustWork = TRUE) diff --git a/R/view-test-images.R b/R/view-test-images.R index 348ead28f1..41641f0be2 100644 --- a/R/view-test-images.R +++ b/R/view-test-images.R @@ -2,7 +2,7 @@ #' #' @param repo_dir directory to the shinycoreci repo #' @export -view_test_images <- function(repo_dir = rprojroot::find_package_root_file()) { +view_test_images <- function(repo_dir = ".") { app_folders <- Filter(repo_apps_paths(repo_dir), f = function(app_folder) { dir.exists(file.path(app_folder, "tests/testthat/_snaps")) }) diff --git a/man/accept_snaps.Rd b/man/accept_snaps.Rd index 609535fe9b..4c41633ddd 100644 --- a/man/accept_snaps.Rd +++ b/man/accept_snaps.Rd @@ -4,7 +4,7 @@ \alias{accept_snaps} \title{Accept all snapshot changes} \usage{ -accept_snaps(repo_dir = rprojroot::find_package_root_file()) +accept_snaps(repo_dir = ".") } \arguments{ \item{repo_dir}{Root repo folder path} diff --git a/man/fix_snaps.Rd b/man/fix_snaps.Rd index a480ac6fab..b8db9fc93b 100644 --- a/man/fix_snaps.Rd +++ b/man/fix_snaps.Rd @@ -10,7 +10,7 @@ fix_snaps( ask_apps = FALSE, ask_branches = TRUE, ask_if_not_main = TRUE, - repo_dir = rprojroot::find_package_root_file() + repo_dir = "." ) } \arguments{ diff --git a/man/test-results.Rd b/man/test-results.Rd index 20f2e36a02..8d380e307f 100644 --- a/man/test-results.Rd +++ b/man/test-results.Rd @@ -4,13 +4,7 @@ \alias{save_test_results} \title{View (and save) \code{test_in_local()} output} \usage{ -save_test_results( - output, - gha_branch_name, - pr_number, - username, - repo_dir = rprojroot::find_package_root_file() -) +save_test_results(output, gha_branch_name, pr_number, username, repo_dir = ".") } \arguments{ \item{output}{output from \code{test_in_local()}.} diff --git a/man/test_in_local.Rd b/man/test_in_local.Rd index 204f9c2f44..30bba3efd7 100644 --- a/man/test_in_local.Rd +++ b/man/test_in_local.Rd @@ -11,7 +11,7 @@ test_in_local( assert = TRUE, timeout = 10 * 60, retries = 2, - repo_dir = rprojroot::find_package_root_file() + repo_dir = "." ) } \arguments{ diff --git a/man/view_test_images.Rd b/man/view_test_images.Rd index de84808be2..19c9c221e7 100644 --- a/man/view_test_images.Rd +++ b/man/view_test_images.Rd @@ -4,7 +4,7 @@ \alias{view_test_images} \title{View Shinytest Images} \usage{ -view_test_images(repo_dir = rprojroot::find_package_root_file()) +view_test_images(repo_dir = ".") } \arguments{ \item{repo_dir}{directory to the shinycoreci repo}