|
| 1 | +# Contributing to ResuMariner |
| 2 | + |
| 3 | +## Development Setup |
| 4 | + |
| 5 | +### Backend Development |
| 6 | + |
| 7 | +The backend uses pre-commit hooks to ensure code quality. All linting and type checking is configured in `/backend/pyproject.toml`. |
| 8 | + |
| 9 | +#### Installing Pre-commit Hooks |
| 10 | + |
| 11 | +From the **backend directory**: |
| 12 | + |
| 13 | +```bash |
| 14 | +cd backend |
| 15 | +uv run pre-commit install |
| 16 | +``` |
| 17 | + |
| 18 | +This will install git hooks that run automatically before each commit. |
| 19 | + |
| 20 | +#### Running Pre-commit Manually |
| 21 | + |
| 22 | +To run all checks on all files: |
| 23 | + |
| 24 | +```bash |
| 25 | +cd backend |
| 26 | +uv run pre-commit run --all-files |
| 27 | +``` |
| 28 | + |
| 29 | +To run checks on staged files only: |
| 30 | + |
| 31 | +```bash |
| 32 | +cd backend |
| 33 | +uv run pre-commit run |
| 34 | +``` |
| 35 | + |
| 36 | +#### Individual Tool Commands |
| 37 | + |
| 38 | +You can also run the tools individually: |
| 39 | + |
| 40 | +**Ruff (linting and auto-fix):** |
| 41 | +```bash |
| 42 | +cd backend |
| 43 | +uv run ruff check --fix . |
| 44 | +``` |
| 45 | + |
| 46 | +**Ruff (formatting):** |
| 47 | +```bash |
| 48 | +cd backend |
| 49 | +uv run ruff format . |
| 50 | +``` |
| 51 | + |
| 52 | +**MyPy (type checking):** |
| 53 | +```bash |
| 54 | +cd backend |
| 55 | +uv run mypy . --config-file pyproject.toml |
| 56 | +``` |
| 57 | + |
| 58 | +## Code Quality Standards |
| 59 | + |
| 60 | +### Python Backend |
| 61 | + |
| 62 | +- **Linting**: Ruff with the configuration in `backend/pyproject.toml` |
| 63 | + - Line length: 120 characters |
| 64 | + - Target: Python 3.12 |
| 65 | + - Selected rules: E (pycodestyle errors), W (warnings), F (pyflakes), I (isort), B (bugbear), C4 (comprehensions), UP (pyupgrade) |
| 66 | + |
| 67 | +- **Formatting**: Ruff formatter |
| 68 | + - Double quotes |
| 69 | + - Space indentation |
| 70 | + - Auto-formatting before commit |
| 71 | + |
| 72 | +- **Type Checking**: MyPy with strict settings |
| 73 | + - Check untyped definitions enabled |
| 74 | + - Warn on unused configs |
| 75 | + - Test files excluded from strict checking |
| 76 | + |
| 77 | +### Pre-commit Hook Configuration |
| 78 | + |
| 79 | +The backend uses a `.pre-commit-config.yaml` file with three hooks: |
| 80 | + |
| 81 | +1. **ruff-check**: Runs linting and auto-fixes issues |
| 82 | +2. **ruff-format**: Formats code according to style guide |
| 83 | +3. **mypy**: Type checks all Python code |
| 84 | + |
| 85 | +All hooks use `uv run` to ensure they run in the correct virtual environment. |
| 86 | + |
| 87 | +### Important Notes |
| 88 | + |
| 89 | +- Pre-commit hooks are configured in `/backend/.pre-commit-config.yaml` |
| 90 | +- Always run commands from the `/backend` directory |
| 91 | +- The hooks use `pass_filenames: false` to run on all files in the backend directory |
| 92 | +- `fail_fast: false` means all hooks will run even if one fails |
| 93 | + |
| 94 | +## Testing |
| 95 | + |
| 96 | +Run tests with pytest: |
| 97 | + |
| 98 | +```bash |
| 99 | +cd backend |
| 100 | +uv run pytest |
| 101 | +``` |
| 102 | + |
| 103 | +Run tests for a specific app: |
| 104 | + |
| 105 | +```bash |
| 106 | +cd backend |
| 107 | +uv run pytest core/ |
| 108 | +uv run pytest processor/ |
| 109 | +uv run pytest storage/ |
| 110 | +uv run pytest search/ |
| 111 | +``` |
| 112 | + |
| 113 | +## Docker Development |
| 114 | + |
| 115 | +Build and run the full stack: |
| 116 | + |
| 117 | +```bash |
| 118 | +docker compose up -d |
| 119 | +``` |
| 120 | + |
| 121 | +Rebuild specific services: |
| 122 | + |
| 123 | +```bash |
| 124 | +docker compose build backend backend-worker-processing backend-worker-cleanup |
| 125 | +docker compose up -d backend backend-worker-processing backend-worker-cleanup |
| 126 | +``` |
| 127 | + |
| 128 | +Force rebuild without cache: |
| 129 | + |
| 130 | +```bash |
| 131 | +docker compose build --no-cache backend backend-worker-processing backend-worker-cleanup |
| 132 | +``` |
| 133 | + |
| 134 | +## Common Workflows |
| 135 | + |
| 136 | +### Making Changes to Backend Code |
| 137 | + |
| 138 | +1. Make your changes |
| 139 | +2. Run pre-commit hooks: `cd backend && uv run pre-commit run --all-files` |
| 140 | +3. Fix any issues reported |
| 141 | +4. Commit your changes (hooks will run automatically) |
| 142 | +5. If hooks fail, fix issues and commit again |
| 143 | + |
| 144 | +### Adding New Dependencies |
| 145 | + |
| 146 | +1. Edit `backend/pyproject.toml` |
| 147 | +2. Run `cd backend && uv lock` to update lockfile |
| 148 | +3. Rebuild Docker containers |
| 149 | +4. Test the changes |
| 150 | + |
| 151 | +### Before Opening a Pull Request |
| 152 | + |
| 153 | +1. Ensure all pre-commit hooks pass: `cd backend && uv run pre-commit run --all-files` |
| 154 | +2. Run the full test suite: `cd backend && uv run pytest` |
| 155 | +3. Test the application with Docker: `docker compose up -d` |
| 156 | +4. Verify all services are healthy: `docker compose ps` |
0 commit comments