Skip to content

Commit 6fc3b1f

Browse files
committed
GHA: skip tests that need GH token in PRs
1 parent fa7655c commit 6fc3b1f

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

tests/testthat/test-install-github.R

+50
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ test_that("github_resolve_ref.github_release", {
33
skip_on_cran()
44
skip_if_offline()
55
skip_if_over_rate_limit()
6+
# skip in GHA PRs, no token
7+
if (Sys.getenv("GITHUB_ACTIONS") == "true" &&
8+
startsWith(Sys.getenv("GITHUB_REF"), "refs/pull")) {
9+
skip("GHA pull request, no token")
10+
}
611

712
expect_error(
813
github_resolve_ref.github_release(
@@ -38,6 +43,11 @@ test_that("github_resolve_ref.github_release", {
3843
skip_on_cran()
3944
skip_if_offline()
4045
skip_if_over_rate_limit()
46+
# skip in GHA PRs, no token
47+
if (Sys.getenv("GITHUB_ACTIONS") == "true" &&
48+
startsWith(Sys.getenv("GITHUB_REF"), "refs/pull")) {
49+
skip("GHA pull request, no token")
50+
}
4151

4252
expect_error(
4353
github_resolve_ref(
@@ -54,6 +64,11 @@ test_that("github_release", {
5464
skip_on_cran()
5565
skip_if_offline()
5666
skip_if_over_rate_limit()
67+
# skip in GHA PRs, no token
68+
if (Sys.getenv("GITHUB_ACTIONS") == "true" &&
69+
startsWith(Sys.getenv("GITHUB_REF"), "refs/pull")) {
70+
skip("GHA pull request, no token")
71+
}
5772

5873
Sys.unsetenv("R_TESTS")
5974

@@ -79,6 +94,11 @@ test_that("install_github", {
7994
skip_on_cran()
8095
skip_if_offline()
8196
skip_if_over_rate_limit()
97+
# skip in GHA PRs, no token
98+
if (Sys.getenv("GITHUB_ACTIONS") == "true" &&
99+
startsWith(Sys.getenv("GITHUB_REF"), "refs/pull")) {
100+
skip("GHA pull request, no token")
101+
}
82102

83103
Sys.unsetenv("R_TESTS")
84104

@@ -110,6 +130,11 @@ test_that("error if not username, warning if given as argument", {
110130
skip_on_cran()
111131
skip_if_offline()
112132
skip_if_over_rate_limit()
133+
# skip in GHA PRs, no token
134+
if (Sys.getenv("GITHUB_ACTIONS") == "true" &&
135+
startsWith(Sys.getenv("GITHUB_REF"), "refs/pull")) {
136+
skip("GHA pull request, no token")
137+
}
113138

114139
Sys.unsetenv("R_TESTS")
115140

@@ -153,6 +178,11 @@ test_that("remote_sha.github_remote", {
153178
skip_on_cran()
154179
skip_if_offline()
155180
skip_if_over_rate_limit()
181+
# skip in GHA PRs, no token
182+
if (Sys.getenv("GITHUB_ACTIONS") == "true" &&
183+
startsWith(Sys.getenv("GITHUB_REF"), "refs/pull")) {
184+
skip("GHA pull request, no token")
185+
}
156186

157187
expect_equal(
158188
remote_sha.github_remote(
@@ -176,6 +206,11 @@ test_that("github_remote with deleted branch", {
176206
# skip this test unless we are using curl
177207
skip_if(is_standalone() || !pkg_installed("curl"))
178208

209+
# skip in GHA PRs, no token
210+
if (Sys.getenv("GITHUB_ACTIONS") == "true" &&
211+
startsWith(Sys.getenv("GITHUB_REF"), "refs/pull")) {
212+
skip("GHA pull request, no token")
213+
}
179214

180215
expect_equal(
181216
remote_sha.github_remote(
@@ -198,6 +233,11 @@ test_that("github_pull", {
198233
skip_on_cran()
199234
skip_if_offline()
200235
skip_if_over_rate_limit()
236+
# skip in GHA PRs, no token
237+
if (Sys.getenv("GITHUB_ACTIONS") == "true" &&
238+
startsWith(Sys.getenv("GITHUB_REF"), "refs/pull")) {
239+
skip("GHA pull request, no token")
240+
}
201241

202242
Sys.unsetenv("R_TESTS")
203243

@@ -222,6 +262,11 @@ test_that("remote_sha.github_remote errors if remote doesn't exist", {
222262
skip_on_cran()
223263
skip_if_offline()
224264
skip_if_over_rate_limit()
265+
# skip in GHA PRs, no token
266+
if (Sys.getenv("GITHUB_ACTIONS") == "true" &&
267+
startsWith(Sys.getenv("GITHUB_REF"), "refs/pull")) {
268+
skip("GHA pull request, no token")
269+
}
225270

226271
expect_error(remote_sha(github_remote("arst/arst")))
227272
})
@@ -230,6 +275,11 @@ test_that("remote_sha.github_remote returns expected value if remote does exist"
230275
skip_on_cran()
231276
skip_if_offline()
232277
skip_if_over_rate_limit()
278+
# skip in GHA PRs, no token
279+
if (Sys.getenv("GITHUB_ACTIONS") == "true" &&
280+
startsWith(Sys.getenv("GITHUB_REF"), "refs/pull")) {
281+
skip("GHA pull request, no token")
282+
}
233283

234284
expect_equal(remote_sha(github_remote("r-lib/devtools@v1.8.0")), "ad9aac7b9a522354e1ff363a86f389e32cec181b")
235285
})

0 commit comments

Comments
 (0)