From d842352a388cfb024013ac8330c3294068587588 Mon Sep 17 00:00:00 2001 From: "Faruk D." Date: Mon, 26 Aug 2024 21:04:24 +0200 Subject: [PATCH 1/4] add linting next step as a question --- copier/questions/features.yml | 5 +++++ ...{% if AddLinting %}next_steps_linting.yml{% endif %}} | 9 +++++---- ...nting %}next_steps_linting_issue.md{% endif %}.jinja} | 0 3 files changed, 10 insertions(+), 4 deletions(-) rename template/.github/workflows/{next_steps.yml => {% if AddLinting %}next_steps_linting.yml{% endif %}} (74%) rename template/.github/{next_steps/05_linting.md.jinja => workflows/{% if AddLinting %}next_steps_linting_issue.md{% endif %}.jinja} (100%) diff --git a/copier/questions/features.yml b/copier/questions/features.yml index c5c6e185..7e218894 100644 --- a/copier/questions/features.yml +++ b/copier/questions/features.yml @@ -60,3 +60,8 @@ AddDevDoc: type: bool default: "{{ template_profile != 'minimum' }}" help: Add developer documentation? +AddLinting: + when: "{{ template_profile == 'ask' }}" + type: bool + default: "{{ template_profile != 'minimum' }}" + help: Add linting? diff --git a/template/.github/workflows/next_steps.yml b/template/.github/workflows/{% if AddLinting %}next_steps_linting.yml{% endif %} similarity index 74% rename from template/.github/workflows/next_steps.yml rename to template/.github/workflows/{% if AddLinting %}next_steps_linting.yml{% endif %} index 56263d50..9be89e43 100644 --- a/template/.github/workflows/next_steps.yml +++ b/template/.github/workflows/{% if AddLinting %}next_steps_linting.yml{% endif %} @@ -2,7 +2,7 @@ on: [push] permissions: contents: write issues: write -name: Create issues for next steps +name: Create issues for linting jobs: next_steps: runs-on: ubuntu-latest @@ -13,7 +13,7 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: - filename: .github/next_steps/05_linting.md + filename: .github/workflows/next_steps_linting_issue.md id: linting - name: List created issues run: | @@ -23,7 +23,8 @@ jobs: run: | git config --global user.name 'NLeSC Python template' git config --global user.email 'nlesc-python-template@users.noreply.github.com' - git rm .github/workflows/next_steps.yml - git rm -r .github/next_steps + git pull # other next step workflows may push changes before + git rm .github/workflows/next_steps_linting.yml + git rm .github/workflows/next_steps_linting_issue.md git commit -am "Cleanup automated next steps issue generator" git push diff --git a/template/.github/next_steps/05_linting.md.jinja b/template/.github/workflows/{% if AddLinting %}next_steps_linting_issue.md{% endif %}.jinja similarity index 100% rename from template/.github/next_steps/05_linting.md.jinja rename to template/.github/workflows/{% if AddLinting %}next_steps_linting_issue.md{% endif %}.jinja From f534857a992121159f3ff34ff035d0ad6ab03a0f Mon Sep 17 00:00:00 2001 From: "Faruk D." Date: Mon, 26 Aug 2024 21:15:14 +0200 Subject: [PATCH 2/4] add condition for linting mentions in README.dev.md --- template/{% if AddDevDoc %}README.dev.md{% endif %}.jinja | 2 ++ 1 file changed, 2 insertions(+) diff --git a/template/{% if AddDevDoc %}README.dev.md{% endif %}.jinja b/template/{% if AddDevDoc %}README.dev.md{% endif %}.jinja index e7740cdd..b992a0b1 100644 --- a/template/{% if AddDevDoc %}README.dev.md{% endif %}.jinja +++ b/template/{% if AddDevDoc %}README.dev.md{% endif %}.jinja @@ -62,6 +62,7 @@ coverage report `coverage` can also generate output in HTML and other formats; see `coverage help` for more information. +{%- if AddLinting -%} ## Running linters locally For linting and sorting imports we will use [ruff](https://beta.ruff.rs/docs/). Running the linters requires an @@ -76,6 +77,7 @@ ruff . --fix ``` To fix readability of your code style you can use [yapf](https://github.com/google/yapf). +{%- endif -%} {%- if AddPreCommit -%} You can enable automatic linting with `ruff` on commit by enabling the git hook from `.githooks/pre-commit`, like so: From 52e184bd806b82a0aecdc41382ca6cc7d32e6a59 Mon Sep 17 00:00:00 2001 From: "Faruk D." Date: Mon, 26 Aug 2024 21:16:03 +0200 Subject: [PATCH 3/4] add condition for linting job in build workflow --- .../workflows/{% if AddGitHubActions %}build.yml{% endif %} | 2 ++ 1 file changed, 2 insertions(+) diff --git a/template/.github/workflows/{% if AddGitHubActions %}build.yml{% endif %} b/template/.github/workflows/{% if AddGitHubActions %}build.yml{% endif %} index 1d4df162..c05f29a1 100644 --- a/template/.github/workflows/{% if AddGitHubActions %}build.yml{% endif %} +++ b/template/.github/workflows/{% if AddGitHubActions %}build.yml{% endif %} @@ -38,6 +38,7 @@ jobs: - name: Verify that we can build the package run: python -m build +{%- if AddLinting -%} lint: name: Linting build runs-on: ubuntu-latest @@ -62,3 +63,4 @@ jobs: run: | ruff check ruff format --check +{%- endif -%} From c4d08e925d3a0a92ad1aafd508d7bf4535ed8a6d Mon Sep 17 00:00:00 2001 From: "Faruk D." Date: Mon, 26 Aug 2024 21:18:01 +0200 Subject: [PATCH 4/4] update the changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6301aa95..66d41981 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## [Unreleased] ### Added +* Make linting optional [#568](https://github.com/NLeSC/python-template/pull/568) * Make contributing guidelines optional [#465]() * Make developer documentation optional [#467](https://github.com/NLeSC/python-template/pull/541) * Make Code of Conduct optional [#464](https://github.com/NLeSC/python-template/pull/530)