Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement a new strategy "Recommended and ask extras" #502

Merged
merged 1 commit into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ BREAKING NOTICE:

- The link-checker now uses lychee version 2, which might lead to failures. See <https://github.com/JuliaBesties/BestieTemplate.jl/pull/495> for the release notes.

### Added

- Create a new strategy to allow users to install all recommended and get asked additional questions.

### Changed

- Update action version
Expand Down
6 changes: 3 additions & 3 deletions copier/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ AddWinToCI:
Defaults to yes for the recommended strategy, or no otherwise.

RunJuliaNightlyOnCI:
when: "{{ AnswerStrategy == 'ask' }}"
when: "{{ AnswerStrategy == 'ask' or AnswerStrategy == 'recommended-ask' }}"
type: bool
help: Julia nightly CI test (Package tests run on Julia version {{ JuliaMinVersion }} and on the latest stable release. Do you also want to run them on the nightly version?)
default: false
Expand All @@ -36,7 +36,7 @@ RunJuliaNightlyOnCI:
Defaults to no.

UseCirrusCI:
when: "{{ AnswerStrategy == 'ask' }}"
when: "{{ AnswerStrategy == 'ask' or AnswerStrategy == 'recommended-ask' }}"
type: bool
help: FreeBSD CI test with CirrusCI (Add CirrusCI to run the package tests on FreeBSD?)
default: false
Expand All @@ -45,7 +45,7 @@ UseCirrusCI:
Defaults to no.

AddCopierCI:
when: "{{ AnswerStrategy == 'ask' }}"
when: "{{ AnswerStrategy == 'ask' or AnswerStrategy == 'recommended-ask' }}"
type: bool
help: Copier.yml (Add workflow to check for template updates? This is a work in progress workflow that checks whether there has been an update to the template and automatically create a pull request)
default: false
Expand Down
4 changes: 2 additions & 2 deletions copier/code-quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ JuliaIndentation:
For existing packages, this will be inferred from the indent value in the `.JuliaFormatter.toml` file.

MarkdownIndentation:
when: "{{ AnswerStrategy == 'ask' }}"
when: "{{ AnswerStrategy != 'minimum' }}"
type: int
help: Indentation length for Markdown files (Used in .markdownlint.json and .editorconfig)
validator: "{% if MarkdownIndentation <= 0 %}Indentation must be positive{% endif %}"
Expand All @@ -56,7 +56,7 @@ MarkdownIndentation:
For existing packages, this will be inferred from the indent value in the `.JuliaFormatter.toml` file.

ConfigIndentation:
when: "{{ AnswerStrategy == 'ask' }}"
when: "{{ AnswerStrategy != 'minimum' }}"
type: int
help: Indentation length for configuration files (Used to format YAML and JSON files)
validator: "{% if ConfigIndentation <= 0 %}Indentation must be positive{% endif %}"
Expand Down
12 changes: 7 additions & 5 deletions copier/strategy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ AnswerStrategy:
default: recommended
help: "Strategy for optional questions (You can see the full list of questions in https://JuliaBesties.github.io/BestieTemplate.jl/dev/30-questions/)"
choices:
Recommended (Our defaults): "recommended"
Recommended only: "recommended"
Recommended and ask other options: "recommended-ask"
Minimum (Answer no to any addition): "minimum"
Ask me (Ask all questions): "ask"
description: |
This defines how to deal with the rest of the questions.
The `minimum` strategy answers "no" to every question. This is not the same as a bare-bones package. The resulting package will have the minimum amount of best practices that we recommend.
The `recommended` strategy uses all our recommended best practices, which might be overwhelming for anyone. See the answers below this step to see all the options. This is not the same as saying "yes" to everything.
The `ask` strategy does not select anything from the list below. All questions will be asked.
Notice that some options are only available through the `ask` strategy, or by explicitly passing them to the Bestie command.
The "minimum" strategy answers "no" to every question. This is not the same as a bare-bones package. The resulting package will have the minimum amount of best practices that we recommend.
Both "recommended" strategies use all our recommended best practices. You then have the option to ignore or ask the optional questions. The optional questions include features that are being tested or that are too specific to be recommended.
The "recommended" strategy might be overwhelming for most people. See the answers below this step to see all the options. This is not the same as saying "yes" to everything.
The "ask" strategy does not select anything from the list below. All questions will be asked.
Notice that some options are only available through the "ask" or "recommended and ask" strategies, or by explicitly passing them to the Bestie command.
Defaults to the "recommended" strategy.
2 changes: 1 addition & 1 deletion docs/src/10-full-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ If you decide to gradually adopt, do this:

1. Follow the relevant application section for [New](@ref new_package) or [Existing](@ref existing_package).
1. Remember to select the "Minimum" optional questions.
1. Follow the [Update section](@ref updating_package), change your answer from "Minimum" to "Recommended" or "Ask me".
1. Follow the [Update section](@ref updating_package), change your answer from "Minimum" to one of the others.

### Things to install

Expand Down
8 changes: 5 additions & 3 deletions docs/src/20-explanation.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,12 @@ Furthermore, they can keep reaping benefits when we create new versions of the t

Let's dive into the details of the template now.

### Recommended vs Minimum vs Others (hidden)
### Recommended vs Minimum

The template contains a few required questions and then asks you whether you would like to use

- The "recommended" options, which include our current recommendation for best practices;
- The "recommended only" options, which include our current recommendation for best practices;
- The "recommended and ask extra" options, which include our current recommendation for best practices and you get asked extra questions;
- The "minimum" options, which answers "no" to everything, but still leaves you with a decent package to start; or
- The option to answer every optional question individually.

Expand Down Expand Up @@ -102,11 +103,12 @@ Our **loose** criteria to make something part of the recommended, but not minimu
- It creates friction - which is good to ensure quality but slows developement (e.g., issue templates).

Finally, there are **other optional features**.
These are neither recommended nor part of the minimum template, which means that unless you (know and) set them explicitly, you are not using them.
These are neither recommended nor part of the minimum template, which means that you need to use one of the strategies that ask extra questions ("Recommended ans ask extra" or "Ask") or set them explicitly.

The **loose** criteria to make something not recommended, nor minimum, is:

- It is a best practice, but for a niche audience (e.g., `.cirrus.yml` for testing on FreeBSD);
- It is potentially disruptive (e.g., testing on Nightly)

To see all the questions, head to [Questions](@ref).

Expand Down
3 changes: 2 additions & 1 deletion docs/src/91-developer.md
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,8 @@ Find an appropriate place to add the question. Comments help identify the option
Follow the other questions style and syntax. The gist of it is that you need:

- A `CamelCase` name.
- `when: "{{ AnswerStrategy == 'ask' }}"` if the question is optional.
- `when: "{{ AnswerStrategy == 'ask' }}"` if the question is optional but should be automatically selected for "Recommended only".
- `when: "{{ AnswerStrategy == 'ask' or AnswerStrategy == 'recommended-ask' }}"` if the question is extra.
- A `type`.
- A `help: Short description or title (Longer description and details)`.
- A `default`, if the question is optional.
Expand Down
3 changes: 2 additions & 1 deletion src/api.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ function _copy(src_path, dst_path, data; kwargs...)
First, some **required** questions will need to be filled.
Then, you will have the option of selecting

- The _recommended_ options, which includes our current _best practices recommendations_;
- The _recommended only_ options, which includes our current _best practices recommendations_;
- The _recommended and possible extras_ options, which is the same as _recommended but asks additional questions that are not in recommended;
- The _minimum_ options, which will answer _no_ to everything, but still give you what
we consider the minimum best practices you need to get started; or
- Answer every optional question.
Expand Down
11 changes: 7 additions & 4 deletions src/debug/Data.jl
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,12 @@ const strategy_minimum = merge(
),
)

const strategy_recommended = merge(strategy_minimum, Dict("AnswerStrategy" => "recommended"))
const strategy_recommended_only = merge(strategy_minimum, Dict("AnswerStrategy" => "recommended"))

const strategy_ask = merge(strategy_recommended, Dict("AnswerStrategy" => "ask"))
const strategy_recommended_ask =
merge(strategy_minimum, Dict("AnswerStrategy" => "recommended-ask"))

const strategy_ask = merge(strategy_minimum, Dict("AnswerStrategy" => "ask"))

const optional_questions_with_default = Dict(
"AddPrecommit" => true,
Expand All @@ -61,9 +64,9 @@ const optional_questions_with_default = Dict(
const strategy_ask_default = merge(strategy_ask, optional_questions_with_default)

const strategy_ask_and_say_no =
merge(strategy_recommended, Dict(k => false for k in keys(optional_questions_with_default)))
merge(strategy_recommended_only, Dict(k => false for k in keys(optional_questions_with_default)))

const strategy_ask_and_say_yes =
merge(strategy_recommended, Dict(k => true for k in keys(optional_questions_with_default)))
merge(strategy_recommended_only, Dict(k => true for k in keys(optional_questions_with_default)))

end
6 changes: 4 additions & 2 deletions src/debug/helper.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@ function dbg_data(data_choice, _data = Dict())
Data.minimum_defaults
elseif data_choice in [:minimum, :min]
Data.strategy_minimum
elseif data_choice in [:recommended, :rec]
Data.strategy_recommended
elseif data_choice in [:recommended, (:recommended_only):rec, :rec_only]
Data.strategy_recommended_only
elseif data_choice in [:recommended_ask, :rec_ask]
Data.strategy_recommended_ask
elseif data_choice in [:ask]
Data.strategy_ask
elseif data_choice in [:ask_default]
Expand Down