Skip to content

Commit 0c96f88

Browse files
authored
ci: improve commitlint failure messaging for developers (#653)
Add a dedicated help step that prints a clear, actionable guide when commit message linting fails. Includes the required format, all allowed types, realistic examples, and tips for amending or rebasing commits.
1 parent 1f2fadb commit 0c96f88

1 file changed

Lines changed: 50 additions & 1 deletion

File tree

.github/workflows/commitlint.yaml

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,53 @@ jobs:
2727
run: npm install --save-dev @commitlint/{cli,config-conventional}
2828

2929
- name: Lint commits
30-
run: npx commitlint --from ${{ github.event.pull_request.base.sha }} --to ${{ github.event.pull_request.head.sha }} --verbose
30+
id: lint
31+
run: |
32+
npx commitlint --from ${{ github.event.pull_request.base.sha }} --to ${{ github.event.pull_request.head.sha }} --verbose 2>&1 | tee commitlint-output.txt
33+
continue-on-error: true
34+
35+
- name: Show help on failure
36+
if: steps.lint.outcome == 'failure'
37+
run: |
38+
echo ""
39+
echo "============================================"
40+
echo " ❌ Commit message lint failed"
41+
echo "============================================"
42+
echo ""
43+
echo "One or more commit messages in this PR don't follow the"
44+
echo "Conventional Commits format required by this project."
45+
echo ""
46+
echo "Required format:"
47+
echo ""
48+
echo " <type>: <description> (max 120 chars for the full header)"
49+
echo ""
50+
echo "Allowed types:"
51+
echo " feat, fix, docs, example, examples, chore,"
52+
echo " refactor, perf, test, ci, revert"
53+
echo ""
54+
echo "Examples:"
55+
echo " feat: add support for streaming responses"
56+
echo " fix: resolve timeout on large payloads"
57+
echo " docs: update configuration guide"
58+
echo " chore: bump dependency versions"
59+
echo " refactor: simplify request routing logic"
60+
echo ""
61+
echo "Optional body/footer (no line-length limit):"
62+
echo ""
63+
echo " feat: add retry logic for failed requests"
64+
echo " "
65+
echo " Adds exponential backoff with jitter when upstream"
66+
echo " returns 5xx. Configurable via RETRY_COUNT env var."
67+
echo " "
68+
echo " Closes #142"
69+
echo ""
70+
echo "Tip: To fix the most recent commit message, run:"
71+
echo " git commit --amend"
72+
echo ""
73+
echo "To reword older commits in this PR, use interactive rebase:"
74+
echo " git rebase -i origin/main"
75+
echo ""
76+
echo "For the full spec, see: https://www.conventionalcommits.org"
77+
echo "============================================"
78+
echo ""
79+
exit 1

0 commit comments

Comments
 (0)