Skip to content

Commit de1721f

Browse files
author
tz-lom
committed
Update documentation and improve coverage
1 parent 407d4b9 commit de1721f

File tree

3 files changed

+62
-4
lines changed

3 files changed

+62
-4
lines changed

src/deployconfig.jl

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,9 @@ end
297297
298298
Implementation of `DeployConfig` for deploying from GitHub Actions.
299299
300+
For self-hosted GitHub installation use `GitHubActions(host, pages_url)` constructor
301+
to specify the host name and a **full path** to the GitHub pages location.
302+
300303
The following environment variables influences the build
301304
when using the `GitHubActions` configuration:
302305
@@ -311,6 +314,10 @@ when using the `GitHubActions` configuration:
311314
- `GITHUB_TOKEN` or `DOCUMENTER_KEY`: used for authentication with GitHub,
312315
see the manual section for [GitHub Actions](@ref) for more information.
313316
317+
- `GITHUB_API_URL`: defines URL to GitHub API.
318+
319+
- `GITHUB_ACTOR`: Name of the person/app that initiated the workflow.
320+
314321
The `GITHUB_*` variables are set automatically on GitHub Actions, see the
315322
[documentation](https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/store-information-in-variables#default-environment-variables).
316323
"""
@@ -559,8 +566,8 @@ function post_github_status(cfg::GitHubActions, type::S, deploydocs_repo::S, sha
559566
io = IOBuffer()
560567
res = run(pipeline(cmd; stdout = io, stderr = devnull))
561568
@debug "Response of curl POST request" response = String(take!(io))
562-
catch
563-
@debug "Failed to post status"
569+
catch e
570+
@debug "Failed to post status" exception = e
564571
end
565572
return nothing
566573
end

src/utilities/Remotes.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@ end
106106
const GITHUB_HOST = "github.com"
107107

108108
"""
109-
GitHub(user :: AbstractString, repo :: AbstractString)
110-
GitHub(remote :: AbstractString)
109+
GitHub(user :: AbstractString, repo :: AbstractString, [host :: AbstractString])
110+
GitHub(remote :: AbstractString, [host :: AbstractString])
111111
112112
Represents a remote Git repository hosted on GitHub. The repository is identified by the
113113
names of the user (or organization) and the repository: `GitHub(user, repository)`. E.g.:
@@ -120,6 +120,8 @@ makedocs(
120120
121121
The single-argument constructor assumes that the user and repository parts are separated by
122122
a slash (e.g. `JuliaDocs/Documenter.jl`).
123+
124+
A `host` can be provided to point to the location of the self-hosted GitHub installation.
123125
"""
124126
struct GitHub <: Remote
125127
user::String

test/deployconfig.jl

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1516,3 +1516,52 @@ end
15161516
@test length(r.stdout) > 0
15171517
end
15181518
end
1519+
1520+
@testset "post_status" begin
1521+
if Sys.which("curl") === nothing
1522+
@warn "'curl' binary not found, skipping related tests."
1523+
else
1524+
@testset "Default GitHubActions" begin
1525+
buffer = IOBuffer()
1526+
logger = SimpleLogger(buffer, Logging.Debug)
1527+
with_logger(logger) do
1528+
withenv(
1529+
"GITHUB_EVENT_NAME" => "push",
1530+
"GITHUB_REPOSITORY" => "JuliaDocs/Documenter.jl",
1531+
"GITHUB_REF" => "refs/tags/v1.2.3",
1532+
"GITHUB_ACTOR" => "github-actions",
1533+
"GITHUB_SHA" => "407d4b94",
1534+
"GITHUB_TOKEN" => "SGVsbG8sIHdvcmxkLg==",
1535+
"GITHUB_API_URL" => "badurl://api.github.com" # use bad url protocol to trigger CURL failure
1536+
) do
1537+
cfg = Documenter.GitHubActions()
1538+
Documenter.post_status(cfg; type = "success", repo = "github.com/JuliaDocs/Documenter.jl")
1539+
end
1540+
end
1541+
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)
1543+
end
1544+
1545+
@testset "Self-hosted GitHubActions" begin
1546+
buffer = IOBuffer()
1547+
logger = SimpleLogger(buffer, Logging.Debug)
1548+
with_logger(logger) do
1549+
withenv(
1550+
"GITHUB_EVENT_NAME" => "push",
1551+
"GITHUB_REPOSITORY" => "JuliaDocs/Documenter.jl",
1552+
"GITHUB_REF" => "refs/tags/v1.2.3",
1553+
"GITHUB_ACTOR" => "github-actions",
1554+
"GITHUB_SHA" => "407d4b94",
1555+
"GITHUB_TOKEN" => "SGVsbG8sIHdvcmxkLg==",
1556+
"GITHUB_API_URL" => "badurl://api.github.selfhosted" # use bad url protocol to trigger CURL failure
1557+
) do
1558+
cfg = Documenter.GitHubActions("github.selfhosted", "pages.selfhosted")
1559+
Documenter.post_status(cfg; type = "success", repo = "github.selfhosted/JuliaDocs/Documenter.jl")
1560+
end
1561+
end
1562+
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)
1564+
end
1565+
1566+
end
1567+
end

0 commit comments

Comments
 (0)