Skip to content

Commit c4b6330

Browse files
authored
ci: Enforce conventional commit structure for commit messages #1 (cadence-workflow#7278)
<!-- Tell your future self why have you made these changes --> **Why?** Our existing commit process: - doesn't immediately convey when there are breaking changes to the releaser - doesn't provide information about how to categorize changes in each release - is entirely manual preparing releases - doesn't always give "good" information about what is contained within a commit - doesn't give a good idea of the risk of a given commit Furthermore, users have stated that our release notes do not provide easily discernable information about what is in a release, including: - if there are breaking changes - which features are in a given release - why they should upgrade Adding conventional commits aims to tackle these pieces and make contributing to the repository significantly easier. This PR adds a linter that will give feedback to developers on their commit message style, and will eventually enforce conventional commits for each merge PR. <!-- How have you verified this change? Tested locally? Added a unit test? Checked in staging env? --> **How did you test it?** Currently testing. <!-- Assuming the worst case, what can be broken when deploying this change to production? --> **Potential risks** Adding this GitHub action may have unintended consequences for the commit process, and should be monitored to ensure that it doesn't inhibit merging to the repository. <!-- Is it notable for release? e.g. schema updates, configuration or data migration required? If so, please mention it, and also update CHANGELOG.md --> **Release notes** N/A <!-- Is there any documentation updates should be made for config, https://cadenceworkflow.io/docs/operation-guide/setup/ ? If so, please open an PR in https://github.com/cadence-workflow/cadence-docs --> **Documentation Changes** ⚠️ TODO
1 parent e446b5c commit c4b6330

File tree

1 file changed

+72
-0
lines changed

1 file changed

+72
-0
lines changed

.github/workflows/semantic-pr.yml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: Semantic Pull Request
2+
3+
on:
4+
pull_request:
5+
types:
6+
- opened
7+
- edited
8+
- synchronize
9+
10+
jobs:
11+
semantic-pr:
12+
name: Validate PR title follows conventional commit format
13+
runs-on: ubuntu-latest
14+
# TODO: Remove this once we commit to conventional commits
15+
continue-on-error: true
16+
17+
steps:
18+
- name: Validate PR title
19+
id: lint_pr_title
20+
uses: amannn/action-semantic-pull-request@v5.4.0
21+
with:
22+
# Allow standard conventional commit types
23+
types: |
24+
fix
25+
feat
26+
docs
27+
style
28+
refactor
29+
perf
30+
test
31+
chore
32+
ci
33+
build
34+
# TODO: Remove this once we've decided on scopes
35+
requireScope: false
36+
# Skip validation for certain labels if needed
37+
ignoreLabels: |
38+
skip-commit-format
39+
env:
40+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
41+
42+
- name: Comment on PR if validation fails
43+
if: steps.lint_pr_title.outputs.error_message != null
44+
uses: actions/github-script@v7
45+
with:
46+
script: |
47+
github.rest.issues.createComment({
48+
issue_number: context.issue.number,
49+
owner: context.repo.owner,
50+
repo: context.repo.repo,
51+
body: `⚠️ **Semantic PR Check Failed**
52+
53+
**Error Details:**
54+
\`\`\`
55+
${{ steps.lint_pr_title.outputs.error_message }}
56+
\`\`\`
57+
58+
**Required Format:**
59+
\`\`\`
60+
<type>: <description>
61+
\`\`\`
62+
63+
**Allowed types:** fix, feat, docs, style, refactor, perf, test, chore, ci, build
64+
65+
**Examples:**
66+
- \`feat: add user authentication system\`
67+
- \`fix: resolve memory leak in worker pool\`
68+
- \`docs: update API documentation\`
69+
- \`test: add integration tests for auth flow\`
70+
71+
This is currently a **warning only** and won't block your PR from being merged.`
72+
})

0 commit comments

Comments
 (0)