Skip to content

Commit 8f65be2

Browse files
authored
Merge pull request #6 from dkmaker/pr-validation
ci(pr): add conventional commit and build validation for pull requests
2 parents 416edfb + d6ae41c commit 8f65be2

File tree

4 files changed

+1391
-126
lines changed

4 files changed

+1391
-126
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Pull Request Validation
2+
3+
on:
4+
pull_request:
5+
branches: [ main ]
6+
7+
jobs:
8+
validate:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v4
12+
with:
13+
fetch-depth: 0
14+
15+
- name: Setup Node.js
16+
uses: actions/setup-node@v4
17+
with:
18+
node-version: '18'
19+
cache: 'npm'
20+
21+
- name: Install dependencies
22+
run: npm ci
23+
24+
- name: Validate Conventional Commits
25+
run: npx commitlint --from ${{ github.event.pull_request.base.sha }} --to ${{ github.event.pull_request.head.sha }} --verbose
26+
27+
- name: Build
28+
run: npm run build
29+
30+
- name: Run Tests
31+
run: |
32+
if [ -f "package.json" ] && grep -q "\"test\":" "package.json"; then
33+
npm test
34+
else
35+
echo "No test script found in package.json"
36+
fi

commitlint.config.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
export default {
2+
extends: ['@commitlint/config-conventional'],
3+
rules: {
4+
'type-enum': [
5+
2,
6+
'always',
7+
[
8+
'build',
9+
'chore',
10+
'ci',
11+
'docs',
12+
'feat',
13+
'fix',
14+
'perf',
15+
'refactor',
16+
'revert',
17+
'style',
18+
'test'
19+
]
20+
],
21+
'type-case': [2, 'always', 'lower-case'],
22+
'type-empty': [2, 'never'],
23+
'scope-case': [2, 'always', 'lower-case'],
24+
'subject-case': [2, 'always', 'lower-case'],
25+
'subject-empty': [2, 'never'],
26+
'subject-full-stop': [2, 'never', '.']
27+
}
28+
}

0 commit comments

Comments
 (0)