Skip to content

Commit

Permalink
chore: setup commitlint and husky git hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
zavoloklom committed Dec 6, 2024
1 parent 95a427c commit 067bb49
Show file tree
Hide file tree
Showing 8 changed files with 820 additions and 37 deletions.
105 changes: 105 additions & 0 deletions .commitlintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
module.exports = {
extends: ['@commitlint/config-conventional'],
rules: {
'type-enum': [
2,
'always',
[
'feat',
'fix',
'refactor',
'perf',
'test',
'ci',
'deps',
'docs',
'chore',
'revert',
'release'
],
],
},
prompt: {
questions: {
type: {
description: "Select the type of change that you're committing",
enum: {
feat: {
description: 'A new feature',
title: 'Features',
emoji: '✨'
},
fix: {
description: 'A bug fix',
title: 'Bug Fixes',
emoji: '🐛'
},
docs: {
description: 'Documentation only changes',
title: 'Documentation',
emoji: '📚'
},
refactor: {
description: 'A code change that neither fixes a bug nor adds a feature (including formatting)',
title: 'Code Refactoring',
emoji: '📦'
},
perf: {
description: 'A code change that improves performance',
title: 'Performance Improvements',
emoji: '🚀'
},
test: {
description: 'Adding missing tests or correcting existing tests',
title: 'Tests',
emoji: '🚨'
},
ci: {
description: 'Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs)',
title: 'Continuous Integrations',
emoji: '⚙️'
},
deps: {
description: 'Any changes in dependencies',
title: 'Dependencies',
emoji: '📦'
},
chore: {
description: "Other changes that don't modify src or test files",
title: 'Chores',
emoji: '♻️'
},
revert: {
description: 'Reverts a previous commit',
title: 'Reverts',
emoji: '🗑'
},
release: {
description: 'Release new version. DO NOT USE IT.',
title: 'Release',
emoji: '🚀'
}
}
},
scope: {
description: 'What is the scope of this change (e.g. component or file name)'
},
subject: {
description: 'Write a short, imperative tense description of the change'
},
body: { description: 'Provide a longer description of the change' },
isBreaking: { description: 'Are there any breaking changes?' },
breakingBody: {
description: 'A BREAKING CHANGE commit requires a body. Please enter a longer description of the commit itself'
},
breaking: { description: 'Describe the breaking changes' },
isIssueAffected: { description: 'Does this change affect any open issues?' },
issuesBody: {
description: 'If issues are closed, the commit requires a body. Please enter a longer description of the commit itself'
},
issues: {
description: 'Add issue references (e.g. "ref: #123", "ref: #123, #124".)'
}
}
}
};
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ updates:
target-branch: "main"
commit-message:
prefix: "deps"
prefix-development: "chore(deps-dev)"
prefix-development: "deps(dev)"
ignore:
- dependency-name: "@types/node"
update-types: ["version-update:semver-major"]
Expand Down
14 changes: 12 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,24 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Node.js with Cache and Install
uses: ./.github/actions/install-dependencies
with:
node-version: '20.18.0'

- name: Run linter
run: npm run lint
- name: Fetch main branch and run commitlint
if: github.event_name == 'pull_request'
run: |
git fetch origin main
npx commitlint --from=origin/main
- name: Run linters (eslint, markdownlint)
run: |
npm run eslint
npm run markdownlint
- name: Run Hadolint on Dockerfile
uses: hadolint/[email protected]
Expand Down
4 changes: 4 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx --no-install commitlint --edit "$1"
8 changes: 6 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,12 @@ Before making contributions, ensure the following:
errors.
- **Testing**: All changes must be accompanied by passing tests. Add new tests if you are adding functionality or fix
existing tests if you are changing code.
- **Conventional Commits**: Commit your changes using the [Conventional Commits](https://www.conventionalcommits.org)
format. This standardization helps automate the version management and changelog generation.
- **Commit Convention**: Commit your changes using the [Conventional Commits](https://www.conventionalcommits.org)
format. This standardization helps automate the version management and changelog generation. The commit message
rules are defined in the [.commitlintrc.cjs](./.commitlintrc.cjs) file, which you can refer to for detailed
guidelines.

## Commit Convention

## How to Add a New Rule

Expand Down
Loading

0 comments on commit 067bb49

Please sign in to comment.