Thank you for your interest in contributing to Ollama LanCache! This document provides guidelines and information for contributors.
- Fork the repository on GitHub
- Clone your fork locally:
git clone https://github.com/YOUR_USERNAME/ollama-lancache.git cd ollama-lancache - Create a feature branch:
git checkout -b feature/your-feature-name
- Make your changes and commit them
- Push to your fork and submit a pull request
- Go 1.21 or higher
- Git
- Make (optional, but recommended)
# Clone the repository
git clone https://github.com/jjasghar/ollama-lancache.git
cd ollama-lancache
# Install dependencies
go mod download
# Build the project
make build
# OR
go build -o ollama-lancache .
# Run tests
make test
# OR
go test ./...
# Run the application
./ollama-lancache serve --port 8080# Format code
make fmt
go fmt ./...
# Run linter
make lint
golangci-lint run
# Run tests with coverage
make test-coverage
go test -coverprofile=coverage.out ./...
# Build for multiple platforms
make build-all
# Clean build artifacts
make clean- Follow standard Go formatting (
gofmt) - Use meaningful variable and function names
- Add comments for exported functions and complex logic
- Keep functions small and focused
- Handle errors appropriately
- Use Go modules for dependency management
// Good: Clear function name and documentation
// ServeModel handles HTTP requests for model downloads
func (s *ModelServer) ServeModel(w http.ResponseWriter, r *http.Request) {
modelName := r.URL.Query().Get("model")
if modelName == "" {
http.Error(w, "model parameter required", http.StatusBadRequest)
return
}
// Handle the request...
}
// Good: Proper error handling
func (s *ModelServer) loadModels() error {
files, err := os.ReadDir(s.modelsDir)
if err != nil {
return fmt.Errorf("failed to read models directory: %w", err)
}
// Process files...
return nil
}We follow the Conventional Commits specification:
type(scope): description
[optional body]
[optional footer(s)]
Types:
feat: New featurefix: Bug fixdocs: Documentation changesstyle: Code style changes (formatting, etc.)refactor: Code refactoringtest: Adding or updating testschore: Maintenance tasks
Examples:
feat(server): add model distribution endpoint
fix(client): handle Windows path separators correctly
docs(readme): update installation instructions
test(cache): add unit tests for cache management
# Run all tests
go test ./...
# Run tests with verbose output
go test -v ./...
# Run tests with coverage
go test -coverprofile=coverage.out ./...
go tool cover -html=coverage.out
# Run specific test package
go test ./internal/cache/
# Run specific test function
go test -run TestCacheStats ./internal/cache/- Write tests for all new functionality
- Use table-driven tests where appropriate
- Include both positive and negative test cases
- Mock external dependencies
- Aim for high test coverage (>80%)
Test Example:
func TestModelServer_ListModels(t *testing.T) {
tests := []struct {
name string
setup func() *ModelServer
want int
wantErr bool
}{
{
name: "valid models directory",
setup: func() *ModelServer {
return &ModelServer{modelsDir: "testdata/models"}
},
want: 3,
wantErr: false,
},
{
name: "empty directory",
setup: func() *ModelServer {
return &ModelServer{modelsDir: "testdata/empty"}
},
want: 0,
wantErr: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
s := tt.setup()
got, err := s.ListModels()
if (err != nil) != tt.wantErr {
t.Errorf("ListModels() error = %v, wantErr %v", err, tt.wantErr)
return
}
if len(got) != tt.want {
t.Errorf("ListModels() got %d models, want %d", len(got), tt.want)
}
})
}
}- Document all exported functions, types, and variables
- Use clear, concise language
- Provide examples for complex functions
- Keep documentation up-to-date with code changes
When adding new features or changing existing ones:
- Update the README.md if user-facing changes
- Update inline code documentation
- Add or update examples
- Update CLI help text if applicable
When reporting bugs, please include:
- Description: Clear description of the issue
- Steps to Reproduce: Detailed steps to reproduce the bug
- Expected Behavior: What you expected to happen
- Actual Behavior: What actually happened
- Environment: OS, Go version, Ollama version
- Logs: Relevant log output or error messages
Bug Report Template:
## Bug Description
A clear description of what the bug is.
## Steps to Reproduce
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
## Expected Behavior
A clear description of what you expected to happen.
## Actual Behavior
A clear description of what actually happened.
## Environment
- OS: [e.g. Ubuntu 20.04, Windows 11, macOS 13]
- Go Version: [e.g. 1.21.5]
- Ollama Version: [e.g. 0.1.17]
- Ollama LanCache Version: [e.g. 1.0.0]
## Additional Context
Add any other context about the problem here.
For feature requests, please provide:
- Use Case: Describe your use case and problem
- Proposed Solution: Your proposed solution
- Alternatives: Alternative solutions you've considered
- Additional Context: Any additional context or screenshots
- Create an issue for discussion (for significant changes)
- Fork the repository and create a feature branch
- Write tests for your changes
- Update documentation as needed
- Run tests and ensure they pass
- Run linting and fix any issues
- Title: Use a clear, descriptive title
- Description: Provide a detailed description of changes
- Link Issues: Reference related issues using
#issue-number - Small Changes: Keep PRs focused and relatively small
- Test Coverage: Ensure adequate test coverage
## Description
Brief description of the changes.
## Type of Change
- [ ] Bug fix (non-breaking change that fixes an issue)
- [ ] New feature (non-breaking change that adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to change)
- [ ] Documentation update
## Related Issues
Fixes #(issue number)
## Testing
- [ ] Unit tests added/updated
- [ ] Integration tests added/updated
- [ ] Manual testing completed
## Checklist
- [ ] Code follows the project's style guidelines
- [ ] Self-review of code completed
- [ ] Code is commented, particularly hard-to-understand areas
- [ ] Documentation updated as needed
- [ ] Tests added/updated and all tests pass
- [ ] No new warnings or errors introduced- Automated Checks: CI/CD will run tests and linting
- Code Review: Maintainers will review your code
- Feedback: Address any requested changes
- Approval: PR will be approved once ready
- Merge: Maintainers will merge the PR
- GitHub Issues: For bug reports and feature requests
- GitHub Discussions: For questions and general discussion
- Pull Requests: For code contributions
We welcome contributions in these areas:
- Performance improvements for large model transfers
- Better error handling and user feedback
- Cross-platform compatibility fixes
- Security enhancements
- Additional client scripts (Python, Ruby, etc.)
- Web UI improvements for the model browser
- Monitoring and metrics collection
- Configuration management enhancements
- Additional storage backends (S3, GCS, etc.)
- Load balancing capabilities
- Advanced caching strategies
- Plugin system for extensibility
Contributors will be:
- Listed in the project's contributor list
- Mentioned in release notes for significant contributions
- Given credit in documentation where appropriate
If you have questions about contributing, please:
- Check existing documentation
- Search through GitHub issues
- Start a GitHub discussion
- Contact the maintainers
Thank you for contributing to Ollama LanCache! π