@@ -48,12 +48,24 @@ if auth === nothing
4848 auth = GitHub. AnonymousAuth ()
4949end
5050
51- w = GitHub. whoami (; auth= auth)
52- @info " " w w. login
53- testuser = Owner (w. login)
51+ # is_gha_token is true if we're using the GITHUB_TOKEN made available automatically in GitHub Actions
52+ # false otherwise
53+ #
54+ # This try-catch is a crude heuristic.
55+ # Ideally there would be an actual API we could hit to determine this.
56+ (testsuite_username, is_gha_token) = try
57+ w = GitHub. whoami (; auth= auth)
58+ @info " Information for the test user being used in the test suite" w w. login
59+ (w. login, false )
60+ catch ex
61+ @info " Looks like this is the GITHUB_TOKEN from GitHub Actions"
62+ (" github-actions[bot]" , true )
63+ end
5464
5565@test rate_limit (; auth = auth)[" rate" ][" limit" ] > 0
5666
67+ testuser = Owner (testsuite_username)
68+
5769@testset " Owners" begin
5870 # test GitHub.owner
5971 @test name (owner (testuser; auth = auth)) == name (testuser)
@@ -78,7 +90,14 @@ testuser = Owner(w.login)
7890 # "-----BEGIN PGP PUBLIC KEY BLOCK-----")
7991
8092 # test membership queries
81- @test GitHub. check_membership (julweb, testuser; auth = auth)
93+ if is_gha_token
94+ # The `@test ex skip=is_gha_token` syntax requires Julia 1.7+, so we can't use it here.
95+ @info " Skipping check_membership() test because is_gha_token is true" is_gha_token
96+ @test_skip GitHub. check_membership (julweb, testuser; auth = auth)
97+ else
98+ @test GitHub. check_membership (julweb, testuser; auth = auth)
99+ end
100+
82101 @test ! GitHub. check_membership (" JuliaLang" , testuser; auth = auth, public_only= true )
83102
84103 @test GitHub. isorg (julweb)
@@ -188,14 +207,20 @@ end
188207end
189208
190209@testset " Gists" begin
191- kc_gists, page_data = gists (" KristofferC" ; page_limit= 1 , params= Dict (" per_page" => 5 ), auth = auth)
192- @test typeof (kc_gists) == Vector{Gist}
193- @test length (kc_gists) != 0
194- @test kc_gists[1 ]. owner. login == " KristofferC"
195-
196- gist_obj = gist (" 0cb70f50a28d79905aae907e12cbe58e" ; auth = auth)
197- @test length (gist_obj. files) == 2
198- @test gist_obj. files[" file1.jl" ][" content" ] == " Hello World!"
210+ # skip=is_gha_token
211+ if is_gha_token
212+ @info " Skipping gists tests because is_gha_token is true" is_gha_token
213+ @test_skip false
214+ else
215+ kc_gists, page_data = gists (" KristofferC" ; page_limit= 1 , params= Dict (" per_page" => 5 ), auth = auth)
216+ @test typeof (kc_gists) == Vector{Gist}
217+ @test length (kc_gists) != 0
218+ @test kc_gists[1 ]. owner. login == " KristofferC"
219+
220+ gist_obj = gist (" 0cb70f50a28d79905aae907e12cbe58e" ; auth = auth)
221+ @test length (gist_obj. files) == 2
222+ @test gist_obj. files[" file1.jl" ][" content" ] == " Hello World!"
223+ end
199224end
200225
201226@testset " Reviews" begin
0 commit comments