Skip to content

Commit

Permalink
ci: add husky hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
dev-ahmadbilal committed Aug 30, 2024
1 parent 3c4669c commit 0e9c3e4
Show file tree
Hide file tree
Showing 7 changed files with 1,151 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx --no -- commitlint --edit "$1"
23 changes: 23 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

# Run linting
npm run lint

echo "Linting passed. Proceeding with the unit tests."

# Run NestJS unit tests
echo "Running NestJS unit tests..."
npm run test

# Capture the exit code of the tests
TEST_RESULT=$?

# Check if tests passed
if [ $TEST_RESULT -ne 0 ]; then
echo "Tests failed. Please fix the issues before committing."
exit $TEST_RESULT
fi

echo "Tests passed. Proceeding with the commit."
exit 0
4 changes: 4 additions & 0 deletions .husky/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npm run build
4 changes: 4 additions & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// eslint-disable-next-line no-undef
module.exports = {
extends: ['@commitlint/config-conventional'],
};
1 change: 1 addition & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// eslint-disable-next-line no-undef
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
Expand Down
Loading

0 comments on commit 0e9c3e4

Please sign in to comment.