Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto detect deploy system. #1152

Merged
merged 1 commit into from
Oct 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

* ![Feature][badge-feature] Deployment is now more customizable and thus not as tied to Travis CI as before. ([#1147][github-1147])

* ![Feature][badge-feature] Documenter now has builtin support for deploying from GitHub Actions. ([#1144][github-1144])
* ![Feature][badge-feature] Documenter now has builtin support for deploying from GitHub Actions. Documenter will autodetect the running system, unless explicitly specified. ([#1144][github-1144], [#1152][github-1152])

* ![Enhancement][badge-enhancement] In the PDF/LaTeX output, images that are wider than the text are now being scaled down to text width automatically. The PDF builds now require the [adjustbox](https://ctan.org/pkg/adjustbox) LaTeX package to be available. ([#1137][github-1137])

Expand Down Expand Up @@ -421,6 +421,7 @@
[github-1144]: https://github.com/JuliaDocs/Documenter.jl/pull/1144
[github-1147]: https://github.com/JuliaDocs/Documenter.jl/pull/1147
[github-1151]: https://github.com/JuliaDocs/Documenter.jl/pull/1151
[github-1152]: https://github.com/JuliaDocs/Documenter.jl/pull/1152

[documenterlatex]: https://github.com/JuliaDocs/DocumenterLaTeX.jl
[documentermarkdown]: https://github.com/JuliaDocs/DocumenterMarkdown.jl
Expand Down
5 changes: 1 addition & 4 deletions src/Documenter.jl
Original file line number Diff line number Diff line change
Expand Up @@ -408,12 +408,9 @@ function deploydocs(;
devurl = "dev",
versions = ["stable" => "v^", "v#.#", devurl => devurl],
forcepush::Bool = false,
deploy_config = nothing,
deploy_config = auto_detect_deploy_system(),
)

# Default to Travis (TODO: Autodetect)
deploy_config = something(deploy_config, Travis())

if should_deploy(deploy_config; repo=repo, devbranch=devbranch)
# Add local bin path if needed.
Deps.updatepath!()
Expand Down
17 changes: 16 additions & 1 deletion src/deployconfig.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ Return `true` if the current build should deploy, and `false` otherwise.
This function is called with the `repo` and `devbranch` arguments from
[`deploydocs`](@ref).
"""
should_deploy(cfg::DeployConfig; kwargs...) = false
should_deploy(::DeployConfig; kwargs...) = false
should_deploy(::Nothing; kwargs...) = false # when auto-detection fails

#############
# Travis CI #
Expand Down Expand Up @@ -197,3 +198,17 @@ function git_tag(cfg::GitHubActions)
m = match(r"^refs/tags/(.*)$", cfg.github_ref)
return m === nothing ? nothing : String(m.captures[1])
end


##################
# Auto-detection #
##################
function auto_detect_deploy_system()
if haskey(ENV, "TRAVIS_REPO_SLUG")
return Travis()
elseif haskey(ENV, "GITHUB_REPOSITORY")
return GitHubActions()
else
return nothing
end
end
21 changes: 21 additions & 0 deletions test/deployconfig.jl
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,24 @@ end
@test !Documenter.should_deploy(cfg; repo="github.com/JuliaDocs/Documenter.jl.git", devbranch="master")
end
end

@testset "Autodetection of deploy system" begin
withenv("TRAVIS_REPO_SLUG" => "JuliaDocs/Documenter.jl",
"GITHUB_REPOSITORY" => nothing,
) do
cfg = Documenter.auto_detect_deploy_system()
@test cfg isa Documenter.Travis
end
withenv("TRAVIS_REPO_SLUG" => nothing,
"GITHUB_REPOSITORY" => "JuliaDocs/Documenter.jl",
) do
cfg = Documenter.auto_detect_deploy_system()
@test cfg isa Documenter.GitHubActions
end
withenv("TRAVIS_REPO_SLUG" => nothing,
"GITHUB_REPOSITORY" => nothing,
) do
cfg = Documenter.auto_detect_deploy_system()
@test cfg === nothing
end
end