This document explains the automated PR validation system that ensures code quality and maintainability.
The PR validation system automatically checks every pull request to ensure:
- ✅ Code follows formatting standards
- ✅ Code passes all linting rules
- ✅ All tests pass
- ✅ Code builds successfully
- ✅ Documentation builds without errors
- ✅ No security vulnerabilities
The validation runs automatically when:
- A new PR is opened
- Changes are pushed to an existing PR
- A PR is reopened
cargo fmt --all -- --check- Purpose: Ensures consistent code formatting
- Status: Required ❌
- Fix: Run
cargo fmt --all
cargo clippy --all-targets --all-features -- -D warnings- Purpose: Catches potential bugs and enforces style guidelines
- Status: Required ❌
- Fix: Address all clippy warnings
cargo test --lib- Purpose: Verifies all tests pass
- Status: Required ❌
- Fix: Fix failing tests
cargo build- Purpose: Ensures code compiles in debug mode
- Status: Required ❌
- Fix: Fix compilation errors
cargo build --target wasm32-unknown-unknown --release- Purpose: Ensures WASM builds for blockchain deployment
- Status: Required ❌
- Fix: Fix WASM compilation errors
cargo doc --no-deps --document-private-items- Purpose: Ensures documentation builds without errors
- Status: Optional
⚠️ - Fix: Fix documentation errors
cargo audit- Purpose: Checks for known security vulnerabilities
- Status: Optional
⚠️ - Fix: Update dependencies with vulnerabilities
The system provides:
- PR Comments: Detailed status of all checks
- Status Checks: GitHub status indicators
- Merge Protection: Prevents merging if required checks fail
| Check | Required | Description |
|---|---|---|
| Code Formatting | ✅ | Code must be properly formatted |
| Clippy Lints | ✅ | No linting warnings allowed |
| Unit Tests | ✅ | All tests must pass |
| Debug Build | ✅ | Must compile in debug mode |
| WASM Release Build | ✅ | Must compile for deployment |
| Documentation | Recommended but not required | |
| Security Audit | Recommended but not required |
A PR can only be merged when:
- ✅ All required checks pass
- ✅ At least one code review is approved
- ✅ No merge conflicts exist
- ✅ PR is up to date with main branch
# Fix formatting
cargo fmt --all
# Fix clippy warnings
cargo clippy --fix
# Run tests
cargo test --lib
# Build project
cargo build
cargo build --target wasm32-unknown-unknown --release
# Build documentation
cargo doc --no-deps
# Check security
cargo audit- Problem: Code not properly formatted
- Solution: Run
cargo fmt --alland commit changes
- Problem: Linting rule violations
- Solution: Address each warning, some may require code changes
- Problem: Tests are failing
- Solution: Fix broken tests or update test expectations
- Problem: Compilation errors
- Solution: Fix syntax errors, missing imports, or type issues
- Problem: WASM-specific compilation errors
- Solution: Check for WASM-incompatible code patterns
- ✅ Success: All required checks passed
- ❌ Failure: Required checks failed
- ⏳ Pending: Checks in progress
The system automatically comments on PRs with:
- Overall status (Ready to merge/Not ready)
- Detailed breakdown of each check
- Fix suggestions for failed checks
- Commands to resolve issues
The validation integrates with:
- GitHub Actions: Automated workflow execution
- Branch Protection: Enforces check requirements
- PR Templates: Guides contributors through requirements
- Status API: Updates GitHub status indicators
- Run all validation commands locally
- Ensure all tests pass
- Format code properly
- Address all clippy warnings
- Update documentation if needed
- Run
cargo test --libfrequently - Use
cargo clippyduring development - Format code with
cargo fmt --allregularly - Build WASM to catch deployment issues early
- Verify all required checks pass
- Get at least one code review
- Resolve any merge conflicts
- Update PR description with test results
.github/workflows/pr-validation.yml- Main validation workflow.github/pull_request_template.md- PR creation template.github/branch-protection.yml- Branch protection rulesCONTRIBUTING.md- Development guidelines
If you encounter issues with the validation system:
- Check the logs: Look at the GitHub Actions run logs
- Review the PR comment: Check specific failure reasons
- Run locally: Reproduce the issue using the same commands
- Ask for help: Comment on the PR or open an issue
The validation system is designed to:
- Catch issues early in the development process
- Provide clear feedback on problems
- Maintain high code quality standards
- Reduce review time for maintainers
- Prevent broken code from reaching production
This system helps maintain code quality and makes contributing easier for everyone! 🚀