Skip to content

Commit 8aae0dd

Browse files
v 0.1
Add project automation and onboarding: a GitHub Actions CI workflow (matrix testing on Python 3.9–3.12, flake8, mypy, black check, pytest with coverage, and a build job using build/twine), a Chinese CONTRIBUTING.md with contribution guidelines and dev setup instructions, and a setup.py packaging script that reads README/requirements, declares metadata, extras, and a console entry point. These changes set up continuous testing, linting, type checking, developer docs, and packaging for release.
1 parent 332abd3 commit 8aae0dd

3 files changed

Lines changed: 230 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main, develop ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
python-version: ["3.9", "3.10", "3.11", "3.12"]
15+
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Set up Python ${{ matrix.python-version }}
20+
uses: actions/setup-python@v5
21+
with:
22+
python-version: ${{ matrix.python-version }}
23+
24+
- name: Install dependencies
25+
run: |
26+
python -m pip install --upgrade pip
27+
pip install -r requirements.txt
28+
pip install pytest pytest-asyncio black flake8 mypy
29+
30+
- name: Lint with flake8
31+
run: |
32+
flake8 src --count --select=E9,F63,F7,F82 --show-source --statistics
33+
flake8 src --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
34+
35+
- name: Type check with mypy
36+
run: |
37+
mypy src --ignore-missing-imports
38+
39+
- name: Format check with black
40+
run: |
41+
black --check src tests || true
42+
43+
- name: Test with pytest
44+
run: |
45+
pytest tests/ -v --cov=src --cov-report=xml
46+
47+
- name: Upload coverage
48+
uses: codecov/codecov-action@v3
49+
with:
50+
file: ./coverage.xml
51+
fail_ci_if_error: false
52+
53+
build:
54+
runs-on: ubuntu-latest
55+
needs: test
56+
57+
steps:
58+
- uses: actions/checkout@v4
59+
60+
- name: Set up Python
61+
uses: actions/setup-python@v5
62+
with:
63+
python-version: "3.11"
64+
65+
- name: Install build dependencies
66+
run: |
67+
python -m pip install --upgrade pip
68+
pip install build twine
69+
70+
- name: Build package
71+
run: |
72+
python -m build
73+
74+
- name: Check package
75+
run: |
76+
twine check dist/*

CONTRIBUTING.md

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# 贡献指南
2+
3+
感谢您对 BlockConnect 项目的关注!我们欢迎各种形式的贡献。
4+
5+
## 如何贡献
6+
7+
### 报告问题
8+
9+
如果您发现了 bug 或有功能建议,请通过 GitHub Issues 提交:
10+
11+
1. 检查是否已有相关 issue
12+
2. 创建新 issue,提供详细信息:
13+
- 问题描述
14+
- 复现步骤
15+
- 预期行为
16+
- 实际行为
17+
- 环境信息(Python版本、操作系统等)
18+
19+
### 提交代码
20+
21+
1. Fork 本仓库
22+
2. 创建特性分支 (`git checkout -b feature/AmazingFeature`)
23+
3. 提交更改 (`git commit -m 'Add some AmazingFeature'`)
24+
4. 推送分支 (`git push origin feature/AmazingFeature`)
25+
5. 创建 Pull Request
26+
27+
### 代码规范
28+
29+
- 遵循 PEP 8 规范
30+
- 使用类型注解
31+
- 编写单元测试
32+
- 更新相关文档
33+
34+
### 开发环境设置
35+
36+
```bash
37+
# 克隆仓库
38+
git clone https://github.com/StarsailsClover/BlockConnect.git
39+
cd BlockConnect
40+
41+
# 创建虚拟环境
42+
python -m venv venv
43+
source venv/bin/activate # Linux/Mac
44+
#
45+
venv\Scripts\activate # Windows
46+
47+
# 安装开发依赖
48+
pip install -r requirements.txt
49+
pip install pytest black flake8 mypy
50+
51+
# 运行测试
52+
pytest tests/
53+
54+
# 代码格式化
55+
black src tests
56+
57+
# 代码检查
58+
flake8 src tests
59+
mypy src
60+
```
61+
62+
## 项目结构
63+
64+
```
65+
BlockConnect/
66+
├── src/ # 源代码
67+
├── tests/ # 测试代码
68+
├── docs/ # 文档
69+
├── examples/ # 示例代码
70+
└── tools/ # 开发工具
71+
```
72+
73+
## 联系方式
74+
75+
- GitHub Issues: [https://github.com/StarsailsClover/BlockConnect/issues](https://github.com/StarsailsClover/BlockConnect/issues)
76+
- Email: SailsHuang@gmail.com
77+
78+
## 行为准则
79+
80+
- 尊重所有参与者
81+
- 欢迎新手,耐心指导
82+
- 专注于建设性讨论
83+
- 接受不同观点
84+
85+
再次感谢您的贡献!

setup.py

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
"""
2+
BlockConnect 安装配置
3+
"""
4+
5+
from setuptools import setup, find_packages
6+
from pathlib import Path
7+
8+
# 读取 README
9+
readme_path = Path(__file__).parent / "README.md"
10+
long_description = readme_path.read_text(encoding="utf-8") if readme_path.exists() else ""
11+
12+
# 读取 requirements
13+
requirements_path = Path(__file__).parent / "requirements.txt"
14+
requirements = []
15+
if requirements_path.exists():
16+
with open(requirements_path, "r", encoding="utf-8") as f:
17+
requirements = [
18+
line.strip()
19+
for line in f
20+
if line.strip() and not line.startswith("#")
21+
]
22+
23+
setup(
24+
name="blockconnect",
25+
version="0.1.0",
26+
author="StarsailsClover",
27+
author_email="SailsHuang@gmail.com",
28+
description="通用游戏互联框架 - 实现任意游戏与 Minecraft 的无缝互通",
29+
long_description=long_description,
30+
long_description_content_type="text/markdown",
31+
url="https://github.com/StarsailsClover/BlockConnect",
32+
packages=find_packages(where="src"),
33+
package_dir={"": "src"},
34+
classifiers=[
35+
"Development Status :: 3 - Alpha",
36+
"Intended Audience :: Developers",
37+
"License :: OSI Approved :: MIT License",
38+
"Operating System :: OS Independent",
39+
"Programming Language :: Python :: 3",
40+
"Programming Language :: Python :: 3.9",
41+
"Programming Language :: Python :: 3.10",
42+
"Programming Language :: Python :: 3.11",
43+
"Programming Language :: Python :: 3.12",
44+
"Topic :: Games/Entertainment",
45+
"Topic :: Software Development :: Libraries :: Python Modules",
46+
],
47+
python_requires=">=3.9",
48+
install_requires=requirements,
49+
extras_require={
50+
"dev": [
51+
"pytest>=8.0.0",
52+
"pytest-asyncio>=0.23.0",
53+
"black>=24.0.0",
54+
"flake8>=7.0.0",
55+
"mypy>=1.8.0",
56+
],
57+
"docs": [
58+
"sphinx>=7.2.0",
59+
"sphinx-rtd-theme>=2.0.0",
60+
],
61+
},
62+
entry_points={
63+
"console_scripts": [
64+
"blockconnect=core.server:main",
65+
],
66+
},
67+
include_package_data=True,
68+
zip_safe=False,
69+
)

0 commit comments

Comments
 (0)