Skip to content

Commit 046b66d

Browse files
authored
feat: name the commit in each finding, print the fix, add warn status (#278)
1 parent 7ae61d9 commit 046b66d

4 files changed

Lines changed: 686 additions & 119 deletions

File tree

README.md

Lines changed: 55 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -234,10 +234,29 @@ Structured check results as JSON, available to downstream steps via
234234
Use `dry-run` (or `continue-on-error`) when a downstream step is meant to
235235
read the result and decide for itself.
236236

237-
Each scope carries the check outcomes (`rule_id`, `check`, `status`, `value`,
238-
`error`, `suggest`, `docs_url`) exactly as produced by
239-
`commit-check --format json`, so downstream jobs can build their own reports
240-
or gate on individual rules.
237+
The top-level `status` is one of:
238+
239+
| `status` | Meaning | Exit code |
240+
|---|---|---|
241+
| `pass` | every check passed | 0 |
242+
| `warn` | nothing failed, but a rule listed under the config's `warn` found something | 0 |
243+
| `skip` | every check declined to run (for example the author is in `ignore_authors`) | 0 |
244+
| `fail` | at least one check failed | 1 (0 with `dry-run`) |
245+
246+
Only `fail` is ever non-zero; `warn` exists so a downstream step can react to a
247+
bent-but-not-broken policy without the run turning red:
248+
249+
```yaml
250+
- if: fromJSON(steps.commit-check.outputs.result).status == 'warn'
251+
run: echo "passed with warnings"
252+
```
253+
254+
Each entry in `scopes` has a `label` (`PR title`, `Commit 2/3`, `Branch`, ...),
255+
a `status` like the ones above, a `sha` (the full hash of the commit a
256+
`Commit N/M` or `Commit message` scope checked; empty for the others) and the
257+
check outcomes (`rule_id`, `check`, `status`, `value`, `error`, `suggest`,
258+
`fix`, `docs_url`) exactly as produced by `commit-check --format json`, so
259+
downstream jobs can build their own reports or gate on individual rules.
241260

242261
## GitHub Action Job Summary
243262

@@ -261,7 +280,7 @@ Passing runs stay to one line, with the detail folded away:
261280
> ```text
262281
> Commit message
263282
> ✔ PR title (feat: add login page)
264-
> ✔ Commit 1/2 (feat: add login page)
283+
> ✔ Commit 1/2 (d87faca) (feat: add login page)
265284
> Branch
266285
> ✔ Branch (feature/add-login)
267286
> ```
@@ -273,35 +292,37 @@ Passing runs stay to one line, with the detail folded away:
273292
### Failure Job Summary
274293

275294
Failures open with a count, then a table of only the scopes that failed — every
276-
rule ID links to its documentation — with the full tree still one click away:
295+
rule ID links to its documentation, and every commit to itself — with the full
296+
tree still one click away:
277297

278298
> **Commit Check**
279299
>
280300
> ❌ **2 of 4 checks failed**
281301
>
282302
> | Scope | Checked value | Failed checks |
283303
> |---|---|---|
284-
> | Commit 2/2 | `bad msg` | [CC001 message](https://commit-check.com/rules/#cc001) |
285-
> | Branch | `my-changes` | [CC201 branch](https://commit-check.com/rules/#cc201) |
304+
> | [Commit 2/2 (5584f46)](https://github.com/acme/widgets/commit/5584f462cc3c947b2ba8d3d1a5735571803ee159) | `bad msg` | [CC001 message](https://commit-check.com/rules/#cc001) |
305+
> | Branch | `Feature/Add-Login` | [CC201 branch](https://commit-check.com/rules/#cc201) |
286306
>
287307
> <details>
288308
> <summary>Show all 4 checks</summary>
289309
>
290310
> ```text
291311
> Commit message
292312
> ✔ PR title (feat: add login page)
293-
> ✔ Commit 1/2 (feat: add login page)
294-
> ✖ Commit 2/2 (1 failure)
313+
> ✔ Commit 1/2 (d87faca) (feat: add login page)
314+
> ✖ Commit 2/2 (5584f46) (1 failure)
295315
> CC001 message
296316
> value: bad msg
297317
> The commit message should follow Conventional Commits.
298318
> Suggest: Use <type>(<scope>): <description>
299319
> Branch
300320
> ✖ Branch (1 failure)
301321
> CC201 branch
302-
> value: my-changes
322+
> value: Feature/Add-Login
303323
> The branch should follow Conventional Branch.
304-
> Suggest: Use <type>/<description> with allowed types
324+
> Suggest: Rename the branch to "feature/Add-Login" (git branch -m feature/Add-Login)
325+
> Fix: feature/Add-Login
305326
> ```
306327
>
307328
> </details>
@@ -312,6 +333,26 @@ A scope is one thing that was checked — a commit message, the branch, the auth
312333
— not one rule evaluation, so the total matches the ✔/✖ lines you can count and
313334
does not grow with the number of rules in your config.
314335

336+
A commit scope names its commit by short hash, and the table row links to it,
337+
so a reviewer can jump from a failed row straight to the offending commit.
338+
`Fix:` is the corrected text commit-check proposes whenever the correction is
339+
mechanical (a capitalised subject, a dropped WIP marker, a missing sign-off
340+
trailer); when the suggestion is nothing more than "use the fix", only `Fix:`
341+
is shown.
342+
343+
The step log prints the same tree, then one annotation per finding — shown in
344+
the run summary and on the Files changed tab — whose message carries the
345+
commit, the checked value, the suggestion and the fix on separate lines:
346+
347+
```text
348+
::error title=CC001 message::Commit 2/2 (5584f46): The commit message should follow Conventional Commits.%0Avalue: bad msg%0ASuggest: Use <type>(<scope>): <description>
349+
::error title=CC201 branch::Branch: The branch should follow Conventional Branch.%0Avalue: Feature/Add-Login%0ASuggest: Rename the branch to "feature/Add-Login" (git branch -m feature/Add-Login)%0AFix: feature/Add-Login
350+
✖ commit-check: 2 of 4 checks failed
351+
```
352+
353+
The verdict is a plain line rather than another `::error`, so the run's error
354+
count equals the number of findings.
355+
315356
### Skipped Job Summary
316357

317358
Some runs validate nothing at all — most commonly when the commit author is
@@ -383,7 +424,8 @@ A warned scope is marked `⚠`, never `✖`, and a real failure elsewhere still
383424
fails the run — the verdict then reads `❌ **N of M checks failed**, K
384425
warnings` and both tables appear. In the step log, a warning becomes a
385426
`::warning` annotation rather than `::error`, so it never counts toward the
386-
run's error count.
427+
run's error count. The [`result`](#result) output reports the run as
428+
`"status": "warn"`, with exit code 0.
387429
388430
This needs commit-check 2.17.0 or newer, which reports `"status": "warn"` in
389431
its JSON. Against an older engine, or a config with no `warn` list, no check

action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ inputs:
3939
default: false
4040
outputs:
4141
result:
42-
description: Structured check results as JSON (status + per-scope checks). Consume with fromJSON(steps.<id>.outputs.result).
42+
description: Structured check results as JSON (status pass/warn/skip/fail + per-scope label, sha and checks). Consume with fromJSON(steps.<id>.outputs.result).
4343
# Composite actions do not forward step outputs automatically: without this
4444
# mapping (and the step id it refers to) the output is always the empty
4545
# string, and fromJSON('') fails the calling workflow.

0 commit comments

Comments
 (0)