Skip to content

Commit

Permalink
Don't include GHA log output in pkgdown website (#2633)
Browse files Browse the repository at this point in the history
* Don't include GHA log output in pkgdown website

* add a test

* extra blank line

* make future-proof

---------

Co-authored-by: Michael Chirico <[email protected]>
  • Loading branch information
IndrajeetPatil and MichaelChirico authored Jul 18, 2024
1 parent 73e55d3 commit f0d9407
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
4 changes: 4 additions & 0 deletions R/actions.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ in_github_actions <- function() {
identical(Sys.getenv("GITHUB_ACTIONS"), "true")
}

in_pkgdown <- function() {
identical(Sys.getenv("IN_PKGDOWN"), "true")
}

# Output logging commands for any lints found
github_actions_log_lints <- function(lints, project_dir = "") {
for (x in lints) {
Expand Down
2 changes: 1 addition & 1 deletion R/methods.R
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ print.lints <- function(x, ...) {
inline_data <- x[[1L]][["filename"]] == "<text>"
if (!inline_data && use_rstudio_source_markers) {
rstudio_source_markers(x)
} else if (in_github_actions()) {
} else if (in_github_actions() && !in_pkgdown()) {
github_actions_log_lints(x, project_dir = github_annotation_project_dir)
} else {
lapply(x, print, ...)
Expand Down
13 changes: 11 additions & 2 deletions tests/testthat/test-ci.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
test_that("GitHub Actions functionality works", {
withr::local_envvar(list(GITHUB_ACTIONS = "true"))
withr::local_envvar(list(GITHUB_ACTIONS = "true", IN_PKGDOWN = "false"))
withr::local_options(lintr.rstudio_source_markers = FALSE)
tmp <- withr::local_tempfile(lines = "x <- 1:nrow(y)")

Expand All @@ -26,7 +26,7 @@ test_that("GitHub Actions functionality works in a subdirectory", {
patrick::with_parameters_test_that(
"GitHub Actions - error on lint works",
{
withr::local_envvar(list(GITHUB_ACTIONS = "true", LINTR_ERROR_ON_LINT = env_var_value))
withr::local_envvar(list(GITHUB_ACTIONS = "true", IN_PKGDOWN = "", LINTR_ERROR_ON_LINT = env_var_value))
withr::local_options(lintr.rstudio_source_markers = FALSE)
tmp <- withr::local_tempfile(lines = "x <- 1:nrow(y)")

Expand All @@ -51,3 +51,12 @@ patrick::with_parameters_test_that(
},
env_var_value = list("", "F", NA, NULL)
)

test_that("GitHub Actions log is skipped in pkgdown websites", {
withr::local_envvar(list(GITHUB_ACTIONS = "true", IN_PKGDOWN = "true"))
withr::local_options(lintr.rstudio_source_markers = FALSE)
tmp <- withr::local_tempfile(lines = "x <- 1:nrow(y)")

l <- lint(tmp, linters = seq_linter())
expect_output(print(l), "warning: [seq_linter]", fixed = TRUE)
})

0 comments on commit f0d9407

Please sign in to comment.