diff --git a/.github/workflows/check-commit-convention.yml b/.github/workflows/check-commit-convention.yml new file mode 100644 index 0000000..04e69ae --- /dev/null +++ b/.github/workflows/check-commit-convention.yml @@ -0,0 +1,52 @@ +name: Check Commit Message Convention + +on: pull_request + +jobs: + check-commit-message: + runs-on: ubuntu-latest + steps: + - name: Checkout code with full history + uses: actions/checkout@v4 + with: + fetch-depth: 0 # 전체 Git 히스토리를 가져옴 + + - name: Get base branch + run: echo "BASE_BRANCH=${{ github.base_ref }}" >> $GITHUB_ENV + + - name: Get all new commit messages in PR + run: | + commit_messages=$(git log --format=%s origin/$BASE_BRANCH..HEAD) + echo "Commit Messages in PR:" + echo "$commit_messages" + echo "COMMIT_MESSAGES<> $GITHUB_ENV + echo "$commit_messages" >> $GITHUB_ENV + echo "EOF" >> $GITHUB_ENV + + - name: Validate commit messages + run: | + invalid_commits=0 + echo "🔍 Checking commit message convention..." + while IFS= read -r commit_message; do + # "Merge"로 시작하는 메시지는 검사에서 제외 + if [[ "$commit_message" =~ ^Merge ]]; then + echo "⚡ Skipping merge commit: $commit_message" + continue + fi + + # Commit message validation + if [[ ! "$commit_message" =~ ^(feat|fix|docs|style|refactor|test|chore)(\(.+\))?!?:\ .+ ]]; then + echo "❌ Invalid commit message: $commit_message" + invalid_commits=$((invalid_commits + 1)) + else + echo "✅ Valid commit message: $commit_message" + fi + done <<< "$COMMIT_MESSAGES" + + if [[ $invalid_commits -gt 0 ]]; then + echo "🚨 Some commit messages do not follow the convention!" + echo "Example: 'feat: add login API'" + exit 1 + fi + + echo "🎉 All commit messages follow the convention!" diff --git a/.github/workflows/check-indent.yml b/.github/workflows/check-indent.yml index f7bfa59..d09c48d 100644 --- a/.github/workflows/check-indent.yml +++ b/.github/workflows/check-indent.yml @@ -16,6 +16,9 @@ jobs: run: | echo "[FORMAT]" > .pylintrc echo "max-nested-blocks=2" >> .pylintrc + echo "[MESSAGES CONTROL]" >> .pylintrc + echo "disable=all" >> .pylintrc + echo "enable=format" >> .pylintrc - name: Run pylint run: pylint --rcfile=.pylintrc src/