-
Notifications
You must be signed in to change notification settings - Fork 0
chore: add CI (ruff + compose + yaml + patterns validation) #7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,94 @@ | ||
| name: CI | ||
|
|
||
| # PR 트리거 한정 — push마다 분당 비용을 누적하지 않는다. | ||
| on: | ||
| pull_request: | ||
| branches: [master] | ||
| workflow_dispatch: | ||
|
|
||
| jobs: | ||
| python-lint: | ||
| name: Python Lint (ruff) | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 10 | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: '3.11' | ||
|
|
||
| - name: ruff 설치 | ||
| run: pip install ruff==0.5.7 | ||
|
|
||
| - name: ruff 검사 | ||
| # main.py, learning_store.py, pattern_index.py, tests/ 전체 | ||
| run: ruff check . | ||
|
|
||
| - name: ruff 포맷 검사 | ||
| run: ruff format --check . | ||
|
|
||
| compose-validate: | ||
| name: docker-compose 구문 검증 | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 5 | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: docker compose config 검증 | ||
| # 시크릿 미설정 상태에서도 schema/필수 키 검사 | ||
| run: docker compose -f docker-compose.yml config --quiet | ||
|
|
||
| yaml-lint: | ||
| name: YAML 구문 검증 | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 5 | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: '3.11' | ||
|
|
||
| - name: PyYAML 설치 | ||
| run: pip install pyyaml | ||
|
|
||
| - name: 모든 YAML 파일 syntax 검증 | ||
| run: | | ||
| python3 -c " | ||
| import yaml, glob, sys | ||
| ok = True | ||
| for f in glob.glob('**/*.yml', recursive=True) + glob.glob('**/*.yaml', recursive=True): | ||
| try: | ||
| yaml.safe_load(open(f)) | ||
| print(f'OK {f}') | ||
| except yaml.YAMLError as e: | ||
| ok = False | ||
| print(f'FAIL {f}: {e}') | ||
| sys.exit(0 if ok else 1) | ||
| " | ||
|
Comment on lines
+49
to
+69
|
||
|
|
||
| # 패턴 JSON 파일 + tests 폴더 무결성 — 패턴 라이브러리가 깨지면 서버 기동 실패하므로 | ||
| # PR 단계에서 catch. | ||
| patterns-validate: | ||
| name: 패턴 JSON 검증 | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 5 | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: patterns/*.json syntax 검증 | ||
| run: | | ||
| python3 -c " | ||
| import json, glob, sys | ||
| ok = True | ||
| for f in glob.glob('patterns/*.json'): | ||
| try: | ||
| with open(f) as fp: | ||
| json.load(fp) | ||
| print(f'OK {f}') | ||
| except json.JSONDecodeError as e: | ||
| ok = False | ||
| print(f'FAIL {f}: {e}') | ||
| sys.exit(0 if ok else 1) | ||
| " | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The YAML validation script uses
yaml.safe_load(open(f)), which leaves file handles unclosed and only parses the first YAML document in a file. Use awith open(..., encoding='utf-8')block and ensure all documents are consumed (e.g., iteratesafe_load_all) so the check reliably validates the entire file contents.