Thank you for your interest in contributing to crossplane-diff! This document provides guidelines and instructions for contributing to the project.
Before you begin, ensure you have the following tools installed:
- Go 1.24+: Download and install Go
- Docker: Required for running tests and builds
- kubectl: For interacting with Kubernetes clusters
- Earthly: Install Earthly for building and testing
- setup-envtest: For integration tests
go install sigs.k8s.io/controller-runtime/tools/setup-envtest@release-0.20 setup-envtest use 1.30.3 # or latest supported version
-
Fork and clone the repository:
git clone https://github.com/your-username/crossplane-diff.git cd crossplane-diff -
Generate required manifests:
earthly +go-generate --CROSSPLANE_IMAGE_TAG=main
-
Build the project:
earthly +build
-
Run unit and integration tests:
cd cmd/diff go test ./...
-
Create a feature branch:
git checkout -b feature/your-feature-name
-
Make your changes following the coding guidelines
-
Write tests for your changes:
- Unit tests for individual components
- Integration tests for component interactions
- E2E tests for full workflow scenarios when appropriate
-
Run the development checks:
# Run all pre-commit checks (linting, unit tests, etc.) earthly +reviewable # Run the full end-to-end test matrix (takes longer) earthly -P +e2e-matrix
Always run these commands before submitting your PR:
-
Check your code is ready for review:
earthly +reviewable
This command runs:
- Code generation verification
- Linting checks
- Unit and integration tests
-
Run the full test suite:
earthly -P +e2e-matrix
This runs end-to-end tests against multiple Crossplane versions (release-1.20 and main).
-
Ensure your commits are clean:
- Use descriptive commit messages
- Squash related commits into logical units
- Follow conventional commit format when possible
The project follows the principles outlined in CLAUDE.md:
- Accuracy over convenience: Never silently continue in the face of failures
- Fail fast and clearly: Provide useful error messages with context
- No partial results: If we can't diff an XR completely, fail the entire diff for that XR
- Comprehensive logging: Include contextual objects in log messages
- Follow standard Go conventions and use
gofmt - Use meaningful variable and function names
- Add comments for complex logic, especially around namespace handling and resource resolution
- Prefer explicit error handling over silent failures
- Unit tests: Test individual functions and methods in isolation
- Integration tests: Test component interactions using
envtest - E2E tests: Test full scenarios with real Crossplane clusters
- Aim for high test coverage, especially for critical paths
- Test both success and failure scenarios
When adding new features:
-
Follow the layered architecture:
- Command Layer: CLI parsing and coordination
- Application Layer: Process orchestration
- Domain Layer: Core business logic
- Client Layer: External system interactions
-
Use dependency injection: Components should depend on interfaces, not concrete implementations
-
Maintain separation of concerns: Each component should have a single, well-defined responsibility
# Unit and integration tests (fast)
cd cmd/diff
go test ./...
# All development checks (linting, tests, etc.)
earthly +reviewable
# Full end-to-end test matrix (slower, comprehensive)
earthly -P +e2e-matrix
# Individual E2E test against specific Crossplane version
earthly +e2e --CROSSPLANE_IMAGE_TAG=main- Unit Tests (
*_test.go): Fast, isolated tests for individual components - Integration Tests (
*_integration_test.go): Tests usingenvtestfor realistic Kubernetes interactions - E2E Tests (
test/e2e/): Full end-to-end scenarios with real Crossplane clusters
-
Ensure your branch is up to date:
git fetch upstream git rebase upstream/main
-
Run all checks:
earthly +reviewable earthly -P +e2e-matrix
-
Open a pull request with:
- Clear description of the changes
- Reference to any related issues
- Screenshots/examples for UI/output changes
- Notes about testing performed
-
Address review feedback promptly and thoroughly
Use clear, descriptive commit messages:
<type>: <short description>
<longer description if needed>
Fixes #issue-number
Types: feat, fix, docs, test, refactor, chore
- Update relevant documentation when making changes
- Add or update code comments for complex logic
- Update the design document for architectural changes
- Include examples in the README for new features
- Issues: Check existing GitHub issues or create a new one
- Discussions: Use GitHub Discussions for questions and ideas
- Code of Conduct: Please follow our Code of Conduct
Releases are handled by maintainers. Contributors should:
- Ensure changes are well-tested and documented
- Update version-related documentation if needed
- Note any breaking changes in the PR description
Thank you for contributing to crossplane-diff!