feat: CI品質ゲートをimport-linter等の6本に拡充 - #4
Merged
Merged
Conversation
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概要
python-uv-ci-setupPlaybook の品質ゲートを ruff / mypy / pytest の 3 本から 6 本(+ import-linter / deptry / coverage 閾値)に拡充する。__init__.py・smoke テスト)を作るようにする。背景 / 目的
adapters -> application -> ports -> domain)を設計原則にしているが、依存方向は文書上の約束で、CI は検証していなかった。__init__.pyも build-system も生成しないため、テンプレートどおりに立ち上げるとsrc/配下が import できず CI が赤から始まっていた。変更内容
templates.md: pyproject(uv_buildの build-system /[tool.importlinter]の layers 契約と forbidden 契約 / ruff に S・SIM・C4・RUF・PTH / mypy にdisallow_untyped_defs等 / coveragefail_under = 80)、pre-commit(pre-commit-hooks + import-linter + deptry)、ci.yml(permissions/concurrency/ checkout@v7 / setup-python@v7 / setup-uv@v10)、dependabot.yml の雛形を更新tooling-best-practices.md: import-linter / deptry / coverage / Dependabot / pre-commit-hooks の節を追加。CI に入れなかったuv auditは「強化する場合」に記載python-uv-ci-setup.md: 手順を 6 本のゲートに更新。逆依存をわざと 1 行足して lint-imports が落ちることを確認する手順を追加bootstrap_python_project.py:src/<pkg>とtests/の全ディレクトリに__init__.py、tests/unit/test_smoke.py、.gitignoreに coverage 出力を生成。生成する依存方向の記述を ports 込みに修正.github/workflows/ai-context-sync.ymlを checkout@v7 / setup-python@v7 に、.github/dependabot.yml(github-actions)を追加.claude/skills/python-uv-ci-setup/SKILL.md/docs/ai/playbooks/python-uv-ci-setup.md)をsync_ai_context.pyで再生成影響範囲
検証
更新後の bootstrap でサンプルプロジェクトを生成し、
templates.mdのコードブロックをそのまま抽出して配置して実走した(uv 0.10.7 / Python 3.12.12 / import-linter 2.15 / deptry 0.25.1 / ruff 0.16.7 / mypy 2.3.1 / pytest 9.1.1)。uv lock→uv sync --locked --dev: exit 0uv run ruff format --check ./uv run ruff check ./uv run mypy ./uv run lint-imports/uv run deptry src/uv run pytest -q: すべて exit 0(lint-imports は 2 契約 KEPT、coverage 100%)uv run lint-importsが exit 1(違反行を指す)。戻すと exit 0uv run pre-commit run --all-filesと--hook-stage pre-push: 全フック Passedactionlintで ci.yml / ai-context-sync.yml とも指摘なしpython3 scripts/sync_ai_context.py→python3 scripts/sync_ai_context.py --check:[OK] Generated files are up to date.未実施: GitHub Actions runner 上での ci.yml の実走(テンプレート自身には pyproject が無いので、利用先プロジェクトの初回 PR で確認する)、Dependabot の実動作。
AI実行ログ(AIが作成した場合は必須)
python-uv-ci-setupPlaybook /adr-managementPlaybook /git-commitPlaybook / import-linter・deptry・uv・setup-uv・Dependabot の公式ドキュメントチェックリスト
https://claude.ai/code/session_01BCnNRzPkgcTJ3fo7sZMemX