From bc35ff63e708b599e13dd0fe02d80c25bfa70d0a Mon Sep 17 00:00:00 2001 From: maze Date: Thu, 9 Oct 2025 12:27:21 +0200 Subject: [PATCH] Added contributing docs and Makefile for doing checks --- CODE_OF_CONDUCT.md | 27 +++++++++++++++ CONTRIBUTING.md | 83 ++++++++++++++++++++++++++++++++++++++++++++++ Makefile | 33 ++++++++++++++++++ 3 files changed, 143 insertions(+) create mode 100644 CODE_OF_CONDUCT.md create mode 100644 CONTRIBUTING.md create mode 100644 Makefile diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..5a7579b --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -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). \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..25ed913 --- /dev/null +++ b/CONTRIBUTING.md @@ -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! \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..2edd74b --- /dev/null +++ b/Makefile @@ -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 \ No newline at end of file