-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' of github.com:HaUI-HIT-AnodisO/Control-Vaccina…
…tion-Services into ai
- Loading branch information
Showing
9 changed files
with
2,220 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
name: Commitlint | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- '**' # Kiểm tra commit trên tất cả các nhánh trước khi merge | ||
push: | ||
branches: | ||
- '**' # Kiểm tra commit khi đẩy lên bất kỳ nhánh nào | ||
|
||
jobs: | ||
commitlint: | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
# Bước 1: Checkout mã nguồn | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 # Lấy toàn bộ lịch sử commit | ||
|
||
# Bước 2: Cài đặt các phụ thuộc cần thiết | ||
- name: Install dependencies | ||
run: | | ||
sudo apt update | ||
sudo apt install -y git curl | ||
curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash - | ||
sudo DEBIAN_FRONTEND=noninteractive apt install -y nodejs | ||
npm install | ||
# Bước 3: In ra phiên bản của các công cụ | ||
- name: Print versions | ||
run: | | ||
git --version | ||
node --version | ||
npm --version | ||
npx commitlint --version | ||
# Bước 4: Cài đặt commitlint nếu chưa cài đặt | ||
- name: Install commitlint | ||
run: | | ||
npm install @commitlint/cli @commitlint/config-conventional | ||
# Bước 5: Kiểm tra commit trên Pull Request (PR) | ||
- name: Validate PR commits with commitlint | ||
if: github.event_name == 'pull_request' | ||
run: | | ||
npx commitlint --from ${{ github.event.pull_request.head.sha }}~${{ github.event.pull_request.commits }} --to ${{ github.event.pull_request.head.sha }} --verbose | ||
# Bước 6: Kiểm tra commit của push | ||
- name: Validate push commit with commitlint | ||
if: github.event_name == 'push' | ||
run: | | ||
npx commitlint --from HEAD~1 --to HEAD --verbose |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/node_modules | ||
__pycache__/ | ||
*.pyc | ||
*.jpg | ||
*.log | ||
env/ | ||
target/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#!/bin/sh | ||
npx --no-install commitlint --edit "$1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/usr/bin/env sh | ||
. "$(dirname -- "$0")/_/husky.sh" | ||
|
||
# Format and lint code | ||
echo "🪄 In the process of formatting and linting code." | ||
npx lint-staged || exit 1 # Dừng lại nếu linting gặp lỗi | ||
|
||
echo "✨ All code is beautiful ✨" | ||
|
||
# Get the current branch name | ||
branch_name=$(git rev-parse --abbrev-ref HEAD) | ||
|
||
# Define branch naming convention regex | ||
branch_regex="^(feature|bugfix|hotfix|release|docs|ci)(\/[a-z0-9._-]+)?$" | ||
|
||
# Allowed email for protected branches | ||
allowed_email="[email protected]" | ||
|
||
# Check if pushing to a protected branch | ||
if [ "$branch_name" = "develop" ] || [ "$branch_name" = "uat" ] || [ "$branch_name" = "prod" ]; then | ||
email=$(git config user.email) | ||
|
||
if [ "$email" != "$allowed_email" ]; then | ||
echo "⛔️ Error: User '$email' is not allowed to push to the '$branch_name' branch." | ||
exit 1 | ||
fi | ||
echo "✅ Skipping branch name check for '$branch_name' with user email '$email'." | ||
|
||
else | ||
# Check if the branch name matches the convention | ||
if ! echo "$branch_name" | grep -Eq "$branch_regex"; then | ||
echo "⛔️ Error: Branch name '$branch_name' does not follow the naming convention." | ||
echo "Allowed patterns: feature/*, bugfix/*, hotfix/*, release/*, docs/*" | ||
exit 1 | ||
fi | ||
fi | ||
|
||
# Allow the commit if all checks pass | ||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"arrowParens": "always", | ||
"tabWidth": 2, | ||
"semi": false, | ||
"printWidth": 100, | ||
"bracketSameLine": true, | ||
"jsxSingleQuote": true, | ||
"bracketSpacing": true, | ||
"useTabs": false, | ||
"singleQuote": true, | ||
"embeddedLanguageFormatting": "auto", | ||
"proseWrap": "preserve", | ||
"trailingComma": "all", | ||
"quoteProps": "as-needed" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module.exports = { | ||
extends: ['@commitlint/config-conventional'], | ||
rules: { | ||
'type-enum': [2, 'always', ['feat', 'fix', 'chore', 'docs', 'style', 'refactor', 'test']], | ||
'subject-case': [2, 'never', ['sentence-case']], | ||
'scope-case': [2, 'always', 'lower-case'], | ||
'header-max-length': [2, 'always', 72], | ||
}, | ||
} |
Oops, something went wrong.