Code Contributions
This guide covers the development environment, validation requirements, and contribution workflow. Keep each change focused on one problem so it is easy to review and revert.
Ways to Contribute
You can contribute to HUATUO in several ways:
- Code: fix bugs, add features, or improve performance.
- Documentation: improve documentation, translate content, or write tutorials.
- Testing: write unit and integration tests or report bugs.
- eBPF: add kernel probes or improve kernel compatibility.
- Review: review other contributors’ pull requests.
Development Environment
Prerequisites
| Tool | Requirement | Purpose |
|---|---|---|
| Go | As specified in go.mod (currently 1.24.3) |
Main implementation language |
| Linux | Kernel 4.18+ | Required for eBPF programs |
| Clang/LLVM | A recent version | Compile eBPF C programs |
| Docker | Optional | Containerized development environment |
| Git | A recent version | Version control |
Clone the Repository
# Fork the repository on GitHub first, then:
git clone https://github.com/YOUR_USERNAME/huatuo.git
cd huatuo
git remote add upstream https://github.com/ccfos/huatuo.git
Build and Test
Build
make build # Build BPF programs and Go binaries
make gen-build # Regenerate BPF artifacts and generated Go code
make docker-build # Build the Docker image
Run the Development Stack
Build a development image from the current source and start the collector, API Server, Elasticsearch, Prometheus, and Grafana:
make compose-dev-up
Stop the environment and remove its containers, volumes, and local development image:
make compose-dev-down
Test
make test # Run all tests
make unit # Run unit tests only
make check # Run code style and formatting checks
Note:
make testrequires/etc/kubernetes/pkifor E2E tests. Without a Kubernetes cluster, usemake unit.
To test or debug on other distributions without a local VM, see GitHub Actions VM Debugging.
Contribution Workflow
1. Find or Create an Issue
- Browse open issues for bugs and feature requests.
- To work on an unassigned issue, leave a comment asking to take it.
- For a new idea, create an issue to discuss it first.
2. Create a Branch
git checkout -b fix/short-description
# Or: git checkout -b feat/short-description
# Or: git checkout -b docs/short-description
Branch prefixes:
| Prefix | Purpose |
|---|---|
fix/ |
Bug fixes |
feat/ |
New features |
docs/ |
Documentation |
refactor/ |
Code refactoring |
test/ |
Additional tests |
3. Write Code
- Address one problem at a time.
- Update existing unit tests; add integration tests for components with external dependencies.
- Update documentation when changing configuration, interfaces, storage structures, or features.
- Run
make checkto check code style. - Run
make unitto verify the tests pass.
4. Commit Changes
Use Conventional Commits:
git commit -s -m "fix(scope): short summary
Detailed explanation (optional)
Closes #issue-number
Signed-off-by: Your Name <your.email@example.com>"
The -s flag adds the Signed-off-by line required by the DCO.
5. Push and Open a PR
git push origin your-branch-name
Create a Draft pull request in ccfos/huatuo. When ready, click Ready for review.
6. Code Review
- Maintainers review your PR.
- Address feedback and push new commits.
- You can mark the PR as Draft while revising it, then click Ready for review again.
- Maintainers merge the PR after approval.
Commit Messages
Use type(scope): summary and follow the repository’s AGENTS.md. The body must explain why the change is needed, with no line exceeding 80 characters. Each commit must contain one logical change and no Co-authored-by: trailer.
<type>(<scope>): <description>
Explain why the change is needed (no more than 80 characters per line)
[Optional footer]
Types
| Type | Description |
|---|---|
fix |
Bug fix |
feat |
New feature |
refactor |
Code restructuring without behavior changes |
Examples
fix(pod): preserve response body read errors in httpDoRequest
feat(bpf): add probe for kernel scheduling latency
fix(docs): clarify development setup requirements
fix(request): cover response body reads after doRequest
Code Style
| Language | Tool |
|---|---|
| Go | gofumpt + goimports |
| C (eBPF) | clang-format (configured in .clang-format) |
| Shell | shfmt |
| YAML/JSON | 2-space indentation |
Run make check before every commit to verify compliance.
DCO Sign-off
All contributions require a Developer Certificate of Origin (DCO) sign-off.
Each commit must end with:
Signed-off-by: Your Name <your.email@example.com>
Use git commit -s to add it automatically.
The sign-off confirms that you authored the code or have the right to contribute it under the project’s Apache 2.0 license.
Community
- GitHub Issues: report bugs and request features.
- GitHub Discussions: ask questions and share ideas.
- WeChat: scan the QR code in the README to join the group.