Merge pull request #138 from invenia/cdg/tb
Various updates for GitHub Actions
This commit is contained in:
commit
21617c56f0
|
@ -76,8 +76,8 @@ To understand how they're implemented, let's look at simplified versions of two
|
|||
|
||||
```julia
|
||||
@with_kw_noshow struct Documenter <: Plugin
|
||||
make_jl::String = default_file("docs", "make.jl") <- "Path to make.jl template"
|
||||
index_md::String = default_file("docs", "src", "index.md") <- "Path to index.md template"
|
||||
make_jl::String = default_file("docs", "make.jl")
|
||||
index_md::String = default_file("docs", "src", "index.md")
|
||||
end
|
||||
|
||||
gitignore(::Documenter) = ["/docs/build/"]
|
||||
|
|
|
@ -41,6 +41,7 @@ Readme
|
|||
License
|
||||
Git
|
||||
TagBot
|
||||
Secret
|
||||
```
|
||||
|
||||
### Continuous Integration (CI)
|
||||
|
|
|
@ -27,6 +27,7 @@ export
|
|||
License,
|
||||
ProjectFile,
|
||||
Readme,
|
||||
Secret,
|
||||
SrcDir,
|
||||
TagBot,
|
||||
Tests,
|
||||
|
|
|
@ -1,6 +1,22 @@
|
|||
const TEMPLATES_DIR = normpath(joinpath(@__DIR__, "..", "templates"))
|
||||
const DEFAULT_PRIORITY = 1000
|
||||
|
||||
function Base.:(==)(a::T, b::T) where T <: Plugin
|
||||
return all(n -> getfield(a, n) == getfield(b, n), fieldnames(T))
|
||||
end
|
||||
|
||||
"""
|
||||
Secret(name::AbstractString)
|
||||
|
||||
Represents a GitHub repository secret.
|
||||
When converted to a string, yields `\${{ secrets.<name> }}`.
|
||||
"""
|
||||
struct Secret
|
||||
name::String
|
||||
end
|
||||
|
||||
Base.print(io::IO, s::Secret) = print(io, "\${{ secrets.$(s.name) }}")
|
||||
|
||||
"""
|
||||
A simple plugin that, in general, creates a single file.
|
||||
"""
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
CompatHelper(;
|
||||
file="$(contractuser(default_file("github", "workflows", "CompatHelper.yml")))",
|
||||
destination="CompatHelper.yml",
|
||||
cron="0 0 * * *",
|
||||
)
|
||||
|
||||
Integrates your packages with [CompatHelper](https://github.com/bcbi/CompatHelper.jl) via GitHub Actions.
|
||||
|
@ -10,10 +11,12 @@ Integrates your packages with [CompatHelper](https://github.com/bcbi/CompatHelpe
|
|||
- `file::AbstractString`: Template file for the workflow file.
|
||||
- `destination::AbstractString`: Destination of the workflow file,
|
||||
relative to `.github/workflows`.
|
||||
- `cron::AbstractString`: Cron expression for the schedule interval.
|
||||
"""
|
||||
@with_kw_noshow struct CompatHelper <: BasicPlugin
|
||||
file::String = default_file("github", "workflows", "CompatHelper.yml")
|
||||
destination::String = "CompatHelper.yml"
|
||||
cron::String = "0 0 * * *"
|
||||
end
|
||||
|
||||
source(p::CompatHelper) = p.file
|
||||
|
@ -21,5 +24,6 @@ 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)),
|
||||
"CRON" => p.cron,
|
||||
"VERSION" => format_version(max(v"1.3", t.julia)),
|
||||
)
|
||||
|
|
|
@ -1,25 +1,81 @@
|
|||
"""
|
||||
TagBot(; destination="TagBot.yml", registry=nothing, dispatch=false)
|
||||
TagBot(;
|
||||
file="$(contractuser(default_file("github", "workflows", "TagBot.yml")))",
|
||||
destination="TagBot.yml",
|
||||
cron="0 * * * *",
|
||||
token=Secret("GITHUB_TOKEN"),
|
||||
ssh=nothing,
|
||||
ssh_password=nothing,
|
||||
changelog=nothing,
|
||||
changelog_ignore=nothing,
|
||||
gpg=nothing,
|
||||
gpg_password=nothing,
|
||||
registry=nothing,
|
||||
branches=nothing,
|
||||
dispatch=nothing,
|
||||
dispatch_delay=nothing,
|
||||
)
|
||||
|
||||
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`.
|
||||
- `file::AbstractString`: Template file for the workflow file.
|
||||
- `destination::AbstractString`: Destination of the workflow file, relative to `.github/workflows`.
|
||||
- `cron::AbstractString`: Cron expression for the schedule interval.
|
||||
- `token::Secret`: Name of the token secret to use.
|
||||
- `ssh::Secret`: Name of the SSH private key secret to use.
|
||||
- `ssh_password::Secret`: Name of the SSH key password secret to use.
|
||||
- `changelog::AbstractString`: Custom changelog template.
|
||||
- `changelog_ignore::Vector{<:AbstractString}`: Issue/pull request labels to ignore in the changelog.
|
||||
- `gpg::Secret`: Name of the GPG private key secret to use.
|
||||
- `gpg_password::Secret`: Name of the GPG private key password secret to use.
|
||||
- `registry::AbstractString`: Custom registry, in the format `owner/repo`.
|
||||
- `branches::Bool`: Whether not to enable the `branches` option.
|
||||
- `dispatch::Bool`: Whether or not to enable the `dispatch` option.
|
||||
- `dispatch_delay::Int`: Number of minutes to delay for dispatch events.
|
||||
"""
|
||||
@with_kw_noshow struct TagBot <: BasicPlugin
|
||||
file::String = default_file("github", "workflows", "TagBot.yml")
|
||||
destination::String = "TagBot.yml"
|
||||
cron::String = "0 * * * *"
|
||||
token::Secret = Secret("GITHUB_TOKEN")
|
||||
ssh::Union{Secret, Nothing} = nothing
|
||||
ssh_password::Union{Secret, Nothing} = nothing
|
||||
changelog::Union{String, Nothing} = nothing
|
||||
changelog_ignore::Union{Vector{String}, Nothing} = nothing
|
||||
gpg::Union{Secret, Nothing} = nothing
|
||||
gpg_password::Union{Secret, Nothing} = nothing
|
||||
registry::Union{String, Nothing} = nothing
|
||||
dispatch::Bool = false
|
||||
branches::Union{Bool, Nothing} = nothing
|
||||
dispatch::Union{Bool, Nothing} = nothing
|
||||
dispatch_delay::Union{Int, Nothing} = nothing
|
||||
end
|
||||
|
||||
source(::TagBot) = default_file("github", "workflows", "TagBot.yml")
|
||||
source(p::TagBot) = p.file
|
||||
destination(p::TagBot) = joinpath(".github", "workflows", p.destination)
|
||||
tags(::TagBot) = "<<", ">>"
|
||||
|
||||
view(p::TagBot, ::Template, ::AbstractString) = Dict(
|
||||
"HAS_DISPATCH" => p.dispatch,
|
||||
"REGISTRY" => p.registry,
|
||||
)
|
||||
function view(p::TagBot, ::Template, ::AbstractString)
|
||||
changelog = if p.changelog === nothing
|
||||
nothing
|
||||
else
|
||||
# This magic number aligns the text block just right.
|
||||
lines = map(line -> rstrip(repeat(' ', 12) * line), split(p.changelog, "\n"))
|
||||
"|\n" * join(lines, "\n")
|
||||
end
|
||||
ignore = p.changelog_ignore === nothing ? nothing : join(p.changelog_ignore, ", ")
|
||||
|
||||
return Dict(
|
||||
"BRANCHES" => p.branches === nothing ? nothing : string(p.branches),
|
||||
"CHANGELOG" => changelog,
|
||||
"CHANGELOG_IGNORE" => ignore,
|
||||
"CRON" => p.cron,
|
||||
"DISPATCH" => p.dispatch === nothing ? nothing : string(p.dispatch),
|
||||
"DISPATCH_DELAY" => p.dispatch_delay,
|
||||
"GPG" => p.gpg,
|
||||
"GPG_PASSWORD" => p.gpg_password,
|
||||
"REGISTRY" => p.registry,
|
||||
"SSH" => p.ssh,
|
||||
"SSH_PASSWORD" => p.ssh_password,
|
||||
"TOKEN" => p.token,
|
||||
)
|
||||
end
|
||||
|
|
|
@ -130,6 +130,15 @@ function (t::Template)(pkg::AbstractString)
|
|||
@info "New package is at $pkg_dir"
|
||||
end
|
||||
|
||||
function Base.:(==)(a::Template, b::Template)
|
||||
return a.authors == b.authors &&
|
||||
a.dir == b.dir &&
|
||||
a.host == b.host &&
|
||||
a.julia == b.julia &&
|
||||
a.user == b.user &&
|
||||
all(map(==, a.plugins, b.plugins))
|
||||
end
|
||||
|
||||
# Does the template have a plugin that satisfies some predicate?
|
||||
hasplugin(t::Template, f::Function) = any(f, t.plugins)
|
||||
hasplugin(t::Template, ::Type{T}) where T <: Plugin = hasplugin(t, p -> p isa T)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
name: CompatHelper
|
||||
on:
|
||||
schedule:
|
||||
- cron: 0 * * * *
|
||||
- cron: <<&CRON>>
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
|
|
|
@ -1,17 +1,41 @@
|
|||
name: TagBot
|
||||
on:
|
||||
schedule:
|
||||
- cron: 0 * * * *
|
||||
- cron: {{{CRON}}}
|
||||
jobs:
|
||||
TagBot:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: JuliaRegistries/TagBot@v1
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
<<#REGISTRY>>
|
||||
registry: <<®ISTRY>>
|
||||
<</REGISTRY>>
|
||||
<<#HAS_DISPATCH>>
|
||||
dispatch: true
|
||||
<</HAS_DISPATCH>>
|
||||
token: {{{TOKEN}}}
|
||||
{{#SSH}}
|
||||
ssh: {{{SSH}}}
|
||||
{{/SSH}}
|
||||
{{#SSH_PASSWORD}}
|
||||
ssh_password: {{{SSH_PASSWORD}}}
|
||||
{{/SSH_PASSWORD}}
|
||||
{{#CHANGELOG}}
|
||||
changelog: {{{CHANGELOG}}}
|
||||
{{/CHANGELOG}}
|
||||
{{#CHANGELOG_IGNORE}}
|
||||
changelog_ignore: {{{CHANGELOG_IGNORE}}}
|
||||
{{/CHANGELOG_IGNORE}}
|
||||
{{#GPG}}
|
||||
gpg: {{{GPG}}}
|
||||
{{/GPG}}
|
||||
{{#GPG_PASSWORD}}
|
||||
gpg_password: {{{GPG_PASSWORD}}}
|
||||
{{/GPG_PASSWORD}}
|
||||
{{#REGISTRY}}
|
||||
registry: {{{REGISTRY}}}
|
||||
{{/REGISTRY}}
|
||||
{{#BRANCHES}}
|
||||
branches: {{{BRANCHES}}}
|
||||
{{/BRANCHES}}
|
||||
{{#DISPATCH}}
|
||||
dispatch: {{{DISPATCH}}}
|
||||
{{/DISPATCH}}
|
||||
{{#DISPATCH_DELAY}}
|
||||
dispatch_delay: {{{DISPATCH_DELAY}}}
|
||||
{{/DISPATCH_DELAY}}
|
||||
|
|
|
@ -65,4 +65,5 @@ jobs:
|
|||
- run: julia --project=docs docs/make.jl
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }}
|
||||
<</HAS_DOCUMENTER>>
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
name: CompatHelper
|
||||
on:
|
||||
schedule:
|
||||
- cron: 0 * * * *
|
||||
- cron: 0 0 * * *
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: julia-actions/setup-julia@latest
|
||||
with:
|
||||
version: 1.2
|
||||
version: 1.3
|
||||
- name: Pkg.add("CompatHelper")
|
||||
run: julia -e 'using Pkg; Pkg.add("CompatHelper")'
|
||||
- name: CompatHelper.main()
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
name: CompatHelper
|
||||
on:
|
||||
schedule:
|
||||
- cron: 0 * * * *
|
||||
- cron: 0 0 * * *
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: julia-actions/setup-julia@latest
|
||||
with:
|
||||
version: 1.2
|
||||
version: 1.3
|
||||
- name: Pkg.add("CompatHelper")
|
||||
run: julia -e 'using Pkg; Pkg.add("CompatHelper")'
|
||||
- name: CompatHelper.main()
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
name: CompatHelper
|
||||
on:
|
||||
schedule:
|
||||
- cron: 0 * * * *
|
||||
- cron: 0 0 * * *
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: julia-actions/setup-julia@latest
|
||||
with:
|
||||
version: 1.2
|
||||
version: 1.3
|
||||
- name: Pkg.add("CompatHelper")
|
||||
run: julia -e 'using Pkg; Pkg.add("CompatHelper")'
|
||||
- name: CompatHelper.main()
|
||||
|
|
|
@ -42,3 +42,4 @@ jobs:
|
|||
- run: julia --project=docs docs/make.jl
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }}
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
name: CompatHelper
|
||||
on:
|
||||
schedule:
|
||||
- cron: 0 * * * *
|
||||
- cron: 0 0 * * *
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: julia-actions/setup-julia@latest
|
||||
with:
|
||||
version: 1.2
|
||||
version: 1.3
|
||||
- name: Pkg.add("CompatHelper")
|
||||
run: julia -e 'using Pkg; Pkg.add("CompatHelper")'
|
||||
- name: CompatHelper.main()
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
name: CompatHelper
|
||||
on:
|
||||
schedule:
|
||||
- cron: 0 * * * *
|
||||
- cron: 0 0 */3 * *
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: julia-actions/setup-julia@latest
|
||||
with:
|
||||
version: 1.2
|
||||
version: 1.3
|
||||
- name: Pkg.add("CompatHelper")
|
||||
run: julia -e 'using Pkg; Pkg.add("CompatHelper")'
|
||||
- name: CompatHelper.main()
|
||||
|
|
|
@ -1,13 +1,25 @@
|
|||
name: TagBot
|
||||
on:
|
||||
schedule:
|
||||
- cron: 0 * * * *
|
||||
- cron: 0 0 */3 * *
|
||||
jobs:
|
||||
TagBot:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: JuliaRegistries/TagBot@v1
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
token: ${{ secrets.MYTOKEN }}
|
||||
ssh: ${{ secrets.SSHKEY }}
|
||||
ssh_password: ${{ secrets.SSHPASS }}
|
||||
changelog: |
|
||||
Line 1
|
||||
Line 2
|
||||
|
||||
Line 4
|
||||
changelog_ignore: foo, bar
|
||||
gpg: ${{ secrets.GPGKEY }}
|
||||
gpg_password: ${{ secrets.GPGPASS }}
|
||||
registry: Foo/Bar
|
||||
branches: false
|
||||
dispatch: true
|
||||
dispatch_delay: 20
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
# Don't move this line from the top, please. {{X}} {{Y}} {{Z}}
|
||||
|
||||
struct BasicTest <: PT.BasicPlugin end
|
||||
struct BasicTest <: PT.BasicPlugin
|
||||
a::String
|
||||
b::Bool
|
||||
end
|
||||
|
||||
PT.gitignore(::BasicTest) = ["a", "aa", "aaa"]
|
||||
PT.source(::BasicTest) = @__FILE__
|
||||
|
@ -11,7 +14,7 @@ PT.user_view(::BasicTest, ::Template, ::AbstractString) = Dict("X" => 1, "Z" =>
|
|||
|
||||
@testset "Plugins" begin
|
||||
@testset "BasicPlugin" begin
|
||||
p = BasicTest()
|
||||
p = BasicTest("foo", true)
|
||||
t = tpl(; plugins=[p])
|
||||
|
||||
# The X from user_view should override the X from view.
|
||||
|
@ -34,4 +37,12 @@ PT.user_view(::BasicTest, ::Template, ::AbstractString) = Dict("X" => 1, "Z" =>
|
|||
@test_logs tpl(; julia=v"1.2", plugins=[p])
|
||||
@test_logs tpl(; julia=v"1.3", plugins=[p])
|
||||
end
|
||||
|
||||
@testset "Equality" begin
|
||||
a = BasicTest("foo", true)
|
||||
b = BasicTest("foo", true)
|
||||
@test a == b
|
||||
c = BasicTest("foo", false)
|
||||
@test a != c
|
||||
end
|
||||
end
|
||||
|
|
|
@ -63,6 +63,7 @@ end
|
|||
CirrusCI(; image="freebsd-123", coverage=false, extra_versions=["1.1"]),
|
||||
Citation(; readme=true),
|
||||
Codecov(; file=STATIC_FILE),
|
||||
CompatHelper(; cron="0 0 */3 * *"),
|
||||
Coveralls(; file=STATIC_FILE),
|
||||
Documenter{GitLabCI}(
|
||||
assets=[STATIC_FILE],
|
||||
|
@ -76,7 +77,20 @@ end
|
|||
License(; name="ISC"),
|
||||
ProjectFile(; version=v"1"),
|
||||
Readme(; inline_badges=true),
|
||||
TagBot(; registry="Foo/Bar", dispatch=true),
|
||||
TagBot(;
|
||||
cron="0 0 */3 * *",
|
||||
token=Secret("MYTOKEN"),
|
||||
ssh=Secret("SSHKEY"),
|
||||
ssh_password=Secret("SSHPASS"),
|
||||
changelog="Line 1\nLine 2\n\nLine 4",
|
||||
changelog_ignore=["foo", "bar"],
|
||||
gpg=Secret("GPGKEY"),
|
||||
gpg_password=Secret("GPGPASS"),
|
||||
registry="Foo/Bar",
|
||||
branches=false,
|
||||
dispatch=true,
|
||||
dispatch_delay=20,
|
||||
),
|
||||
Tests(; project=true),
|
||||
TravisCI(;
|
||||
coverage=false,
|
||||
|
|
17
test/show.jl
17
test/show.jl
|
@ -24,6 +24,7 @@ const LICENSES_DIR = joinpath(TEMPLATES_DIR, "licenses")
|
|||
CompatHelper:
|
||||
file: "$(joinpath(TEMPLATES_DIR, "github", "workflows", "CompatHelper.yml"))"
|
||||
destination: "CompatHelper.yml"
|
||||
cron: "0 0 * * *"
|
||||
Git:
|
||||
ignore: String[]
|
||||
ssh: false
|
||||
|
@ -41,9 +42,20 @@ const LICENSES_DIR = joinpath(TEMPLATES_DIR, "licenses")
|
|||
SrcDir:
|
||||
file: "$(joinpath(TEMPLATES_DIR, "src", "module.jl"))"
|
||||
TagBot:
|
||||
file: "$(joinpath(TEMPLATES_DIR, "github", "workflows", "TagBot.yml"))"
|
||||
destination: "TagBot.yml"
|
||||
cron: "0 * * * *"
|
||||
token: Secret("GITHUB_TOKEN")
|
||||
ssh: nothing
|
||||
ssh_password: nothing
|
||||
changelog: nothing
|
||||
changelog_ignore: nothing
|
||||
gpg: nothing
|
||||
gpg_password: nothing
|
||||
registry: nothing
|
||||
dispatch: false
|
||||
branches: nothing
|
||||
dispatch: nothing
|
||||
dispatch_delay: nothing
|
||||
Tests:
|
||||
file: "$(joinpath(TEMPLATES_DIR, "test", "runtests.jl"))"
|
||||
project: false
|
||||
|
@ -52,9 +64,8 @@ const LICENSES_DIR = joinpath(TEMPLATES_DIR, "licenses")
|
|||
end
|
||||
|
||||
@testset "show as serialization" begin
|
||||
# Equality is not implemented for Template, so check the string form.
|
||||
t1 = tpl()
|
||||
t2 = eval(Meta.parse(sprint(show, t1)))
|
||||
@test sprint(show, t1) == sprint(show, t2)
|
||||
@test t1 == t2
|
||||
end
|
||||
end
|
||||
|
|
|
@ -50,6 +50,14 @@
|
|||
end
|
||||
end
|
||||
|
||||
@testset "Equality" begin
|
||||
a = tpl()
|
||||
b = tpl()
|
||||
@test a == b
|
||||
c = tpl(julia=v"0.3")
|
||||
@test a != c
|
||||
end
|
||||
|
||||
@testset "hasplugin" begin
|
||||
t = tpl(; plugins=[TravisCI(), Documenter{TravisCI}()])
|
||||
@test PT.hasplugin(t, typeof(first(PT.default_plugins())))
|
||||
|
|
Loading…
Reference in New Issue