Added contributing docs and Makefile for doing checks
This commit is contained in:
27
CODE_OF_CONDUCT.md
Normal file
27
CODE_OF_CONDUCT.md
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
# Code of Conduct
|
||||||
|
|
||||||
|
## Be Respectful
|
||||||
|
|
||||||
|
We are committed to providing a friendly, safe, and welcoming environment for all, regardless of background or identity.
|
||||||
|
|
||||||
|
## Expected Behavior
|
||||||
|
|
||||||
|
- Use welcoming and inclusive language
|
||||||
|
- Be respectful of differing viewpoints
|
||||||
|
- Provide constructive feedback
|
||||||
|
- Show empathy towards others
|
||||||
|
|
||||||
|
## Unacceptable Behavior
|
||||||
|
|
||||||
|
- Harassment, insults, or personal attacks
|
||||||
|
- Discriminatory jokes or language
|
||||||
|
- Publishing others' private information
|
||||||
|
- Any behavior that would make others feel unsafe
|
||||||
|
|
||||||
|
## Enforcement
|
||||||
|
|
||||||
|
Instances of unacceptable behavior may be reported to project maintainers. All reports will be reviewed and may result in consequences ranging from warning to permanent ban.
|
||||||
|
|
||||||
|
## Attribution
|
||||||
|
|
||||||
|
Adapted from the [Contributor Covenant](https://www.contributor-covenant.org).
|
83
CONTRIBUTING.md
Normal file
83
CONTRIBUTING.md
Normal file
@@ -0,0 +1,83 @@
|
|||||||
|
# Contributing
|
||||||
|
|
||||||
|
Thank you for your interest in contributing! This document outlines the process and requirements for contributing to this Go project.
|
||||||
|
|
||||||
|
## Quick Start
|
||||||
|
|
||||||
|
1. Fork the repository
|
||||||
|
2. Create a feature branch (`git checkout -b feature/amazing-feature`)
|
||||||
|
3. Make your changes
|
||||||
|
4. Ensure code meets quality standards (see below)
|
||||||
|
5. Submit a pull request
|
||||||
|
|
||||||
|
## Code Quality Requirements
|
||||||
|
|
||||||
|
### Go version
|
||||||
|
|
||||||
|
We support Go version 1.25 and onwards.
|
||||||
|
|
||||||
|
### Formatting with `goimports`
|
||||||
|
|
||||||
|
All Go code **must** be formatted using `goimports`:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Format all Go files
|
||||||
|
goimports -local git.maze.io/go/dpi -l -w .
|
||||||
|
|
||||||
|
# Install goimports if not available
|
||||||
|
go install golang.org/x/tools/cmd/goimports@latest
|
||||||
|
```
|
||||||
|
|
||||||
|
### Linting with `golangci-lint`
|
||||||
|
|
||||||
|
All code must pass [golangci-lint](https://golangci-lint.run/) checks:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Run linter
|
||||||
|
golangci-lint run
|
||||||
|
```
|
||||||
|
|
||||||
|
### Checking your code
|
||||||
|
|
||||||
|
For convenience, all of the code checks can be run with a single command:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Run all required code checks
|
||||||
|
make check
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Install golangci-lint if not available
|
||||||
|
|
||||||
|
Please refer to the [official documentation](https://golangci-lint.run/docs/welcome/install/) for help on installong `golangci-lint`.
|
||||||
|
|
||||||
|
## Development Workflow
|
||||||
|
|
||||||
|
### Pre-commit Checklist
|
||||||
|
|
||||||
|
* Code formatted with `goimports`
|
||||||
|
* All `golangci-lint` checks pass
|
||||||
|
* Tests are updated/passing
|
||||||
|
* Documentation updated (if applicable)
|
||||||
|
|
||||||
|
### Testing
|
||||||
|
|
||||||
|
Run the test suite before submitting:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
go test ./...
|
||||||
|
```
|
||||||
|
|
||||||
|
## Pull Request Guidelines
|
||||||
|
|
||||||
|
* Keep changes focused and atomic
|
||||||
|
* Update documentation for new features
|
||||||
|
* Ensure CI checks pass
|
||||||
|
* Respond to review feedback promptly
|
||||||
|
|
||||||
|
## Getting Help
|
||||||
|
|
||||||
|
* Open an issue for bug reports or questions
|
||||||
|
* Use discussions for general questions
|
||||||
|
* Contact maintainers for sensitive issues
|
||||||
|
|
||||||
|
Thank you for contributing!
|
33
Makefile
Normal file
33
Makefile
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
default: help
|
||||||
|
|
||||||
|
.PHONY: help
|
||||||
|
help: ## show this help
|
||||||
|
@echo 'usage: make [target] ...'
|
||||||
|
@echo ''
|
||||||
|
@echo 'targets:'
|
||||||
|
@egrep '^(.+)\:\ .*##\ (.+)' ${MAKEFILE_LIST} | sed 's/:.*##/#/' | column -t -c 2 -s '#'
|
||||||
|
|
||||||
|
.PHONY: check
|
||||||
|
check: check-format test lint ## run all code checks
|
||||||
|
|
||||||
|
.PHONY: lint
|
||||||
|
lint: ## lint the code with golangci-lint
|
||||||
|
golangci-lint run
|
||||||
|
|
||||||
|
.PHONY: test
|
||||||
|
test: ## test the code with go test
|
||||||
|
go test -v ./...
|
||||||
|
|
||||||
|
.PHONY: format
|
||||||
|
format: ## format the code with goimports and tidy the go modules
|
||||||
|
go mod tidy -v
|
||||||
|
goimports -local git.maze.io/go/dpi -w *.go */*.go
|
||||||
|
|
||||||
|
.PHONY: check-format
|
||||||
|
check-format: ## check if the the code formatting and modules
|
||||||
|
go mod tidy -diff
|
||||||
|
goimports -local git.maze.io/go/dpi -l -w *.go */*.go
|
||||||
|
|
||||||
|
.PHONY: tools
|
||||||
|
tools: ## fetch and install all required tools
|
||||||
|
go get -v -u golang.org/x/tools/cmd/goimports@latest
|
Reference in New Issue
Block a user