Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
7 changes: 3 additions & 4 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -240,11 +240,12 @@ graph LR

</div>

## Trusted by developers worldwide
## Used by

<div class="trusted-by" markdown>

**Used by developers and organizations worldwide in their production workflows.**
**Commit Check runs in repositories across these organizations, and in
[many more](https://github.com/commit-check/commit-check-action/network/dependents).**

<div class="logo-grid">
<div class="logo-item">
Expand Down Expand Up @@ -323,8 +324,6 @@ graph LR

</div>

And [many more](https://github.com/commit-check/commit-check-action/network/dependents).

---

<div class="community-section" markdown>
Expand Down
31 changes: 31 additions & 0 deletions tests/docs_sync_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ def _read_doc(name: str) -> str:
#: A pasted failure line, e.g. ``CC003 subject-imperative check failed ==> ...``
_SAMPLE_FAILURE = re.compile(r"(CC\d{3}) (\S+) check failed ==>")

#: A pasted ``--compact`` line, e.g. ``[FAIL] CC003 subject_imperative: ...``.
#: Indented, because these samples sit inside content tabs.
_COMPACT_FAILURE = re.compile(r"^\s*\[FAIL\] (CC\d{3}) ([^:\s]+):", re.M)


def _rule_section(content: str, rule_id: str) -> str:
"""Return just the part of the rules page belonging to one rule."""
Expand Down Expand Up @@ -83,6 +87,33 @@ def test_sample_output_matches_what_the_tool_prints(self):
)
assert not stale, "sample output is out of date:\n " + "\n ".join(stale)

def test_compact_sample_output_matches_what_the_tool_prints(self):
"""Pasted ``--compact`` output names rules the way that format does.

The two text formats spell a check differently: the default output
prints the kebab-case name, and ``--compact`` prints the config key.
A sample of one therefore cannot be validated against the other, and
the guard above only matches the default format — so the compact
samples were checked by nothing at all. That is the blind spot that
let a pre-2.13 sample sit unnoticed in the troubleshooting page.

If the two formats are ever reconciled (see commit-check#528), this
is what will point at the samples that need rewriting.
"""
by_id = {entry.rule_id: entry for entry in ALL_RULES}
stale = []
for page in DOCS.rglob("*.md"):
for rule_id, printed in _COMPACT_FAILURE.findall(page.read_text("utf-8")):
entry = by_id.get(rule_id)
if entry and printed != entry.check:
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
stale.append(
f"{page.relative_to(DOCS)}: {rule_id} shown as "
f"'{printed}', --compact prints '{entry.check}'"
)
assert not stale, (
"compact sample output is out of date:\n " + "\n ".join(stale)
)

def test_every_rule_explains_itself(self):
"""Each rule section must answer what it does and why it matters."""
content = _read_doc("rules.md")
Expand Down