Reliable Development Workflow
How to ensure local testing catches all issues before GitHub CI
The Problem We Solvedβ
Previously, our local testing was incomplete:
- β We tested functionality (builds, ACT, local server)
- β We skipped formatting checks (pre-commit hooks)
- Result: Local tests passed, GitHub CI failed on formatting
The Solutionβ
1. Comprehensive Local CI Scriptβ
Run the complete GitHub CI pipeline locally:
./scripts/local-ci-test.sh
This script mirrors exactly what GitHub Actions runs:
- All pre-commit hooks (formatting, linting, security)
- Python tests and build verification
- Documentation build testing
- ACT workflow simulation
2. Automated Pre-commit Hooksβ
Pre-commit hooks now run automatically on every commit:
# One-time setup (done for you)
pre-commit install
# Now every git commit automatically runs:
# - Trailing whitespace removal
# - End-of-file fixes
# - YAML/TOML validation
# - Black formatting
# - Import sorting
# - Flake8 linting
# - Security scanning
Improved Development Workflowβ
Before Making Changesβ
# 1. Create feature branch
git checkout -b feat/my-feature
# 2. Make your changes
# ... edit files ...
Before Committingβ
# 3. Run comprehensive local CI
./scripts/local-ci-test.sh
# If it passes:
β
ALL CHECKS PASSED - Ready for GitHub!
# If it fails:
β X CHECK(S) FAILED
π§ Fix issues above before committing
Committing Changesβ
# 4. Commit (pre-commit hooks run automatically)
git add .
git commit -m "feat: your feature description"
# 5. Push with confidence
git push origin feat/my-feature
Creating PRβ
# 6. Create PR
gh pr create --title "feat: Your Feature" --body "Description"
# 7. CI will pass because local testing was comprehensive
What This Preventsβ
Before (Unreliable)β
Local Test β "Looks good!" β Push β GitHub CI Fails β Fix β Push Again
After (Reliable)β
Local CI Script β Fix Issues β Commit β Push β GitHub CI Passes β
Emergency Workflowsβ
If GitHub CI Still Failsβ
# 1. Check what GitHub CI ran
gh pr checks PR_NUMBER
# 2. Get detailed logs
gh run view RUN_ID --log-failed
# 3. Reproduce locally
./scripts/local-ci-test.sh
# 4. Fix and retry
git add . && git commit -m "fix: address CI issues"
git push
Quick Pre-commit Fixβ
# Run only pre-commit checks
pre-commit run --all-files
# Auto-fix formatting
git add . && git commit -m "fix: pre-commit formatting"
Key Lessonsβ
Why Local Testing Failed Beforeβ
- Incomplete testing - Only tested functionality, not formatting
- Missing pre-commit - Hooks weren't installed or run
- No CI simulation - Didn't mirror GitHub Actions environment
Why It's Reliable Nowβ
- Complete coverage - Tests everything GitHub CI tests
- Automated hooks - Pre-commit runs on every commit
- Exact mirroring - Same commands, same environment
- Early feedback - Catch issues before they reach GitHub
Best Practicesβ
For All Contributorsβ
# Run before any commit
./scripts/local-ci-test.sh
# Trust the output - if it passes locally, GitHub CI will pass
For New Contributorsβ
# One-time setup
pre-commit install
# Then follow the workflow above
For Complex Changesβ
# Test specific components
cd docs && npm run build # Test docs only
pre-commit run flake8 --all-files # Test Python linting only
pytest tests/ -v # Test Python functionality only
Technical Detailsβ
Pre-commit Hook Configurationβ
- Formatting: trailing-whitespace, end-of-file-fixer
- Validation: check-yaml, check-toml, check-merge-conflict
- Python: black, isort, flake8, bandit
- Security: bandit security scanning
CI Pipeline Mirroringβ
- Node.js: Same version (18) as GitHub Actions
- Python: Tests across multiple versions like CI
- ACT: Simulates actual GitHub Actions containers
- Build: Same npm commands as production workflow
This workflow ensures 100% reliability between local testing and GitHub CI. π―