Skip to content

Commit a23bf9b

Browse files
feat(tooling,ci): add changelog formatting checks (#1691)
Co-authored-by: danceratopz <[email protected]>
1 parent d6a14a2 commit a23bf9b

File tree

7 files changed

+119
-40
lines changed

7 files changed

+119
-40
lines changed

.github/workflows/tox_verify.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,22 @@ jobs:
5353
env:
5454
GITHUB_STEP_SUMMARY: ${{ env.GITHUB_STEP_SUMMARY }}
5555

56+
changelog:
57+
name: Validate changelog entries
58+
runs-on: ubuntu-latest
59+
steps:
60+
- name: Checkout ethereum/execution-spec-tests
61+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
62+
- name: Install uv ${{ vars.UV_VERSION }} and python ${{ vars.DEFAULT_PYTHON_VERSION }}
63+
uses: astral-sh/setup-uv@0c5e2b8115b80b4c7c5ddf6ffdd634974642d182
64+
with:
65+
enable-cache: true
66+
cache-dependency-glob: "uv.lock"
67+
version: ${{ vars.UV_VERSION }}
68+
python-version: ${{ vars.DEFAULT_PYTHON_VERSION }}
69+
- name: Run changelog validation via tox
70+
run: uvx --with=tox-uv tox -e changelog
71+
5672
markdownlint:
5773
name: Lint markdown files with markdownlint
5874
runs-on: ubuntu-latest

.pre-commit-config.yaml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,13 @@ repos:
99
pass_filenames: false
1010
- id: tox-docs
1111
name: tox-docs
12-
entry: uvx --with=tox-uv tox --parallel -e spellcheck,markdownlint,mkdocs
12+
entry: uvx --with=tox-uv tox --parallel -e spellcheck,markdownlint
1313
language: system
1414
files: \.md$
1515
pass_filenames: false
16+
- id: tox-changelog
17+
name: tox-changelog
18+
entry: uvx --with=tox-uv tox -e changelog
19+
language: system
20+
files: ^docs/CHANGELOG\.md$
21+
pass_filenames: false

docs/CHANGELOG.md

Lines changed: 33 additions & 32 deletions
Large diffs are not rendered by default.

docs/getting_started/code_standards.md

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,17 @@ Code pushed to @ethereum/execution-spec-tests must fulfill the following checks
1616
| HTML doc build | `uvx --with=tox-uv tox -e mkdocs` | Documentation generated without warnings. |
1717
| Spellcheck | `uvx --with=tox-uv tox -e spellcheck` | Code and documentation spell-check using codespell. |
1818
| Markdown lint | `uvx --with=tox-uv tox -e markdownlint` | Markdown lint (requires [additional dependency](code_standards_details.md#additional-dependencies)). |
19+
| Changelog validation | `uvx --with=tox-uv tox -e changelog` | Validates changelog entries format and structure in `docs/CHANGELOG.md`. |
20+
21+
!!! important "Avoid CI surprises - Use pre-commit hooks!"
22+
**We strongly encourage all contributors to install and use pre-commit hooks!** This will run fast checks (lint, typecheck, spellcheck) automatically before each commit, helping you catch issues early and avoid frustrating CI failures after pushing your changes.
23+
24+
Install with one simple command:
25+
```console
26+
uvx pre-commit install
27+
```
28+
29+
This saves you time by catching formatting issues, type errors, and spelling mistakes before they reach CI.
1930

2031
!!! tip "Running checks easily"
2132

@@ -43,12 +54,6 @@ Code pushed to @ethereum/execution-spec-tests must fulfill the following checks
4354
uvx --with=tox-uv tox -e lint,typecheck
4455
```
4556

46-
Use [pre-commit hooks](./code_standards_details.md#pre-commit-hooks) that perform the fastest checks:
47-
48-
```
49-
uvx pre-commit install
50-
```
51-
5257
!!! tip "Lint & code formatting: Using `ruff` and VS Code to help autoformat and fix module imports"
5358

5459
On the command-line, solve fixable issues with:

docs/getting_started/code_standards_details.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ uvx --with=tox-uv tox -e lint,typecheck,spellcheck,pytest
4747
#### For Documentation Changes (`./docs/`)
4848

4949
```console
50-
uvx --with=tox-uv tox -e spellcheck,markdownlint,mkdocs
50+
uvx --with=tox-uv tox -e spellcheck,markdownlint,mkdocs,changelog
5151
```
5252

5353
!!! note "Tox Virtual Environment"

src/cli/tox_helpers.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@
77
"""
88

99
import os
10+
import re
1011
import shutil
1112
import subprocess
1213
import sys
14+
from pathlib import Path
1315

1416
import click
1517
from pyspelling import __main__ as pyspelling_main # type: ignore
@@ -186,3 +188,47 @@ def codespell():
186188
sys.exit(1)
187189

188190
sys.exit(0)
191+
sys.exit(pyspelling_main.main())
192+
193+
194+
@click.command()
195+
def validate_changelog():
196+
"""
197+
Validate changelog formatting to ensure bullet points end with proper punctuation.
198+
199+
Checks that all bullet points (including nested ones) end with either:
200+
- A period (.) for regular entries
201+
- A colon (:) for section headers that introduce lists
202+
"""
203+
changelog_path = Path("docs/CHANGELOG.md")
204+
205+
if not changelog_path.exists():
206+
click.echo(f"❌ Changelog file not found: {changelog_path}")
207+
sys.exit(1)
208+
209+
try:
210+
with open(changelog_path, "r", encoding="utf-8") as f:
211+
content = f.read()
212+
except Exception as e:
213+
click.echo(f"❌ Error reading changelog: {e}.")
214+
sys.exit(1)
215+
216+
# Find bullet points that don't end with period or colon
217+
invalid_lines = []
218+
for line_num, line in enumerate(content.splitlines(), 1):
219+
if re.match(r"^\s*-\s+", line) and re.search(r"[^\.:]$", line.rstrip()):
220+
invalid_lines.append((line_num, line.strip()))
221+
222+
if invalid_lines:
223+
click.echo(f"❌ Found bullet points in {changelog_path} without proper punctuation:")
224+
click.echo()
225+
for line_num, line in invalid_lines:
226+
click.echo(f"Line {line_num}: {line}")
227+
click.echo()
228+
click.echo("💡 All bullet points should end with:")
229+
click.echo(" - A period (.) for regular entries.")
230+
click.echo(" - A colon (:) for paragraphs that introduce lists.")
231+
sys.exit(1)
232+
else:
233+
click.echo("✅ All bullet points have proper punctuation!")
234+
sys.exit(0)

tox.ini

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ description = Lint markdown files (markdownlint)
4343
extras = docs
4444
commands = python -c "import src.cli.tox_helpers; src.cli.tox_helpers.markdownlint()"
4545

46+
[testenv:changelog]
47+
description = Validate changelog entries (changelog)
48+
extras = docs
49+
commands = python -c "import src.cli.tox_helpers; src.cli.tox_helpers.validate_changelog()"
50+
4651
[testenv:mkdocs]
4752
description = Build documentation in strict mode (mkdocs)
4853
extras = docs,lint

0 commit comments

Comments
 (0)