|
| 1 | +# Contributing Guide (English Version) |
| 2 | + |
| 3 | +> [中文版点这里 / Chinese Version](./CONTRIBUTING.zh.md) |
| 4 | +
|
| 5 | +Thank you for contributing to this project! |
| 6 | +This guide explains how to set up your development environment (recommended: **VS Code + Dev Container**) and how to contribute code following our workflow and style rules. |
| 7 | + |
| 8 | +GitHub Path: `.github/CONTRIBUTING.md` |
| 9 | + |
| 10 | +--- |
| 11 | + |
| 12 | +## Table of Contents |
| 13 | + |
| 14 | +1. [Overview](#1-overview) |
| 15 | +2. [System Requirements](#2-system-requirements) |
| 16 | +3. [Recommended Setup: Clone in Container Volume](#3-recommended-setup-clone-in-container-volume) |
| 17 | +4. [Alternative Setup: Local Clone (Not Recommended)](#4-alternative-setup-local-clone-not-recommended) |
| 18 | +5. [Windows Users (WSL2 Required)](#5-windows-users-wsl2-required) |
| 19 | +6. [China Mainland Network Mirrors](#6-china-mainland-network-mirrors) |
| 20 | +7. [Dev Container Commands & Debugging](#7-dev-container-commands--debugging) |
| 21 | +8. [Commit & Pull Request Workflow](#8-commit--pull-request-workflow) |
| 22 | +9. [Code Style, Pre-commit & Testing](#9-code-style-pre-commit--testing) |
| 23 | +10. [Issues & Community Conduct](#10-issues--community-conduct) |
| 24 | + |
| 25 | +--- |
| 26 | + |
| 27 | +## 1. Overview |
| 28 | + |
| 29 | +This project uses **VS Code + Dev Container** to provide a consistent, containerized development environment. |
| 30 | + |
| 31 | +> ✅ Recommended: Use **“Dev Containers: Clone Repository in Container Volume...”** directly from VS Code to avoid permission issues. |
| 32 | +
|
| 33 | +--- |
| 34 | + |
| 35 | +## 2. System Requirements |
| 36 | + |
| 37 | +- **OS:** Linux / macOS / Windows (with WSL2) |
| 38 | +- **Python:** ≥ 3.11 (for runtime inside container) |
| 39 | +- **VS Code Extensions:** |
| 40 | + - [Dev Containers](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) |
| 41 | + - [Remote - WSL](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-wsl) (Windows only) |
| 42 | +- **Docker:** Docker Desktop (with WSL2 backend) or native Docker |
| 43 | +- **Reference:** See `.devcontainer/Dockerfile` for the environment build details. |
| 44 | + |
| 45 | +> ⚠️ On Windows, you **do not need** to install Python or any build tools inside WSL manually. The container environment handles everything. |
| 46 | +
|
| 47 | +--- |
| 48 | + |
| 49 | +## 3. Recommended Setup: Clone in Container Volume |
| 50 | + |
| 51 | +1. Open **VS Code**. |
| 52 | +2. Press: |
| 53 | + - **Windows/Linux:** `Ctrl + Shift + P` |
| 54 | + - **macOS:** `Cmd + Shift + P` |
| 55 | +3. Type `Dev Containers: Clone Repository in Container Volume...` and press Enter. |
| 56 | +4. Enter your repository URL (e.g., `https://github.com/<org>/<repo>.git`). |
| 57 | +5. VS Code will automatically: |
| 58 | + - Clone the repository into a Docker-managed volume. |
| 59 | + - Build and open the containerized environment. |
| 60 | + |
| 61 | +**Advantages:** |
| 62 | + |
| 63 | +- Avoids UID/GID conflicts. |
| 64 | +- All dependencies and configs remain inside the container. |
| 65 | + |
| 66 | +--- |
| 67 | + |
| 68 | +## 4. Alternative Setup: Local Clone (Not Recommended) |
| 69 | + |
| 70 | +If you prefer cloning locally: |
| 71 | + |
| 72 | +```bash |
| 73 | +git clone <repo-url> |
| 74 | +cd <repo> |
| 75 | +code . |
| 76 | +``` |
| 77 | + |
| 78 | +Then open via command: |
| 79 | + |
| 80 | +> `Dev Containers: Open Folder in Container` |
| 81 | +
|
| 82 | +⚠️ May cause permission issues if your host user differs from the container user. |
| 83 | +Use at your own risk. |
| 84 | + |
| 85 | +--- |
| 86 | + |
| 87 | +## 5. Windows Users (WSL2 Required) |
| 88 | + |
| 89 | +1. Enable WSL2: |
| 90 | + ```powershell |
| 91 | + wsl --install -d Ubuntu |
| 92 | + wsl --set-default-version 2 |
| 93 | + ``` |
| 94 | +2. No need to install Python or compilers manually. |
| 95 | + Just ensure Docker Desktop (WSL2 backend) and VS Code Dev Container extensions are installed. |
| 96 | +3. Clone or open repositories **inside WSL’s Linux filesystem**: |
| 97 | + - Example path: `/home/<user>/<repo>` |
| 98 | + - Avoid using `C:\` drives to prevent performance and permission issues. |
| 99 | + |
| 100 | +--- |
| 101 | + |
| 102 | +## 6. China Mainland Network Mirrors |
| 103 | + |
| 104 | +For users in China Mainland, set mirrors before building: |
| 105 | + |
| 106 | +```bash |
| 107 | +export APT_MIRROR_DOMAIN="mirrors.tuna.tsinghua.edu.cn" |
| 108 | +export PIP_MIRROR_DOMAIN="pypi.tuna.tsinghua.edu.cn" |
| 109 | +``` |
| 110 | + |
| 111 | +These variables are supported inside `devcontainer/Dockerfile`. |
| 112 | + |
| 113 | +--- |
| 114 | + |
| 115 | +## 7. Dev Container Commands & Debugging |
| 116 | + |
| 117 | +| Command | Description | |
| 118 | +| ---------------------------------------- | ------------------------------------ | |
| 119 | +| **Reopen in Container** | Open current folder inside container | |
| 120 | +| **Rebuild Container** | Rebuild environment | |
| 121 | +| **Clone Repository in Container Volume** | Recommended workflow | |
| 122 | +| **Show Container Log** | View build logs and errors | |
| 123 | + |
| 124 | +--- |
| 125 | + |
| 126 | +## 8. Commit & Pull Request Workflow |
| 127 | + |
| 128 | +1. Create a branch: |
| 129 | + |
| 130 | + ```bash |
| 131 | + git checkout -b feat/add-feature |
| 132 | + ``` |
| 133 | + |
| 134 | +2. Follow [Conventional Commits](https://www.conventionalcommits.org/) message format: |
| 135 | + - `feat:` → New feature |
| 136 | + - `fix:` → Bug fix |
| 137 | + - `chore:` → Tooling, configs, or non-functional updates |
| 138 | + - `docs:` → Documentation only |
| 139 | + - `refactor:` → Code restructure |
| 140 | + - `test:` → Test-only changes |
| 141 | + |
| 142 | +3. Example: |
| 143 | + |
| 144 | + ```bash |
| 145 | + feat: add user authentication |
| 146 | + chore: update pre-commit hooks |
| 147 | + fix: correct API endpoint error |
| 148 | + ``` |
| 149 | + |
| 150 | +4. Push and open a Pull Request. |
| 151 | + GitHub Actions will validate your commit messages automatically. |
| 152 | + |
| 153 | +--- |
| 154 | + |
| 155 | +## 9. Code Style, Pre-commit & Testing |
| 156 | + |
| 157 | +- **Pre-commit** is preinstalled inside the container. |
| 158 | +- It automatically runs: |
| 159 | + - `ruff` → Linting and static analysis |
| 160 | + - `mypy` → Type checking |
| 161 | +- Fix all reported issues before committing. |
| 162 | +- Tests use `pytest` (unless specified otherwise). |
| 163 | + |
| 164 | +--- |
| 165 | + |
| 166 | +## 10. Issues & Community Conduct |
| 167 | + |
| 168 | +When opening Issues: |
| 169 | + |
| 170 | +- Include steps to reproduce, logs, and your environment info. |
| 171 | +- Be respectful, concise, and follow community guidelines. |
| 172 | + |
| 173 | +--- |
| 174 | + |
| 175 | +**File Path:** |
| 176 | + |
| 177 | +- English: `.github/CONTRIBUTING.md` |
| 178 | +- Chinese: `.github/CONTRIBUTING.zh.md` |
0 commit comments