-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.pre-commit-config.yaml
More file actions
59 lines (56 loc) · 2.98 KB
/
Copy path.pre-commit-config.yaml
File metadata and controls
59 lines (56 loc) · 2.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# Four local hooks: three guard the rule catalogue, the fourth guards the docs build config. All
# are local, so contributors need only pre-commit itself plus the uv environment the Makefile
# already uses.
#
# The order matters for the catalogue three. `rules-extract` regenerates meta/oold-rules.json from
# the prose and fails if it changed, so a stale catalogue can never be committed. `rules-baseline`
# then compares that fresh catalogue against meta/rules-baseline.json, the state a human last
# accepted, and stops on the two things nothing else notices: a rule id that has vanished, and a
# rule whose text moved. `rules-page` finally regenerates docs/rules.md from the catalogue.
#
# `markdown-extensions` is independent of those three and guards a different failure: declaring
# any markdown_extensions replaces Zensical's defaults rather than extending them, so dropping one
# switches an extension off with no warning and no build failure.
#
# pre-commit install
repos:
- repo: local
hooks:
- id: rules-extract
name: regenerate the rule catalogue from the spec prose
entry: uv run scripts/extract_rules.py
language: system
pass_filenames: false
files: ^(spec/sections/.*\.md|scripts/extract_rules\.py)$
# Fails when the catalogue it writes differs from what is staged, so the author has to
# look at the diff and stage it deliberately.
require_serial: true
- id: rules-baseline
name: check the catalogue against the accepted baseline
entry: uv run scripts/rules_baseline.py check
language: system
pass_filenames: false
files: ^(spec/sections/.*\.md|meta/oold-rules\.json|meta/rules-baseline\.json)$
require_serial: true
- id: rules-page
name: regenerate the rule catalogue page
entry: uv run scripts/render_rules_page.py
language: system
pass_filenames: false
files: ^(meta/oold-rules\.json|scripts/render_rules_page\.py)$
# docs/rules.md is committed and CI fails on drift, exactly like the catalogue. Without
# this hook it is the one generated artifact a contributor can only discover stale in CI.
require_serial: true
- id: markdown-extensions
name: check zensical.toml restates Zensical's default Markdown extensions
# Goes through make so the zensical version comes from ZENSICAL_VERSION in the Makefile.
# Pinning it here instead would add a third copy of the pin (Makefile, CI workflow) for
# the same guard to then not be watching.
entry: make check-extensions
language: system
pass_filenames: false
# The Makefile is in scope because that is where the pin lives: bumping ZENSICAL_VERSION
# is precisely the moment the restated defaults can go stale, and the moment a contributor
# is least likely to think of zensical.toml.
files: ^(zensical\.toml|scripts/check_markdown_extensions\.py|Makefile)$
require_serial: true