Skip to content

Commit 44f23cd

Browse files
chore: add commitlint configuration and pre-commit hook for enforcing commit message standards (#285)
* chore: add commitlint configuration and pre-commit hook for enforcing commit message standards * chore: rename commitlint configuration file to use .mjs extension * Update CONTRIBUTING.md Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> --------- Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
1 parent 1ac5deb commit 44f23cd

File tree

9 files changed

+11558
-5936
lines changed

9 files changed

+11558
-5936
lines changed

.github/workflows/ci.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,31 @@ on:
77
branches: [master, main]
88

99
jobs:
10+
commitlint:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
with:
15+
fetch-depth: 0
16+
17+
- name: Setup Node.js
18+
uses: actions/setup-node@v4
19+
with:
20+
node-version: 22.x
21+
22+
- name: Install commitlint
23+
run: |
24+
npm install --save-dev @commitlint/config-conventional @commitlint/cli
25+
26+
- name: Validate PR title
27+
run: |
28+
echo "${{ github.event.pull_request.title }}" | npx commitlint
29+
30+
- name: Validate commits
31+
if: github.event.pull_request.commits > 1
32+
run: |
33+
npx commitlint --from ${{ github.event.pull_request.base.sha }} --to ${{ github.event.pull_request.head.sha }} --verbose
34+
1035
lint:
1136
name: Lint
1237
runs-on: ubuntu-latest

.husky/commit-msg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
npx --no -- commitlint --edit ${1}

.husky/pre-commit

Whitespace-only changes.

AGENTS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,4 +81,4 @@ Problem definition → small, safe change → change review → refactor — rep
8181
-`fix: resolve memory leak in user service`
8282
-`feat(auth): add OAuth2 integration`
8383
-`Fix: Some Message.` (wrong case, ends with period)
84-
-`random: some change` (invalid type)
84+
-`random: some change` (invalid type)

CONTRIBUTING.md

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# Contributing to Vercel Action
2+
3+
We welcome contributions to the Vercel Action project! This document provides guidelines and standards for contributing.
4+
5+
## Development Setup
6+
7+
1. Fork and clone the repository
8+
2. Install dependencies: `pnpm install`
9+
3. Run tests: `npm test`
10+
4. Run linter: `npm run lint`
11+
12+
## Commit Message Guidelines
13+
14+
We use [Conventional Commits](https://www.conventionalcommits.org/) specification for our commit messages. This leads to more readable messages and enables automatic generation of the changelog.
15+
16+
### Commit Message Format
17+
18+
Each commit message consists of a **header**, a **body** and a **footer**. The header has a special format that includes a **type**, a **scope** and a **subject**:
19+
20+
```
21+
<type>[optional scope]: <description>
22+
23+
[optional body]
24+
25+
[optional footer(s)]
26+
```
27+
28+
### Type
29+
30+
Must be one of the following:
31+
32+
- **build**: Changes that affect the build system or external dependencies
33+
- **chore**: Other changes that don't modify src or test files
34+
- **ci**: Changes to our CI configuration files and scripts
35+
- **docs**: Documentation only changes
36+
- **feat**: A new feature
37+
- **fix**: A bug fix
38+
- **perf**: A code change that improves performance
39+
- **refactor**: A code change that neither fixes a bug nor adds a feature
40+
- **revert**: Reverts a previous commit
41+
- **style**: Changes that do not affect the meaning of the code (white-space, formatting, etc)
42+
- **test**: Adding missing tests or correcting existing tests
43+
44+
### Examples
45+
46+
```bash
47+
# Feature with scope
48+
feat(auth): add OAuth2 integration
49+
50+
# Bug fix
51+
fix: resolve memory leak in deployment process
52+
53+
# Breaking change
54+
feat: update to Vercel CLI v30
55+
56+
BREAKING CHANGE: Minimum Node.js version is now 18
57+
```
58+
59+
### Commitlint
60+
61+
This repository uses [commitlint](https://commitlint.js.org/) to ensure all commit messages follow our convention. The commit-msg hook will automatically validate your commit messages.
62+
63+
If your commit is rejected, please review the message format and ensure it follows the convention above.
64+
65+
## Pull Request Process
66+
67+
1. Ensure your PR title follows the Conventional Commits format
68+
2. Update the README.md with details of changes if needed
69+
3. Ensure all tests pass and linting is clean
70+
4. Request review from maintainers
71+
72+
## Code Style
73+
74+
- We use ESLint with the Antfu config for code formatting and linting
75+
- Run `npm run lint` to check your code
76+
- Run `npm run lint:fix` to automatically fix issues
77+
78+
## Testing
79+
80+
- Write tests for new features
81+
- Ensure existing tests pass
82+
- Run `npm test` before submitting PR
83+
84+
## Questions?
85+
86+
Feel free to open an issue for any questions about contributing!

commitlint.config.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export default { extends: ['@commitlint/config-conventional'] }

0 commit comments

Comments
 (0)