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 0f11d1f commit bce681e
Show file tree
Hide file tree
Showing 6 changed files with 808 additions and 34 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: #SSO-123", "ref: #SSO-123, #SSO-124".)'
}
}
}
};
9 changes: 7 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,19 @@ 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: Run linters (eslint, markdownlint, commitlint)
run: |
npm run eslint
npm run markdownlint
npx commitlint --from=$GITHUB_BASE_REF
- 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"
Loading

0 comments on commit bce681e

Please sign in to comment.