Fixes for GitLabCI and Documenter

This commit is contained in:
Chris de Graaf 2019-08-31 21:09:22 +07:00
parent 1d26885983
commit 99bc709ef3
No known key found for this signature in database
GPG Key ID: 150FFDD9B0073C7B
8 changed files with 86 additions and 92 deletions

View File

@ -1,13 +1,13 @@
{{#VERSIONS}}
Julia {{.}}:
image: julia:{{.}}
script: julia --project=@. -e '
.definitions:
script: &script
script:
- julia --project=@. -e '
using Pkg;
Pkg.build();
Pkg.test({{#HAS_COVERAGE}}coverage=true{{/HAS_COVERAGE}});'
{{/VERSIONS}}
Pkg.test({{#HAS_COVERAGE}}; coverage=true{{/HAS_COVERAGE}});'
{{#HAS_COVERAGE}}
coverage: /Test Coverage (\d+\.\d+%)/
coverage: &coverage
coverage: /Test coverage (\d+\.\d+%)/
after_script:
- julia -e '
using Pkg;
@ -15,8 +15,16 @@ Julia {{.}}:
using Coverage;
c, t = get_summary(process_folder());
using Printf;
@printf "Test Coverage %.2f%%\n" 100c/t;'
@printf "Test coverage %.2f%%\n" 100c / t;'
{{/HAS_COVERAGE}}
{{#VERSIONS}}
Julia {{.}}:
image: julia:{{.}}
<<: *script
{{#HAS_COVERAGE}}
<<: *coverage
{{/HAS_COVERAGE}}
{{/VERSIONS}}
{{#HAS_DOCUMENTER}}
pages:
image: julia:{{VERSION}}

View File

@ -7,7 +7,7 @@ format_version(v::AbstractString) = string(v)
function collect_versions(t::Template, versions::Vector)
vs = map(format_version, [t.julia_version, versions...])
return unique(sort(vs))
return sort(unique(vs))
end
@with_kw struct TravisCI <: BasicPlugin
@ -128,9 +128,9 @@ end
@with_kw struct GitLabCI <: BasicPlugin
file::String = default_file("gitlab-ci.yml")
documentation::Bool = true
coverage::Bool = true
extra_versions::VersionsOrStrings = ["1.0"] # Nightly has no Docker image.
# Nightly has no Docker image.
extra_versions::VersionsOrStrings = [VERSION, default_version()]
end
gitignore(p::GitLabCI) = p.coverage ? COVERAGE_GITIGNORE : String[]

View File

@ -32,14 +32,14 @@ struct Documenter{T<:Union{TravisCI, GitLabCI, Nothing}} <: Plugin
index_md::String
# Can't use @with_kw due to some weird precompilation issues.
function Documenter{T}(
function Documenter{T}(;
assets::Vector{<:AbstractString}=String[],
makedocs_kwargs::Dict{Symbol}=Dict{Symbol, Any}(),
canonical_url::Union{Function, Nothing}=T === TravisCI ? github_pages_url : nothing,
index_md::AbstractString=default_file("index.md"),
canonical_url::Union{Function, Nothing}=make_canonical(T),
make_jl::AbstractString=default_file("make.jl"),
index_md::AbstractString=default_file("index.md"),
) where T <: Union{TravisCI, GitLabCI, Nothing}
return new(assets, makedocs_kwargs, canonical_url, index_md, make_jl)
return new(assets, makedocs_kwargs, canonical_url, make_jl, index_md)
end
end
@ -71,7 +71,7 @@ view(p::Documenter, t::Template, pkg::AbstractString) = Dict(
"AUTHORS" => join(t.authors, ", "),
"CANONICAL" => p.canonical_url === nothing ? nothing : p.canonical_url(t, pkg),
"HAS_ASSETS" => !isempty(p.assets),
"MAKEDOCS_KWARGS" => map((k, v) -> k => repr(v), collect(p.makedocs_kwargs)),
"MAKEDOCS_KWARGS" => map(((k, v),) -> k => repr(v), collect(p.makedocs_kwargs)),
"PKG" => pkg,
"REPO" => "$(t.host)/$(t.user)/$pkg.jl",
"USER" => t.user,
@ -107,32 +107,9 @@ function gen_plugin(p::Documenter, t::Template, pkg_dir::AbstractString)
end
end
function interactive(::Type{Documenter{T}}) where T
name = "Documenter{$T}"
print("$name: Enter any Documenter asset files (separated by spaces) [none]: ")
assets = split(readline())
print("$name: Enter any extra makedocs key-value pairs (joined by '=') [none]\n> ")
kwargs = Dict{Symbol, Any}()
line = map(split(readline())) do kv
k, v = split(kv, "="; limit=2)
kwargs[Symbol(k)] = eval(Meta.parse(v))
end
return Documenter{T}(; assets=assets, kwargs=kwargs)
end
function interactive(::Type{Documenter})
types = Dict(
"None (local documentation only)" => Nothing,
"TravisCI (GitHub Pages)" => TravisCI,
"GitLabCI (GitLab Pages)" => GitLabCI,
)
options = collect(keys(types))
menu = RadioMenu(options)
T = types[options[request("Documenter: Select integration:", menu)]]
return interactive(Documenter{T})
end
github_pages_url(t::Template, pkg::AbstractString) = "https://$(t.user).github.io/$pkg.jl"
gitlab_pages_url(t::Template, pkg::AbstractString) = "https://$(t.user).gitlab.io/$pkg.jl"
make_canonical(::Type{TravisCI}) = github_pages_url
make_canonical(::Type{GitLabCI}) = gitlab_pages_url
make_canonical(::Type{Nothing}) = nothing

View File

@ -1,15 +1,25 @@
Julia 1.0:
image: julia:1.0
script: julia --project=@. -e '
.definitions:
script: &script
script:
- julia --project=@. -e '
using Pkg;
Pkg.build();
Pkg.test(coverage=true);'
coverage: /Test Coverage (\d+\.\d+%)/
Pkg.test(; coverage=true);'
coverage: &coverage
coverage: /Test coverage (\d+\.\d+%)/
after_script:
- julia -e '
using Pkgl
using Pkg;
Pkg.add("Coverage");
using Coverage;
c, t = get_summary(process_folder());
using Printf;
@printf "Test Coverage %.2f%%\n" 100c/t;'
@printf "Test coverage %.2f%%\n" 100c / t;'
Julia 1.0:
image: julia:1.0
<<: *script
<<: *coverage
Julia 1.2:
image: julia:1.2
<<: *script
<<: *coverage

View File

@ -1,8 +1,15 @@
# AllPlugins
using AllPlugins
using Documenter
```@index
```
```@autodocs
Modules = [AllPlugins]
```
makedocs(;
modules=[AllPlugins],
authors="tester",
repo="https://github.com/tester/AllPlugins.jl/blob/{commit}{path}#L{line}",
sitename="AllPlugins.jl",
format=Documenter.HTML(;
assets=String[],
),
pages=[
"Home" => "index.md",
],
)

View File

@ -1,15 +1,8 @@
using AllPlugins
using Documenter
# AllPlugins
makedocs(;
modules=[AllPlugins],
authors="tester",
repo="https://github.com/tester/AllPlugins.jl/blob/{commit}{path}#L{line}",
sitename="AllPlugins.jl",
format=Documenter.HTML(;
assets=String[],
),
pages=[
"Home" => "index.md",
],
)
```@index
```
```@autodocs
Modules = [AllPlugins]
```

View File

@ -10,7 +10,7 @@ function test_all(pkg::AbstractString; kwargs...)
t(pkg)
try
foreach(readlines(`git -C $pkg_dir ls-files`)) do f
# All fixture files are .txt so that ReferenceTests can't handle them.
# All fixture files are .txt so that ReferenceTests can handle them.
reference = joinpath(@__DIR__, "fixtures", pkg, f * ".txt")
observed = read(joinpath(pkg_dir, f), String)
@test_reference reference observed

View File

@ -7,7 +7,6 @@ using ReferenceTests: @test_reference
using PkgTemplates
const PT = PkgTemplates
const PKG = "TestPkg"
const USER = "tester"
Random.seed!(1)
@ -21,7 +20,7 @@ tpl(; kwargs...) = Template(; user=USER, kwargs...)
try
include("template.jl")
# Some plugins use the current Julia version in their output,
# Quite a bit of output depends on the Julia version,
# and the test fixtures are generated with Julia 1.2.
if VERSION.major == 1 && VERSION.minor == 2
include("generate.jl")