From 85004f7436a00446703d18acf5a99f8e0bd665e3 Mon Sep 17 00:00:00 2001 From: Eli Holmes - NOAA Date: Thu, 21 Nov 2024 18:01:14 -0800 Subject: [PATCH 1/4] Update install-github.R --- R/install-github.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/install-github.R b/R/install-github.R index a08f7c3d..3707518d 100644 --- a/R/install-github.R +++ b/R/install-github.R @@ -243,7 +243,7 @@ remote_package_name.github_remote <- function(remote, ..., use_local = TRUE, # Otherwise lookup the package name from the remote DESCRIPTION file desc <- github_DESCRIPTION(username = remote$username, repo = remote$repo, subdir = remote$subdir, host = remote$host, ref = remote$ref, - pat = remote$auth_token %||% github_pat(), use_curl = use_curl) + pat = remote$auth_token, use_curl = use_curl) if (is.null(desc)) { return(NA_character_) From 76ccfb2828678c5419c21bf40b72cb15334ae490 Mon Sep 17 00:00:00 2001 From: Eli Holmes Date: Thu, 21 Nov 2024 18:14:01 -0800 Subject: [PATCH 2/4] respect auth_token=NULL --- R/install-github.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/install-github.R b/R/install-github.R index 3707518d..e5b03f54 100644 --- a/R/install-github.R +++ b/R/install-github.R @@ -260,7 +260,7 @@ remote_package_name.github_remote <- function(remote, ..., use_local = TRUE, remote_sha.github_remote <- function(remote, ..., use_curl = !is_standalone() && pkg_installed("curl")) { tryCatch( github_commit(username = remote$username, repo = remote$repo, - host = remote$host, ref = remote$ref, pat = remote$auth_token %||% github_pat(), use_curl = use_curl), + host = remote$host, ref = remote$ref, pat = remote$auth_token, use_curl = use_curl), # 422 errors most often occur when a branch or PR has been deleted, so we # ignore the error in this case From 8e17195709c47905ce52ea2debf0c9d854e23b5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Cs=C3=A1rdi?= Date: Thu, 9 Jan 2025 13:58:14 +0100 Subject: [PATCH 3/4] Update amalgamation --- inst/install-github.R | 4 ++-- install-github.R | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/inst/install-github.R b/inst/install-github.R index 70a87111..8855f5d1 100644 --- a/inst/install-github.R +++ b/inst/install-github.R @@ -4026,7 +4026,7 @@ function(...) { # Otherwise lookup the package name from the remote DESCRIPTION file desc <- github_DESCRIPTION(username = remote$username, repo = remote$repo, subdir = remote$subdir, host = remote$host, ref = remote$ref, - pat = remote$auth_token %||% github_pat(), use_curl = use_curl) + pat = remote$auth_token, use_curl = use_curl) if (is.null(desc)) { return(NA_character_) @@ -4043,7 +4043,7 @@ function(...) { remote_sha.github_remote <- function(remote, ..., use_curl = !is_standalone() && pkg_installed("curl")) { tryCatch( github_commit(username = remote$username, repo = remote$repo, - host = remote$host, ref = remote$ref, pat = remote$auth_token %||% github_pat(), use_curl = use_curl), + host = remote$host, ref = remote$ref, pat = remote$auth_token, use_curl = use_curl), # 422 errors most often occur when a branch or PR has been deleted, so we # ignore the error in this case diff --git a/install-github.R b/install-github.R index 70a87111..8855f5d1 100644 --- a/install-github.R +++ b/install-github.R @@ -4026,7 +4026,7 @@ function(...) { # Otherwise lookup the package name from the remote DESCRIPTION file desc <- github_DESCRIPTION(username = remote$username, repo = remote$repo, subdir = remote$subdir, host = remote$host, ref = remote$ref, - pat = remote$auth_token %||% github_pat(), use_curl = use_curl) + pat = remote$auth_token, use_curl = use_curl) if (is.null(desc)) { return(NA_character_) @@ -4043,7 +4043,7 @@ function(...) { remote_sha.github_remote <- function(remote, ..., use_curl = !is_standalone() && pkg_installed("curl")) { tryCatch( github_commit(username = remote$username, repo = remote$repo, - host = remote$host, ref = remote$ref, pat = remote$auth_token %||% github_pat(), use_curl = use_curl), + host = remote$host, ref = remote$ref, pat = remote$auth_token, use_curl = use_curl), # 422 errors most often occur when a branch or PR has been deleted, so we # ignore the error in this case From 6fc3b1fb67e6286e00be711eea8fe8df4f755311 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Cs=C3=A1rdi?= Date: Thu, 9 Jan 2025 15:28:42 +0100 Subject: [PATCH 4/4] GHA: skip tests that need GH token in PRs --- tests/testthat/test-install-github.R | 50 ++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/tests/testthat/test-install-github.R b/tests/testthat/test-install-github.R index 82e11128..625845d2 100644 --- a/tests/testthat/test-install-github.R +++ b/tests/testthat/test-install-github.R @@ -3,6 +3,11 @@ test_that("github_resolve_ref.github_release", { skip_on_cran() skip_if_offline() skip_if_over_rate_limit() + # skip in GHA PRs, no token + if (Sys.getenv("GITHUB_ACTIONS") == "true" && + startsWith(Sys.getenv("GITHUB_REF"), "refs/pull")) { + skip("GHA pull request, no token") + } expect_error( github_resolve_ref.github_release( @@ -38,6 +43,11 @@ test_that("github_resolve_ref.github_release", { skip_on_cran() skip_if_offline() skip_if_over_rate_limit() + # skip in GHA PRs, no token + if (Sys.getenv("GITHUB_ACTIONS") == "true" && + startsWith(Sys.getenv("GITHUB_REF"), "refs/pull")) { + skip("GHA pull request, no token") + } expect_error( github_resolve_ref( @@ -54,6 +64,11 @@ test_that("github_release", { skip_on_cran() skip_if_offline() skip_if_over_rate_limit() + # skip in GHA PRs, no token + if (Sys.getenv("GITHUB_ACTIONS") == "true" && + startsWith(Sys.getenv("GITHUB_REF"), "refs/pull")) { + skip("GHA pull request, no token") + } Sys.unsetenv("R_TESTS") @@ -79,6 +94,11 @@ test_that("install_github", { skip_on_cran() skip_if_offline() skip_if_over_rate_limit() + # skip in GHA PRs, no token + if (Sys.getenv("GITHUB_ACTIONS") == "true" && + startsWith(Sys.getenv("GITHUB_REF"), "refs/pull")) { + skip("GHA pull request, no token") + } Sys.unsetenv("R_TESTS") @@ -110,6 +130,11 @@ test_that("error if not username, warning if given as argument", { skip_on_cran() skip_if_offline() skip_if_over_rate_limit() + # skip in GHA PRs, no token + if (Sys.getenv("GITHUB_ACTIONS") == "true" && + startsWith(Sys.getenv("GITHUB_REF"), "refs/pull")) { + skip("GHA pull request, no token") + } Sys.unsetenv("R_TESTS") @@ -153,6 +178,11 @@ test_that("remote_sha.github_remote", { skip_on_cran() skip_if_offline() skip_if_over_rate_limit() + # skip in GHA PRs, no token + if (Sys.getenv("GITHUB_ACTIONS") == "true" && + startsWith(Sys.getenv("GITHUB_REF"), "refs/pull")) { + skip("GHA pull request, no token") + } expect_equal( remote_sha.github_remote( @@ -176,6 +206,11 @@ test_that("github_remote with deleted branch", { # skip this test unless we are using curl skip_if(is_standalone() || !pkg_installed("curl")) + # skip in GHA PRs, no token + if (Sys.getenv("GITHUB_ACTIONS") == "true" && + startsWith(Sys.getenv("GITHUB_REF"), "refs/pull")) { + skip("GHA pull request, no token") + } expect_equal( remote_sha.github_remote( @@ -198,6 +233,11 @@ test_that("github_pull", { skip_on_cran() skip_if_offline() skip_if_over_rate_limit() + # skip in GHA PRs, no token + if (Sys.getenv("GITHUB_ACTIONS") == "true" && + startsWith(Sys.getenv("GITHUB_REF"), "refs/pull")) { + skip("GHA pull request, no token") + } Sys.unsetenv("R_TESTS") @@ -222,6 +262,11 @@ test_that("remote_sha.github_remote errors if remote doesn't exist", { skip_on_cran() skip_if_offline() skip_if_over_rate_limit() + # skip in GHA PRs, no token + if (Sys.getenv("GITHUB_ACTIONS") == "true" && + startsWith(Sys.getenv("GITHUB_REF"), "refs/pull")) { + skip("GHA pull request, no token") + } expect_error(remote_sha(github_remote("arst/arst"))) }) @@ -230,6 +275,11 @@ test_that("remote_sha.github_remote returns expected value if remote does exist" skip_on_cran() skip_if_offline() skip_if_over_rate_limit() + # skip in GHA PRs, no token + if (Sys.getenv("GITHUB_ACTIONS") == "true" && + startsWith(Sys.getenv("GITHUB_REF"), "refs/pull")) { + skip("GHA pull request, no token") + } expect_equal(remote_sha(github_remote("r-lib/devtools@v1.8.0")), "ad9aac7b9a522354e1ff363a86f389e32cec181b") })