# Contributing to Charon Thank you for your interest in contributing to CaddyProxyManager+! This document provides guidelines and instructions for contributing to the project. ## Table of Contents - [Code of Conduct](#code-of-conduct) - [Getting Started](#getting-started) - [Development Workflow](#development-workflow) - [Coding Standards](#coding-standards) - [Testing Guidelines](#testing-guidelines) - [Pull Request Process](#pull-request-process) - [Issue Guidelines](#issue-guidelines) - [Documentation](#documentation) ## Code of Conduct This project follows a Code of Conduct that all contributors are expected to adhere to: - Be respectful and inclusive - Welcome newcomers and help them get started - Focus on what's best for the community - Show empathy towards other community members ## Getting Started -### Prerequisites - **go 1.26.0+** for backend development - **Node.js 20+** and npm for frontend development - Git for version control - A GitHub account ### Development Tools Install golangci-lint for lefthook pre-commit-phase hooks (required for Go development): Also install lefthook itself so the git hooks work: ```bash # Option 1: Homebrew (macOS/Linux) brew install lefthook # Option 2: Go install go install github.com/evilmartians/lefthook@latest ``` ```bash # Option 1: Homebrew (macOS/Linux) brew install golangci-lint # Option 2: Go install (any platform) go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest # Option 3: Binary installation (see https://golangci-lint.run/usage/install/) curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin ``` Ensure `$GOPATH/bin` is in your `PATH`: ```bash export PATH="$PATH:$(go env GOPATH)/bin" ``` Verify installation: ```bash golangci-lint --version # Should output: golangci-lint has version 1.xx.x ... ``` **Note:** Lefthook pre-commit-phase hooks will **BLOCK commits** if golangci-lint finds issues. This is intentional - fix the issues before committing. ### CI/CD Go Version Management GitHub Actions workflows automatically use go 1.26.0 via `GOTOOLCHAIN: auto`, which allows the `setup-go` action to download and use the correct Go version even if the CI environment has an older version installed. This ensures consistent builds across all workflows. For local development, install go 1.26.0+ from [go.dev/dl](https://go.dev/dl/). ### Go Version Updates When the project's Go version is updated (usually by Renovate): 1. **Pull the latest changes** ```bash git pull ``` 2. **Update your local Go installation** ```bash # Run the Go update skill (downloads and installs the new version) .github/skills/scripts/skill-runner.sh utility-update-go-version ``` 3. **Rebuild your development tools** ```bash # This fixes lefthook hook errors and IDE issues ./scripts/rebuild-go-tools.sh ``` 4. **Restart your IDE's Go language server** - VS Code: Reload window (`Cmd/Ctrl+Shift+P` → "Developer: Reload Window") - GoLand: File → Invalidate Caches → Restart **Why do I need to do this?** Development tools like golangci-lint and gopls are compiled programs. When you upgrade Go, these tools still run on the old version and will break with errors like: ``` error: some/file.go:123:4: undefined: runtime.NewlyAddedFunction ``` Rebuilding tools with `./scripts/rebuild-go-tools.sh` fixes this by compiling them with your new Go version. **What if I forget?** Don't worry! The lefthook pre-commit hook will detect the version mismatch and automatically rebuild tools for you. You'll see: ``` ⚠️ golangci-lint Go version mismatch: golangci-lint: 1.25.6 system Go: 1.26.0 🔧 Rebuilding golangci-lint with current Go version... ``` See [Go Version Upgrades Guide](docs/development/go_version_upgrades.md) for troubleshooting. ### Fork and Clone 1. Fork the repository on GitHub 2. Clone your fork locally: ```bash git clone https://github.com/YOUR_USERNAME/charon.git cd charon ``` 1. Add the upstream remote: ```bash git remote add upstream https://github.com/Wikid82/charon.git ``` ### Set Up Development Environment **Backend:** ```bash cd backend go mod download go run ./cmd/seed/main.go # Seed test data go run ./cmd/api/main.go # Start backend ``` **Frontend:** ```bash cd frontend npm install npm run dev # Start frontend dev server ``` ## Development Workflow ### Branching Strategy - **main** - Production-ready code (stable releases) - **nightly** - Pre-release testing branch (automated daily builds at 02:00 UTC) - **development** - Main development branch (default for contributions) - **feature/** - Feature branches (e.g., `feature/add-ssl-support`) - **bugfix/** - Bug fix branches (e.g., `bugfix/fix-import-crash`) - **hotfix/** - Urgent production fixes ### Branch Flow The project uses a three-tier branching model: ``` development → nightly → main (unstable) (testing) (stable) ``` **Flow details:** 1. **development → nightly**: Automated daily merge at 02:00 UTC 2. **nightly → main**: Manual PR after validation and testing 3. **Contributors always branch from `development`** **Why nightly?** - Provides a testing ground for features before production - Automated daily builds catch integration issues - Users can test pre-release features via `nightly` Docker tag - Maintainers validate stability before merging to `main` ### Creating a Feature Branch Always branch from `development`: ```bash git checkout development git pull upstream development git checkout -b feature/your-feature-name ``` **Note:** Never branch from `nightly` or `main`. The `nightly` branch is managed by automation and receives daily merges from `development`. ### Commit Message Guidelines Follow the [Conventional Commits](https://www.conventionalcommits.org/) specification: ``` ():