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

Automatically set logging variables when debuging a failing GHA #193

Merged
merged 3 commits into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# evaluate (development version)

* Setting `ACTIONS_RUNNER_DEBUG=1` (as in a failing GHA workflow) will automatically set `log_echo` and `log_warning` to `TRUE` (#175).
* `is.value()` has been removed since it tests for an object that evaluate never creates.
* `parse_all()` no longer has a default method, which will generate better errors if you pass in something unexpectected.
* The package now depends on R 4.0.0 in order to decrease our maintenance burden.
Expand Down
8 changes: 8 additions & 0 deletions R/eval.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@
#' force these arguments to be set to `NA`.
#' @param log_echo,log_warning If `TRUE`, will immediately log code and
#' warnings (respectively) to `stderr`.
#'
#' This will be force to `TRUE` if env var `ACTIONS_RUNNER_DEBUG` is
#' `true`, as when debugging a failing GitHub Actions workflow.
#' @param new_device if `TRUE`, will open a new graphics device and
#' automatically close it after completion. This prevents evaluation from
#' interfering with your existing graphics environment.
Expand Down Expand Up @@ -68,6 +71,11 @@ evaluate <- function(input,
keep_message <- NA
keep_warning <- NA
}
if (env_var_is_true("ACTIONS_RUNNER_DEBUG")) {
log_warning <- TRUE
log_echo <- TRUE
}

on_message <- check_keep(keep_message, "keep_message")
on_warning <- check_keep(keep_warning, "keep_warning", log_warning)

Expand Down
5 changes: 4 additions & 1 deletion man/evaluate.Rd

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

12 changes: 12 additions & 0 deletions tests/testthat/test-eval.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,18 @@ test_that("log_echo causes output to be immediately written to stderr()", {
expect_equal(res[[1]]$src, "f()")
})

test_that("ACTIONS_RUNNER_DEBUG forces log_warning and log_echo to TRUE", {
f <- function() {
1
warning("abc")
}
out <- local({
withr::local_envvar(ACTIONS_RUNNER_DEBUG = "true")
capture.output(expect_warning(evaluate("f()"), "abc"), type = "message")
})
expect_equal(out, "f()")
})

test_that("data sets loaded", {
skip_if_not_installed("lattice")

Expand Down
Loading