Thank you for your interest in contributing to HyperFleet Adapter! This document provides guidelines and instructions for contributing to the project.
- Code of Conduct
- Getting Started
- Development Setup
- Making Changes
- Code Style
- Testing
- Submitting Changes
- Pull Request Process
This project follows the Contributor Covenant Code of Conduct. By participating, you are expected to uphold this code.
-
Fork the repository on GitHub
-
Clone your fork locally:
git clone https://github.com/YOUR_USERNAME/hyperfleet-adapter.git cd hyperfleet-adapter -
Add the upstream remote:
git remote add upstream https://github.com/openshift-hyperfleet/hyperfleet-adapter.git
-
Create a branch for your changes:
git checkout -b your-feature-branch
- Go 1.24 or later
- Docker (for building Docker images)
golangci-lint(for linting)make(for running Makefile targets)
-
Install Go dependencies:
make tidy
-
Install golangci-lint (if not already installed):
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
# Build the binary
make build
# The binary will be created at: bin/hyperfleet-adapter# Run unit tests
make test
# Run integration tests
make test-integration
# Run all tests
make test-all
# Run tests with coverage
make test-coverage# Run linter
make lint
# Format code
make fmtUse descriptive branch names that indicate the type of change:
feature/your-feature-name- For new featuresfix/your-fix-name- For bug fixesdocs/your-doc-update- For documentation changesrefactor/your-refactor-name- For code refactoring
Follow these guidelines for commit messages:
- Use the present tense ("Add feature" not "Added feature")
- Use the imperative mood ("Move cursor to..." not "Moves cursor to...")
- Limit the first line to 72 characters or less
- Reference issues and pull requests liberally after the first line
- Consider starting the commit message with an applicable emoji:
- 🎨
:art:- Improving structure / format of the code - 🐛
:bug:- Fixing a bug - 📝
:memo:- Writing docs - ✨
:sparkles:- Introducing new features - ♻️
:recycle:- Refactoring code - ✅
:white_check_mark:- Adding tests - 🔧
:wrench:- Changing configuration
- 🎨
Example:
✨ Add operation ID middleware for request tracing
- Implement OperationIDMiddleware to generate unique operation IDs
- Add GetOperationID and WithOpID helper functions
- Update logger to include operation ID in log context
Fixes #123
- Follow the Effective Go guidelines
- Use
gofmtorgoimportsto format code - Run
make fmtbefore committing
- Keep functions small and focused - Each function should do one thing well
- Use meaningful variable names - Avoid abbreviations unless they're widely understood
- Add comments for exported functions, types, and packages
- Handle errors explicitly - Don't ignore errors
- Use context.Context for cancellation and timeouts in long-running operations
cmd/- Main applications for this projectpkg/- Library code that can be imported by other projectstest/- Integration tests and test utilitiesdata/- Configuration templates and data filescharts/- Helm chart templates
- Write unit tests for all new functionality
- Use table-driven tests when testing multiple scenarios
- Run tests before submitting:
make test
- Write integration tests for components that interact with external systems
- Use testcontainers for testing with real dependencies (e.g., databases, message brokers)
- Run integration tests:
make test-integration
- Test names should be descriptive:
TestFunctionName_Scenario_ExpectedBehavior - Use subtests for multiple test cases:
func TestFunction(t *testing.T) { tests := []struct { name string // ... test cases }{ // ... test data } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { // test implementation }) } }
- Clean up resources in tests (use
deferort.Cleanup())
-
Update your branch with the latest changes from upstream:
git fetch upstream git rebase upstream/main
-
Run all checks:
make verify # Runs fmt-check and vet -
Ensure all tests pass:
make test-all
-
Check for linting errors:
make lint
-
Format your code:
make fmt
-
Push your changes to your fork:
git push origin your-feature-branch
-
Create a Pull Request on GitHub:
- Use a clear and descriptive title
- Reference any related issues in the description
- Describe what changes you made and why
- Include screenshots or examples if applicable
-
PR Checklist:
- Code follows the project's style guidelines
- Self-review completed
- Comments added for complex code
- Documentation updated (if needed)
- Tests added/updated
- All tests pass (
make test-all) - Linting passes (
make lint) - No merge conflicts with main branch
## Description
Brief description of the changes
## Related Issues
Fixes #123
Related to #456
## Type of Change
- [ ] Bug fix
- [ ] New feature
- [ ] Breaking change
- [ ] Documentation update
## Testing
Describe the tests you ran and their results
## Checklist
- [ ] Code follows style guidelines
- [ ] Self-review completed
- [ ] Tests added/updated
- [ ] Documentation updated- All PRs require at least one approval before merging
- Address review comments promptly
- Be respectful and constructive in reviews
- Ask questions if something is unclear
If you have questions or need help:
- Check existing issues and pull requests
- Open a new issue with the
questionlabel - Reach out to maintainers