Thank you for your interest in contributing to infranow! This document provides guidelines and instructions for contributing.
- Go 1.25 or later
- Git
- Make
- (Optional) golangci-lint for linting
- Fork the repository on GitHub
- Clone your fork locally:
git clone https://github.com/YOUR_USERNAME/infranow.git
cd infranow- Add the upstream repository:
git remote add upstream https://github.com/ppiankov/infranow.git- Install dependencies:
make deps- Build the project:
make build- Run tests:
make test- Create a new branch for your feature or fix:
git checkout -b feature/my-new-feature-
Make your changes, following the coding standards below
-
Write or update tests as needed
-
Run the test suite:
make test- Format your code:
make fmt- Run linters (if golangci-lint is installed):
make lint- Commit your changes:
git add .
git commit -m "feat: add my new feature"- Push your branch to your fork:
git push origin feature/my-new-feature-
Open a Pull Request on GitHub
-
Ensure all CI checks pass
-
Wait for review and address any feedback
- Follow standard Go conventions (
gofmt,go vet) - Use meaningful variable and function names
- Keep functions focused and reasonably sized
- Add comments for exported functions and types
- Use early returns to reduce nesting
cmd/- Command-line entry pointsinternal/- Internal packages (not importable by external projects)cli/- CLI command implementationsdetector/- Problem detection logicmetrics/- Metrics provider implementationsmodels/- Core data structuresmonitor/- Monitoring orchestration and TUIutil/- Shared utilities
To add a new detector:
-
Create a new detector struct in
internal/detector/(e.g.,kafka.go) -
Implement the
Detectorinterface:
type MyDetector struct {
interval time.Duration
}
func NewMyDetector() *MyDetector {
return &MyDetector{
interval: 30 * time.Second,
}
}
func (d *MyDetector) Name() string {
return "my_detector"
}
func (d *MyDetector) EntityTypes() []string {
return []string{"my_entity_type"}
}
func (d *MyDetector) Interval() time.Duration {
return d.interval
}
func (d *MyDetector) Detect(ctx context.Context, provider metrics.MetricsProvider, window time.Duration) ([]*models.Problem, error) {
// Implementation
}-
Add tests in
internal/detector/my_test.go -
Register the detector in
internal/cli/monitor.go:
func registerDetectors(registry *detector.Registry) {
// ... existing detectors
registry.Register(detector.NewMyDetector())
}- Document the detector in
docs/DETECTORS.md
- Write unit tests for all new code
- Use table-driven tests where appropriate
- Mock external dependencies (Prometheus, etc.)
- Aim for >80% code coverage
- Test edge cases and error conditions
Example test structure:
func TestMyDetector(t *testing.T) {
mockProvider := &metrics.MockProvider{
QueryInstantFunc: func(ctx context.Context, query string, ts time.Time) (model.Vector, error) {
// Return mock data
},
}
detector := NewMyDetector()
problems, err := detector.Detect(context.Background(), mockProvider, 5*time.Minute)
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
// Assertions
}Follow conventional commits format: type: concise imperative statement
Lowercase after colon, no period, max 72 characters. Say WHAT changed, not every detail of HOW.
Types: feat, fix, docs, test, refactor, chore, perf, ci, build
Examples:
feat: add Kafka broker detector
fix: correct problem count display
docs: update detector documentation
test: add watcher orchestration tests
Optional body (separated by blank line) for WHY, not WHAT.
- Tests pass (
make test) - Code is formatted (
make fmt) - Linters pass (
make lint) - Documentation is updated if needed
- CHANGELOG.md is updated (if applicable)
Include in your PR description:
- What problem does this solve?
- How does it solve it?
- Are there any breaking changes?
- Screenshots (for UI changes)
- Related issues (e.g., "Closes #123")
- Maintainers will review your PR
- Address feedback and update your PR
- Once approved, a maintainer will merge
- Update README.md for user-facing changes
- Update ARCHITECTURE.md for architectural changes
- Update DETECTORS.md when adding new detectors
- Add inline code comments for complex logic
- Open an issue for bugs or feature requests
- Start a discussion for questions or ideas
- Reach out to maintainers
Be respectful, inclusive, and constructive. We're all here to build better tools together.
By contributing, you agree that your contributions will be licensed under the MIT License.