Thank you for your interest in contributing to HyperCache! This document outlines the process and guidelines for contributing to the project.
Before you begin:
-
Read the Documentation: Familiarize yourself with the project by reading:
- README.md - Project overview and features
- Development Setup - Environment setup
- Code Structure - Architecture overview
-
Check Existing Issues: Look through GitHub Issues to see if your idea or bug report already exists.
-
Join the Discussion: Feel free to start a discussion in GitHub Discussions for large features or architectural changes.
When filing a bug report, please include:
- Clear Description: What happened vs. what you expected
- Steps to Reproduce: Minimal steps to reproduce the issue
- Environment: Go version, OS, HyperCache version
- Configuration: Relevant config file sections
- Logs: Error messages and relevant log output
Bug Report Template:
**Bug Description**
A clear description of what the bug is.
**To Reproduce**
Steps to reproduce the behavior:
1. Start HyperCache with config '...'
2. Execute command '...'
3. See error
**Expected Behavior**
What you expected to happen.
**Environment**
- OS: [e.g., Ubuntu 22.04, macOS 13.0]
- Go Version: [e.g., 1.23.2]
- HyperCache Version: [e.g., v0.1.0]
**Additional Context**
Any other context about the problem.For feature requests, please provide:
- Use Case: Why is this feature needed?
- Proposed Solution: How should it work?
- Alternatives: Other solutions you've considered
- Breaking Changes: Any compatibility concerns
# Fork the repository on GitHub
git clone https://github.com/YOUR_USERNAME/HyperCache.git
cd HyperCache
git remote add upstream https://github.com/rishabhverma17/HyperCache.git# Create and switch to a new branch
git checkout -b feature/your-feature-name
# Or for bug fixes
git checkout -b fix/issue-descriptionFollow the Development Workflow and Coding Standards below.
# Run all tests
go test ./...
# Run tests with coverage
go test -cover ./...
# Run specific tests
go test ./internal/cache/ -v
# Run benchmarks (if applicable)
go test -bench=. ./internal/cache/Follow Conventional Commits:
# Examples of good commit messages
git commit -m "feat: add support for Redis SCAN command"
git commit -m "fix: resolve race condition in cluster membership"
git commit -m "docs: update API documentation with new commands"
git commit -m "perf: optimize hash ring lookup performance"
git commit -m "test: add integration tests for persistence layer"Commit Types:
feat: New featurefix: Bug fixdocs: Documentation changestest: Adding or updating testsperf: Performance improvementsrefactor: Code refactoringstyle: Code style changeschore: Maintenance tasks
# Push your branch
git push origin feature/your-feature-name
# Create a Pull Request on GitHub- Sync with Upstream:
git fetch upstream
git checkout main
git merge upstream/main- Update Dependencies:
go mod download
go mod tidy- Run Tests Frequently:
# Quick tests during development
go test ./internal/cache/ -short
# Full test suite before committing
go test ./...- Check Code Quality:
# Format code
go fmt ./...
# Vet code
go vet ./...
# Run linter (if golangci-lint is installed)
golangci-lint run- Update Documentation: Keep docs in sync with code changes
-
Follow Go Conventions:
- Use
gofmtfor formatting - Follow effective Go practices
- Use meaningful names for variables and functions
- Use
-
Package Organization:
- Keep packages focused and cohesive
- Avoid circular dependencies
- Use internal packages for private code
-
Error Handling:
- Always handle errors explicitly
- Use custom error types when appropriate
- Provide context in error messages
-
Comments and Documentation:
- Document all exported functions and types
- Use complete sentences in comments
- Explain the "why" not just the "what"
// Set stores a key-value pair in the cache with an optional TTL.
// If ttl is 0, the key will not expire.
// Returns an error if the key cannot be stored due to memory limits.
func (c *Cache) Set(key string, value []byte, ttl time.Duration) error {
if len(key) == 0 {
return ErrInvalidKey
}
// Implementation...
}// Good: Explicit error handling with context
result, err := cache.Get(key)
if err != nil {
return fmt.Errorf("failed to get key %q: %w", key, err)
}
// Bad: Ignoring errors
result, _ := cache.Get(key)func TestCacheSet(t *testing.T) {
tests := []struct {
name string
key string
value []byte
ttl time.Duration
wantErr bool
}{
{"valid key", "test", []byte("value"), 0, false},
{"empty key", "", []byte("value"), 0, true},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
cache := NewCache()
err := cache.Set(tt.key, tt.value, tt.ttl)
if (err != nil) != tt.wantErr {
t.Errorf("Set() error = %v, wantErr %v", err, tt.wantErr)
}
})
}
}- Rebase on Latest Main:
git fetch upstream
git rebase upstream/main- Run Full Test Suite:
go test ./...
go test -race ./...- Check Build:
go build ./...Use this template for your PR description:
## Summary
Brief description of changes
## Changes
- List of specific changes made
- Any breaking changes
- New features added
## Testing
- [ ] All tests pass
- [ ] New tests added for new functionality
- [ ] Manual testing performed
## Documentation
- [ ] Code comments updated
- [ ] Documentation updated (if needed)
- [ ] Configuration examples updated (if needed)
## Related Issues
Fixes #123
Relates to #456- Automated Checks: CI will run tests and checks
- Code Review: Maintainers will review your code
- Address Feedback: Make requested changes
- Final Approval: Once approved, your PR will be merged
- Small, focused changes
- Include test cases
- Update documentation if needed
- Discuss in an issue first for large features
- Follow existing patterns and conventions
- Include comprehensive tests
- Update configuration examples
- Include benchmarks showing improvement
- Ensure no functionality regression
- Document any trade-offs
- Fix typos and improve clarity
- Add examples and use cases
- Keep documentation in sync with code
- Add missing test coverage
- Improve existing tests
- Add integration or benchmark tests
HyperCache follows semantic versioning (SemVer):
- Major (x.0.0): Breaking changes
- Minor (x.y.0): New features, backwards compatible
- Patch (x.y.z): Bug fixes, backwards compatible
We are committed to providing a welcoming and inclusive environment. Please:
- Be Respectful: Treat everyone with respect and kindness
- Be Constructive: Provide helpful feedback and suggestions
- Be Patient: Remember that everyone has different experience levels
- Be Open: Welcome newcomers and help them learn
- GitHub Issues: For bugs and feature requests
- GitHub Discussions: For questions and general discussion
- Code Review: Ask questions during the review process
Contributors will be:
- Listed in the project's contributors list
- Mentioned in release notes (for significant contributions)
- Credited in documentation (for major features)
For significant architectural changes:
- Create an RFC: Document the proposal thoroughly
- Discuss Early: Get feedback before implementation
- Prototype: Build a minimal proof of concept
- Gradual Implementation: Break into smaller PRs
For performance-sensitive areas:
- Benchmark First: Establish baseline performance
- Profile Changes: Use Go's profiling tools
- Document Trade-offs: Explain performance vs. complexity
- Test Thoroughly: Ensure correctness isn't compromised
For security-related changes:
- Follow Security Best Practices: Use secure coding patterns
- Consider Attack Vectors: Think about potential vulnerabilities
- Document Security Implications: Explain security benefits/risks
- Test Edge Cases: Include security-focused test cases
Thank you for contributing to HyperCache! 🚀