Add GitLabCI plugin
This commit is contained in:
parent
7d1ac85f7c
commit
365a02c0bf
36
defaults/gitlab-ci.yml
Normal file
36
defaults/gitlab-ci.yml
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
stages:
|
||||||
|
- test
|
||||||
|
- coverage
|
||||||
|
|
||||||
|
.test_template: &test_template
|
||||||
|
stage: test
|
||||||
|
artifacts:
|
||||||
|
name: coverage
|
||||||
|
expire_in: 2 hours
|
||||||
|
paths:
|
||||||
|
- coverage/
|
||||||
|
tags:
|
||||||
|
- docker
|
||||||
|
script:
|
||||||
|
- julia -e 'Pkg.clone(pwd()); Pkg.build("{{PKGNAME}}"); Pkg.test("{{PKGNAME}}"{{#GITLABCOVERAGE}}; coverage=true{{/GITLABCOVERAGE}})'
|
||||||
|
- cp -r $(julia -e 'print(Pkg.dir("{{PKGNAME}}", "src"))') coverage
|
||||||
|
|
||||||
|
Julia {{VERSION}}:
|
||||||
|
image: julia:{{VERSION}}
|
||||||
|
<<: *test_template
|
||||||
|
|
||||||
|
Julia nightly:
|
||||||
|
image: staticfloat/julia:nightly-x64
|
||||||
|
allow_failure: true
|
||||||
|
<<: *test_template{{#GITLABCOVERAGE}}
|
||||||
|
|
||||||
|
"Coverage":
|
||||||
|
stage: coverage
|
||||||
|
image: julia:0.6
|
||||||
|
tags:
|
||||||
|
- docker
|
||||||
|
before_script:
|
||||||
|
- apt-get update && apt-get -y install git make unzip gcc bzip2
|
||||||
|
script:
|
||||||
|
- rm -rf src && mv coverage src
|
||||||
|
- julia -e 'Pkg.add("Coverage"); using Coverage; c, t = get_summary(process_folder()); @printf("Test Coverage %.2f%%\n", 100c/t)'{{/GITLABCOVERAGE}}
|
@ -7,7 +7,7 @@ using TerminalMenus
|
|||||||
using URIParser
|
using URIParser
|
||||||
|
|
||||||
export generate, interactive_template, show_license, available_licenses, Template,
|
export generate, interactive_template, show_license, available_licenses, Template,
|
||||||
GitHubPages, AppVeyor, TravisCI, CodeCov, Coveralls
|
GitHubPages, AppVeyor, TravisCI, GitLabCI, CodeCov, Coveralls
|
||||||
|
|
||||||
abstract type Plugin end
|
abstract type Plugin end
|
||||||
|
|
||||||
@ -20,6 +20,7 @@ include(joinpath("plugins", "coveralls.jl"))
|
|||||||
include(joinpath("plugins", "appveyor.jl"))
|
include(joinpath("plugins", "appveyor.jl"))
|
||||||
include(joinpath("plugins", "codecov.jl"))
|
include(joinpath("plugins", "codecov.jl"))
|
||||||
include(joinpath("plugins", "travisci.jl"))
|
include(joinpath("plugins", "travisci.jl"))
|
||||||
|
include(joinpath("plugins", "gitlabci.jl"))
|
||||||
include(joinpath("plugins", "githubpages.jl"))
|
include(joinpath("plugins", "githubpages.jl"))
|
||||||
|
|
||||||
const DEFAULTS_DIR = normpath(joinpath(@__DIR__, "..", "defaults"))
|
const DEFAULTS_DIR = normpath(joinpath(@__DIR__, "..", "defaults"))
|
||||||
|
82
src/plugins/gitlabci.jl
Normal file
82
src/plugins/gitlabci.jl
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
"""
|
||||||
|
GitLabCI(; config_file::Union{AbstractString, Void}="", coverage::Bool=true) -> GitLabCI
|
||||||
|
|
||||||
|
Add `GitLabCI` to a template's plugins to add a `.gitlab-ci.yml` configuration file to
|
||||||
|
generated repositories, and appropriate badge(s) to the README.
|
||||||
|
|
||||||
|
# Keyword Arguments:
|
||||||
|
* `config_file::Union{AbstractString, Void}=""`: Path to a custom `.gitlab-ci.yml`.
|
||||||
|
If `nothing` is supplied, no file will be generated.
|
||||||
|
* `coverage::Bool=true`: Whether or not GitLab CI's built-in code coverage analysis should
|
||||||
|
be enabled. If enabled, you must set a regex in your repo settings; use
|
||||||
|
`Test Coverage (\d+.\d+)%`.
|
||||||
|
"""
|
||||||
|
@auto_hash_equals struct GitLabCI <: GenericPlugin
|
||||||
|
gitignore::Vector{AbstractString}
|
||||||
|
src::Nullable{AbstractString}
|
||||||
|
dest::AbstractString
|
||||||
|
badges::Vector{Badge}
|
||||||
|
view::Dict{String, Any}
|
||||||
|
|
||||||
|
function GitLabCI(; config_file::Union{AbstractString, Void}="", coverage::Bool=true)
|
||||||
|
if config_file != nothing
|
||||||
|
if isempty(config_file)
|
||||||
|
config_file = joinpath(DEFAULTS_DIR, "gitlab-ci.yml")
|
||||||
|
elseif !isfile(config_file)
|
||||||
|
throw(ArgumentError("File $(abspath(config_file)) does not exist"))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
badges = [
|
||||||
|
Badge(
|
||||||
|
"Build Status",
|
||||||
|
"https://gitlab.com/{{USER}}/{{PKGNAME}}.jl/badges/master/build.svg",
|
||||||
|
"https://gitlab.com/{{USER}}/{{PKGNAME}}.jl/commits/master",
|
||||||
|
),
|
||||||
|
]
|
||||||
|
if coverage
|
||||||
|
push!(
|
||||||
|
badges,
|
||||||
|
Badge(
|
||||||
|
"Coverage",
|
||||||
|
"https://gitlab.com/{{USER}}/{{PKGNAME}}.jl/badges/master/coverage.svg",
|
||||||
|
"https://gitlab.com/{{USER}}/{{PKGNAME}}.jl/commits/master",
|
||||||
|
),
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
new(
|
||||||
|
coverage ? ["*.jl.cov", "*.jl.*.cov", "*.jl.mem"] : [],
|
||||||
|
config_file,
|
||||||
|
".gitlab-ci.yml",
|
||||||
|
badges,
|
||||||
|
Dict("GITLABCOVERAGE" => coverage),
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function interactive(plugin_type::Type{GitLabCI})
|
||||||
|
name = "GitLabCI"
|
||||||
|
kwargs = Dict{Symbol, Any}()
|
||||||
|
|
||||||
|
default_config_file = joinpath(DEFAULTS_DIR, "gitlab-ci.yml")
|
||||||
|
print("$name: Enter the config template filename (\"None\" for no file) ")
|
||||||
|
print("[$default_config_file]: ")
|
||||||
|
config_file = readline()
|
||||||
|
kwargs[:config_file] = if uppercase(config_file) == "NONE"
|
||||||
|
nothing
|
||||||
|
elseif isempty(config_file)
|
||||||
|
default_config_file
|
||||||
|
else
|
||||||
|
config_file
|
||||||
|
end
|
||||||
|
|
||||||
|
print("$name: Enable test coverage analysis? [yes]: ")
|
||||||
|
coverage = readline()
|
||||||
|
kwargs[:coverage] = if isempty(coverage)
|
||||||
|
true
|
||||||
|
else
|
||||||
|
!in(uppercase(user_image), ["N", "NO", "FALSE", "NONE"])
|
||||||
|
end
|
||||||
|
|
||||||
|
return GitLabCI(; kwargs...)
|
||||||
|
end
|
Loading…
Reference in New Issue
Block a user