Skip to content

Commit 438901a

Browse files
author
tz-lom
committed
Fix flaky test
1 parent de1721f commit 438901a

File tree

2 files changed

+44
-6
lines changed

2 files changed

+44
-6
lines changed

src/deployconfig.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -520,8 +520,8 @@ function post_status(cfg::GitHubActions; type, repo::String, subfolder = nothing
520520
end
521521
sha === nothing && return
522522
return post_github_status(cfg, type, repo, sha, subfolder)
523-
catch
524-
@debug "Failed to post status"
523+
catch e
524+
@debug "Failed to post status" e
525525
end
526526
end
527527

test/deployconfig.jl

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1521,7 +1521,7 @@ end
15211521
if Sys.which("curl") === nothing
15221522
@warn "'curl' binary not found, skipping related tests."
15231523
else
1524-
@testset "Default GitHubActions" begin
1524+
@testset "Default GitHubActions push" begin
15251525
buffer = IOBuffer()
15261526
logger = SimpleLogger(buffer, Logging.Debug)
15271527
with_logger(logger) do
@@ -1539,7 +1539,40 @@ end
15391539
end
15401540
end
15411541
logged = read(seek(buffer, 0), String)
1542-
@test occursin("""`curl -sX POST -H 'Authorization: token SGVsbG8sIHdvcmxkLg==' -H 'User-Agent: Documenter.jl' -H 'Content-Type: application/json' -d '{"target_url":"https://JuliaDocs.github.io/Documenter.jl/","context":"documenter/deploy","description":"Documentation build succeeded","state":"success"}' badurl://api.github.com/repos/JuliaDocs/Documenter.jl/statuses/407d4b94`""", logged)
1542+
@test occursin(r"""`curl -sX POST -H 'Authorization: token SGVsbG8sIHdvcmxkLg==' -H 'User-Agent: Documenter.jl' -H 'Content-Type: application/json' -d '{.+?}' badurl://api.github.com/repos/JuliaDocs/Documenter.jl/statuses/407d4b94`""", logged)
1543+
@test occursin(r"""`.+?{.*?\"target_url":"https://JuliaDocs.github.io/Documenter.jl/".*?}'.+?`""", logged)
1544+
@test occursin(r"""`.+?{.*?\"context\":\"documenter/deploy\".*?}'.+?`""", logged)
1545+
@test occursin(r"""`.+?{.*?\"description\":\"Documentation build succeeded\".*?}'.+?`""", logged)
1546+
@test occursin(r"""`.+?{.*?\"state\":\"success\".*?}'.+?`""", logged)
1547+
end
1548+
1549+
@testset "Default GitHubActions pull_request" begin
1550+
buffer = IOBuffer()
1551+
logger = SimpleLogger(buffer, Logging.Debug)
1552+
with_logger(logger) do
1553+
mktemp() do path, io
1554+
write(io, """{"pull_request":{"head":{"sha":"407d4b94"}}}""")
1555+
close(io)
1556+
withenv(
1557+
"GITHUB_EVENT_NAME" => "pull_request",
1558+
"GITHUB_EVENT_PATH" => path,
1559+
"GITHUB_REPOSITORY" => "JuliaDocs/Documenter.jl",
1560+
"GITHUB_REF" => "refs/tags/v1.2.3",
1561+
"GITHUB_ACTOR" => "github-actions",
1562+
"GITHUB_TOKEN" => "SGVsbG8sIHdvcmxkLg==",
1563+
"GITHUB_API_URL" => "badurl://api.github.com" # use bad url protocol to trigger CURL failure
1564+
) do
1565+
cfg = Documenter.GitHubActions()
1566+
Documenter.post_status(cfg; type = "success", repo = "github.com/JuliaDocs/Documenter.jl")
1567+
end
1568+
end
1569+
end
1570+
logged = read(seek(buffer, 0), String)
1571+
@test occursin(r"""`curl -sX POST -H 'Authorization: token SGVsbG8sIHdvcmxkLg==' -H 'User-Agent: Documenter.jl' -H 'Content-Type: application/json' -d '{.+?}' badurl://api.github.com/repos/JuliaDocs/Documenter.jl/statuses/407d4b94`""", logged)
1572+
@test occursin(r"""`.+?{.*?\"target_url":"https://JuliaDocs.github.io/Documenter.jl/".*?}'.+?`""", logged)
1573+
@test occursin(r"""`.+?{.*?\"context\":\"documenter/deploy\".*?}'.+?`""", logged)
1574+
@test occursin(r"""`.+?{.*?\"description\":\"Documentation build succeeded\".*?}'.+?`""", logged)
1575+
@test occursin(r"""`.+?{.*?\"state\":\"success\".*?}'.+?`""", logged)
15431576
end
15441577

15451578
@testset "Self-hosted GitHubActions" begin
@@ -1555,12 +1588,17 @@ end
15551588
"GITHUB_TOKEN" => "SGVsbG8sIHdvcmxkLg==",
15561589
"GITHUB_API_URL" => "badurl://api.github.selfhosted" # use bad url protocol to trigger CURL failure
15571590
) do
1558-
cfg = Documenter.GitHubActions("github.selfhosted", "pages.selfhosted")
1591+
cfg = Documenter.GitHubActions("github.selfhosted", "pages.selfhosted/pages/JuliaDocs/Documenter.jl")
15591592
Documenter.post_status(cfg; type = "success", repo = "github.selfhosted/JuliaDocs/Documenter.jl")
15601593
end
15611594
end
15621595
logged = read(seek(buffer, 0), String)
1563-
@test occursin("""`curl -sX POST -H 'Authorization: token SGVsbG8sIHdvcmxkLg==' -H 'User-Agent: Documenter.jl' -H 'Content-Type: application/json' -d '{\"target_url\":\"pages.selfhosted\",\"context\":\"documenter/deploy\",\"description\":\"Documentation build succeeded\",\"state\":\"success\"}' badurl://api.github.selfhosted/repos/JuliaDocs/Documenter.jl/statuses/407d4b94`""", logged)
1596+
@test occursin(r"""`curl -sX POST -H 'Authorization: token SGVsbG8sIHdvcmxkLg==' -H 'User-Agent: Documenter.jl' -H 'Content-Type: application/json' -d '{.+?}' badurl://api.github.selfhosted/repos/JuliaDocs/Documenter.jl/statuses/407d4b94`""", logged)
1597+
@test occursin(r"""`.+?{.*?\"target_url\":\"pages.selfhosted/pages/JuliaDocs/Documenter.jl\".*?}'.+?`""", logged)
1598+
@test occursin(r"""`.+?{.*?\"context\":\"documenter/deploy\".*?}'.+?`""", logged)
1599+
@test occursin(r"""`.+?{.*?\"description\":\"Documentation build succeeded\".*?}'.+?`""", logged)
1600+
@test occursin(r"""`.+?{.*?\"state\":\"success\".*?}'.+?`""", logged)
1601+
15641602
end
15651603

15661604
end

0 commit comments

Comments
 (0)