5.3 KiB
5.3 KiB
Contributing to sio
Thank you for your interest in contributing to sio! This document provides guidelines and instructions for contributing.
Code of Conduct
Be respectful and professional in all interactions. We're here to build great software together.
Getting Started
Prerequisites
- Go 1.24 or later
- Git
- golangci-lint (for linting)
- Basic understanding of cryptography (helpful but not required)
Development Setup
- Fork the repository on GitHub
- Clone your fork:
git clone https://github.com/YOUR_USERNAME/sio.git cd sio - Add the upstream repository:
git remote add upstream https://github.com/minio/sio.git - Install dependencies:
go mod download
Development Workflow
1. Create a Branch
git checkout -b feature/your-feature-name
Use prefixes:
feature/- New featuresfix/- Bug fixesdocs/- Documentation changesperf/- Performance improvementsrefactor/- Code refactoring
2. Make Changes
Follow the coding standards below and ensure your code:
- Is well-tested
- Includes documentation
- Passes all existing tests
- Doesn't introduce security vulnerabilities
3. Run Tests
# Run all tests
go test -v ./...
# Run with race detector
go test -race ./...
# Run with coverage
go test -coverprofile=coverage.out ./...
go tool cover -html=coverage.out
4. Run Linters
# Run gofmt
gofmt -s -w .
# Run go vet
go vet ./...
# Run golangci-lint
golangci-lint run
5. Commit Changes
Write clear commit messages following this format:
Short summary (50 chars or less)
More detailed explanation if needed. Wrap at 72 characters.
Explain the problem this commit solves and why you chose
this solution.
Fixes #123
6. Push and Create Pull Request
git push origin feature/your-feature-name
Then create a pull request on GitHub with:
- Clear description of the changes
- Reference to related issues
- Screenshots/examples if applicable
Coding Standards
Go Style
- Follow Effective Go
- Use
gofmtfor formatting - Keep functions small and focused
- Write self-documenting code with clear names
Error Handling
- Always check errors
- Wrap errors with context using
fmt.Errorf("context: %w", err) - Return errors, don't panic (except for truly unrecoverable situations)
- Use typed errors for API boundaries
Testing
- Write table-driven tests where appropriate
- Test edge cases and error conditions
- Aim for >80% code coverage
- Use meaningful test names:
TestFunctionName_Scenario
Documentation
- Add godoc comments for all exported types, functions, and constants
- Include usage examples for complex functionality
- Update README.md if adding user-facing features
- Document security considerations
Security
- Never commit secrets or sensitive data
- Be cautious with cryptographic code
- Consider timing attacks and side channels
- Add tests for security-critical code paths
Pull Request Process
- Update documentation - README.md, godoc comments, etc.
- Add tests - New code must include tests
- Pass CI checks - All tests and linters must pass
- Get reviewed - At least one maintainer must approve
- Squash commits - Keep history clean with meaningful commits
PR Checklist
- Tests added/updated and passing
- Documentation updated
- golangci-lint passes
- No breaking changes (or documented in PR)
- Commit messages are clear
- Branch is up to date with master
Testing Guidelines
Unit Tests
Focus on:
- Individual function behavior
- Edge cases (empty inputs, max size, etc.)
- Error conditions
- Different cipher suites
Integration Tests
Focus on:
- End-to-end encryption/decryption
- Different stream sizes
- Reader/Writer interfaces
- Version compatibility
Fuzzing
For cryptographic code, consider adding fuzz tests:
func FuzzDecrypt(f *testing.F) {
// Add corpus and fuzz implementation
}
Benchmarking
When making performance-related changes:
# Run benchmarks
go test -bench=. -benchmem
# Compare before/after
go test -bench=. -benchmem > old.txt
# make changes
go test -bench=. -benchmem > new.txt
benchstat old.txt new.txt
Release Process
(For maintainers)
- Update version numbers and CHANGELOG
- Run full test suite including race detector
- Tag release:
git tag v1.x.x - Push tag:
git push origin v1.x.x - GitHub Actions will create the release
Common Tasks
Adding a New Function
- Implement the function
- Add godoc comment
- Add unit tests
- Add example test
- Update README if user-facing
Fixing a Bug
- Add a test that reproduces the bug
- Fix the bug
- Verify the test now passes
- Consider adding additional edge case tests
Improving Performance
- Add benchmark before changes
- Make improvements
- Run benchmark again
- Include benchmark results in PR
- Verify no functionality regression
Getting Help
- Questions: Open a GitHub Discussion
- Bugs: Open a GitHub Issue
- Security: Email security@min.io
- Chat: Join MinIO Slack (link in README)
Recognition
Contributors will be:
- Listed in release notes
- Mentioned in commit history
- Added to CONTRIBUTORS file (if significant contribution)
Thank you for contributing to sio!