From c417e88c92df1e552779965eaaee804bdb42ae78 Mon Sep 17 00:00:00 2001 From: Nick Robinson Date: Fri, 4 Oct 2019 07:29:30 +0100 Subject: [PATCH 1/3] [ci skip] Add code style badge (#99) --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 00a30c1..003eace 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,7 @@ [![Build Status](https://travis-ci.org/invenia/PkgTemplates.jl.svg?branch=master)](https://travis-ci.org/invenia/PkgTemplates.jl) [![Build Status](https://ci.appveyor.com/api/projects/status/r24xamruqlm88uti/branch/master?svg=true)](https://ci.appveyor.com/project/christopher-dG/pkgtemplates-jl/branch/master) [![Codecov](https://codecov.io/gh/invenia/PkgTemplates.jl/branch/master/graph/badge.svg)](https://codecov.io/gh/invenia/PkgTemplates.jl) +[![Code Style: Blue](https://img.shields.io/badge/code%20style-blue-4495d1.svg)](https://github.com/invenia/BlueStyle) **PkgTemplates is a Julia package for creating new Julia packages in an easy, repeatable, and customizable way.** From 6d2c4ea7c0ebcb99c24d410da0b81d50322613ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mos=C3=A8=20Giordano?= Date: Sat, 5 Oct 2019 07:44:35 +0100 Subject: [PATCH 2/3] Add Drone CI plugin (#94) --- defaults/drone.yml | 29 ++++++++++++++++++++++++++ src/PkgTemplates.jl | 2 ++ src/plugins/droneci.jl | 45 +++++++++++++++++++++++++++++++++++++++++ test/plugins/droneci.jl | 41 +++++++++++++++++++++++++++++++++++++ test/tests.jl | 1 + 5 files changed, 118 insertions(+) create mode 100644 defaults/drone.yml create mode 100644 src/plugins/droneci.jl create mode 100644 test/plugins/droneci.jl diff --git a/defaults/drone.yml b/defaults/drone.yml new file mode 100644 index 0000000..90f3f82 --- /dev/null +++ b/defaults/drone.yml @@ -0,0 +1,29 @@ +--- +kind: pipeline +name: linux - arm - Julia {{VERSION}} + +platform: + os: linux + arch: arm + +steps: +- name: build + image: julia:{{VERSION}} + commands: + - "julia --project=. --check-bounds=yes --color=yes -e 'using InteractiveUtils; versioninfo(verbose=true); using Pkg; Pkg.build(); Pkg.test(coverage=true)'" + +--- +kind: pipeline +name: linux - arm64 - Julia {{VERSION}} + +platform: + os: linux + arch: arm64 + +steps: +- name: build + image: julia:{{VERSION}} + commands: + - "julia --project=. --check-bounds=yes --color=yes -e 'using InteractiveUtils; versioninfo(verbose=true); using Pkg; Pkg.build(); Pkg.test(coverage=true)'" + +... diff --git a/src/PkgTemplates.jl b/src/PkgTemplates.jl index 6f54e10..ebd05c2 100644 --- a/src/PkgTemplates.jl +++ b/src/PkgTemplates.jl @@ -24,6 +24,7 @@ export TravisCI, GitLabCI, CirrusCI, + DroneCI, Codecov, Coveralls, Citation @@ -45,6 +46,7 @@ include(joinpath("plugins", "codecov.jl")) include(joinpath("plugins", "travisci.jl")) include(joinpath("plugins", "gitlabci.jl")) include(joinpath("plugins", "cirrusci.jl")) +include(joinpath("plugins", "droneci.jl")) include(joinpath("plugins", "githubpages.jl")) include(joinpath("plugins", "gitlabpages.jl")) include(joinpath("plugins", "citation.jl")) diff --git a/src/plugins/droneci.jl b/src/plugins/droneci.jl new file mode 100644 index 0000000..5ce2027 --- /dev/null +++ b/src/plugins/droneci.jl @@ -0,0 +1,45 @@ +""" + DroneCI(; config_file::Union{AbstractString, Nothing}="") -> DroneCI + +Add `DroneCI` to a template's plugins to add a `.drone.yml` configuration file to +generated repositories, and an appropriate badge to the README. The default configuration +file supports Linux on ARM32 and ARM64. + +# Keyword Arguments +* `config_file::Union{AbstractString, Nothing}=""`: Path to a custom `.drone.yml`. + If `nothing` is supplied, no file will be generated. +""" +struct DroneCI <: GenericPlugin + gitignore::Vector{String} + src::Union{String, Nothing} + dest::String + badges::Vector{Badge} + view::Dict{String, Any} + + function DroneCI(; config_file::Union{AbstractString, Nothing}="") + if config_file !== nothing + config_file = if isempty(config_file) + joinpath(DEFAULTS_DIR, "drone.yml") + elseif isfile(config_file) + abspath(config_file) + else + throw(ArgumentError("File $(abspath(config_file)) does not exist")) + end + end + return new( + [], + config_file, + ".drone.yml", + [ + Badge( + "Build Status", + "https://cloud.drone.io/api/badges/{{USER}}/{{PKGNAME}}.jl/status.svg", + "https://cloud.drone.io/{{USER}}/{{PKGNAME}}.jl", + ), + ], + Dict{String, Any}(), + ) + end +end + +interactive(::Type{DroneCI}) = interactive(DroneCI; file="drone.yml") diff --git a/test/plugins/droneci.jl b/test/plugins/droneci.jl new file mode 100644 index 0000000..5b7fc6f --- /dev/null +++ b/test/plugins/droneci.jl @@ -0,0 +1,41 @@ +t = Template(; user=me) +pkg_dir = joinpath(t.dir, test_pkg) + +@testset "DroneCI" begin + @testset "Plugin creation" begin + p = DroneCI() + @test isempty(p.gitignore) + @test p.src == joinpath(DEFAULTS_DIR, "drone.yml") + @test p.dest == ".drone.yml" + @test p.badges == [ + Badge( + "Build Status", + "https://cloud.drone.io/api/badges/{{USER}}/{{PKGNAME}}.jl/status.svg", + "https://cloud.drone.io/{{USER}}/{{PKGNAME}}.jl", + ), + ] + @test isempty(p.view) + p = DroneCI(; config_file=nothing) + @test p.src === nothing + p = DroneCI(; config_file=test_file) + @test p.src == test_file + @test_throws ArgumentError DroneCI(; config_file=fake_path) + end + + @testset "Badge generation" begin + p = DroneCI() + @test badges(p, me, test_pkg) == ["[![Build Status](https://cloud.drone.io/api/badges/$me/$test_pkg.jl/status.svg)](https://cloud.drone.io/$me/$test_pkg.jl)"] + end + + @testset "File generation" begin + # Without a coverage plugin in the template, there should be no coverage step. + p = DroneCI() + @test gen_plugin(p, t, test_pkg) == [".drone.yml"] + @test isfile(joinpath(pkg_dir, ".drone.yml")) + drone = read(joinpath(pkg_dir, ".drone.yml"), String) + @test !occursin("coverage_script", drone) + rm(joinpath(pkg_dir, ".drone.yml")) + end +end + +rm(pkg_dir; recursive=true) diff --git a/test/tests.jl b/test/tests.jl index ea8a0ad..198e0f1 100644 --- a/test/tests.jl +++ b/test/tests.jl @@ -441,6 +441,7 @@ end include(joinpath("plugins", "appveyor.jl")) include(joinpath("plugins", "gitlabci.jl")) include(joinpath("plugins", "cirrusci.jl")) + include(joinpath("plugins", "droneci.jl")) include(joinpath("plugins", "codecov.jl")) include(joinpath("plugins", "coveralls.jl")) include(joinpath("plugins", "githubpages.jl")) From 26a494410a5617af35acd8097ed3bcf303d71543 Mon Sep 17 00:00:00 2001 From: Chris de Graaf Date: Sat, 5 Oct 2019 13:45:17 +0700 Subject: [PATCH 3/3] Version bump --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 4ddb988..fc66eec 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "PkgTemplates" uuid = "14b8a8f1-9102-5b29-a752-f990bacb7fe1" authors = ["Chris de Graaf "] -version = "0.6.2" +version = "0.6.3" [deps] Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"