Skip to content
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
24 changes: 12 additions & 12 deletions .github/workflows/linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,50 +14,50 @@ jobs:
- name: Checkout source
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

- name: Cache pre-commit
- name: Cache prek
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ~/.cache/pre-commit
key: pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}
path: ~/.cache/prek
key: prek-${{ hashFiles('.pre-commit-config.yaml') }}

- name: Set up python
uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0
with:
python-version: "3.x"

- name: Install dependencies
run: python -m pip install pre-commit
run: python -m pip install prek

- name: Run pre-commit
run: pre-commit run --all-files --color always --verbose
- name: Run prek
run: prek run --all-files --color always --verbose
Comment thread
paddyroddy marked this conversation as resolved.

lint-the-template:
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

- name: Cache pre-commit
- name: Cache prek
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ~/.cache/pre-commit
key: pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}
path: ~/.cache/prek
key: prek-${{ hashFiles('.pre-commit-config.yaml') }}

- name: Set up python
uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0
with:
python-version: "3.x"

- name: Install dependencies
run: python -m pip install cookiecutter pre-commit
run: python -m pip install cookiecutter prek

- name: Create template
run: cookiecutter . --no-input --output-dir cookie-template

- name: Run pre-commit
- name: Run prek
run: |-
git add .
pre-commit run --all-files --color always --verbose
prek run --all-files --color always --verbose
working-directory: cookie-template/python-template

lint-prose:
Expand Down
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ To contribute a change, please:

1. Create a new branch (or fork if you're not in [@UCL-ARC/collaborations]).
2. Modify an existing page, create a new one, or tweak the template. a. Run
[pre-commit] which will lint your changes. b. Check
the tests pass if you modified the template (`pytest -s`).
[prek] which will lint your changes. b. Check the tests pass if you modified
the template (`pytest -s`).
3. Open a _pull request_ (PR) with changes.
4. Ask someone who did not contribute to the PR from [@UCL-ARC/collaborations]
to review it. If it should have two reviewers, you can also request a review
Expand Down Expand Up @@ -90,7 +90,7 @@ See the [jekyll docs] for more info.
[open an issue]: https://github.com/UCL-ARC/python-tooling/issues/new/choose
[Discussions tab]: https://github.com/UCL-ARC/python-tooling/discussions
[Research software engineers]: https://society-rse.org/about/history
[pre-commit]: https://pre-commit.com
[prek]: https://prek.j178.dev
[@UCL-ARC/collaborations]: https://github.com/orgs/UCL-ARC/teams/collaborations
[@UCL-ARC/collaborations-python-tooling]: https://github.com/orgs/UCL-ARC/teams/collaborations-python-tooling
[uv tool]: https://docs.astral.sh/uv/guides/tools
Expand Down
2 changes: 1 addition & 1 deletion docs/pages/ci.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ layout: default
| [AppVeyor](https://www.appveyor.com/docs/) | Continuous integration and continuous delivery platform. | <span class="label label-yellow">Good</span> |
| [Bamboo](https://confluence.atlassian.com/bamboo/bamboo-documentation-289276551.html) | Atlassian continuous integration and continuous delivery platform. | <span class="label label-yellow">Good</span> |
| [Travis CI](https://docs.travis-ci.com/) | Continuous integration and continuous delivery platform. | <span class="label label-yellow">Good</span> |
| [pre-commit.ci](https://pre-commit.ci/) | A bot that adds a pre-commit job to your GitHub Actions CI, and can automatically fix most trivial linting failures. Free for open-source projects. | <span class="label label-green">Best</span> |
| [pre-commit.ci](https://pre-commit.ci/) | A bot that adds a pre-commit job to your GitHub Actions CI, and can automatically fix most trivial linting failures. Free for open-source projects. | <span class="label label-yellow">Good</span> |

<details><summary> <span class="label label-green">Best</span> explanation</summary><!-- markdownlint-disable-line MD033 -->
We have many projects using GitHub CI and, it has good integration with GitHub itself, and is free for public repositories (with limited free monthly minutes for private repositories).
Expand Down
3 changes: 2 additions & 1 deletion docs/pages/linting.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ for some of these.

| Name | Short description | 🚦 |
| ------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :------------------------------------------: |
| [pre-commit](https://pre-commit.com/) | Universal tool which performs a git hook on commit, allows you to run linters/formatters on any code. A tool to automatically run many of the tools listed below. | <span class="label label-green">Best</span> |
| [prek](https://prek.j178.dev/) | A rust-powered improvement on `pre-commit`. Known for its friendlier community and feature rich implementation. | <span class="label label-green">Best</span> |
| [pre-commit](https://pre-commit.com/) | Universal tool which performs a git hook on commit, allows you to run linters/formatters on any code. A tool to automatically run many of the tools listed below. | <span class="label label-yellow">Good</span> |

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keep yellow or move to red? Is there any reason not to use prek?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting question. I guess it depends on how we define 🔴 Vs 🟡. I would have said 🟡 is that there isn't anything "wrong" with pre-commit. However, the bug identified in #644 suggests otherwise as that is an actual blocker.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leave as is and chat with other pythonistas IRL at TI planning?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, let's do it

| [ruff-format](https://github.com/astral-sh/ruff) | A drop-in replacement for `black` (and also super fast). A nice "no-need to think" code formatter. If you have your own opinions about code style, you might not like this. | <span class="label label-green">Best</span> |
| [ruff](https://github.com/astral-sh/ruff) | A fast linter which incorporates a range of other linters. Notably [isort](https://pycqa.github.io/isort/) can be included as a [ruff rule](https://docs.astral.sh/ruff/rules/) (which we recommend). | <span class="label label-green">Best</span> |
| [toml-sort](https://github.com/pappasam/toml-sort) | Sorts TOML files which are now part of PEP 8. | <span class="label label-green">Best</span> |
Expand Down
16 changes: 8 additions & 8 deletions docs/pages/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -396,33 +396,33 @@
from the root of the project repository.
The built documentation will be output to a directory `site`.

## ✅ Using `pre-commit` to run checks when committing
## ✅ Using `prek` to run checks when committing
Comment thread
paddyroddy marked this conversation as resolved.

The package is set-up to use [pre-commit](https://pre-commit.com/), a framework for running [Git hook scripts](https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks) on each commit to the repository.
The package is set-up to use [prek](https://prek.j178.dev/), a framework for running [Git hook scripts](https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks) on each commit to the repository.

There is a `.pre-commit-config.yaml` configuration file which you can take a look at.

Check failure on line 403 in docs/pages/tutorial.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/pages/tutorial.md#L403

[write-good.ThereIs] Don't start a sentence with 'There is'.
Raw output
{"message": "[write-good.ThereIs] Don't start a sentence with 'There is'.", "location": {"path": "docs/pages/tutorial.md", "range": {"start": {"line": 403, "column": 1}}}, "severity": "ERROR"}
With this setup `pre-commit` will run a series of fast linters, checks and formatters on the repository on every commit.
With this setup `prek` will run a series of fast linters, checks and formatters on the repository on every commit.

The main tools we recommend are [ruff](https://docs.astral.sh/ruff/), [ty](https://docs.astral.sh/ty/) and [prettier](https://prettier.io/).
These Git hook scripts can be installed locally by running

```sh
pre-commit install
prek install
```

from the root of the project repository.
You will only need to do this once per `git clone` of the code.

Once installed, the scripts will be called to inspect the changes each time `git commit` is run.
Any failures of the checks will need to be fixed before the changes can be committed.
Some of the `pre-commit` hooks include support for auto-fixing easy problems - in this case you will be alerted that a file has been changed by a hook and these changes need to be staged using `git add` before recommitting.
Some of the `prek` hooks include support for auto-fixing easy problems - in this case you will be alerted that a file has been changed by a hook and these changes need to be staged using `git add` before recommitting.

The hooks typically only run on the files _changed_ in a commit.
The `pre-commit` hooks can be run against _all files in the repository_ by running
The `prek` hooks can be run against _all files in the repository_ by running

```sh
pre-commit run --all-files
prek run --all-files
```

from the root of the project repository.
This is useful to check they will pass if the `pre-commit` configuration is updated, for example, when [adding a new plug-in](https://pre-commit.com/#plugins).
This is useful to check they will pass if the `prek` configuration is updated, for example, when [adding a new plug-in](https://prek.j178.dev/authoring-hooks).
12 changes: 6 additions & 6 deletions tests/data/test_package_generation/.github/workflows/linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ jobs:
- name: Checkout source
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

- name: Cache pre-commit
- name: Cache prek
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ~/.cache/pre-commit
key: pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}
path: ~/.cache/prek
key: prek-${{ hashFiles('.pre-commit-config.yaml') }}

- name: Set up python
uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0
Expand All @@ -27,7 +27,7 @@ jobs:
cache-dependency-path: pyproject.toml

- name: Install dependencies
run: python -m pip install pre-commit
run: python -m pip install prek

- name: Run pre-commit
run: pre-commit run --all-files --color always --verbose
- name: Run prek
run: prek run --all-files --color always --verbose
2 changes: 1 addition & 1 deletion tests/data/test_package_generation/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Cookiecutter Test

Check warning on line 1 in tests/data/test_package_generation/README.md

View workflow job for this annotation

GitHub Actions / vale

[vale] tests/data/test_package_generation/README.md#L1

[Readability.SMOG] Try to keep the SMOG grade (10.95) below 10.
Raw output
{"message": "[Readability.SMOG] Try to keep the SMOG grade (10.95) below 10.", "location": {"path": "tests/data/test_package_generation/README.md", "range": {"start": {"line": 1, "column": 1}}}, "severity": "WARNING"}

Check warning on line 1 in tests/data/test_package_generation/README.md

View workflow job for this annotation

GitHub Actions / vale

[vale] tests/data/test_package_generation/README.md#L1

[Readability.FleschKincaid] Try to keep the Flesch–Kincaid grade level (9.93) below 8.
Raw output
{"message": "[Readability.FleschKincaid] Try to keep the Flesch–Kincaid grade level (9.93) below 8.", "location": {"path": "tests/data/test_package_generation/README.md", "range": {"start": {"line": 1, "column": 1}}}, "severity": "WARNING"}

Check warning on line 1 in tests/data/test_package_generation/README.md

View workflow job for this annotation

GitHub Actions / vale

[vale] tests/data/test_package_generation/README.md#L1

[Readability.FleschReadingEase] Try to keep the Flesch reading ease score (38.41) above 70.
Raw output
{"message": "[Readability.FleschReadingEase] Try to keep the Flesch reading ease score (38.41) above 70.", "location": {"path": "tests/data/test_package_generation/README.md", "range": {"start": {"line": 1, "column": 1}}}, "severity": "WARNING"}

Check warning on line 1 in tests/data/test_package_generation/README.md

View workflow job for this annotation

GitHub Actions / vale

[vale] tests/data/test_package_generation/README.md#L1

[Readability.GunningFog] Try to keep the Gunning-Fog index (11.63) below 10.
Raw output
{"message": "[Readability.GunningFog] Try to keep the Gunning-Fog index (11.63) below 10.", "location": {"path": "tests/data/test_package_generation/README.md", "range": {"start": {"line": 1, "column": 1}}}, "severity": "WARNING"}

Check warning on line 1 in tests/data/test_package_generation/README.md

View workflow job for this annotation

GitHub Actions / vale

[vale] tests/data/test_package_generation/README.md#L1

[Readability.LIX] Try to keep the LIX score (43.37) below 35.
Raw output
{"message": "[Readability.LIX] Try to keep the LIX score (43.37) below 35.", "location": {"path": "tests/data/test_package_generation/README.md", "range": {"start": {"line": 1, "column": 1}}}, "severity": "WARNING"}

Check warning on line 1 in tests/data/test_package_generation/README.md

View workflow job for this annotation

GitHub Actions / vale

[vale] tests/data/test_package_generation/README.md#L1

[Readability.ColemanLiau] Try to keep the Coleman–Liau Index grade (11.78) below 9.
Raw output
{"message": "[Readability.ColemanLiau] Try to keep the Coleman–Liau Index grade (11.78) below 9.", "location": {"path": "tests/data/test_package_generation/README.md", "range": {"start": {"line": 1, "column": 1}}}, "severity": "WARNING"}

[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)](https://github.com/pre-commit/pre-commit)
[![prek](https://img.shields.io/badge/prek-enabled-brightgreen?logo=prek&logoColor=white)](https://github.com/j178/prek)
[![Tests status][tests-badge]][tests-link]
[![Linting status][linting-badge]][linting-link]
[![Documentation status][documentation-badge]][documentation-link]
Expand Down
2 changes: 1 addition & 1 deletion tests/data/test_package_generation/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ requires = [
[dependency-groups]
dev = [
"build",
"pre-commit",
"prek",
"ruff",
"tox",
"twine",
Expand Down
12 changes: 6 additions & 6 deletions {{cookiecutter.project_slug}}/.github/workflows/linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ jobs:
- name: Checkout source
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

- name: Cache pre-commit
- name: Cache prek
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ~/.cache/pre-commit
key: pre-commit-${{ '{{' }} hashFiles('.pre-commit-config.yaml') {{ '}}' }}
path: ~/.cache/prek
key: prek-${{ '{{' }} hashFiles('.pre-commit-config.yaml') {{ '}}' }}

- name: Set up python
uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0
Expand All @@ -27,7 +27,7 @@ jobs:
cache-dependency-path: pyproject.toml

- name: Install dependencies
run: python -m pip install pre-commit
run: python -m pip install prek

- name: Run pre-commit
run: pre-commit run --all-files --color always --verbose
- name: Run prek
run: prek run --all-files --color always --verbose
2 changes: 1 addition & 1 deletion {{cookiecutter.project_slug}}/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# {{cookiecutter.project_name}}

Check warning on line 1 in {{cookiecutter.project_slug}}/README.md

View workflow job for this annotation

GitHub Actions / vale

[vale] {{cookiecutter.project_slug}}/README.md#L1

[Readability.SMOG] Try to keep the SMOG grade (12.23) below 10.
Raw output
{"message": "[Readability.SMOG] Try to keep the SMOG grade (12.23) below 10.", "location": {"path": "{{cookiecutter.project_slug}}/README.md", "range": {"start": {"line": 1, "column": 1}}}, "severity": "WARNING"}

Check warning on line 1 in {{cookiecutter.project_slug}}/README.md

View workflow job for this annotation

GitHub Actions / vale

[vale] {{cookiecutter.project_slug}}/README.md#L1

[Readability.FleschKincaid] Try to keep the Flesch–Kincaid grade level (11.58) below 8.
Raw output
{"message": "[Readability.FleschKincaid] Try to keep the Flesch–Kincaid grade level (11.58) below 8.", "location": {"path": "{{cookiecutter.project_slug}}/README.md", "range": {"start": {"line": 1, "column": 1}}}, "severity": "WARNING"}

Check warning on line 1 in {{cookiecutter.project_slug}}/README.md

View workflow job for this annotation

GitHub Actions / vale

[vale] {{cookiecutter.project_slug}}/README.md#L1

[Readability.FleschReadingEase] Try to keep the Flesch reading ease score (28.13) above 70.
Raw output
{"message": "[Readability.FleschReadingEase] Try to keep the Flesch reading ease score (28.13) above 70.", "location": {"path": "{{cookiecutter.project_slug}}/README.md", "range": {"start": {"line": 1, "column": 1}}}, "severity": "WARNING"}

Check warning on line 1 in {{cookiecutter.project_slug}}/README.md

View workflow job for this annotation

GitHub Actions / vale

[vale] {{cookiecutter.project_slug}}/README.md#L1

[Readability.GunningFog] Try to keep the Gunning-Fog index (14.21) below 10.
Raw output
{"message": "[Readability.GunningFog] Try to keep the Gunning-Fog index (14.21) below 10.", "location": {"path": "{{cookiecutter.project_slug}}/README.md", "range": {"start": {"line": 1, "column": 1}}}, "severity": "WARNING"}

Check warning on line 1 in {{cookiecutter.project_slug}}/README.md

View workflow job for this annotation

GitHub Actions / vale

[vale] {{cookiecutter.project_slug}}/README.md#L1

[Readability.LIX] Try to keep the LIX score (46.59) below 35.
Raw output
{"message": "[Readability.LIX] Try to keep the LIX score (46.59) below 35.", "location": {"path": "{{cookiecutter.project_slug}}/README.md", "range": {"start": {"line": 1, "column": 1}}}, "severity": "WARNING"}

Check warning on line 1 in {{cookiecutter.project_slug}}/README.md

View workflow job for this annotation

GitHub Actions / vale

[vale] {{cookiecutter.project_slug}}/README.md#L1

[Readability.ColemanLiau] Try to keep the Coleman–Liau Index grade (14.37) below 9.
Raw output
{"message": "[Readability.ColemanLiau] Try to keep the Coleman–Liau Index grade (14.37) below 9.", "location": {"path": "{{cookiecutter.project_slug}}/README.md", "range": {"start": {"line": 1, "column": 1}}}, "severity": "WARNING"}

Check warning on line 1 in {{cookiecutter.project_slug}}/README.md

View workflow job for this annotation

GitHub Actions / vale

[vale] {{cookiecutter.project_slug}}/README.md#L1

[Readability.AutomatedReadability] Try to keep the Automated Readability Index (9.88) below 8.
Raw output
{"message": "[Readability.AutomatedReadability] Try to keep the Automated Readability Index (9.88) below 8.", "location": {"path": "{{cookiecutter.project_slug}}/README.md", "range": {"start": {"line": 1, "column": 1}}}, "severity": "WARNING"}

[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)](https://github.com/pre-commit/pre-commit)
[![prek](https://img.shields.io/badge/prek-enabled-brightgreen?logo=prek&logoColor=white)](https://github.com/j178/prek)
[![Tests status][tests-badge]][tests-link]
[![Linting status][linting-badge]][linting-link]
[![Documentation status][documentation-badge]][documentation-link]
Expand Down
2 changes: 1 addition & 1 deletion {{cookiecutter.project_slug}}/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ requires = [
[dependency-groups]
dev = [
"build",
"pre-commit",
"prek",
"ruff",
"tox",
"twine",
Expand Down
Loading