|
| 1 | +# GitHub Actions Workflows |
| 2 | + |
| 3 | +## Overview |
| 4 | + |
| 5 | +This project uses a simplified two-workflow strategy optimized for Python packages with Rust extensions. |
| 6 | + |
| 7 | +## Workflows |
| 8 | + |
| 9 | +### 1. ci.yml - Code Quality (Runs on every push/PR) |
| 10 | + |
| 11 | +**Purpose**: Fast feedback on code quality |
| 12 | + |
| 13 | +**Jobs**: |
| 14 | +- **lint** - Pre-commit hooks, mypy type checking, import-linter |
| 15 | +- **test** - Pytest across Python 3.10, 3.11, 3.12 with coverage |
| 16 | + |
| 17 | +**Does NOT**: |
| 18 | +- Build wheels (too slow, not needed on every push) |
| 19 | +- Publish to PyPI (only on release) |
| 20 | + |
| 21 | +**Runtime**: ~3-5 minutes |
| 22 | + |
| 23 | +--- |
| 24 | + |
| 25 | +### 2. wheels.yml - Build & Publish (Runs on release) |
| 26 | + |
| 27 | +**Purpose**: Build production wheels and publish to PyPI |
| 28 | + |
| 29 | +**Triggers**: |
| 30 | +- On release creation (automatic) |
| 31 | +- Manual workflow dispatch (for testing) |
| 32 | + |
| 33 | +**Jobs**: |
| 34 | +- **build_wheels** - Uses cibuildwheel for Linux, Windows, macOS |
| 35 | +- **build_sdist** - Source distribution |
| 36 | +- **publish** - Publishes to PyPI (only on release) |
| 37 | + |
| 38 | +**Does**: |
| 39 | +- Builds wheels with maturin (Rust extension) |
| 40 | +- Tests each wheel after building |
| 41 | +- Handles cross-platform builds |
| 42 | +- Publishes to PyPI with trusted publishing |
| 43 | + |
| 44 | +**Runtime**: ~20-30 minutes (cross-platform builds) |
| 45 | + |
| 46 | +--- |
| 47 | + |
| 48 | +## Why This Structure? |
| 49 | + |
| 50 | +### Problems with Previous Setup |
| 51 | +- Had 3 workflows, 2 were failing with maturin errors |
| 52 | +- Attempted to build wheels on every push (slow, unnecessary) |
| 53 | +- Duplicated testing across workflows |
| 54 | + |
| 55 | +### Current Benefits |
| 56 | +1. **Fast CI** - Code quality checks in minutes, not hours |
| 57 | +2. **Reliable** - No maturin builds in CI (only on release with proper tooling) |
| 58 | +3. **Standard Practice** - Follows Python+Rust project conventions |
| 59 | +4. **Clear Separation** - Code quality vs distribution packaging |
| 60 | + |
| 61 | +## Development Workflow |
| 62 | + |
| 63 | +### Daily Development |
| 64 | +```bash |
| 65 | +# Make changes |
| 66 | +git commit -m "feat: add new feature" |
| 67 | +git push |
| 68 | + |
| 69 | +# CI runs: |
| 70 | +# ✓ Lint (pre-commit, mypy, import-linter) |
| 71 | +# ✓ Test (pytest on Python 3.10, 3.11, 3.12) |
| 72 | +# → ~3-5 minutes |
| 73 | +``` |
| 74 | + |
| 75 | +### Creating a Release |
| 76 | +```bash |
| 77 | +# Create release on GitHub |
| 78 | +gh release create v0.5.0 --generate-notes |
| 79 | + |
| 80 | +# wheels.yml runs automatically: |
| 81 | +# ✓ Build wheels (Linux, Windows, macOS) |
| 82 | +# ✓ Build sdist |
| 83 | +# ✓ Test wheels |
| 84 | +# ✓ Publish to PyPI |
| 85 | +# → ~20-30 minutes |
| 86 | +``` |
| 87 | + |
| 88 | +## Testing Installation Locally |
| 89 | + |
| 90 | +### Editable Install (Development) |
| 91 | +```bash |
| 92 | +# No wheel needed, no maturin required |
| 93 | +pip install -e . |
| 94 | +python -c "import aiochainscan" |
| 95 | +``` |
| 96 | + |
| 97 | +### Test Wheel Build (Before Release) |
| 98 | +```bash |
| 99 | +# Requires Rust toolchain |
| 100 | +pip install maturin |
| 101 | +maturin develop |
| 102 | +``` |
| 103 | + |
| 104 | +### Test From GitHub (Any Branch) |
| 105 | +```bash |
| 106 | +pip install git+https://github.com/VaitaR/aiochainscan.git@develop |
| 107 | +``` |
| 108 | + |
| 109 | +## Troubleshooting |
| 110 | + |
| 111 | +### CI Failing on Lint |
| 112 | +- Run `pre-commit run --all-files` locally |
| 113 | +- Fix issues, commit, push |
| 114 | + |
| 115 | +### CI Failing on Tests |
| 116 | +- Run `pytest` locally |
| 117 | +- Check test output for failures |
| 118 | + |
| 119 | +### Wheels Failing to Build |
| 120 | +- Check Rust is installed: `rustc --version` |
| 121 | +- Check maturin version: `pip show maturin` (should be ≥1.8) |
| 122 | +- Test locally: `maturin build --release` |
| 123 | + |
| 124 | +## Related Documentation |
| 125 | + |
| 126 | +- [CI_SIMPLIFICATION.md](../../docs/CI_SIMPLIFICATION.md) - Why we simplified |
| 127 | +- [PYPI_PUBLISHING.md](../../docs/PYPI_PUBLISHING.md) - Publishing guide |
| 128 | +- [CONTRIBUTING.md](../../CONTRIBUTING.md) - Development guide |
0 commit comments