|
| 1 | +# GitHub Actions Workflows for Spoon Core |
| 2 | + |
| 3 | +This directory contains GitHub Actions workflows for automated testing, building, and publishing of the Spoon AI SDK Python package. |
| 4 | + |
| 5 | +## Workflows Overview |
| 6 | + |
| 7 | +### 1. CI Workflow (`ci.yml`) |
| 8 | +- **Trigger**: Push to `main`/`develop` branches, Pull Requests |
| 9 | +- **Purpose**: Build package and verify compatibility across Python versions |
| 10 | +- **Features**: |
| 11 | + - Multi-Python version build verification (3.11, 3.12, 3.13) |
| 12 | + - Package build and validation |
| 13 | + - Artifact upload for releases |
| 14 | + - No testing - focuses on build verification only |
| 15 | + |
| 16 | +### 2. Release Workflow (`release.yml`) |
| 17 | +- **Trigger**: Push of version tags (e.g., `v1.2.3`) |
| 18 | +- **Purpose**: Automatically publish to PyPI and create GitHub releases |
| 19 | +- **Features**: |
| 20 | + - Build package distribution |
| 21 | + - Upload to PyPI using API token |
| 22 | + - Create GitHub release with changelog |
| 23 | + |
| 24 | +### 3. Version Bump Workflow (`version-bump.yml`) |
| 25 | +- **Trigger**: Manual workflow dispatch |
| 26 | +- **Purpose**: Automated version management and tagging |
| 27 | +- **Features**: |
| 28 | + - Support for patch/minor/major version bumps |
| 29 | + - Custom version input option |
| 30 | + - Automatic commit and tag creation |
| 31 | + - Push to repository |
| 32 | + |
| 33 | +## Setup Instructions |
| 34 | + |
| 35 | +### 1. PyPI API Token Setup |
| 36 | + |
| 37 | +1. Go to [PyPI](https://pypi.org/) and log in |
| 38 | +2. Go to Account Settings → API tokens |
| 39 | +3. Create a new API token with scope for your project |
| 40 | +4. In your GitHub repository, go to Settings → Secrets and variables → Actions |
| 41 | +5. Add a new repository secret named `PYPI_API_TOKEN` with your token value |
| 42 | + |
| 43 | +### 2. Repository Settings |
| 44 | + |
| 45 | +Ensure your repository has the following settings: |
| 46 | + |
| 47 | +- **Actions permissions**: Allow actions to create and approve pull requests |
| 48 | +- **Workflow permissions**: Read and write permissions for GITHUB_TOKEN |
| 49 | + |
| 50 | +### 3. Branch Protection (Recommended) |
| 51 | + |
| 52 | +Set up branch protection for `main` branch: |
| 53 | +- Require status checks to pass |
| 54 | +- Require branches to be up to date |
| 55 | +- Include administrators in restrictions |
| 56 | + |
| 57 | +## Usage |
| 58 | + |
| 59 | +### Automatic Release Process |
| 60 | + |
| 61 | +1. **Version Bump**: Use the Version Bump workflow to increment version |
| 62 | + - Go to Actions → Version Bump and Tag → Run workflow |
| 63 | + - Choose version type (patch/minor/major) or enter custom version |
| 64 | + |
| 65 | +2. **Automatic Publishing**: When a version tag is pushed, the release workflow automatically: |
| 66 | + - Builds the package |
| 67 | + - Publishes to PyPI |
| 68 | + - Creates a GitHub release |
| 69 | + |
| 70 | +### Manual Version Management |
| 71 | + |
| 72 | +If you prefer manual version management: |
| 73 | + |
| 74 | +1. Update version in `pyproject.toml` |
| 75 | +2. Commit changes: `git commit -m "Bump version to x.y.z"` |
| 76 | +3. Create tag: `git tag vx.y.z` |
| 77 | +4. Push: `git push && git push --tags` |
| 78 | + |
| 79 | +## Workflow Details |
| 80 | + |
| 81 | +### CI Workflow |
| 82 | +```yaml |
| 83 | +# Runs on every push/PR |
| 84 | +- Multi-version Python build verification |
| 85 | +- Package build and twine check |
| 86 | +- Upload build artifacts |
| 87 | +- No testing - focuses on build verification only |
| 88 | +``` |
| 89 | +
|
| 90 | +### Release Workflow |
| 91 | +```yaml |
| 92 | +# Runs on version tags |
| 93 | +- Checkout code |
| 94 | +- Setup Python 3.11 |
| 95 | +- Install build tools |
| 96 | +- Build package (sdist + wheel) |
| 97 | +- Upload to PyPI |
| 98 | +- Create GitHub release |
| 99 | +``` |
| 100 | +
|
| 101 | +### Version Bump Workflow |
| 102 | +```yaml |
| 103 | +# Manual trigger |
| 104 | +- Checkout with write permissions |
| 105 | +- Install bump2version |
| 106 | +- Calculate new version |
| 107 | +- Update pyproject.toml |
| 108 | +- Commit and tag |
| 109 | +- Push changes |
| 110 | +``` |
| 111 | +
|
| 112 | +## Dependencies |
| 113 | +
|
| 114 | +The following tools are used in the workflows: |
| 115 | +
|
| 116 | +- `build`: Package building |
| 117 | +- `twine`: PyPI uploading |
| 118 | +- `pytest`: Testing framework |
| 119 | +- `pytest-cov`: Coverage reporting |
| 120 | +- `pytest-asyncio`: Async test support |
| 121 | +- `tox`: Multi-environment testing |
| 122 | +- `bump2version`: Version management |
| 123 | + |
| 124 | +## Testing Configuration |
| 125 | + |
| 126 | +The CI workflow uses both pytest and tox for comprehensive testing: |
| 127 | + |
| 128 | +### pytest Configuration |
| 129 | +- Located in `tests/pytest.ini` |
| 130 | +- Asyncio mode: auto |
| 131 | +- Coverage reporting enabled |
| 132 | + |
| 133 | +### tox Configuration |
| 134 | +- Located in `tox.ini` |
| 135 | +- Supports Python versions: 3.9, 3.10, 3.11, 3.12, 3.13 |
| 136 | +- Isolated build environments |
| 137 | +- Coverage reporting support |
| 138 | + |
| 139 | +## Troubleshooting |
| 140 | + |
| 141 | +### Common Issues |
| 142 | + |
| 143 | +1. **PyPI Upload Fails** |
| 144 | + - Check `PYPI_API_TOKEN` secret is set correctly |
| 145 | + - Verify token has upload permissions for the project |
| 146 | + |
| 147 | +2. **Tests Fail** |
| 148 | + - Check Python version compatibility (requires >=3.10) |
| 149 | + - Ensure all dependencies are in `requirements.txt` |
| 150 | + - Verify test configuration in `pytest.ini` |
| 151 | + |
| 152 | +3. **Build Fails** |
| 153 | + - Check `pyproject.toml` configuration |
| 154 | + - Ensure package structure matches `setuptools` configuration |
| 155 | + - Verify Python version compatibility |
| 156 | + |
| 157 | +### Debug Mode |
| 158 | + |
| 159 | +To debug workflow issues: |
| 160 | +1. Go to Actions tab in GitHub |
| 161 | +2. Select the failed workflow run |
| 162 | +3. Check logs for each step |
| 163 | +4. Use `debug` logging level if available |
| 164 | + |
| 165 | +## Contributing |
| 166 | + |
| 167 | +When contributing to the workflows: |
| 168 | + |
| 169 | +1. Test changes on a feature branch first |
| 170 | +2. Update this documentation if workflows change |
| 171 | +3. Ensure backward compatibility |
| 172 | +4. Follow GitHub Actions best practices |
| 173 | + |
| 174 | +## Security Notes |
| 175 | + |
| 176 | +- Never commit secrets to the repository |
| 177 | +- Use repository secrets for sensitive data |
| 178 | +- Regularly rotate API tokens |
| 179 | +- Limit token scopes to minimum required permissions |
0 commit comments