From 1f653ec04b441cf8c983c7ac0e8d9b4f9d3d2ea4 Mon Sep 17 00:00:00 2001 From: Chris de Graaf Date: Sun, 10 Nov 2019 11:54:08 +0700 Subject: [PATCH] Add a CompatHelper plugin TODO: Handle the Manifest.toml updating stuff. --- docs/src/user.md | 1 + src/PkgTemplates.jl | 4 +-- src/plugin.jl | 1 + src/plugins/ci.jl | 2 -- src/plugins/compat_helper.jl | 25 +++++++++++++++++++ templates/github/workflows/CompatHelper.yml | 17 +++++++++++++ .../.github/workflows/CompatHelper.yml | 17 +++++++++++++ test/reference.jl | 4 +-- test/runtests.jl | 3 ++- 9 files changed, 67 insertions(+), 7 deletions(-) create mode 100644 src/plugins/compat_helper.jl create mode 100644 templates/github/workflows/CompatHelper.yml create mode 100644 test/fixtures/AllPlugins/.github/workflows/CompatHelper.yml diff --git a/docs/src/user.md b/docs/src/user.md index be25765..ddb0a7e 100644 --- a/docs/src/user.md +++ b/docs/src/user.md @@ -75,6 +75,7 @@ Documenter ```@docs Develop +CompatHelper Citation ``` diff --git a/src/PkgTemplates.jl b/src/PkgTemplates.jl index 673a6dc..5b0528d 100644 --- a/src/PkgTemplates.jl +++ b/src/PkgTemplates.jl @@ -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, diff --git a/src/plugin.jl b/src/plugin.jl index f620839..1d412a5 100644 --- a/src/plugin.jl +++ b/src/plugin.jl @@ -261,5 +261,6 @@ 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")) diff --git a/src/plugins/ci.jl b/src/plugins/ci.jl index 3bbf4fb..b203b48 100644 --- a/src/plugins/ci.jl +++ b/src/plugins/ci.jl @@ -61,7 +61,6 @@ end source(p::GitHubActions) = p.file destination(p::GitHubActions) = joinpath(".github", "workflows", p.destination) - tags(::GitHubActions) = "<<", ">>" badges(p::GitHubActions) = Badge( @@ -305,7 +304,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" diff --git a/src/plugins/compat_helper.jl b/src/plugins/compat_helper.jl new file mode 100644 index 0000000..43dc85e --- /dev/null +++ b/src/plugins/compat_helper.jl @@ -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 worflow 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) = "<<", ">>" + +function view(p::CompatHelper, t::Template, ::AbstractString) + return Dict("VERSION" => format_version(max(v"1.2", t.julia))) +end diff --git a/templates/github/workflows/CompatHelper.yml b/templates/github/workflows/CompatHelper.yml new file mode 100644 index 0000000..7a5cf86 --- /dev/null +++ b/templates/github/workflows/CompatHelper.yml @@ -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 }} diff --git a/test/fixtures/AllPlugins/.github/workflows/CompatHelper.yml b/test/fixtures/AllPlugins/.github/workflows/CompatHelper.yml new file mode 100644 index 0000000..e78623d --- /dev/null +++ b/test/fixtures/AllPlugins/.github/workflows/CompatHelper.yml @@ -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 }} diff --git a/test/reference.jl b/test/reference.jl index 3083d6f..34f8040 100644 --- a/test/reference.jl +++ b/test/reference.jl @@ -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 diff --git a/test/runtests.jl b/test/runtests.jl index b4835d4..30cf2b2 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -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