Merge pull request #107 from invenia/cdg/actions

Add plugins for TagBot and CompatHelper
This commit is contained in:
Chris de Graaf 2019-12-18 11:26:05 +07:00 committed by GitHub
commit ab9949a236
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
25 changed files with 275 additions and 25 deletions

11
.github/workflows/TagBot.yml vendored Normal file
View File

@ -0,0 +1,11 @@
name: TagBot
on:
schedule:
- cron: 0 * * * *
jobs:
TagBot:
runs-on: ubuntu-latest
steps:
- uses: JuliaRegistries/TagBot@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}

View File

@ -12,7 +12,8 @@ Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"
[compat]
Mustache = ">= 0.5.13"
Mustache = "1"
Parameters = "0.12"
julia = "1"
[extras]

View File

@ -40,6 +40,7 @@ Tests
Readme
License
Git
TagBot
```
### Continuous Integration (CI)
@ -74,6 +75,7 @@ Documenter
```@docs
Develop
CompatHelper
Citation
```

View File

@ -1,7 +1,6 @@
module PkgTemplates
using Base: active_project
using Base.Filesystem: contractuser
using Base: active_project, contractuser
using Dates: month, today, year
using LibGit2: LibGit2, GitRemote, GitRepo
@ -18,6 +17,7 @@ export
Citation,
DroneCI,
Codecov,
CompatHelper,
Coveralls,
Develop,
Documenter,
@ -28,6 +28,7 @@ export
ProjectFile,
Readme,
SrcDir,
TagBot,
Tests,
TravisCI

View File

@ -257,8 +257,10 @@ include(joinpath("plugins", "tests.jl"))
include(joinpath("plugins", "readme.jl"))
include(joinpath("plugins", "license.jl"))
include(joinpath("plugins", "git.jl"))
include(joinpath("plugins", "tagbot.jl"))
include(joinpath("plugins", "develop.jl"))
include(joinpath("plugins", "coverage.jl"))
include(joinpath("plugins", "ci.jl"))
include(joinpath("plugins", "compat_helper.jl"))
include(joinpath("plugins", "citation.jl"))
include(joinpath("plugins", "documenter.jl"))

View File

@ -29,7 +29,7 @@ Integrates your packages with [GitHub Actions](https://github.com/features/actio
## Keyword Arguments
- `file::AbstractString`: Template file for the workflow file.
- `destination::AbstractString`: Destination of the worflow file,
- `destination::AbstractString`: Destination of the workflow file,
relative to `.github/workflows`.
- `linux::Bool`: Whether or not to run builds on Linux.
- `osx::Bool`: Whether or not to run builds on OSX (MacOS).
@ -58,7 +58,6 @@ end
source(p::GitHubActions) = p.file
destination(p::GitHubActions) = joinpath(".github", "workflows", p.destination)
tags(::GitHubActions) = "<<", ">>"
badges(::GitHubActions) = Badge(
@ -302,7 +301,6 @@ See [`Documenter`](@ref) for more information.
end
gitignore(p::GitLabCI) = p.coverage ? COVERAGE_GITIGNORE : String[]
source(p::GitLabCI) = p.file
destination(::GitLabCI) = ".gitlab-ci.yml"

View File

@ -0,0 +1,25 @@
"""
CompatHelper(;
file="$(contractuser(default_file("github", "workflows", "CompatHelper.yml")))",
destination="CompatHelper.yml",
)
Integrates your packages with [CompatHelper](https://github.com/bcbi/CompatHelper.jl) via GitHub Actions.
## Keyword Arguments
- `file::AbstractString`: Template file for the workflow file.
- `destination::AbstractString`: Destination of the workflow file,
relative to `.github/workflows`.
"""
@with_kw_noshow struct CompatHelper <: BasicPlugin
file::String = default_file("github", "workflows", "CompatHelper.yml")
destination::String = "CompatHelper.yml"
end
source(p::CompatHelper) = p.file
destination(p::CompatHelper) = joinpath(".github", "workflows", p.destination)
tags(::CompatHelper) = "<<", ">>"
view(p::CompatHelper, t::Template, ::AbstractString) = Dict(
"VERSION" => format_version(max(v"1.2", t.julia)),
)

25
src/plugins/tagbot.jl Normal file
View File

@ -0,0 +1,25 @@
"""
TagBot(; destination="TagBot.yml", registry=nothing, dispatch=false)
Adds GitHub release support via [TagBot](https://github.com/JuliaRegistries/TagBot).
## Keyword Arguments
- `destination::AbstractString`: Destination of the workflow file,
relative to `.github/workflows`.
- `registry::Union{AbstractString, Nothing}`: Custom registry, in the format `owner/repo`.
- `dispatch::Bool`: Whether or not to enable the `dispatch` option.
"""
@with_kw_noshow struct TagBot <: BasicPlugin
destination::String = "TagBot.yml"
registry::Union{String, Nothing} = nothing
dispatch::Bool = false
end
source(::TagBot) = default_file("github", "workflows", "TagBot.yml")
destination(p::TagBot) = joinpath(".github", "workflows", p.destination)
tags(::TagBot) = "<<", ">>"
view(p::TagBot, ::Template, ::AbstractString) = Dict(
"HAS_DISPATCH" => p.dispatch,
"REGISTRY" => p.registry,
)

View File

@ -1,6 +1,15 @@
default_plugins() = [ProjectFile(), SrcDir(), Git(), License(), Readme(), Tests()]
default_user() = LibGit2.getconfig("github.user", "")
default_version() = VersionNumber(VERSION.major)
default_plugins() = [
CompatHelper(),
ProjectFile(),
SrcDir(),
Git(),
License(),
Readme(),
Tests(),
TagBot(),
]
function default_authors()
name = LibGit2.getconfig("user.name", "")

View File

@ -0,0 +1,17 @@
name: CompatHelper
on:
schedule:
- cron: 0 * * * *
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: julia-actions/setup-julia@latest
with:
version: <<&VERSION>>
- name: Pkg.add("CompatHelper")
run: julia -e 'using Pkg; Pkg.add("CompatHelper")'
- name: CompatHelper.main()
run: julia -e 'using CompatHelper; CompatHelper.main()'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View File

@ -0,0 +1,17 @@
name: TagBot
on:
schedule:
- cron: 0 * * * *
jobs:
TagBot:
runs-on: ubuntu-latest
steps:
- uses: JuliaRegistries/TagBot@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
<<#REGISTRY>>
registry: <<&REGISTRY>>
<</REGISTRY>>
<<#HAS_DISPATCH>>
dispatch: true
<</HAS_DISPATCH>>

View File

@ -0,0 +1,17 @@
name: CompatHelper
on:
schedule:
- cron: 0 * * * *
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: julia-actions/setup-julia@latest
with:
version: 1.2
- name: Pkg.add("CompatHelper")
run: julia -e 'using Pkg; Pkg.add("CompatHelper")'
- name: CompatHelper.main()
run: julia -e 'using CompatHelper; CompatHelper.main()'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View File

@ -0,0 +1,11 @@
name: TagBot
on:
schedule:
- cron: 0 * * * *
jobs:
TagBot:
runs-on: ubuntu-latest
steps:
- uses: JuliaRegistries/TagBot@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}

View File

@ -13,15 +13,15 @@ uuid = "8ba89e20-285c-5b6f-9357-94700520ee1b"
[[DocStringExtensions]]
deps = ["LibGit2", "Markdown", "Pkg", "Test"]
git-tree-sha1 = "0513f1a8991e9d83255e0140aace0d0fc4486600"
git-tree-sha1 = "88bb0edb352b16608036faadcc071adda068582a"
uuid = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
version = "0.8.0"
version = "0.8.1"
[[Documenter]]
deps = ["Base64", "DocStringExtensions", "InteractiveUtils", "JSON", "LibGit2", "Logging", "Markdown", "REPL", "Test", "Unicode"]
git-tree-sha1 = "1b6ae3796f60311e39cd1770566140d2c056e87f"
git-tree-sha1 = "d45c163c7a3ae293c15361acc52882c0f853f97c"
uuid = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
version = "0.23.3"
version = "0.23.4"
[[InteractiveUtils]]
deps = ["Markdown"]
@ -48,9 +48,9 @@ uuid = "a63ad114-7e13-5084-954f-fe012c677804"
[[Parsers]]
deps = ["Dates", "Test"]
git-tree-sha1 = "ef0af6c8601db18c282d092ccbd2f01f3f0cd70b"
git-tree-sha1 = "c56ecb484f286639f161e712b8311f5ab77e8d32"
uuid = "69de0a69-1ddd-5017-9359-2bf0b02dc9f0"
version = "0.3.7"
version = "0.3.8"
[[Pkg]]
deps = ["Dates", "LibGit2", "Markdown", "Printf", "REPL", "Random", "SHA", "UUIDs"]

View File

@ -0,0 +1,17 @@
name: CompatHelper
on:
schedule:
- cron: 0 * * * *
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: julia-actions/setup-julia@latest
with:
version: 1.2
- name: Pkg.add("CompatHelper")
run: julia -e 'using Pkg; Pkg.add("CompatHelper")'
- name: CompatHelper.main()
run: julia -e 'using CompatHelper; CompatHelper.main()'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View File

@ -0,0 +1,11 @@
name: TagBot
on:
schedule:
- cron: 0 * * * *
jobs:
TagBot:
runs-on: ubuntu-latest
steps:
- uses: JuliaRegistries/TagBot@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}

View File

@ -0,0 +1,17 @@
name: CompatHelper
on:
schedule:
- cron: 0 * * * *
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: julia-actions/setup-julia@latest
with:
version: 1.2
- name: Pkg.add("CompatHelper")
run: julia -e 'using Pkg; Pkg.add("CompatHelper")'
- name: CompatHelper.main()
run: julia -e 'using CompatHelper; CompatHelper.main()'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View File

@ -0,0 +1,11 @@
name: TagBot
on:
schedule:
- cron: 0 * * * *
jobs:
TagBot:
runs-on: ubuntu-latest
steps:
- uses: JuliaRegistries/TagBot@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}

View File

@ -0,0 +1,17 @@
name: CompatHelper
on:
schedule:
- cron: 0 * * * *
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: julia-actions/setup-julia@latest
with:
version: 1.2
- name: Pkg.add("CompatHelper")
run: julia -e 'using Pkg; Pkg.add("CompatHelper")'
- name: CompatHelper.main()
run: julia -e 'using CompatHelper; CompatHelper.main()'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View File

@ -0,0 +1,11 @@
name: TagBot
on:
schedule:
- cron: 0 * * * *
jobs:
TagBot:
runs-on: ubuntu-latest
steps:
- uses: JuliaRegistries/TagBot@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}

View File

@ -0,0 +1,17 @@
name: CompatHelper
on:
schedule:
- cron: 0 * * * *
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: julia-actions/setup-julia@latest
with:
version: 1.2
- name: Pkg.add("CompatHelper")
run: julia -e 'using Pkg; Pkg.add("CompatHelper")'
- name: CompatHelper.main()
run: julia -e 'using CompatHelper; CompatHelper.main()'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View File

@ -0,0 +1,13 @@
name: TagBot
on:
schedule:
- cron: 0 * * * *
jobs:
TagBot:
runs-on: ubuntu-latest
steps:
- uses: JuliaRegistries/TagBot@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
registry: Foo/Bar
dispatch: true

View File

@ -39,8 +39,8 @@ end
@testset "All plugins" begin
test_all("AllPlugins"; authors=USER, plugins=[
AppVeyor(), CirrusCI(), Citation(), Codecov(), Coveralls(), Develop(),
Documenter(), DroneCI(), GitHubActions(), GitLabCI(), TravisCI(),
AppVeyor(), CirrusCI(), Citation(), Codecov(), CompatHelper(), Coveralls(),
Develop(), Documenter(), DroneCI(), GitHubActions(), GitLabCI(), TravisCI(),
])
end
@ -76,6 +76,7 @@ end
License(; name="ISC"),
ProjectFile(; version=v"1"),
Readme(; inline_badges=true),
TagBot(; registry="Foo/Bar", dispatch=true),
Tests(; project=true),
TravisCI(;
coverage=false,

View File

@ -1,4 +1,5 @@
using Base.Filesystem: contractuser, path_separator
using Base: contractuser
using Base.Filesystem: path_separator
using LibGit2: LibGit2, GitCommit, GitRemote, GitRepo
using Pkg: Pkg, PackageSpec, TOML

View File

@ -13,15 +13,6 @@ const LICENSES_DIR = joinpath(TEMPLATES_DIR, "licenses")
end
@testset "Template" begin
expected = """
Template:
authors: ["Chris de Graaf <chrisadegraaf@gmail.com>"]
dir: "~/.local/share/julia/dev"
host: "github.com"
julia: v"1.0.0"
user: "$USER"
plugins:
"""
expected = """
Template:
authors: ["$USER"]
@ -30,6 +21,9 @@ const LICENSES_DIR = joinpath(TEMPLATES_DIR, "licenses")
julia: v"1.0.0"
user: "$USER"
plugins:
CompatHelper:
file: "$(joinpath(TEMPLATES_DIR, "github", "workflows", "CompatHelper.yml"))"
destination: "CompatHelper.yml"
Git:
ignore: String[]
ssh: false
@ -46,6 +40,10 @@ const LICENSES_DIR = joinpath(TEMPLATES_DIR, "licenses")
inline_badges: false
SrcDir:
file: "$(joinpath(TEMPLATES_DIR, "src", "module.jl"))"
TagBot:
destination: "TagBot.yml"
registry: nothing
dispatch: false
Tests:
file: "$(joinpath(TEMPLATES_DIR, "test", "runtests.jl"))"
project: false