Contributing#
Thank you for your interest in contributing to GeoServer CLI!
Development Setup#
Prerequisites#
- Go 1.24 or later
- Git
- Make (optional)
Getting Started#
Clone the repository:
1 2git clone https://gitlab.com/aice/geoserver-cli.git cd geoserver-cliInstall development tools:
1 2./scripts/setup-git-hooks.sh ./scripts/install-tools.shBuild the project:
1go build -o geoserver-cli ./cmd/geoserver-cliRun tests:
1go test ./...
Code Style#
Formatting#
Code must be formatted with gofmt:
| |
Linting#
Code must pass golangci-lint:
| |
Testing#
All new features should include tests:
| |
Git Workflow#
Create a branch:
1git checkout -b feature/my-featureMake changes and commit:
1 2git add . git commit -m "Add feature X"Push and create merge request:
1git push origin feature/my-feature
Pre-commit Hooks#
The repository uses Git pre-commit hooks to ensure code quality before commits are created. This catches issues early and keeps the commit history clean.
What Gets Checked#
The pre-commit hook automatically runs four checks:
Code Formatting (
gofmt)- Automatically formats all staged
.gofiles - Re-stages formatted files
- Ensures consistent code style
- Automatically formats all staged
Static Analysis (
go vet)- Detects common mistakes and suspicious constructs
- Catches bugs like unreachable code, incorrect struct tags, etc.
Linting (
golangci-lint)- Runs comprehensive linting with multiple linters
- Enforces best practices and style guidelines
- Requires
golangci-lintto be installed (via./scripts/install-tools.sh)
Unit Tests (
go test)- Runs all unit tests in the repository
- Ensures new changes don’t break existing functionality
Setup#
The hooks are set up automatically when you run:
| |
This configures Git to use the .githooks/ directory for hooks.
Verify Setup#
Check that hooks are active:
| |
When Checks Fail#
If any check fails, the commit is blocked and you’ll see error messages:
| |
Fix the issues and try committing again:
| |
Bypassing Hooks (Not Recommended)#
In rare cases, you can skip hooks with:
| |
Warning: This bypasses all quality checks. Use only for emergency fixes or when hooks are incorrectly failing. CI will still catch issues.
Code Organization#
Package Structure#
| |
Adding New Commands#
- Create command function in
internal/cli/ - Add to root command in
internal/cli/root.go - Add tests in
*_test.gofiles - Update documentation
Adding New Features#
- Implement in appropriate
internal/package - Add unit tests
- Add CLI command (if user-facing)
- Update documentation
- Add examples
Documentation#
Code Documentation#
- Use Go doc comments for exported functions
- Follow Go documentation conventions
- Include examples in doc comments when helpful
User Documentation#
- Update
docs/directory for user-facing changes - Add examples for new commands
- Update guides for new workflows
Testing Guidelines#
Unit Tests#
- Test all exported functions
- Use
httptestfor HTTP client tests - Mock external dependencies
- Aim for >80% code coverage
Integration Tests#
- Test against real GeoServer instances (optional)
- Use test containers or local GeoServer
- Document test setup requirements
Commit Messages#
Follow conventional commit format:
| |
Review Process#
- Create merge request
- Ensure CI passes
- Address review comments
- Squash commits if requested
- Merge after approval
Questions?#
- Open an issue for questions
- Check existing issues for similar questions
- Review code comments and documentation
Thank you for contributing!