|
| 1 | +# GitHub Workflows Documentation |
| 2 | + |
| 3 | +This directory contains automated workflows for the FastApps project. |
| 4 | + |
| 5 | +## Workflows Overview |
| 6 | + |
| 7 | +### 1. CI Pipeline (`ci.yml`) |
| 8 | +**Triggers**: Push/PR to main or develop branches |
| 9 | + |
| 10 | +**Jobs**: |
| 11 | +- **Test**: Runs tests on multiple OS (Ubuntu, macOS, Windows) and Python versions (3.11, 3.12) |
| 12 | + - Runs pytest with coverage |
| 13 | + - Uploads coverage to Codecov |
| 14 | +- **Lint**: Checks code formatting with Black and lints with Ruff |
| 15 | +- **Type Check**: Runs mypy for type checking |
| 16 | +- **Build**: Builds the package and validates it with twine |
| 17 | + |
| 18 | +### 2. PyPI Publishing (`publish.yml`) |
| 19 | +**Triggers**: GitHub release is published |
| 20 | + |
| 21 | +**Actions**: |
| 22 | +- Builds the package |
| 23 | +- Publishes to PyPI using API token |
| 24 | +- Requires `PYPI_API_TOKEN` secret |
| 25 | + |
| 26 | +### 3. Test PyPI Publishing (`test-publish.yml`) |
| 27 | +**Triggers**: GitHub release is created (draft) |
| 28 | + |
| 29 | +**Actions**: |
| 30 | +- Builds the package |
| 31 | +- Publishes to Test PyPI for validation |
| 32 | +- Requires `TEST_PYPI_API_TOKEN` secret |
| 33 | + |
| 34 | +### 4. Dependency Review (`dependency-review.yml`) |
| 35 | +**Triggers**: Pull requests to main |
| 36 | + |
| 37 | +**Actions**: |
| 38 | +- Reviews dependencies for security vulnerabilities |
| 39 | +- Fails on moderate or higher severity issues |
| 40 | + |
| 41 | +### 5. CodeQL Analysis (`codeql.yml`) |
| 42 | +**Triggers**: |
| 43 | +- Push to main |
| 44 | +- Pull requests to main |
| 45 | +- Weekly schedule (Mondays) |
| 46 | + |
| 47 | +**Actions**: |
| 48 | +- Scans code for security vulnerabilities |
| 49 | +- Analyzes Python codebase |
| 50 | +- Reports findings to GitHub Security |
| 51 | + |
| 52 | +### 6. Release Drafter (`release-drafter.yml`) |
| 53 | +**Triggers**: Push to main |
| 54 | + |
| 55 | +**Actions**: |
| 56 | +- Automatically drafts release notes |
| 57 | +- Categorizes changes by labels |
| 58 | +- Suggests version bumps based on labels |
| 59 | + |
| 60 | +## Setup Requirements |
| 61 | + |
| 62 | +### Required Secrets |
| 63 | + |
| 64 | +Add these secrets in GitHub Settings → Secrets and variables → Actions: |
| 65 | + |
| 66 | +1. **PYPI_API_TOKEN** |
| 67 | + - Get from: https://pypi.org/manage/account/token/ |
| 68 | + - Scope: Entire account or specific to fastapps |
| 69 | + - Used by: `publish.yml` |
| 70 | + |
| 71 | +2. **TEST_PYPI_API_TOKEN** (Optional) |
| 72 | + - Get from: https://test.pypi.org/manage/account/token/ |
| 73 | + - Used by: `test-publish.yml` |
| 74 | + - Useful for testing releases before production |
| 75 | + |
| 76 | +### Codecov Integration (Optional) |
| 77 | + |
| 78 | +1. Sign up at https://codecov.io |
| 79 | +2. Connect your GitHub repository |
| 80 | +3. Token is automatically provided by GitHub Actions |
| 81 | + |
| 82 | +## Release Process |
| 83 | + |
| 84 | +### Standard Release Flow |
| 85 | + |
| 86 | +1. **Develop** → Merge features into `develop` branch |
| 87 | + - CI runs on every commit |
| 88 | + - Tests must pass |
| 89 | + |
| 90 | +2. **Prepare Release** |
| 91 | + - Update version in `pyproject.toml` and `setup.py` |
| 92 | + - Merge `develop` → `main` |
| 93 | + - Release Drafter creates draft release notes |
| 94 | + |
| 95 | +3. **Create Release** |
| 96 | + - Go to Releases → Edit draft |
| 97 | + - Review and edit release notes |
| 98 | + - Create tag (e.g., `v1.0.9`) |
| 99 | + - Publish release |
| 100 | + |
| 101 | +4. **Automatic Publishing** |
| 102 | + - `publish.yml` triggers on release publish |
| 103 | + - Package builds and publishes to PyPI |
| 104 | + - Users can install with `pip install fastapps` |
| 105 | + |
| 106 | +### Testing Releases (Optional) |
| 107 | + |
| 108 | +Before publishing to production PyPI: |
| 109 | + |
| 110 | +1. Create a **draft** release |
| 111 | +2. `test-publish.yml` publishes to Test PyPI |
| 112 | +3. Test installation: `pip install -i https://test.pypi.org/simple/ fastapps` |
| 113 | +4. If successful, publish the release |
| 114 | + |
| 115 | +## PR Labels for Release Notes |
| 116 | + |
| 117 | +Use these labels on pull requests for automatic categorization: |
| 118 | + |
| 119 | +- `feature`, `enhancement` → 🚀 Features |
| 120 | +- `fix`, `bugfix`, `bug` → 🐛 Bug Fixes |
| 121 | +- `chore`, `dependencies` → 🧰 Maintenance |
| 122 | +- `documentation`, `docs` → 📚 Documentation |
| 123 | + |
| 124 | +Version bump labels: |
| 125 | +- `major` → Breaking changes (1.0.0 → 2.0.0) |
| 126 | +- `minor`, `feature` → New features (1.0.0 → 1.1.0) |
| 127 | +- `patch`, `fix` → Bug fixes (1.0.0 → 1.0.1) |
| 128 | + |
| 129 | +## Dependabot |
| 130 | + |
| 131 | +Configured in `.github/dependabot.yml`: |
| 132 | +- Updates GitHub Actions weekly |
| 133 | +- Updates Python dependencies weekly |
| 134 | +- Automatically creates PRs for updates |
| 135 | + |
| 136 | +## Running Tests Locally |
| 137 | + |
| 138 | +```bash |
| 139 | +# Install dev dependencies |
| 140 | +pip install -e ".[dev]" |
| 141 | + |
| 142 | +# Run tests |
| 143 | +pytest |
| 144 | + |
| 145 | +# Run tests with coverage |
| 146 | +pytest --cov=fastapps --cov-report=html |
| 147 | + |
| 148 | +# Format code |
| 149 | +black . |
| 150 | + |
| 151 | +# Lint code |
| 152 | +ruff check . |
| 153 | + |
| 154 | +# Build package |
| 155 | +python -m build |
| 156 | + |
| 157 | +# Check package |
| 158 | +twine check dist/* |
| 159 | +``` |
| 160 | + |
| 161 | +## Troubleshooting |
| 162 | + |
| 163 | +### CI Failures |
| 164 | + |
| 165 | +**Tests fail**: |
| 166 | +- Check test output in GitHub Actions logs |
| 167 | +- Run tests locally: `pytest -v` |
| 168 | + |
| 169 | +**Linting fails**: |
| 170 | +- Run `black .` to auto-format |
| 171 | +- Run `ruff check .` to see issues |
| 172 | + |
| 173 | +**Build fails**: |
| 174 | +- Ensure `pyproject.toml` is valid |
| 175 | +- Check dependencies are correct |
| 176 | + |
| 177 | +### Publishing Failures |
| 178 | + |
| 179 | +**PyPI upload fails**: |
| 180 | +- Verify `PYPI_API_TOKEN` is set correctly |
| 181 | +- Ensure version number is unique (not already published) |
| 182 | +- Check package name isn't taken |
| 183 | + |
| 184 | +**Test PyPI works but production fails**: |
| 185 | +- Version might already exist on PyPI |
| 186 | +- Token might have wrong permissions |
| 187 | + |
| 188 | +## Badge Examples |
| 189 | + |
| 190 | +Add to your README.md: |
| 191 | + |
| 192 | +```markdown |
| 193 | +[](https://github.com/fastapps-framework/fastapps/actions/workflows/ci.yml) |
| 194 | +[](https://codecov.io/gh/fastapps-framework/fastapps) |
| 195 | +[](https://badge.fury.io/py/fastapps) |
| 196 | +[](https://pypi.org/project/fastapps/) |
| 197 | +``` |
0 commit comments