Fixes for GitLabCI and Documenter
This commit is contained in:
parent
1d26885983
commit
99bc709ef3
@ -1,32 +1,40 @@
|
|||||||
|
.definitions:
|
||||||
|
script: &script
|
||||||
|
script:
|
||||||
|
- julia --project=@. -e '
|
||||||
|
using Pkg;
|
||||||
|
Pkg.build();
|
||||||
|
Pkg.test({{#HAS_COVERAGE}}; coverage=true{{/HAS_COVERAGE}});'
|
||||||
|
{{#HAS_COVERAGE}}
|
||||||
|
coverage: &coverage
|
||||||
|
coverage: /Test coverage (\d+\.\d+%)/
|
||||||
|
after_script:
|
||||||
|
- julia -e '
|
||||||
|
using Pkg;
|
||||||
|
Pkg.add("Coverage");
|
||||||
|
using Coverage;
|
||||||
|
c, t = get_summary(process_folder());
|
||||||
|
using Printf;
|
||||||
|
@printf "Test coverage %.2f%%\n" 100c / t;'
|
||||||
|
{{/HAS_COVERAGE}}
|
||||||
{{#VERSIONS}}
|
{{#VERSIONS}}
|
||||||
Julia {{.}}:
|
Julia {{.}}:
|
||||||
image: julia:{{.}}
|
image: julia:{{.}}
|
||||||
script: julia --project=@. -e '
|
<<: *script
|
||||||
using Pkg;
|
{{#HAS_COVERAGE}}
|
||||||
Pkg.build();
|
<<: *coverage
|
||||||
Pkg.test({{#HAS_COVERAGE}}coverage=true{{/HAS_COVERAGE}});'
|
{{/HAS_COVERAGE}}
|
||||||
{{/VERSIONS}}
|
{{/VERSIONS}}
|
||||||
{{#HAS_COVERAGE}}
|
|
||||||
coverage: /Test Coverage (\d+\.\d+%)/
|
|
||||||
after_script:
|
|
||||||
- julia -e '
|
|
||||||
using Pkg;
|
|
||||||
Pkg.add("Coverage");
|
|
||||||
using Coverage;
|
|
||||||
c, t = get_summary(process_folder());
|
|
||||||
using Printf;
|
|
||||||
@printf "Test Coverage %.2f%%\n" 100c/t;'
|
|
||||||
{{/HAS_COVERAGE}}
|
|
||||||
{{#HAS_DOCUMENTER}}
|
{{#HAS_DOCUMENTER}}
|
||||||
pages:
|
pages:
|
||||||
image: julia:{{VERSION}}
|
image: julia:{{VERSION}}
|
||||||
stage: deploy
|
stage: deploy
|
||||||
script:
|
script:
|
||||||
- julia --project=docs -e '
|
- julia --project=docs -e '
|
||||||
using Pkg;
|
using Pkg;
|
||||||
Pkg.develop(PackageSpec(; path=pwd()));
|
Pkg.develop(PackageSpec(; path=pwd()));
|
||||||
Pkg.instantiate();
|
Pkg.instantiate();
|
||||||
include("docs/make.jl");'
|
include("docs/make.jl");'
|
||||||
- mkdir -p public
|
- mkdir -p public
|
||||||
- mv docs/build public/dev
|
- mv docs/build public/dev
|
||||||
artifacts:
|
artifacts:
|
||||||
|
@ -7,7 +7,7 @@ format_version(v::AbstractString) = string(v)
|
|||||||
|
|
||||||
function collect_versions(t::Template, versions::Vector)
|
function collect_versions(t::Template, versions::Vector)
|
||||||
vs = map(format_version, [t.julia_version, versions...])
|
vs = map(format_version, [t.julia_version, versions...])
|
||||||
return unique(sort(vs))
|
return sort(unique(vs))
|
||||||
end
|
end
|
||||||
|
|
||||||
@with_kw struct TravisCI <: BasicPlugin
|
@with_kw struct TravisCI <: BasicPlugin
|
||||||
@ -128,9 +128,9 @@ end
|
|||||||
|
|
||||||
@with_kw struct GitLabCI <: BasicPlugin
|
@with_kw struct GitLabCI <: BasicPlugin
|
||||||
file::String = default_file("gitlab-ci.yml")
|
file::String = default_file("gitlab-ci.yml")
|
||||||
documentation::Bool = true
|
|
||||||
coverage::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
|
end
|
||||||
|
|
||||||
gitignore(p::GitLabCI) = p.coverage ? COVERAGE_GITIGNORE : String[]
|
gitignore(p::GitLabCI) = p.coverage ? COVERAGE_GITIGNORE : String[]
|
||||||
|
@ -32,14 +32,14 @@ struct Documenter{T<:Union{TravisCI, GitLabCI, Nothing}} <: Plugin
|
|||||||
index_md::String
|
index_md::String
|
||||||
|
|
||||||
# Can't use @with_kw due to some weird precompilation issues.
|
# Can't use @with_kw due to some weird precompilation issues.
|
||||||
function Documenter{T}(
|
function Documenter{T}(;
|
||||||
assets::Vector{<:AbstractString}=String[],
|
assets::Vector{<:AbstractString}=String[],
|
||||||
makedocs_kwargs::Dict{Symbol}=Dict{Symbol, Any}(),
|
makedocs_kwargs::Dict{Symbol}=Dict{Symbol, Any}(),
|
||||||
canonical_url::Union{Function, Nothing}=T === TravisCI ? github_pages_url : nothing,
|
canonical_url::Union{Function, Nothing}=make_canonical(T),
|
||||||
index_md::AbstractString=default_file("index.md"),
|
|
||||||
make_jl::AbstractString=default_file("make.jl"),
|
make_jl::AbstractString=default_file("make.jl"),
|
||||||
|
index_md::AbstractString=default_file("index.md"),
|
||||||
) where T <: Union{TravisCI, GitLabCI, Nothing}
|
) 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
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -71,7 +71,7 @@ view(p::Documenter, t::Template, pkg::AbstractString) = Dict(
|
|||||||
"AUTHORS" => join(t.authors, ", "),
|
"AUTHORS" => join(t.authors, ", "),
|
||||||
"CANONICAL" => p.canonical_url === nothing ? nothing : p.canonical_url(t, pkg),
|
"CANONICAL" => p.canonical_url === nothing ? nothing : p.canonical_url(t, pkg),
|
||||||
"HAS_ASSETS" => !isempty(p.assets),
|
"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,
|
"PKG" => pkg,
|
||||||
"REPO" => "$(t.host)/$(t.user)/$pkg.jl",
|
"REPO" => "$(t.host)/$(t.user)/$pkg.jl",
|
||||||
"USER" => t.user,
|
"USER" => t.user,
|
||||||
@ -107,32 +107,9 @@ function gen_plugin(p::Documenter, t::Template, pkg_dir::AbstractString)
|
|||||||
end
|
end
|
||||||
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"
|
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
|
||||||
|
36
test/fixtures/AllPlugins/.gitlab-ci.yml.txt
vendored
36
test/fixtures/AllPlugins/.gitlab-ci.yml.txt
vendored
@ -1,15 +1,25 @@
|
|||||||
|
.definitions:
|
||||||
|
script: &script
|
||||||
|
script:
|
||||||
|
- julia --project=@. -e '
|
||||||
|
using Pkg;
|
||||||
|
Pkg.build();
|
||||||
|
Pkg.test(; coverage=true);'
|
||||||
|
coverage: &coverage
|
||||||
|
coverage: /Test coverage (\d+\.\d+%)/
|
||||||
|
after_script:
|
||||||
|
- julia -e '
|
||||||
|
using Pkg;
|
||||||
|
Pkg.add("Coverage");
|
||||||
|
using Coverage;
|
||||||
|
c, t = get_summary(process_folder());
|
||||||
|
using Printf;
|
||||||
|
@printf "Test coverage %.2f%%\n" 100c / t;'
|
||||||
Julia 1.0:
|
Julia 1.0:
|
||||||
image: julia:1.0
|
image: julia:1.0
|
||||||
script: julia --project=@. -e '
|
<<: *script
|
||||||
using Pkg;
|
<<: *coverage
|
||||||
Pkg.build();
|
Julia 1.2:
|
||||||
Pkg.test(coverage=true);'
|
image: julia:1.2
|
||||||
coverage: /Test Coverage (\d+\.\d+%)/
|
<<: *script
|
||||||
after_script:
|
<<: *coverage
|
||||||
- julia -e '
|
|
||||||
using Pkgl
|
|
||||||
Pkg.add("Coverage");
|
|
||||||
using Coverage;
|
|
||||||
c, t = get_summary(process_folder());
|
|
||||||
using Printf;
|
|
||||||
@printf "Test Coverage %.2f%%\n" 100c/t;'
|
|
||||||
|
21
test/fixtures/AllPlugins/docs/make.jl.txt
vendored
21
test/fixtures/AllPlugins/docs/make.jl.txt
vendored
@ -1,8 +1,15 @@
|
|||||||
# AllPlugins
|
using AllPlugins
|
||||||
|
using Documenter
|
||||||
|
|
||||||
```@index
|
makedocs(;
|
||||||
```
|
modules=[AllPlugins],
|
||||||
|
authors="tester",
|
||||||
```@autodocs
|
repo="https://github.com/tester/AllPlugins.jl/blob/{commit}{path}#L{line}",
|
||||||
Modules = [AllPlugins]
|
sitename="AllPlugins.jl",
|
||||||
```
|
format=Documenter.HTML(;
|
||||||
|
assets=String[],
|
||||||
|
),
|
||||||
|
pages=[
|
||||||
|
"Home" => "index.md",
|
||||||
|
],
|
||||||
|
)
|
||||||
|
21
test/fixtures/AllPlugins/docs/src/index.md.txt
vendored
21
test/fixtures/AllPlugins/docs/src/index.md.txt
vendored
@ -1,15 +1,8 @@
|
|||||||
using AllPlugins
|
# AllPlugins
|
||||||
using Documenter
|
|
||||||
|
|
||||||
makedocs(;
|
```@index
|
||||||
modules=[AllPlugins],
|
```
|
||||||
authors="tester",
|
|
||||||
repo="https://github.com/tester/AllPlugins.jl/blob/{commit}{path}#L{line}",
|
```@autodocs
|
||||||
sitename="AllPlugins.jl",
|
Modules = [AllPlugins]
|
||||||
format=Documenter.HTML(;
|
```
|
||||||
assets=String[],
|
|
||||||
),
|
|
||||||
pages=[
|
|
||||||
"Home" => "index.md",
|
|
||||||
],
|
|
||||||
)
|
|
||||||
|
@ -10,7 +10,7 @@ function test_all(pkg::AbstractString; kwargs...)
|
|||||||
t(pkg)
|
t(pkg)
|
||||||
try
|
try
|
||||||
foreach(readlines(`git -C $pkg_dir ls-files`)) do f
|
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")
|
reference = joinpath(@__DIR__, "fixtures", pkg, f * ".txt")
|
||||||
observed = read(joinpath(pkg_dir, f), String)
|
observed = read(joinpath(pkg_dir, f), String)
|
||||||
@test_reference reference observed
|
@test_reference reference observed
|
||||||
|
@ -7,7 +7,6 @@ using ReferenceTests: @test_reference
|
|||||||
using PkgTemplates
|
using PkgTemplates
|
||||||
const PT = PkgTemplates
|
const PT = PkgTemplates
|
||||||
|
|
||||||
const PKG = "TestPkg"
|
|
||||||
const USER = "tester"
|
const USER = "tester"
|
||||||
|
|
||||||
Random.seed!(1)
|
Random.seed!(1)
|
||||||
@ -21,7 +20,7 @@ tpl(; kwargs...) = Template(; user=USER, kwargs...)
|
|||||||
try
|
try
|
||||||
include("template.jl")
|
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.
|
# and the test fixtures are generated with Julia 1.2.
|
||||||
if VERSION.major == 1 && VERSION.minor == 2
|
if VERSION.major == 1 && VERSION.minor == 2
|
||||||
include("generate.jl")
|
include("generate.jl")
|
||||||
|
Loading…
Reference in New Issue
Block a user