diff --git a/copier.yml b/copier.yml index be6aa756..2b5975f9 100644 --- a/copier.yml +++ b/copier.yml @@ -1,3 +1,4 @@ +# Essential questions PackageName: type: str help: Package name without '.jl' @@ -36,22 +37,18 @@ License: - MPL-2.0 default: MIT +# Optional AskAdvancedQuestions: type: bool help: Ask further questions? You can stop now with the minimum and use the default values for code of conduct, indentation, and package tests. default: false -AddAllcontributors: - when: "{{ AskAdvancedQuestions }}" - type: bool - default: true - help: Add allcontributors to the package? - -AddCodeOfConduct: +# Formatting and Linting +AddPrecommit: when: "{{ AskAdvancedQuestions }}" type: bool default: true - help: Add a CODE_OF_CONDUCT.md file from Contributor Covenant? {{ AuthorEmail }} will be listed as contact point. + help: Add pre-commit config? (pre-commit runs before every commit fixing your formatting and preventing bad practices) Indentation: when: "{{ AskAdvancedQuestions }}" @@ -60,6 +57,13 @@ Indentation: validator: "{% if Indentation <= 0 %}Indentation must be positive{% endif %}" default: 2 +# CI +SimplifiedPRTest: + when: "{{ AskAdvancedQuestions }}" + type: bool + help: (Simplified PR Test) Do you want to limit the Pull Request test to a single configuration (ubuntu + latest stable Julia)? This will make the PR tests run faster, but might miss OS-specific or LTS specific errors. + default: true + AddMacToCI: when: "{{ AskAdvancedQuestions }}" type: bool @@ -75,16 +79,23 @@ RunJuliaNightlyOnCI: type: bool help: Package tests run on Julia version {{ JuliaMinVersion }} and on the latest stable release. Do you also want to run them on the nightly version? -SimplifiedPRTest: +UseCirrusCI: + when: "{{ AskAdvancedQuestions }}" + type: bool + help: Add CirrusCI to run the package tests on FreeBSD? + +# General +AddAllcontributors: when: "{{ AskAdvancedQuestions }}" type: bool - help: (Simplified PR Test) Do you want to limit the Pull Request test to a single configuration (ubuntu + latest stable Julia)? This will make the PR tests run faster, but might miss OS-specific or LTS specific errors. default: true + help: Add allcontributors to the package? -UseCirrusCI: +AddCodeOfConduct: when: "{{ AskAdvancedQuestions }}" type: bool - help: Add CirrusCI to run the package tests on FreeBSD? + default: true + help: Add a CODE_OF_CONDUCT.md file from Contributor Covenant? {{ AuthorEmail }} will be listed as contact point. _skip_if_exists: - "**/*.jl" diff --git a/template/.github/workflows/Copier.yml.jinja b/template/.github/workflows/{% if AddPrecommit %}Copier.yml{% endif %}.jinja similarity index 79% rename from template/.github/workflows/Copier.yml.jinja rename to template/.github/workflows/{% if AddPrecommit %}Copier.yml{% endif %}.jinja index 19096193..20df8399 100644 --- a/template/.github/workflows/Copier.yml.jinja +++ b/template/.github/workflows/{% if AddPrecommit %}Copier.yml{% endif %}.jinja @@ -1,4 +1,4 @@ -{% raw %}name: Copier Update +name: Copier Update on: schedule: @@ -11,7 +11,7 @@ jobs: steps: - uses: actions/checkout@v4 with: - token: ${{ secrets.COPIER_PAT }} + token: {% raw %}${{ secrets.COPIER_PAT }}{% endraw %} - uses: julia-actions/setup-julia@v2 with: version: "1" @@ -33,15 +33,17 @@ jobs: find . -name "*.rej" | xargs rm -f echo -e '```' >> /tmp/body.md git diff + {% if AddPrecommit %} - name: Run pre-commit to run the formatters run: | pip install pre-commit pre-commit run -a || true # Ignore pre-commit errors + {% endif %} - name: Create Pull Request id: cpr uses: peter-evans/create-pull-request@v6 with: - token: ${{ secrets.COPIER_PAT }} + token: {% raw %}${{ secrets.COPIER_PAT }}{% endraw %} commit-message: ":robot: COPIERTemplate.jl update" title: "[AUTO] COPIERTemplate.jl update" body-path: /tmp/body.md @@ -50,5 +52,5 @@ jobs: labels: configuration, automated pr, no changelog - name: Check outputs run: | - echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}" - echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}"{% endraw %} + {% raw %}echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}"{% endraw %} + {% raw %}echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}"{% endraw %} diff --git a/template/.github/workflows/Lint.yml b/template/.github/workflows/{% if AddPrecommit %}Lint.yml{% endif %}.jinja similarity index 79% rename from template/.github/workflows/Lint.yml rename to template/.github/workflows/{% if AddPrecommit %}Lint.yml{% endif %}.jinja index 595e4104..0da6eccf 100644 --- a/template/.github/workflows/Lint.yml +++ b/template/.github/workflows/{% if AddPrecommit %}Lint.yml{% endif %}.jinja @@ -10,10 +10,11 @@ on: concurrency: # Skip intermediate builds: always. # Cancel intermediate builds: only if it is a pull request build. - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }} + group: {% raw %}${{ github.workflow }}-${{ github.ref }}{% endraw %} + cancel-in-progress: {% raw %}${{ startsWith(github.ref, 'refs/pull/') }}{% endraw %} jobs: + {% if AddPrecommit %} lint: name: Linting runs-on: ubuntu-latest @@ -36,11 +37,12 @@ jobs: uses: actions/cache@v4 with: path: ~/.cache/pre-commit - key: ${{ runner.os }}-pre-commit-${{ hashFiles('**/.pre-commit-config.yaml') }} + key: {% raw %}${{ runner.os }}-pre-commit-${{ hashFiles('**/.pre-commit-config.yaml') }}{% endraw %} - name: Install pre-commit run: pip install pre-commit - name: Run pre-commit run: SKIP=no-commit-to-branch pre-commit run -a + {% endif %} link-checker: name: Link checker runs-on: ubuntu-latest diff --git a/template/.github/workflows/PreCommitUpdate.yml b/template/.github/workflows/{% if AddPrecommit %}PreCommitUpdate.yml{% endif %}.jinja similarity index 80% rename from template/.github/workflows/PreCommitUpdate.yml rename to template/.github/workflows/{% if AddPrecommit %}PreCommitUpdate.yml{% endif %}.jinja index d2d4723c..2c6d1ff9 100644 --- a/template/.github/workflows/PreCommitUpdate.yml +++ b/template/.github/workflows/{% if AddPrecommit %}PreCommitUpdate.yml{% endif %}.jinja @@ -31,5 +31,5 @@ jobs: labels: chore - name: Check outputs run: | - echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}" - echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}" + {% raw %}echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}"{% endraw %} + {% raw %}echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}"{% endraw %} diff --git a/template/docs/src/90-developer.md.jinja b/template/docs/src/90-developer.md.jinja index bffe7945..499f37f5 100644 --- a/template/docs/src/90-developer.md.jinja +++ b/template/docs/src/90-developer.md.jinja @@ -28,6 +28,7 @@ You will create branches and push to `origin`, and you will fetch and update you Install a plugin on your editor to use [EditorConfig](https://editorconfig.org). This will ensure that your editor is configured with important formatting settings. +{% if AddPrecommit %} We use [https://pre-commit.com](https://pre-commit.com) to run the linters and formatters. In particular, the Julia code is formatted using [JuliaFormatter.jl](https://github.com/domluna/JuliaFormatter.jl), so please install it globally first: @@ -57,6 +58,7 @@ pre-commit run -a ``` **Now, you can only commit if all the pre-commit tests pass**. +{% endif %} ## Testing @@ -114,7 +116,7 @@ We try to keep a linear history in this repo, so it is important to keep your br Try to create "atomic git commits" (recommended reading: [The Utopic Git History](https://blog.esciencecenter.nl/the-utopic-git-history-d44b81c09593)). - Make sure the tests pass. -- Make sure the pre-commit tests pass. +{% if AddPrecommit %}- Make sure the pre-commit tests pass.{% endif %} - Fetch any `main` updates from upstream and rebase your branch, if necessary: ```bash diff --git a/template/.markdownlint.json.jinja b/template/{% if AddPrecommit %}.markdownlint.json{% endif %}.jinja similarity index 100% rename from template/.markdownlint.json.jinja rename to template/{% if AddPrecommit %}.markdownlint.json{% endif %}.jinja diff --git a/template/.pre-commit-config.yaml.jinja b/template/{% if AddPrecommit %}.pre-commit-config.yaml{% endif %}.jinja similarity index 100% rename from template/.pre-commit-config.yaml.jinja rename to template/{% if AddPrecommit %}.pre-commit-config.yaml{% endif %}.jinja diff --git a/template/.yamllint.yml.jinja b/template/{% if AddPrecommit %}.yamllint.yml{% endif %}.jinja similarity index 100% rename from template/.yamllint.yml.jinja rename to template/{% if AddPrecommit %}.yamllint.yml{% endif %}.jinja diff --git a/test/runtests.jl b/test/runtests.jl index f12d5473..7cd66946 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -44,6 +44,7 @@ template_options = Dict( "RunJuliaNightlyOnCI" => true, "SimplifiedPRTest" => true, "UseCirrusCI" => true, + "AddPrecommit" => true, ) function test_diff_dir(dir1, dir2)