|
| 1 | +# BINGO Project Guide |
| 2 | + |
| 3 | +## Build Commands |
| 4 | +```bash |
| 5 | +# Quick setup for development |
| 6 | +./setup.sh |
| 7 | + |
| 8 | +# Install dependencies |
| 9 | +poetry install |
| 10 | + |
| 11 | +# Run application (old monolithic structure) |
| 12 | +poetry run python main.py |
| 13 | + |
| 14 | +# Run application (new modular structure) |
| 15 | +poetry run python app.py |
| 16 | + |
| 17 | +# Run tests |
| 18 | +poetry run pytest |
| 19 | + |
| 20 | +# Run tests with coverage |
| 21 | +poetry run pytest --cov=src --cov-report=html |
| 22 | + |
| 23 | +# Lint code |
| 24 | +poetry run flake8 |
| 25 | +poetry run black --check . |
| 26 | +poetry run isort --check . |
| 27 | + |
| 28 | +# Format code |
| 29 | +poetry run black . |
| 30 | +poetry run isort . |
| 31 | + |
| 32 | +# Build Docker container |
| 33 | +docker build -t bingo . |
| 34 | + |
| 35 | +# Run Docker container |
| 36 | +docker run -p 8080:8080 bingo |
| 37 | + |
| 38 | +# Helm deployment |
| 39 | +cd helm && ./package.sh && helm install bingo ./bingo |
| 40 | + |
| 41 | +# Using Makefile |
| 42 | +make install # Install dependencies |
| 43 | +make run # Run application |
| 44 | +make test # Run tests |
| 45 | +make lint # Run linters |
| 46 | +make format # Format code |
| 47 | +make build # Build package |
| 48 | +``` |
| 49 | + |
| 50 | +## Code Style Guidelines |
| 51 | +- **Imports**: Standard library first, third-party second, local modules last |
| 52 | +- **Formatting**: Use f-strings for string formatting |
| 53 | +- **Constants**: Defined at top of file in UPPER_CASE |
| 54 | +- **Naming**: snake_case for functions/variables, UPPER_CASE for constants |
| 55 | +- **Error Handling**: Use try/except blocks with proper logging |
| 56 | +- **UI Elements**: Define class constants for styling |
| 57 | +- **Logging**: Use Python's logging module with descriptive messages |
| 58 | +- **Comments**: Use docstrings for functions and descriptive comments |
| 59 | +- **Line Length**: Max 88 characters (Black's default) |
| 60 | +- **Code Formatting**: Use Black for code formatting and isort for import sorting |
| 61 | + |
| 62 | +## Project Structure |
| 63 | +- `app.py`: Main entry point for modular application |
| 64 | +- `src/`: Source code directory |
| 65 | + - `config/`: Configuration and constants |
| 66 | + - `core/`: Core game logic |
| 67 | + - `ui/`: User interface components |
| 68 | + - `utils/`: Utility functions |
| 69 | +- `phrases.txt`: Contains customizable bingo phrases |
| 70 | +- `static/`: Static assets for fonts and styles |
| 71 | +- `tests/`: Unit and integration tests |
| 72 | +- `helm/`: Kubernetes deployment configuration |
| 73 | +- `.github/workflows/`: CI pipeline configuration |
| 74 | +- `CHANGELOG.md`: Release history tracking |
| 75 | + |
| 76 | +## Git Workflow |
| 77 | + |
| 78 | +### Branch Naming |
| 79 | +- Use feature branches for each change: `feature/description-of-change` |
| 80 | +- Use bugfix branches for bug fixes: `fix/description-of-bug` |
| 81 | +- Use chore branches for maintenance: `chore/description-of-task` |
| 82 | + |
| 83 | +### Commit Guidelines |
| 84 | +Follow conventional changelog format: |
| 85 | + |
| 86 | +``` |
| 87 | +<type>(<scope>): <subject> |
| 88 | +
|
| 89 | +<body> |
| 90 | +
|
| 91 | +<footer> |
| 92 | +``` |
| 93 | + |
| 94 | +1. **Types**: |
| 95 | + - `feat`: A new feature |
| 96 | + - `fix`: A bug fix |
| 97 | + - `docs`: Documentation only changes |
| 98 | + - `style`: Changes that do not affect meaning (white-space, formatting) |
| 99 | + - `refactor`: Code change that neither fixes a bug nor adds a feature |
| 100 | + - `perf`: Change that improves performance |
| 101 | + - `test`: Adding missing tests or correcting existing tests |
| 102 | + - `chore`: Changes to the build process or auxiliary tools |
| 103 | + |
| 104 | +2. **Scope** (optional): The module/component affected, e.g., `core`, `ui`, `board` |
| 105 | + |
| 106 | +3. **Subject**: Short description in imperative, present tense (not past tense) |
| 107 | + - Good: "add feature X" (not "added feature X") |
| 108 | + - Use lowercase |
| 109 | + - No period at the end |
| 110 | + |
| 111 | +4. **Body** (optional): Detailed explanation of changes |
| 112 | + - Use present tense |
| 113 | + - Include motivation and context |
| 114 | + - Explain "what" and "why" (not "how") |
| 115 | + |
| 116 | +5. **Footer** (optional): Reference issues, PRs, breaking changes |
| 117 | + |
| 118 | +### Example Commits: |
| 119 | +``` |
| 120 | +feat(board): add color theme selector |
| 121 | +
|
| 122 | +Add ability for users to choose color themes for the bingo board |
| 123 | +
|
| 124 | +Resolves #123 |
| 125 | +``` |
| 126 | + |
| 127 | +``` |
| 128 | +fix(ui): resolve client disconnection issues |
| 129 | +
|
| 130 | +Handle race conditions during client disconnects to prevent |
| 131 | +server exceptions and ensure smooth reconnection |
| 132 | +
|
| 133 | +Fixes #456 |
| 134 | +``` |
| 135 | + |
| 136 | +## Semantic Versioning |
| 137 | + |
| 138 | +This project follows semantic versioning (SEMVER) principles: |
| 139 | + |
| 140 | +- **MAJOR** version when making incompatible API changes (X.0.0) |
| 141 | +- **MINOR** version when adding functionality in a backwards compatible manner (0.X.0) |
| 142 | +- **PATCH** version when making backwards compatible bug fixes (0.0.X) |
| 143 | + |
| 144 | +Version numbers are automatically updated by the CI/CD pipeline based on commit messages. |
| 145 | +The project uses python-semantic-release to analyze commit messages and determine the appropriate |
| 146 | +version bump according to the conventional commit format. |
| 147 | + |
| 148 | +## CI/CD Pipeline |
| 149 | + |
| 150 | +The project utilizes GitHub Actions for continuous integration and deployment: |
| 151 | + |
| 152 | +1. **CI Job**: |
| 153 | + - Runs on each push to main and pull request |
| 154 | + - Installs dependencies |
| 155 | + - Runs linters (flake8, black, isort) |
| 156 | + - Runs all tests with pytest |
| 157 | + - Uploads coverage reports |
| 158 | + |
| 159 | +2. **Release Job**: |
| 160 | + - Runs after successful CI job on the main branch |
| 161 | + - Determines new version based on commit messages |
| 162 | + - Updates CHANGELOG.md |
| 163 | + - Creates Git tag for the release |
| 164 | + - Publishes release on GitHub |
0 commit comments