Skip to content

Commit e70c58b

Browse files
.pre-commit-config.yaml → prek.toml (#648)
Follows on from - #645 - #644 Replace the pre-commit-config files, since it's a bit confusing to have a config file named after a legacy tool. --------- Co-authored-by: Patrick Roddy <patrickjamesroddy@gmail.com>
1 parent 3a475d1 commit e70c58b

10 files changed

Lines changed: 209 additions & 132 deletions

File tree

‎.github/workflows/linting.yml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
1919
with:
2020
path: ~/.cache/prek
21-
key: prek-${{ hashFiles('.pre-commit-config.yaml') }}
21+
key: prek-${{ hashFiles('prek.toml') }}
2222

2323
- name: Set up python
2424
uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0
@@ -41,7 +41,7 @@ jobs:
4141
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
4242
with:
4343
path: ~/.cache/prek
44-
key: prek-${{ hashFiles('.pre-commit-config.yaml') }}
44+
key: prek-${{ hashFiles('prek.toml') }}
4545

4646
- name: Set up python
4747
uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0

‎.pre-commit-config.yaml‎

Lines changed: 0 additions & 64 deletions
This file was deleted.

‎CONTRIBUTING.md‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Contributing Guide
22

3+
[![Link Checker](https://github.com/UCL-ARC/python-tooling/actions/workflows/links.yml/badge.svg)](https://github.com/UCL-ARC/python-tooling/actions/workflows/links.yml)
4+
[![Linting](https://github.com/UCL-ARC/python-tooling/actions/workflows/linting.yml/badge.svg)](https://github.com/UCL-ARC/python-tooling/actions/workflows/linting.yml)
5+
[![Run template tests](https://github.com/UCL-ARC/python-tooling/actions/workflows/test.yml/badge.svg)](https://github.com/UCL-ARC/python-tooling/actions/workflows/test.yml)
6+
[![SPEC 0 — Minimum Supported Dependencies](https://img.shields.io/badge/SPEC-0-green?labelColor=%23004811&color=%235CA038)](https://scientific-python.org/specs/spec-0000/)
7+
[![prek](https://raw.githubusercontent.com/j178/prek/master/docs/assets/badge.svg)](https://github.com/j178/prek)
8+
39
This template and our [recommendation pages][website] were made by [research
410
software engineers] at [UCL's Centre for Advanced Research Computing][UCL ARC].
511
We made it with research software projects in mind, but whoever you are, we hope
@@ -62,8 +68,6 @@ branch you want to test.
6268

6369
#### Python version support
6470

65-
[![SPEC 0 — Minimum Supported Dependencies](https://img.shields.io/badge/SPEC-0-green?labelColor=%23004811&color=%235CA038)](https://scientific-python.org/specs/spec-0000/)
66-
6771
We follow Scientific Python's [SPEC 0](https://scientific-python.org/specs/spec-0000/) policy.
6872
Notably this means our template will support [Python versions for three years after their release](https://scientific-python.org/specs/spec-0000/#support-window), and changes to the template are required to pass tests in all such python versions.
6973
(See [the CI checks](./.github/workflows/test.yml) for precise details.)

‎docs/pages/linting.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ layout: default
66
## Linting
77

88
See
9-
[here for an example configuration](https://github.com/UCL-ARC/python-tooling/blob/main/%7B%7Bcookiecutter.project_slug%7D%7D/.pre-commit-config.yaml)
9+
[here for an example configuration](https://github.com/UCL-ARC/python-tooling/blob/main/%7B%7Bcookiecutter.project_slug%7D%7D/prek.toml)
1010
for some of these.
1111

1212
### Code formatting

‎docs/pages/tutorial.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ The built documentation will be output to a directory `site`.
400400

401401
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.
402402

403-
There is a `.pre-commit-config.yaml` configuration file which you can take a look at.
403+
There is a `prek.toml` configuration file which you can take a look at.
404404
With this setup `prek` will run a series of fast linters, checks and formatters on the repository on every commit.
405405

406406
The main tools we recommend are [ruff](https://docs.astral.sh/ruff/), [ty](https://docs.astral.sh/ty/) and [prettier](https://prettier.io/).

‎prek.toml‎

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# Configuration file for `prek`, a git hook framework written in Rust.
2+
# See https://prek.j178.dev for more information.
3+
# :schema https://www.schemastore.org/prek.json
4+
# ^ Remove the space here when toml-sort/#105 is resolved. The directive should be: '#:schema'
5+
6+
exclude = "^{{cookiecutter.project_slug}}/|^tests/data/test_package_generation/"
7+
8+
[[repos]]
9+
hooks = [
10+
{args = [
11+
"--config=pyproject.toml",
12+
], id = "ruff-check"},
13+
{args = [
14+
"--config=pyproject.toml",
15+
], id = "ruff-format"},
16+
]
17+
repo = "https://github.com/astral-sh/ruff-pre-commit"
18+
rev = "v0.15.19"
19+
20+
[[repos]]
21+
hooks = [{args = ["--dot"], id = "markdownlint-fix"}]
22+
repo = "https://github.com/igorshubovych/markdownlint-cli"
23+
rev = "v0.49.1"
24+
25+
[[repos]]
26+
hooks = [{id = "forbid-tabs"}]
27+
repo = "https://github.com/Lucas-C/pre-commit-hooks"
28+
rev = "v1.5.6"
29+
30+
[[repos]]
31+
hooks = [{id = "toml-sort-fix"}]
32+
repo = "https://github.com/pappasam/toml-sort"
33+
rev = "v0.24.4"
34+
35+
[[repos]]
36+
hooks = [
37+
{args = [
38+
"--group=typechecking",
39+
"--isolated",
40+
"--no-default-groups",
41+
], id = "ty"},
42+
]
43+
repo = "https://github.com/astral-sh/ty-pre-commit"
44+
rev = "v0.0.79"
45+
46+
[[repos]]
47+
hooks = [{args = ["--quote-props=as-needed"], id = "prettier"}]
48+
repo = "https://github.com/rbubley/mirrors-prettier"
49+
rev = "v3.8.4"
50+
51+
[[repos]]
52+
hooks = [
53+
{args = [
54+
"--fix=lf",
55+
], id = "mixed-line-ending"},
56+
{id = "check-case-conflict"},
57+
{id = "check-docstring-first"},
58+
{id = "check-merge-conflict"},
59+
{id = "end-of-file-fixer"},
60+
{id = "trailing-whitespace"},
61+
]
62+
repo = "https://github.com/pre-commit/pre-commit-hooks"
63+
rev = "v6.0.0"
64+
65+
[[repos]]
66+
hooks = [
67+
{args = [
68+
"--schemafile=.github/schemas/github-issue-forms.json",
69+
"--verbose",
70+
], exclude = '^\.github/ISSUE_TEMPLATE/config\.yml$', files = '^\.github/ISSUE_TEMPLATE/.*\.yml$', id = "check-jsonschema", name = "Validate GitHub issue templates"},
71+
]
72+
repo = "https://github.com/python-jsonschema/check-jsonschema"
73+
rev = "0.38.0"
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# :schema https://www.schemastore.org/prek.json
2+
3+
[[repos]]
4+
hooks = [{id = "ruff-check"}, {id = "ruff-format"}]
5+
repo = "https://github.com/astral-sh/ruff-pre-commit"
6+
rev = "v0.15.19"
7+
8+
[[repos]]
9+
hooks = [{args = ["--dot"], id = "markdownlint-fix"}]
10+
repo = "https://github.com/igorshubovych/markdownlint-cli"
11+
rev = "v0.49.1"
12+
13+
[[repos]]
14+
hooks = [{id = "forbid-tabs"}]
15+
repo = "https://github.com/Lucas-C/pre-commit-hooks"
16+
rev = "v1.5.6"
17+
18+
[[repos]]
19+
hooks = [{id = "toml-sort-fix"}]
20+
repo = "https://github.com/pappasam/toml-sort"
21+
rev = "v0.24.4"
22+
23+
[[repos]]
24+
hooks = [
25+
{args = [
26+
"--group=typechecking",
27+
"--isolated",
28+
"--no-default-groups",
29+
], id = "ty"},
30+
]
31+
repo = "https://github.com/astral-sh/ty-pre-commit"
32+
rev = "v0.0.79"
33+
34+
[[repos]]
35+
hooks = [{args = ["--quote-props=as-needed"], id = "prettier"}]
36+
repo = "https://github.com/rbubley/mirrors-prettier"
37+
rev = "v3.8.4"
38+
39+
[[repos]]
40+
hooks = [
41+
{args = [
42+
"--fix=lf",
43+
], id = "mixed-line-ending"},
44+
{id = "check-case-conflict"},
45+
{id = "check-docstring-first"},
46+
{id = "check-merge-conflict"},
47+
{id = "check-toml"},
48+
{id = "end-of-file-fixer"},
49+
{id = "trailing-whitespace"},
50+
]
51+
repo = "https://github.com/pre-commit/pre-commit-hooks"
52+
rev = "v6.0.0"
53+
54+
[[repos]]
55+
hooks = [
56+
{args = [
57+
"--schemafile=.github/schemas/github-issue-forms.json",
58+
"--verbose",
59+
], exclude = '^\.github/ISSUE_TEMPLATE/config\.yml$', files = '^\.github/ISSUE_TEMPLATE/.*\.yml$', id = "check-jsonschema", name = "Validate GitHub issue templates"},
60+
]
61+
repo = "https://github.com/python-jsonschema/check-jsonschema"
62+
rev = "0.38.0"

‎{{cookiecutter.project_slug}}/.github/workflows/linting.yml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ jobs:
1717
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
1818
with:
1919
path: ~/.cache/prek
20-
key: prek-${{ '{{' }} hashFiles('.pre-commit-config.yaml') {{ '}}' }}
20+
key: prek-${{ '{{' }} hashFiles('prek.toml') {{ '}}' }}
2121

2222
- name: Set up python
2323
uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0
2424
with:
2525
python-version: "3.x"
2626
cache: pip
27-
cache-dependency-path: pyproject.toml
27+
cache-dependency-path: prek.toml
2828

2929
- name: Install dependencies
3030
run: python -m pip install prek

‎{{cookiecutter.project_slug}}/.pre-commit-config.yaml‎

Lines changed: 0 additions & 60 deletions
This file was deleted.
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# :schema https://www.schemastore.org/prek.json
2+
3+
[[repos]]
4+
hooks = [{id = "ruff-check"}, {id = "ruff-format"}]
5+
repo = "https://github.com/astral-sh/ruff-pre-commit"
6+
rev = "v0.15.19"
7+
8+
[[repos]]
9+
hooks = [{args = ["--dot"], id = "markdownlint-fix"}]
10+
repo = "https://github.com/igorshubovych/markdownlint-cli"
11+
rev = "v0.49.1"
12+
13+
[[repos]]
14+
hooks = [{id = "forbid-tabs"}]
15+
repo = "https://github.com/Lucas-C/pre-commit-hooks"
16+
rev = "v1.5.6"
17+
18+
[[repos]]
19+
hooks = [{id = "toml-sort-fix"}]
20+
repo = "https://github.com/pappasam/toml-sort"
21+
rev = "v0.24.4"
22+
23+
[[repos]]
24+
hooks = [
25+
{args = [
26+
"--group=typechecking",
27+
"--isolated",
28+
"--no-default-groups",
29+
], id = "ty"},
30+
]
31+
repo = "https://github.com/astral-sh/ty-pre-commit"
32+
rev = "v0.0.79"
33+
34+
[[repos]]
35+
hooks = [{args = ["--quote-props=as-needed"], id = "prettier"}]
36+
repo = "https://github.com/rbubley/mirrors-prettier"
37+
rev = "v3.8.4"
38+
39+
[[repos]]
40+
hooks = [
41+
{args = [
42+
"--fix=lf",
43+
], id = "mixed-line-ending"},
44+
{id = "check-case-conflict"},
45+
{id = "check-docstring-first"},
46+
{id = "check-merge-conflict"},
47+
{id = "check-toml"},
48+
{id = "end-of-file-fixer"},
49+
{id = "trailing-whitespace"},
50+
]
51+
repo = "https://github.com/pre-commit/pre-commit-hooks"
52+
rev = "v6.0.0"
53+
54+
[[repos]]
55+
hooks = [
56+
{args = [
57+
"--schemafile=.github/schemas/github-issue-forms.json",
58+
"--verbose",
59+
], exclude = '^\.github/ISSUE_TEMPLATE/config\.yml$', files = '^\.github/ISSUE_TEMPLATE/.*\.yml$', id = "check-jsonschema", name = "Validate GitHub issue templates"},
60+
]
61+
repo = "https://github.com/python-jsonschema/check-jsonschema"
62+
rev = "0.38.0"

0 commit comments

Comments
 (0)