Skip to content

Commit d3da4ee

Browse files
bokelleyclaude
andauthored
ci: add conventional commit validation to CI pipeline (#24)
* ci: add conventional commit validation to CI pipeline Add a new CI job that validates all commits in pull requests follow Conventional Commits format. This ensures compatibility with release-please and prevents releases from failing due to unparseable commit messages. The validator checks for: - Standard types (feat, fix, docs, style, refactor, perf, test, build, ci, chore, revert) - Optional scope in parentheses - Optional breaking change indicator (!) - Proper format: type(scope)!: description Additionally validates PR titles using action-semantic-pull-request. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * fix: skip merge commits in conventional commit validation GitHub automatically creates merge commits for PR branches that don't follow conventional commit format. These should be skipped during validation as they're automatically generated and don't affect release-please's parsing of actual commits. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent e0e9adb commit d3da4ee

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

.github/workflows/ci.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,56 @@ jobs:
3939
run: |
4040
pytest tests/ -v --cov=src/adcp --cov-report=term-missing
4141
42+
conventional-commits:
43+
name: Validate conventional commit format
44+
runs-on: ubuntu-latest
45+
if: github.event_name == 'pull_request'
46+
47+
steps:
48+
- uses: actions/checkout@v4
49+
with:
50+
fetch-depth: 0
51+
52+
- name: Validate PR commits
53+
uses: amannn/action-semantic-pull-request@v5
54+
env:
55+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
56+
57+
- name: Validate individual commits
58+
run: |
59+
# Get the base branch
60+
BASE_SHA=$(git merge-base origin/${{ github.base_ref }} HEAD)
61+
62+
# Check each commit since the base
63+
echo "Validating commits since $BASE_SHA..."
64+
git log --format="%H %s" $BASE_SHA..HEAD | while read sha message; do
65+
# Skip merge commits (GitHub automatically creates these)
66+
if echo "$message" | grep -qE '^Merge [0-9a-f]+ into [0-9a-f]+'; then
67+
echo "⊙ Skipping merge commit: $sha"
68+
continue
69+
fi
70+
71+
# Check if message matches conventional commit format
72+
if ! echo "$message" | grep -qE '^(feat|fix|docs|style|refactor|perf|test|build|ci|chore|revert)(\([^)]+\))?!?: .+'; then
73+
echo "❌ Commit $sha does not follow Conventional Commits format:"
74+
echo " $message"
75+
echo ""
76+
echo "Expected format: <type>[optional scope]: <description>"
77+
echo "Types: feat, fix, docs, style, refactor, perf, test, build, ci, chore, revert"
78+
echo ""
79+
echo "Examples:"
80+
echo " feat: add new feature"
81+
echo " fix: resolve bug in parser"
82+
echo " feat(api): add new endpoint"
83+
echo " feat!: breaking change"
84+
exit 1
85+
else
86+
echo "✓ $sha: $message"
87+
fi
88+
done
89+
echo ""
90+
echo "✅ All commits follow Conventional Commits format"
91+
4292
schema-check:
4393
name: Validate schemas are up-to-date
4494
runs-on: ubuntu-latest

0 commit comments

Comments
 (0)