Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
11 changes: 8 additions & 3 deletions copier/questions/features_code_quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ SelectCodeQualityFeatures:
type: yaml
default: |-
{% if template_profile == 'recommended' %}
[SelectGitHubActions_flag, not_implemented_linting, AddSonarCloud_flag, not_implemented_editor_config]
[SelectGitHubActions_flag, AddLinting_flag, AddSonarCloud_flag, not_implemented_editor_config]
{%- else -%}
[]
{%- endif %}
Expand All @@ -17,8 +17,8 @@ SelectCodeQualityFeatures:
GitHub Actions:
value: SelectGitHubActions_flag
# validator: "{% if something != 'AnotherThing' %}BlaBla{% endif %}"
Linting (using ruff NOT_IMPLEMENTED):
value: not_implemented_linting
Linting:
value: AddLinting_flag
# validator: "{% if something != 'AnotherThing' %}BlaBla{% endif %}"
Pre-commit:
value: AddPreCommit_flag
Expand Down Expand Up @@ -80,3 +80,8 @@ AddSonarCloud:
type: bool
default: "{{ 'AddSonarCloud_flag' in SelectCodeQualityFeatures }}"
when: false

AddLinting:
type: bool
default: "{{ 'AddLinting_flag' in SelectCodeQualityFeatures }}"
when: false
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -62,3 +63,4 @@ jobs:
run: |
ruff check
ruff format --check
{%- endif -%}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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: |
Expand All @@ -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
2 changes: 2 additions & 0 deletions template/{% if AddDevDoc %}README.dev.md{% endif %}.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down