diff --git a/.claude/commands/pre-commit.md b/.claude/commands/pre-commit.md new file mode 100644 index 0000000..7053a44 --- /dev/null +++ b/.claude/commands/pre-commit.md @@ -0,0 +1,20 @@ +# Pre-commit checklist + +Before running the checklist, run `git fetch origin`. If the current branch is behind `origin/master`, stop and rebase before proceeding. + +Run the pre-commit checklist for this project: + +1. Update `CHANGELOG.md` `[Unreleased]` section — add an entry under the + appropriate subsection (Added / Changed / Fixed / Removed) describing the + changes made, referencing the issue number. +2. Run `uv run flake8 .` — must pass. +3. Run `uv run black --check .` — must pass (run `uv run black .` to auto-fix). +4. Run `uv run pytest --cov=./ --cov-report=term --cov-fail-under=80` — all tests must pass, coverage must be ≥80%. +5. If Docker is running, run `docker compose build` — must succeed with no + errors. Skip this step with a note if Docker Desktop is not running. +6. If `coderabbit` CLI is installed, run `coderabbit review --type uncommitted --prompt-only`: + - If actionable/serious findings are reported, stop and address them before proposing the commit. + - If only nitpick-level findings, report them and continue to the commit proposal. + - If `coderabbit` is not installed, skip this step with a note. + +Run steps 1–5, report the results clearly, then run step 6 (CodeRabbit review) if available, then propose a branch name and commit message for my approval using the format `type(scope): description (#issue)` (max 80 chars; types: `feat` `fix` `chore` `docs` `test` `refactor` `ci` `perf`). Do not create the branch or commit until I explicitly confirm. diff --git a/.claude/commands/prerelease.md b/.claude/commands/pre-release.md similarity index 75% rename from .claude/commands/prerelease.md rename to .claude/commands/pre-release.md index ff4d5a1..5ae1ad4 100644 --- a/.claude/commands/prerelease.md +++ b/.claude/commands/pre-release.md @@ -20,11 +20,16 @@ open PRs, or create tags until I explicitly confirm. - **Next codename**: next letter in the A–Z sequence after the current one. Use lowercase with no spaces for the tag (e.g. `eriksson`); Title Case for the CHANGELOG heading (e.g. `Eriksson`). + If no tags exist yet, start at `A` (first coach in the table). + If letters were skipped, pick the next after the highest existing + codename — do not backfill gaps. + If the last codename is `Z` (Zeman), the list is finite — stop and + flag that the naming convention needs to be revisited. - **Version bump** — infer from `[Unreleased]`: | Condition | Bump | |---|---| - | Any entry marked BREAKING | MAJOR | + | Any entry marked BREAKING (case-insensitive), `BREAKING CHANGE:` token in a commit footer, or `!` suffix after type/scope (e.g. `feat!:`) | MAJOR | | Entries under Added | MINOR | | Only Changed / Fixed / Removed | PATCH | @@ -63,9 +68,9 @@ open PRs, or create tags until I explicitly confirm. 5. **Propose commit**: `docs(changelog): release vX.Y.Z Codename` -6. **After confirmation**: commit. Then run steps 2–4 of `/precommit` (linting, - formatting, tests — the CHANGELOG step is already handled). Push the branch - and open a PR into `master` only once all checks pass. +6. **After confirmation**: commit. Then run steps 2–5 of `/pre-commit` (linting, + formatting, tests, CodeRabbit review — the CHANGELOG step is already handled). + Push the branch and open a PR into `master` only once all checks pass. --- @@ -73,7 +78,6 @@ open PRs, or create tags until I explicitly confirm. 7. **Stop and wait** for confirmation that: - All CI checks have passed - - CodeRabbit review comments have been addressed - The PR has been merged into `master` 8. **Pull `master`**, then propose the annotated tag: diff --git a/.claude/commands/precommit.md b/.claude/commands/precommit.md deleted file mode 100644 index 8c656a9..0000000 --- a/.claude/commands/precommit.md +++ /dev/null @@ -1,12 +0,0 @@ -# Pre-commit checklist - -Run the pre-commit checklist for this project: - -1. Update `CHANGELOG.md` `[Unreleased]` section — add an entry under the - appropriate subsection (Added / Changed / Fixed / Removed) describing the - changes made, referencing the issue number. -2. Run `uv run flake8 .` — must pass. -3. Run `uv run black --check .` — must pass (run `uv run black .` to auto-fix). -4. Run `uv run pytest --cov=./ --cov-report=term` — all tests must pass, coverage must be ≥80%. - -Run steps 1–4, report the results clearly, then propose a branch name and commit message for my approval using the format `type(scope): description (#issue)` (max 80 chars; types: `feat` `fix` `chore` `docs` `test` `refactor` `ci` `perf`). Do not create the branch or commit until I explicitly confirm. diff --git a/.dockerignore b/.dockerignore index e139133..57cd0cc 100644 --- a/.dockerignore +++ b/.dockerignore @@ -6,18 +6,23 @@ .vscode/ htmlcov/ postman-collections/ +.claude/ +CLAUDE.md .codacy.yml +.coderabbit.yaml .coverage .coveragerc .flake8 .gitignore .pylintrc +CHANGELOG.md CODE_OF_CONDUCT.md codecov.yml commitlint.config.mjs CONTRIBUTING.md coverage.xml LICENSE +.sonarcloud.properties /tests/ __pycache__/ *.pyc diff --git a/.sonarcloud.properties b/.sonarcloud.properties new file mode 100644 index 0000000..82f8263 --- /dev/null +++ b/.sonarcloud.properties @@ -0,0 +1,58 @@ +# ============================================================================= +# SonarCloud Automatic Analysis configuration +# https://docs.sonarsource.com/sonarqube-cloud/advanced-setup/automatic-analysis/ +# +# SonarCloud's automatic analysis (GitHub App, no CI workflow) reads THIS file. +# Wildcard patterns are NOT supported here, so all exclusion paths must be +# listed explicitly. +# ============================================================================= + +sonar.projectKey=nanotaboada_python-samples-fastapi-restful +sonar.organization=nanotaboada +sonar.projectName=python-samples-fastapi-restful + +sonar.sources=databases,models,routes,schemas,services,tools,main.py +sonar.tests=tests + +# ============================================================================= +# Global exclusions +# Standalone seed scripts excluded from analysis. +# ============================================================================= + +sonar.exclusions=\ + tools/seed_001_starting_eleven.py,\ + tools/seed_002_substitutes.py + +# ============================================================================= +# Coverage exclusions +# Mirrors codecov.yml ignore list — focus on routes/, services/ +# ============================================================================= + +sonar.coverage.exclusions=\ + databases/__init__.py,\ + databases/player_database.py,\ + models/__init__.py,\ + models/player_model.py,\ + schemas/__init__.py,\ + schemas/player_schema.py,\ + tools/seed_001_starting_eleven.py,\ + tools/seed_002_substitutes.py,\ + tests/__init__.py,\ + tests/conftest.py,\ + tests/player_stub.py,\ + tests/test_main.py,\ + main.py + +# ============================================================================= +# Duplicate code (CPD) exclusions +# Automatic analysis does not support wildcard patterns, so each file is +# listed explicitly. +# +# player_stub.py — test fixture; parallel field assignments by design. +# seed scripts — sequential insert calls are intentionally repetitive. +# ============================================================================= + +sonar.cpd.exclusions=\ + tests/player_stub.py,\ + tools/seed_001_starting_eleven.py,\ + tools/seed_002_substitutes.py diff --git a/CHANGELOG.md b/CHANGELOG.md index d7b1e59..a017668 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -44,6 +44,10 @@ This project uses famous football coaches as release codenames, following an A-Z ### Added +- `.sonarcloud.properties`: SonarCloud Automatic Analysis configuration — + sources, tests, coverage exclusions aligned with `codecov.yml` (#554) +- `.dockerignore`: added `.claude/`, `CLAUDE.md`, `.coderabbit.yaml`, + `.sonarcloud.properties`, `CHANGELOG.md`, `README.md` (#554) - CD workflow now verifies tag commit is reachable from `master` before proceeding with build and publish steps (#549) diff --git a/CLAUDE.md b/CLAUDE.md index 7d3153d..8ef5c13 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -4,4 +4,4 @@ ## Claude Code -- Run `/precommit` to execute the full pre-commit checklist for this project. +- Run `/pre-commit` to execute the full pre-commit checklist for this project. diff --git a/README.md b/README.md index ca8b3e3..69c4853 100644 --- a/README.md +++ b/README.md @@ -9,9 +9,9 @@ [![License: MIT](https://img.shields.io/badge/License-MIT-3DA639.svg)](https://opensource.org/licenses/MIT) [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black) ![Dependabot](https://img.shields.io/badge/Dependabot-contributing-025E8C?logo=dependabot&logoColor=white&labelColor=181818) -![GitHub Copilot](https://img.shields.io/badge/GitHub_Copilot-contributing-8662C5?logo=githubcopilot&logoColor=white&labelColor=181818) -![Claude](https://img.shields.io/badge/Claude-Sonnet_4.6-D97757?logo=claude&logoColor=white&labelColor=181818) -![CodeRabbit Pull Request Reviews](https://img.shields.io/coderabbit/prs/github/nanotaboada/python-samples-fastapi-restful?utm_source=oss&utm_medium=github&utm_campaign=nanotaboada%2Fpython-samples-fastapi-restful&link=https%3A%2F%2Fcoderabbit.ai&label=CodeRabbit+Reviews&labelColor=181818) +![Copilot](https://img.shields.io/badge/Copilot-contributing-8662C5?logo=githubcopilot&logoColor=white&labelColor=181818) +![Claude](https://img.shields.io/badge/Claude-contributing-D97757?logo=claude&logoColor=white&labelColor=181818) +![CodeRabbit](https://img.shields.io/badge/CodeRabbit-reviewing-FF570A?logo=coderabbit&logoColor=white&labelColor=181818) Proof of Concept for a RESTful API built with [Python 3](https://www.python.org/) and [FastAPI](https://fastapi.tiangolo.com/). Manage football player data with SQLite, SQLAlchemy 2.0 (async), Pydantic validation, and in-memory caching.