SIENTIAPDE-1231

Enhance README with code quality and validation guidelines

- Added a new section on code quality and validation tools, detailing the use of Ruff, mypy, Bandit, and pytest.
- Included installation instructions for development dependencies and options for running validation scripts.
- Provided best practices for maintaining code quality and integrating CI/CD workflows.
This commit is contained in:
vitor-aignosi
2025-10-16 11:04:37 -03:00
parent 644a43093a
commit a7cc917760

View File

@@ -511,6 +511,68 @@ fi
python -m laborious.worker.worker
```
## Code Quality & Validation
### Overview
Since Python is not compiled, we validate quality, security, and correctness before execution.
### Validation Tools
- Ruff: Linting and formatting
- mypy: Static type checking
- Bandit: Security analysis
- pytest: Unit/integration testing with coverage
### Tools Installation
```bash
pip install -r requirements-dev.txt
```
### Complete Validation
Option 1 (recommended):
```bash
./validate.sh
```
The script runs, in order:
1. Format check (Ruff)
2. Linting (Ruff)
3. Type checking (mypy)
4. Security analysis (Bandit)
5. Tests with coverage (pytest)
Option 2 (individual commands):
```bash
ruff format --check laborious/ tests/
ruff check laborious/ tests/
mypy laborious/
bandit -r laborious/ -ll
pytest tests/ --cov=laborious --cov-report=term-missing
```
### Automatic Fixes
```bash
ruff format laborious/ tests/
ruff check --fix laborious/ tests/
```
### Configuration
All settings reside in `pyproject.toml` (Ruff, mypy, pytest, Bandit).
### CI/CD Integration
The workflow at `.github/workflows/quality-gate.yml` executes validations on each push/PR.
### Best Practices
- Run `./validate.sh` before committing
- Use `ruff check --watch` for continuous feedback
- Add type hints and tests for new code
## 🧪 Testing
### Test Structure