2017-08-11 22:18:09 +00:00
|
|
|
"""
|
2017-08-12 03:36:29 +00:00
|
|
|
CodeCov(; config_file::AbstractString="") -> CodeCov
|
2017-08-11 22:18:09 +00:00
|
|
|
|
|
|
|
Add CodeCov to a template's plugins to enable CodeCov coverage reports.
|
|
|
|
|
|
|
|
# Keyword Arguments:
|
|
|
|
* `config_file::AbstractString`: Path to a custom `.codecov.yml`.
|
2017-08-12 03:36:29 +00:00
|
|
|
If `nothing` is supplied, then no file will be generated.
|
2017-08-11 22:18:09 +00:00
|
|
|
"""
|
2017-08-14 18:12:37 +00:00
|
|
|
@auto_hash_equals struct CodeCov <: Plugin
|
2017-08-11 22:18:09 +00:00
|
|
|
gitignore_files::Vector{AbstractString}
|
2017-08-14 18:59:33 +00:00
|
|
|
config_file::Union{AbstractString, Void}
|
2017-08-11 22:18:09 +00:00
|
|
|
|
2017-08-14 18:59:33 +00:00
|
|
|
function CodeCov(; config_file::Union{AbstractString, Void}="")
|
2017-08-12 03:36:29 +00:00
|
|
|
if config_file != nothing
|
|
|
|
if isempty(config_file)
|
|
|
|
config_file = joinpath(DEFAULTS_DIR, "codecov.yml")
|
|
|
|
end
|
|
|
|
if !isfile(abspath(config_file))
|
|
|
|
throw(ArgumentError("File $config_file does not exist"))
|
|
|
|
end
|
2017-08-11 22:18:09 +00:00
|
|
|
end
|
|
|
|
new(["*.jl.cov", "*.jl.*.cov", "*.jl.mem"], config_file)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
"""
|
2017-08-15 23:46:36 +00:00
|
|
|
badges(\_::CodeCov, user::AbstractString, pkg_name::AbstractString) -> Vector{String}
|
2017-08-11 22:18:09 +00:00
|
|
|
|
2017-08-12 03:36:29 +00:00
|
|
|
Generate Markdown badges for the current package.
|
2017-08-11 22:18:09 +00:00
|
|
|
|
|
|
|
# Arguments
|
2017-08-15 16:10:05 +00:00
|
|
|
* `_::CodeCov`: Plugin whose badges we are generating.
|
|
|
|
* `user::AbstractString`: GitHub username of the package creator.
|
2017-08-11 22:18:09 +00:00
|
|
|
* `pkg_name::AbstractString`: Name of the package.
|
2017-08-12 03:36:29 +00:00
|
|
|
|
|
|
|
Returns an array of Markdown badges.
|
2017-08-11 22:18:09 +00:00
|
|
|
"""
|
2017-08-15 16:10:05 +00:00
|
|
|
function badges(_::CodeCov, user::AbstractString, pkg_name::AbstractString)
|
2017-08-11 22:18:09 +00:00
|
|
|
return [
|
2017-08-15 14:19:37 +00:00
|
|
|
"[](https://codecov.io/gh/$user/$pkg_name.jl)"
|
2017-08-11 22:18:09 +00:00
|
|
|
]
|
|
|
|
end
|
|
|
|
|
|
|
|
"""
|
2017-08-12 03:36:29 +00:00
|
|
|
gen_plugin(plugin::CodeCov, template::Template, pkg_name::AbstractString) -> Vector{String}
|
2017-08-11 22:18:09 +00:00
|
|
|
|
|
|
|
Generate a .codecov.yml.
|
|
|
|
|
|
|
|
# Arguments
|
|
|
|
* `plugin::CodeCov`: Plugin whose files are being generated.
|
|
|
|
* `template::Template`: Template configuration and plugins.
|
|
|
|
* `pkg_name::AbstractString`: Name of the package.
|
|
|
|
|
2017-08-15 23:46:36 +00:00
|
|
|
Returns an array of generated file/directory names.
|
2017-08-11 22:18:09 +00:00
|
|
|
"""
|
|
|
|
function gen_plugin(plugin::CodeCov, template::Template, pkg_name::AbstractString)
|
2017-08-12 03:36:29 +00:00
|
|
|
if plugin.config_file == nothing
|
|
|
|
return String[]
|
|
|
|
end
|
2017-08-11 22:18:09 +00:00
|
|
|
text = substitute(readstring(plugin.config_file), pkg_name, template)
|
2017-08-15 23:46:36 +00:00
|
|
|
gen_file(joinpath(template.temp_dir, pkg_name, ".codecov.yml"), text)
|
2017-08-11 22:18:09 +00:00
|
|
|
return [".codecov.yml"]
|
|
|
|
end
|