From 8cf1baf4219ce0db3999950c95dc8aa86e263767 Mon Sep 17 00:00:00 2001 From: Indrajeet Patil Date: Thu, 18 Jul 2024 17:36:06 +0200 Subject: [PATCH 1/4] Don't include GHA log output in pkgdown website --- R/actions.R | 4 ++++ R/methods.R | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/R/actions.R b/R/actions.R index 9a20a1986..606442b8f 100644 --- a/R/actions.R +++ b/R/actions.R @@ -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) { diff --git a/R/methods.R b/R/methods.R index 46e8ed804..29a974d48 100644 --- a/R/methods.R +++ b/R/methods.R @@ -92,7 +92,7 @@ print.lints <- function(x, ...) { inline_data <- x[[1L]][["filename"]] == "" 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, ...) From ca810c4ebf46abcdb39dbb3a59467730857279cd Mon Sep 17 00:00:00 2001 From: Indrajeet Patil Date: Thu, 18 Jul 2024 17:43:45 +0200 Subject: [PATCH 2/4] add a test --- tests/testthat/test-ci.R | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/tests/testthat/test-ci.R b/tests/testthat/test-ci.R index 3f4f98762..b60255cc4 100644 --- a/tests/testthat/test-ci.R +++ b/tests/testthat/test-ci.R @@ -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)") @@ -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)") @@ -51,3 +51,13 @@ 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) + expect_output(print(l), "warning: [seq_linter]", fixed = TRUE) +}) From 5bf70fa54237f5ea26a6fe07d6d5ae69d26ce2b5 Mon Sep 17 00:00:00 2001 From: Michael Chirico Date: Thu, 18 Jul 2024 11:30:57 -0700 Subject: [PATCH 3/4] extra blank line --- tests/testthat/test-ci.R | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/testthat/test-ci.R b/tests/testthat/test-ci.R index b60255cc4..00eef1d5e 100644 --- a/tests/testthat/test-ci.R +++ b/tests/testthat/test-ci.R @@ -52,7 +52,6 @@ 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) From 8a109b9994c3675390e520a6984b6c2b270f55d7 Mon Sep 17 00:00:00 2001 From: Indrajeet Patil Date: Thu, 18 Jul 2024 22:20:59 +0200 Subject: [PATCH 4/4] make future-proof --- tests/testthat/test-ci.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/testthat/test-ci.R b/tests/testthat/test-ci.R index 00eef1d5e..40401e934 100644 --- a/tests/testthat/test-ci.R +++ b/tests/testthat/test-ci.R @@ -57,6 +57,6 @@ test_that("GitHub Actions log is skipped in pkgdown websites", { withr::local_options(lintr.rstudio_source_markers = FALSE) tmp <- withr::local_tempfile(lines = "x <- 1:nrow(y)") - l <- lint(tmp) + l <- lint(tmp, linters = seq_linter()) expect_output(print(l), "warning: [seq_linter]", fixed = TRUE) })