Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
indent_style = space
indent_size = 4

[*.py]
indent_size = 4
max_line_length = 88

[*.{yml,yaml,toml,json}]
indent_size = 2

[*.md]
trim_trailing_whitespace = false

[Makefile]
indent_style = tab
31 changes: 31 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: CI

on:
push:
branches: [main]
pull_request:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6

- uses: actions/setup-python@v6
with:
python-version: "3.12"
cache: "pip"
cache-dependency-path: pyproject.toml

- name: Create venv and install dev dependencies
run: |
python -m venv .venv
.venv/bin/pip install --upgrade pip
.venv/bin/pip install -e ".[dev]"

- name: Run all checks (lint + format check + mypy + pytest + coverage)
run: make ci-check
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,10 @@ dmypy.json
*.iml
*.iws

# VSCode
.vscode/
# VSCode (팀 공유 설정만 추적)
.vscode/*
!.vscode/settings.json
!.vscode/extensions.json
*.code-workspace

# Vim
Expand Down
55 changes: 52 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
default_language_version:
python: python3.12

default_stages: [pre-commit] # commit 단계에서만 실행
fail_fast: false # 오류 발생 시 즉시 종료
default_stages: [pre-commit]
fail_fast: false

repos:
# ==========================================
Expand Down Expand Up @@ -45,6 +45,16 @@ repos:
- id: detect-private-key
name: "Private 키 탐지"

# AWS 자격증명 탐지
- id: detect-aws-credentials
name: "AWS 자격증명 탐지"
args: [--allow-missing-credentials]

# 대용량 파일 차단 (1MB)
- id: check-added-large-files
name: "대용량 파일 차단"
args: [--maxkb=1024]

# ==========================================
# 2. Ruff Linter
# ==========================================
Expand All @@ -64,11 +74,50 @@ repos:
name: "Ruff 포매터"

# ==========================================
# 4. Commitizen
# 4. 자동 수정 결과를 같은 커밋에 stage
# (반드시 ruff/ruff-format 다음에 위치)
# stdlib만 사용하므로 어떤 python3든 OK.
# ==========================================
- repo: local
hooks:
- id: stage-fixes
name: "자동 수정 파일 stage"
entry: python3 scripts/stage_fixes.py
language: system
stages: [pre-commit]
pass_filenames: true

# ==========================================
# 5. Commitizen (commit-msg 단계)
# ==========================================
- repo: https://github.com/commitizen-tools/commitizen
rev: v3.29.1
hooks:
- id: commitizen
name: "Commitizen 메시지 검증"
stages: [commit-msg]

# ==========================================
# 6. Pre-push 게이트 (테스트 + 타입체크)
# 빠른 모드 — 30s 이내로 --no-verify 우회 유혹 차단.
# 80% 커버리지 게이트는 CI에서만 적용.
# 프로젝트 venv 경로를 명시 (Makefile과 일관).
# ==========================================
- repo: local
hooks:
- id: pytest-push
name: "pytest (push 전, 빠른 모드)"
entry: .venv/bin/python -m pytest -x --no-cov -q
language: system
stages: [pre-push]
pass_filenames: false
always_run: true

- id: mypy-push
name: "mypy (push 전)"
entry: .venv/bin/python -m mypy src
language: system
types: [python]
stages: [pre-push]
pass_filenames: false
always_run: true
9 changes: 9 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"recommendations": [
"charliermarsh.ruff",
"ms-python.python",
"ms-python.mypy-type-checker",
"tamasfe.even-better-toml",
"EditorConfig.EditorConfig"
]
}
15 changes: 15 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"[python]": {
"editor.defaultFormatter": "charliermarsh.ruff",
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll": "explicit",
"source.organizeImports": "explicit"
}
},
"python.analysis.typeCheckingMode": "strict",
"python.testing.pytestEnabled": true,
"python.testing.pytestArgs": ["tests"],
"files.insertFinalNewline": true,
"files.trimTrailingWhitespace": true
}
62 changes: 54 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ COMMITIZEN := $(VENV_BIN)/cz
.DEFAULT_GOAL := help

.PHONY: help install install-dev install-hooks clean lint format \
check ci-check validate test typecheck commit bump-version pre-commit run-all update-hooks
check ci-check validate test typecheck commit bump-version \
pre-commit run-all update-hooks quick-check full-check list-checks init

# ============================================================================
# help - 사용 가능한 명령어 목록
Expand All @@ -65,10 +66,16 @@ help:
@echo "$(COLOR_GREEN)통합 명령어:$(COLOR_RESET)"
@echo " make check - 코드 스타일 검사 (lint+format)"
@echo " make validate - 커밋 전 전체 검증 (lint+format+test+typecheck)"
@echo " make ci-check - CI용 검사 (수정 없이 검증만)"
@echo " make ci-check - CI용 검사 (수정 없이 검증만, 80%+ coverage)"
@echo " make quick-check - commit 시뮬 (pre-commit 단계 훅)"
@echo " make full-check - push 시뮬 (pre-commit + pre-push 단계 훅)"
@echo " make list-checks - 정의된 모든 검사 목록 보기"
@echo " make pre-commit - pre-commit 훅 수동 실행"
@echo " make run-all - 모든 파일에 pre-commit 실행"
@echo ""
@echo "$(COLOR_GREEN)프로젝트 초기화:$(COLOR_RESET)"
@echo " make init NAME=foo - your_project 플레이스홀더를 'foo'로 일괄 치환"
@echo ""
@echo "$(COLOR_GREEN)Git 관련:$(COLOR_RESET)"
@echo " make commit - 대화형 커밋 생성 (Conventional Commits)"
@echo " make bump-version - 버전 자동 증가 및 태그 생성"
Expand Down Expand Up @@ -105,9 +112,10 @@ install-dev:
# ============================================================================
install-hooks:
@echo "$(COLOR_BOLD)$(COLOR_BLUE)Git 훅 설치 중...$(COLOR_RESET)"
@$(PRE_COMMIT) install
@$(PRE_COMMIT) install --hook-type pre-commit
@$(PRE_COMMIT) install --hook-type commit-msg
@echo "$(COLOR_GREEN)✓ Git 훅 설치 완료$(COLOR_RESET)"
@$(PRE_COMMIT) install --hook-type pre-push
@echo "$(COLOR_GREEN)✓ Git 훅 설치 완료 (pre-commit, commit-msg, pre-push)$(COLOR_RESET)"

# ============================================================================
# clean - 임시 파일 및 캐시 삭제
Expand Down Expand Up @@ -161,22 +169,22 @@ validate: lint format test typecheck
@echo ""

# ============================================================================
# ci-check - CI용 검사 (수정 없이 검증만)
# ci-check - CI용 검사 (수정 없이 검증만, coverage 80% 게이트)
# ============================================================================
ci-check:
@echo "$(COLOR_BOLD)$(COLOR_BLUE)CI 검사 중...$(COLOR_RESET)"
@$(RUFF) check $(ALL_DIRS) --no-fix
@$(RUFF) format $(ALL_DIRS) --check
@$(VENV_BIN)/mypy $(SRC_DIR)
@$(VENV_BIN)/pytest --no-header -q
@$(VENV_BIN)/pytest --cov=$(SRC_DIR) --cov-report=term-missing --no-header -q
@echo "$(COLOR_GREEN)✓ CI 검사 통과$(COLOR_RESET)"

# ============================================================================
# test - 테스트 실행
# test - 테스트 실행 (coverage 포함, 80% 게이트)
# ============================================================================
test:
@echo "$(COLOR_BOLD)$(COLOR_BLUE)테스트 실행 중...$(COLOR_RESET)"
@$(VENV_BIN)/pytest
@$(VENV_BIN)/pytest --cov=$(SRC_DIR) --cov-report=term-missing
@echo "$(COLOR_GREEN)✓ 테스트 완료$(COLOR_RESET)"

# ============================================================================
Expand Down Expand Up @@ -235,6 +243,44 @@ update-hooks:
@$(PRE_COMMIT) autoupdate
@echo "$(COLOR_GREEN)✓ 훅 업데이트 완료$(COLOR_RESET)"

# ============================================================================
# quick-check - commit 시뮬레이션 (pre-commit 단계 훅 전체)
# ============================================================================
quick-check:
@echo "$(COLOR_BOLD)$(COLOR_BLUE)Quick check (commit 시뮬)...$(COLOR_RESET)"
@$(PRE_COMMIT) run --all-files --hook-stage pre-commit
@echo "$(COLOR_GREEN)✓ commit 단계 통과$(COLOR_RESET)"

# ============================================================================
# full-check - push 시뮬레이션 (pre-commit + pre-push 모두)
# ============================================================================
full-check:
@echo "$(COLOR_BOLD)$(COLOR_BLUE)Full check (push 시뮬)...$(COLOR_RESET)"
@$(PRE_COMMIT) run --all-files --hook-stage pre-commit
@$(PRE_COMMIT) run --all-files --hook-stage pre-push
@echo "$(COLOR_GREEN)✓ commit + push 단계 모두 통과$(COLOR_RESET)"

# ============================================================================
# list-checks - 정의된 모든 검사를 한눈에 보기
# ============================================================================
list-checks:
@echo "$(COLOR_BOLD)$(COLOR_CYAN)정의된 pre-commit 훅 목록:$(COLOR_RESET)"
@$(PRE_COMMIT) run --all-files --verbose --hook-stage manual 2>/dev/null || true
@echo ""
@echo "$(COLOR_GREEN)단계별 훅 위치는 .pre-commit-config.yaml의 stages 필드 참고$(COLOR_RESET)"

# ============================================================================
# init - your_project 플레이스홀더를 새 이름으로 일괄 치환
# 사용법: make init NAME=my_app
# ============================================================================
init:
ifndef NAME
$(error NAME 변수가 필요합니다. 예: make init NAME=my_app)
endif
@echo "$(COLOR_BOLD)$(COLOR_BLUE)프로젝트 초기화: $(NAME)$(COLOR_RESET)"
@$(PYTHON) scripts/init_project.py $(NAME)
@echo "$(COLOR_GREEN)✓ 초기화 완료. 'make install-dev' 후 'make ci-check'로 검증하세요.$(COLOR_RESET)"

# ============================================================================
# 개발 워크플로우 예시
# ============================================================================
Expand Down
Loading