Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into pr/rikhuijzer/336
Browse files Browse the repository at this point in the history
  • Loading branch information
gdalle committed Oct 30, 2023
2 parents b95b16b + 774f9fd commit 21aaf74
Show file tree
Hide file tree
Showing 93 changed files with 822 additions and 194 deletions.
7 changes: 7 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/" # Location of package manifests
schedule:
interval: "weekly"
20 changes: 12 additions & 8 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,21 @@ jobs:
- os: windows-latest
arch: x86
include:
# Add 1.7.1 to run the reference tests
# Add specific version used to run the reference tests.
# Must be kept in sync with version check in `test/runtests.jl`,
# and with the branch protection rules on the repository which
# require this specific job to pass on all PRs
# (see Settings > Branches > Branch protection rules).
- os: ubuntu-latest
version: 1.7.1
version: 1.7.2
arch: x64
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v1
with:
version: ${{ matrix.version }}
arch: ${{ matrix.arch }}
- uses: actions/cache@v2
- uses: actions/cache@v3
env:
cache-name: cache-artifacts
with:
Expand All @@ -63,7 +67,7 @@ jobs:
git config --global user.email [email protected]
- uses: julia-actions/julia-runtest@latest
- uses: julia-actions/julia-processcoverage@v1
- uses: codecov/codecov-action@v2
- uses: codecov/codecov-action@v3
with:
files: lcov.info

Expand All @@ -73,8 +77,8 @@ jobs:
runs-on: ubuntu-latest
if: always() && github.event_name == 'schedule'
steps:
- uses: technote-space/workflow-conclusion-action@v2
- uses: voxmedia/github-action-slack-notify-build@v1
- uses: technote-space/workflow-conclusion-action@v3
- uses: voxmedia/github-action-slack-notify-build@v2
if: env.WORKFLOW_CONCLUSION == 'failure'
with:
channel: nightly-dev
Expand All @@ -87,7 +91,7 @@ jobs:
name: Documentation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v1
with:
version: '1'
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/CompatHelper.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ on:
jobs:
CompatHelper:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Pkg.add("CompatHelper")
run: julia -e 'using Pkg; Pkg.add("CompatHelper")'
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/JuliaNightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ jobs:
name: Julia Nightly - Ubuntu - x64
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v1
with:
version: nightly
arch: x64
- uses: actions/cache@v2
- uses: actions/cache@v3
env:
cache-name: julia-nightly-cache-artifacts
with:
Expand All @@ -27,6 +27,6 @@ jobs:
git config --global user.email [email protected]
- uses: julia-actions/julia-runtest@latest
- uses: julia-actions/julia-processcoverage@v1
- uses: codecov/codecov-action@v2
- uses: codecov/codecov-action@v3
with:
files: lcov.info
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
*.jl.cov
*.jl.mem
/Manifest.toml
/test/fixtures/*/test/Manifest.toml
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "PkgTemplates"
uuid = "14b8a8f1-9102-5b29-a752-f990bacb7fe1"
authors = ["Chris de Graaf", "Invenia Technical Computing Corporation"]
version = "0.7.26"
version = "0.7.45"

[deps]
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# PkgTemplates

[![Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://invenia.github.io/PkgTemplates.jl/stable)
[![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://invenia.github.io/PkgTemplates.jl/dev)
[![CI](https://github.com/invenia/PkgTemplates.jl/workflows/CI/badge.svg)](https://github.com/invenia/PkgTemplates.jl/actions?query=workflow%3ACI)
[![Codecov](https://codecov.io/gh/invenia/PkgTemplates.jl/branch/master/graph/badge.svg)](https://codecov.io/gh/invenia/PkgTemplates.jl)
[![Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://juliaci.github.io/PkgTemplates.jl/stable)
[![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://juliaci.github.io/PkgTemplates.jl/dev)
[![CI](https://github.com/JuliaCI/PkgTemplates.jl/workflows/CI/badge.svg)](https://github.com/JuliaCI/PkgTemplates.jl/actions?query=workflow%3ACI)
[![Codecov](https://codecov.io/gh/JuliaCI/PkgTemplates.jl/branch/master/graph/badge.svg?token=WsGRSymBmZ)](https://codecov.io/gh/JuliaCI/PkgTemplates.jl)
[![Code Style: Blue](https://img.shields.io/badge/code%20style-blue-4495d1.svg)](https://github.com/invenia/BlueStyle)
[![ColPrac: Contributor Guide on Collaborative Practices for Community Packages](https://img.shields.io/badge/ColPrac-Contributor%20Guide-blueviolet)](https://github.com/SciML/ColPrac)

Expand Down Expand Up @@ -69,10 +69,10 @@ tpl = Template(;

---

For a much more detailed overview, please see [the User Guide documentation](https://invenia.github.io/PkgTemplates.jl/stable/user/).
For a much more detailed overview, please see [the User Guide documentation](https://juliaci.github.io/PkgTemplates.jl/stable/user/).

## Contributing

Issues and pull requests are welcome!
New contributors should make sure to read the [ColPrac Contributor Guide](https://github.com/SciML/ColPrac).
For some more PkgTemplates-specific tips, see the [Developer Guide documentation](https://invenia.github.io/PkgTemplates.jl/stable/developer/).
For some more PkgTemplates-specific tips, see the [Developer Guide documentation](https://juliaci.github.io/PkgTemplates.jl/stable/developer/).
6 changes: 3 additions & 3 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ using PkgTemplates: PkgTemplates
makedocs(;
modules=[PkgTemplates],
authors="Chris de Graaf, Invenia Technical Computing Corporation",
repo="https://github.com/invenia/PkgTemplates.jl/blob/{commit}{path}#{line}",
repo="https://github.com/JuliaCI/PkgTemplates.jl/blob/{commit}{path}#{line}",
sitename="PkgTemplates.jl",
format=Documenter.HTML(;
prettyurls=get(ENV, "CI", "false") == "true",
canonical="https://invenia.github.io/PkgTemplates.jl",
canonical="https://juliaci.github.io/PkgTemplates.jl",
assets=String[],
),
pages=[
Expand All @@ -20,5 +20,5 @@ makedocs(;
)

deploydocs(;
repo="github.com/invenia/PkgTemplates.jl",
repo="github.com/JuliaCI/PkgTemplates.jl",
)
24 changes: 18 additions & 6 deletions docs/src/developer.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Pages = ["developer.md"]
Issues and pull requests are welcome!
New contributors should make sure to read the [ColPrac Contributor Guide](https://github.com/SciML/ColPrac).

[PkgTemplates](https://github.com/invenia/PkgTemplates.jl/) can be easily extended by adding new [`Plugin`](@ref)s.
[PkgTemplates](https://github.com/JuliaCI/PkgTemplates.jl/) can be easily extended by adding new [`Plugin`](@ref)s.

There are three types of plugins: [`Plugin`](@ref), [`FilePlugin`](@ref), and [`BadgePlugin`](@ref).

Expand Down Expand Up @@ -107,12 +107,12 @@ view(p::Documenter, t::Template, pkg::AbstractString) = Dict(
)

function hook(p::Documenter, t::Template, pkg_dir::AbstractString)
pkg = basename(pkg_dir)
pkg = pkg_name(pkg_dir)
docs_dir = joinpath(pkg_dir, "docs")

make = render_file(p.make_jl, combined_view(p, t, pkg), tags(p))
gen_file(joinpath(docs_dir, "make.jl"), make)

index = render_file(p.index_md, combined_view(p, t, pkg), tags(p))
gen_file(joinpath(docs_dir, "src", "index.md"), index)

Expand Down Expand Up @@ -186,7 +186,7 @@ end
function prehook(::Git, t::Template, pkg_dir::AbstractString)
LibGit2.with(LibGit2.init(pkg_dir)) do repo
LibGit2.commit(repo, "Initial commit")
pkg = basename(pkg_dir)
pkg = pkg_name(pkg_dir)
url = "https://$(t.host)/$(t.user)/$pkg.jl"
close(GitRemote(repo, "origin", url))
end
Expand Down Expand Up @@ -287,7 +287,7 @@ end

function hook(p::FilePlugin, t::Template, pkg_dir::AbstractString)
source(p) === nothing && return
pkg = basename(pkg_dir)
pkg = pkg_name(pkg_dir)
path = joinpath(pkg_dir, destination(p))
text = render_plugin(p, t, pkg)
gen_file(path, text)
Expand Down Expand Up @@ -375,7 +375,7 @@ Here are some testing tips to ensure that your PR goes through as smoothly as po
### Updating Reference Tests & Fixtures

If you've added or modified plugins, you should update the reference tests and the associated test fixtures.
In `test/reference.jl`, you'll find a "Reference tests" test set that basically generates a bunch of packages, and then checks each file against a reference file, which is stored somewhere in `test/fixtures`.
In `test/reference.jl`, you'll find a "Reference tests" test set that basically generates a bunch of packages, and then checks each file against a reference file, which is stored somewhere in `test/fixtures`.
Note the reference tests only run on one specific version of Julia; check `test/runtests.jl` to see the current version used.

For new plugins, you should add an instance of your plugin to the "All plugins" and "Wacky options" test sets, then run the tests with `Pkg.test`.
Expand All @@ -385,6 +385,18 @@ Check them to make sure that they contain exactly what you would expect!
For changes to existing plugins, update the plugin options appropriately in the "Wacky options" test set.
Failing tests will give you the option to review and accept changes to the fixtures, updating the files automatically for you.

### Running reference tests locally

In the file `test/runtests.jl`, there is a variable called `REFERENCE_JULIA_VERSION`, currently set to `v"1.7.2"`.
If you use any other Julia version (even the latest stable one) to launch the test suite, the reference tests mentioned above will not run, and you will miss a crucial correctness check for your code.
Therefore, we strongly suggest you test PkgTemplates locally against Julia 1.7.2.
This version can be easily installed and started with [juliaup](https://github.com/JuliaLang/juliaup):

```bash
juliaup add 1.7.2
julia +1.7.2
```

### Updating "Show" Tests

Depending on what you've changed, the tests in `test/show.jl` might fail.
Expand Down
2 changes: 1 addition & 1 deletion docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ CurrentModule = PkgTemplates

# PkgTemplates

**[PkgTemplates](https://github.com/invenia/PkgTemplates.jl/) creates new Julia packages in an easy, repeatable, and customizable way.**
**[PkgTemplates](https://github.com/JuliaCI/PkgTemplates.jl/) creates new Julia packages in an easy, repeatable, and customizable way.**

## Documentation

Expand Down
4 changes: 2 additions & 2 deletions docs/src/migrating.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ Although it's unlikely that anyone used these.

| Old | New |
| :------------------: | :--------------------------------------------------------------------------------------------------: |
| `available_licenses` | [View licenses on GitHub](https://github.com/invenia/PkgTemplates.jl/tree/master/templates/licenses) |
| `show_license` | [View licenses on GitHub](https://github.com/invenia/PkgTemplates.jl/tree/master/templates/licenses) |
| `available_licenses` | [View licenses on GitHub](https://github.com/JuliaCI/PkgTemplates.jl/tree/master/templates/licenses) |
| `show_license` | [View licenses on GitHub](https://github.com/JuliaCI/PkgTemplates.jl/tree/master/templates/licenses) |

## Custom Plugins

Expand Down
11 changes: 6 additions & 5 deletions docs/src/user.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ CurrentModule = PkgTemplates
Pages = ["user.md"]
```

Using [PkgTemplates](https://github.com/invenia/PkgTemplates.jl/) is straightforward.
Using [PkgTemplates](https://github.com/JuliaCI/PkgTemplates.jl/) is straightforward.
Just create a [`Template`](@ref), and call it on a package name to generate that package:

```julia
Expand Down Expand Up @@ -41,6 +41,7 @@ Tests
Readme
License
Git
GitHubActions
CompatHelper
TagBot
Secret
Expand All @@ -54,7 +55,6 @@ These plugins will create the configuration files of common CI services for you.
AppVeyor
CirrusCI
DroneCI
GitHubActions
GitLabCI
TravisCI
```
Expand Down Expand Up @@ -85,6 +85,7 @@ PkgEvalBadge
### Miscellaneous

```@docs
Dependabot
Develop
Citation
RegisterAction
Expand All @@ -97,7 +98,7 @@ Here are a few example templates that use the options and plugins explained abov
This one includes plugins suitable for a project hosted on GitHub, and some other customizations:

```julia
Template(;
Template(;
user="my-username",
dir="~/code",
authors="Acme Corp",
Expand Down Expand Up @@ -130,7 +131,7 @@ Template(;

!!! note "Templates vs Templating"
This documentation refers plenty to [`Template`](@ref)s, the package's main type, but it also refers to "template files" and "text templating", which are plaintext files with placeholders to be filled with data, and the technique of filling those placeholders with data, respectively.

These concepts should be familiar if you've used [Jinja](https://palletsprojects.com/p/jinja) or [Mustache](https://mustache.github.io) (Mustache is the particular flavour used by PkgTemplates, via [Mustache.jl](https://github.com/jverzani/Mustache.jl)).
Please keep the difference between these two things in mind!

Expand All @@ -144,7 +145,7 @@ Here's an example template file:
Hello, {{{name}}}.
{{#weather}}
It's {{{weather}}} outside.
It's {{{weather}}} outside.
{{/weather}}
{{^weather}}
I don't know what the weather outside is.
Expand Down
3 changes: 3 additions & 0 deletions src/PkgTemplates.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,15 @@ export
CirrusCI,
Citation,
Codecov,
CodeOwners,
ColPracBadge,
CompatHelper,
Coveralls,
Dependabot,
Develop,
Documenter,
DroneCI,
Formatter,
Git,
GitHubActions,
GitLabCI,
Expand Down
28 changes: 23 additions & 5 deletions src/interactive.jl
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,14 @@ end
Provide some extra tips to users on how to structure their input for the type `T`,
for example if multiple delimited values are expected.
"""
input_tips(::Type{Vector{T}}) where T = ["comma-delimited", input_tips(T)...]
input_tips(::Type{Nothing}) = String[]
input_tips(::Type{Union{T, Nothing}}) where T = ["'nothing' for nothing", input_tips(T)...]
input_tips(::Type{Vector{T}}) where T = [input_tips(T)..., "comma-delimited"]
input_tips(::Type{Union{T, Nothing}}) where T = [input_tips(T)..., input_tips(Nothing)...]
input_tips(::Type{Nothing}) = ["'nothing' for nothing"]
input_tips(::Type{Secret}) = ["name only"]
input_tips(::Type) = String[]
# Show expected input type as a tip if it's anything other than `String`
input_tips(::Type{T}) where T = String[string(T)]
input_tips(::Type{String}) = String[]
input_tips(::Type{<:Signed}) = ["Int"] # Specific Int type likely not important

"""
convert_input(::Type{P}, ::Type{T}, s::AbstractString) -> T
Expand All @@ -92,6 +95,16 @@ function convert_input(P::Type, ::Type{Union{T, Nothing}}, s::AbstractString) wh
return s == "nothing" ? nothing : convert_input(P, T, s)
end

function convert_input(P::Type, ::Type{Union{T, Symbol, Nothing}}, s::AbstractString) where T
# Assume inputs starting with ':' char are intended as Symbols, if a plugin accept symbols.
# i.e. assume the set of valid Symbols the plugin expects can be spelt starting with ':'.
return if startswith(s, ":")
Symbol(chop(s, head=1, tail=0)) # remove ':'
else
convert_input(P, Union{T,Nothing}, s)
end
end

function convert_input(::Type, ::Type{Bool}, s::AbstractString)
s = lowercase(s)
return if startswith(s, 't') || startswith(s, 'y')
Expand All @@ -109,6 +122,11 @@ function convert_input(P::Type, T::Type{<:Vector}, s::AbstractString)
return map(x -> convert_input(P, eltype(T), x), xs)
end

# how would the user type `x` in interactive mode?
input_string(x) = string(x)
input_string(x::AbstractString) = isempty(x) ? repr(x) : String(x)
input_string(x::Symbol) = repr(x)

"""
prompt(::Type{P}, ::Type{T}, ::Val{name::Symbol}) -> Any
Expand All @@ -119,8 +137,8 @@ prompt(P::Type, T::Type, name::Symbol) = prompt(P, T, Val(name))

# The trailing `nothing` is a hack for `fallback_prompt` to use, ignore it.
function prompt(P::Type, ::Type{T}, ::Val{name}, ::Nothing=nothing) where {T, name}
tips = join([T; input_tips(T); "default=$(repr(defaultkw(P, name)))"], ", ")
default = defaultkw(P, name)
tips = join([input_tips(T); "default: $(input_string(default))"], ", ")
input = Base.prompt(pretty_message("Enter value for '$name' ($tips)"))
input === nothing && throw(InterruptException())
input = strip(input, '"')
Expand Down
Loading

0 comments on commit 21aaf74

Please sign in to comment.