forked from Rockachopa/Timmy-time-dashboard
* CI/CD Optimization: Guard Rails, Black Linting, and Pre-commit Hooks - Fixed all test collection errors (Selenium imports, fixture paths, syntax) - Implemented pre-commit hooks with Black formatting and isort - Created comprehensive Makefile with test targets (unit, integration, functional, e2e) - Added pytest.ini with marker definitions for test categorization - Established guard rails to prevent future collection errors - Wrapped optional dependencies (Selenium, MoviePy) in try-except blocks - Added conftest_markers for automatic test categorization This ensures a smooth development stream with: - Fast feedback loops (pre-commit checks before push) - Consistent code formatting (Black) - Reliable CI/CD (no collection errors, proper test isolation) - Clear test organization (unit, integration, functional, E2E) * Fix CI/CD test failures: - Export templates from dashboard.app - Fix model name assertion in test_agent.py - Fix platform-agnostic path resolution in test_path_resolution.py - Skip Docker tests in test_docker_deployment.py if docker not available - Fix test_model_fallback_chain logic in test_ollama_integration.py * Add preventative pre-commit checks and Docker test skipif decorators: - Create pre_commit_checks.py script for common CI failures - Add skipif decorators to Docker tests - Improve test robustness for CI environments
72 lines
1.7 KiB
YAML
72 lines
1.7 KiB
YAML
# Pre-commit hooks for local development
|
|
# Install: pip install pre-commit
|
|
# Setup: pre-commit install
|
|
# Run manually: pre-commit run --all-files
|
|
|
|
repos:
|
|
# Code formatting
|
|
- repo: https://github.com/psf/black
|
|
rev: 23.12.1
|
|
hooks:
|
|
- id: black
|
|
language_version: python3.11
|
|
args: [--line-length=100]
|
|
|
|
# Import sorting
|
|
- repo: https://github.com/PyCQA/isort
|
|
rev: 5.13.2
|
|
hooks:
|
|
- id: isort
|
|
args: [--profile=black, --line-length=100]
|
|
|
|
# Type checking (optional - can be slow)
|
|
- repo: https://github.com/pre-commit/mirrors-mypy
|
|
rev: v1.7.1
|
|
hooks:
|
|
- id: mypy
|
|
additional_dependencies: [types-all]
|
|
args: [--ignore-missing-imports, --no-error-summary]
|
|
exclude: ^tests/
|
|
stages: [manual]
|
|
|
|
# YAML validation
|
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
|
rev: v4.5.0
|
|
hooks:
|
|
- id: check-yaml
|
|
- id: check-json
|
|
- id: check-toml
|
|
- id: trailing-whitespace
|
|
- id: end-of-file-fixer
|
|
- id: check-merge-conflict
|
|
- id: debug-statements
|
|
- id: mixed-line-ending
|
|
|
|
# Security checks (optional)
|
|
- repo: https://github.com/PyCQA/bandit
|
|
rev: 1.7.5
|
|
hooks:
|
|
- id: bandit
|
|
args: [-ll, --skip, B101,B601]
|
|
exclude: ^tests/
|
|
stages: [manual]
|
|
|
|
# Fast unit tests only (not E2E, not slow tests)
|
|
- repo: local
|
|
hooks:
|
|
- id: pytest-unit
|
|
name: pytest-unit
|
|
entry: pytest
|
|
language: system
|
|
types: [python]
|
|
stages: [commit]
|
|
pass_filenames: false
|
|
always_run: true
|
|
args:
|
|
- tests
|
|
- -m
|
|
- "unit"
|
|
- --tb=short
|
|
- -q
|
|
verbose: true
|