Skip to content

Commit d68e05b

Browse files
authored
feat: show failures as a diff under a status heading, with how to fix them (#336)
2 parents 25b7143 + 423dc75 commit d68e05b

4 files changed

Lines changed: 1591 additions & 673 deletions

File tree

‎README.md‎

Lines changed: 68 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ The GitHub Action for [Commit Check](https://github.com/commit-check/commit-chec
2525
commit policy as code for teams and AI agents. It checks every commit of a pull
2626
request — message, branch, author, and optionally the PR title and the AI
2727
attribution in its description — against your `cchk.toml`, and reports the
28-
result in the job summary, as annotations on the diff and, if you want, as a PR
28+
result in the job summary, as annotations on the run and, if you want, as a PR
2929
comment. It can also label the pull requests that AI tools wrote.
3030

3131
## Usage
@@ -113,34 +113,72 @@ the run. Every key: [configuration reference](https://commit-check.com/configura
113113

114114
## What it looks like
115115

116-
A failing run opens with a count and a table of only what failed — each rule ID
117-
links to its documentation, each commit to itself — with the full tree one
118-
click away:
116+
A failing run says so in its heading, gives each group one line, and shows what
117+
failed as a diff: red is what was found, green is what to write instead. Each
118+
commit and rule is linked under it, and two folds hold the rest: how to fix it
119+
(a prompt for an AI coding agent, and the git commands) and the full list.
119120

120-
> **Commit Check**
121+
> <img alt="✖" width="24" height="24" align="top" src="https://raw.githubusercontent.com/commit-check/.github/main/branding/status/failed.png"> **Commit Check failed**
121122
>
122-
> ❌ **2 of 4 checks failed**
123+
> <img alt="✔" width="16" height="16" align="top" src="https://raw.githubusercontent.com/commit-check/.github/main/branding/status/line-passed.png"> Pull request: passed<br>
124+
> <img alt="✖" width="16" height="16" align="top" src="https://raw.githubusercontent.com/commit-check/.github/main/branding/status/line-failed.png"> Commits: 1 of 2 failed<br>
125+
> <img alt="✖" width="16" height="16" align="top" src="https://raw.githubusercontent.com/commit-check/.github/main/branding/status/line-failed.png"> Branch: failed
123126
>
124-
> | Scope | Checked value | Failed checks |
125-
> |---|---|---|
126-
> | [Commit 2/2 (5584f46)](https://github.com/acme/widgets/commit/5584f462cc3c947b2ba8d3d1a5735571803ee159) | `bad msg` | [CC001 message](https://commit-check.com/rules/#cc001) |
127-
> | Branch | `Feature/Add-Login` | [CC201 branch](https://commit-check.com/rules/#cc201) |
127+
> ```diff
128+
> @@ 5584f46 @@
129+
> - bad msg
130+
> # Use <type>(<scope>): <description>
131+
> @@ Branch @@
132+
> - Feature/Add-Login
133+
> + feature/Add-Login
134+
> ```
135+
>
136+
> <sub>Commits: [`5584f46`](https://github.com/acme/widgets/commit/5584f462cc3c947b2ba8d3d1a5735571803ee159) &nbsp;|&nbsp; Rules: [CC001](https://commit-check.com/rules/#cc001) · [CC201](https://commit-check.com/rules/#cc201)</sub>
128137
>
129138
> <details>
130-
> <summary>Show all 4 checks</summary>
139+
> <summary><b>How to fix</b></summary>
140+
>
141+
> **With an AI coding agent.** Paste this prompt:
142+
>
143+
> ```text
144+
> Fix these Commit Check findings without changing any code:
145+
> - Commit 5584f46 "bad msg": Use <type>(<scope>): <description>
146+
> - Branch: change "Feature/Add-Login" to "feature/Add-Login"
147+
> ```
148+
>
149+
> **Commit messages.** Reword it, then force-push:
150+
>
151+
> ```bash
152+
> git commit --amend
153+
> git push --force-with-lease
154+
> ```
155+
>
156+
> **Branch name.** Rename the branch and push it. A pull request cannot change its branch, so open a new one from the renamed branch:
157+
>
158+
> ```bash
159+
> git branch -m feature/Add-Login
160+
> git push -u origin HEAD
161+
> ```
162+
>
163+
> **Next time.** The [pre-commit hook](https://commit-check.com/guides/integrations/#as-a-pre-commit-hook) runs the same rules before you push.
164+
>
165+
> </details>
166+
>
167+
> <details>
168+
> <summary>All 4 checks</summary>
131169
>
132170
> ```text
133171
> Pull request
134-
> ✔ PR title (feat: add login page)
135-
> Commit message
136-
> ✔ Commit 1/2 (d87faca) (feat: add login page)
137-
> ✖ Commit 2/2 (5584f46) (1 failure)
172+
> ✔ title feat: add login page
173+
> Commits
174+
> ✔ d87faca feat: add login page
175+
> ✖ 5584f46 bad msg
138176
> CC001 message
139177
> value: bad msg
140178
> The commit message should follow Conventional Commits.
141179
> Suggest: Use <type>(<scope>): <description>
142180
> Branch
143-
> ✖ Branch (1 failure)
181+
> ✖ branch Feature/Add-Login
144182
> CC201 branch
145183
> value: Feature/Add-Login
146184
> The branch should follow Conventional Branch.
@@ -150,36 +188,28 @@ click away:
150188
>
151189
> </details>
152190
>
153-
> _commit-check &lt;version&gt; · [Rules reference](https://commit-check.com/rules/)_
191+
> <sub>Checked by [Commit Check](https://commit-check.com) &lt;version&gt; · [Rules](https://commit-check.com/rules/) · [Check before you push](https://commit-check.com/guides/integrations/#as-a-pre-commit-hook)</sub>
154192

155193
The rest follow the same layout:
156194

157-
- **Passed:** one line, `✅ All 3 checks passed`, with the tree folded away.
158-
- **Warned:** a rule under `warn` gets its own ⚠ row and counts as passed.
195+
- **Passed:** the heading reads "Commit Check passed", with the list folded away.
196+
- **Warned:** a rule under `warn` gets its own diff under "Warnings", a ⚠ in
197+
the list, and counts as passed.
159198
- **Skipped:** a run where nothing was validated — typically a bot listed in
160-
`ignore_authors` — reads `⊘`, never `✔`.
199+
`ignore_authors` — reads "Commit Check skipped", never passed.
161200

162-
The step log prints the same tree, plus one annotation per finding on the
163-
Files changed tab. With `pr-comments: true` the same report is posted to the
164-
pull request, and later runs edit that one comment instead of adding more.
201+
The step log prints the same list, each group folded under its own result, plus
202+
one annotation per finding on the run page. With `pr-comments: true` the same
203+
report is posted to the pull request, and later runs edit that one comment
204+
instead of adding more.
165205

166206
With `pr-body-ai-attribution: true` and `ai_attribution = "forbid"`, a
167-
description that credits an AI co-author fails the same way, and the report
168-
names the line to remove:
207+
description that credits an AI co-author fails the same way, and the diff is
208+
the line to remove:
169209

170-
> ❌ **1 of 2 checks failed**
171-
>
172-
> | Scope | Checked value | Failed checks |
173-
> |---|---|---|
174-
> | PR description | `Claude Code` | [CC013 ai-attribution](https://commit-check.com/rules/#cc013) |
175-
>
176-
> ```text
177-
> Pull request
178-
> ✖ PR description (1 failure)
179-
> CC013 ai-attribution
180-
> value: Claude Code
181-
> AI attribution is forbidden in this project — detected: Claude Code
182-
> Suggest: In the description, remove "Co-Authored-By: Claude <noreply@anthropic.com>"
210+
> ```diff
211+
> @@ PR description @@
212+
> - Co-Authored-By: Claude <noreply@anthropic.com>
183213
> ```
184214

185215
With `ai-label: true`, a pull request an AI tool wrote also gets the

‎docs/fork-pr-comments.md‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,18 @@ Everything except the comment. The action does not degrade on a fork PR:
1111
| Surface | Fork PR | Why |
1212
|---|---|---|
1313
| The check's pass/fail status | ✅ works | the job's own conclusion |
14-
| `::error` annotations on the **Files changed** tab | ✅ works | workflow commands are written by the runner, not the API |
15-
| The **job summary** — the full report table and details | ✅ works | `$GITHUB_STEP_SUMMARY` is a file on the runner |
14+
| `::error` annotations on the run page | ✅ works | workflow commands are written by the runner, not the API |
15+
| The **job summary** — the full report | ✅ works | `$GITHUB_STEP_SUMMARY` is a file on the runner |
1616
| The `result` output for later steps | ✅ works | `$GITHUB_OUTPUT` is a file on the runner |
1717
| A **PR comment** | ❌ skipped | writing a comment needs the API, and the token is read-only |
1818

1919
So a contributor pushing to a fork already gets the red check, the per-finding annotations
20-
on their diff, and the whole report in the job summary. The action says so in the log:
20+
on the run page, and the whole report in the job summary. The action says so in the log:
2121

2222
```text
2323
::warning::Skipping PR comment: pull requests from forked repositories cannot write
2424
comments via the pull_request event (GITHUB_TOKEN is read-only for forks). The findings
25-
are in this job's summary and in the annotations on the Files changed tab.
25+
are in this job's summary and in the annotations on the run page.
2626
```
2727

2828
(with `job-summary: false` the message names the annotations alone, since there is no

0 commit comments

Comments
 (0)