Skip to content

Commit e8f0eb6

Browse files
author
Ubuntu
committed
feat: initial project structure
- Main script with modular architecture (bin/auto-pr) - Modules: checks.sh, submit.sh, watch.sh, fix.sh - Templates: copilot-instructions, pr-template, coderabbit.yaml - Tests: test_init.sh (10/10 passing) - CI: GitHub Actions workflow with shellcheck + tests - Support: Rust, Node.js, Python, Go, Bash projects
0 parents  commit e8f0eb6

16 files changed

Lines changed: 1338 additions & 0 deletions

.coderabbit.yaml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# CodeRabbit 配置模板
2+
# 文件位置: .coderabbit.yaml
3+
4+
reviews:
5+
# 自动审查状态
6+
review_status: true
7+
8+
# 自动审查配置
9+
auto_review:
10+
enabled: true
11+
drafts: false
12+
13+
# 路径特定指令
14+
path_instructions:
15+
- path: "src/**/*.rs"
16+
instructions: |
17+
Focus on Rust idioms and error handling
18+
Avoid unwrap() in production code
19+
Check for memory safety issues
20+
21+
- path: "tests/**"
22+
instructions: |
23+
Check test coverage and edge cases
24+
Ensure tests are readable and maintainable
25+
26+
- path: "*.md"
27+
instructions: |
28+
Check for typos and grammar
29+
Ensure code examples are correct
30+
31+
# 忽略的文件
32+
ignore_paths:
33+
- "node_modules/**"
34+
- "target/**"
35+
- ".git/**"
36+
- "*.lock"

.github/copilot-instructions.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Copilot Code Review 自定义指令
2+
# 文件位置: .github/copilot-instructions.md
3+
# 最大 4000 字符
4+
5+
## Code Review Guidelines
6+
7+
### Security
8+
- Check for SQL injection, XSS, path traversal
9+
- No hardcoded secrets or credentials
10+
- Input validation on user-facing inputs
11+
- Auth/authz checks where needed
12+
13+
### Code Quality
14+
- Clear naming (variables, functions, classes)
15+
- No unnecessary complexity
16+
- DRY — no duplicated logic
17+
- Functions focused (single responsibility)
18+
19+
### Testing
20+
- New code paths must have tests
21+
- Happy path and error cases covered
22+
- Tests should be readable and maintainable
23+
24+
### Documentation
25+
- Public APIs must have doc comments
26+
- Non-obvious logic needs "why" comments
27+
- README updated if behavior changed
28+
29+
### Performance
30+
- No N+1 queries or unnecessary loops
31+
- Appropriate caching where beneficial
32+
- No blocking operations in async code paths

.github/dependabot.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "github-actions"
4+
directory: "/"
5+
schedule:
6+
interval: "weekly"
7+
open-pull-requests-limit: 5

.github/pull_request_template.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# PR 模板
2+
# 文件位置: .github/pull_request_template.md
3+
4+
## Summary
5+
<!-- 一句话描述这个 PR 做了什么 -->
6+
7+
## Changes
8+
-
9+
-
10+
11+
## Test Plan
12+
- [ ] CI passes
13+
- [ ] Manual testing done
14+
- [ ] Documentation updated
15+
16+
## Screenshots (if applicable)
17+
<!-- 截图或 GIF -->
18+
19+
## Related Issues
20+
Closes #

.github/workflows/ci.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
15+
- name: Setup
16+
run: |
17+
chmod +x bin/auto-pr
18+
chmod +x tests/*.sh
19+
20+
- name: Check bash syntax
21+
run: |
22+
for f in bin/* src/*.sh tests/*.sh; do
23+
bash -n "$f"
24+
done
25+
26+
- name: Run tests
27+
run: |
28+
./tests/test_init.sh ./bin/auto-pr
29+
30+
lint:
31+
runs-on: ubuntu-latest
32+
steps:
33+
- uses: actions/checkout@v4
34+
35+
- name: Install shellcheck
36+
run: sudo apt-get install -y shellcheck
37+
38+
- name: Run shellcheck
39+
run: |
40+
find . -name "*.sh" -exec shellcheck {} \;
41+
shellcheck bin/auto-pr

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2026 KuaaMU
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
# Auto-PR Workflow 🔄
2+
3+
全自动 PR 提交工作流 — 从代码变更到合并,最大限度减少人工干预。
4+
5+
## ✨ 特性
6+
7+
- **本地安全门禁** — 提交前自动检查 lint、test、密钥
8+
- **AI 双重审查** — Copilot + CodeRabbit 同时审查
9+
- **CI 自动监控** — 失败自动诊断、自动修复(最多3轮)
10+
- **Auto-Merge** — CI 全绿自动合并
11+
- **多语言支持** — Rust、Node.js、Python
12+
13+
## 🚀 安装
14+
15+
```bash
16+
# 克隆
17+
git clone https://github.com/KuaaMU/auto-pr-workflow.git
18+
19+
# 添加到 PATH
20+
echo 'export PATH="$HOME/auto-pr-workflow/bin:$PATH"' >> ~/.bashrc
21+
source ~/.bashrc
22+
```
23+
24+
## 📖 使用
25+
26+
```bash
27+
# 初始化项目配置
28+
auto-pr init
29+
30+
# 提交 PR
31+
auto-pr submit
32+
33+
# 监控 CI 并自动修复
34+
auto-pr watch
35+
36+
# 手动触发 AI 审查
37+
auto-pr review
38+
39+
# 启用 auto-merge
40+
auto-pr merge
41+
```
42+
43+
## 🔄 工作流程
44+
45+
```
46+
Agent 改代码
47+
48+
49+
本地安全门禁 ──── 失败 → 自动修复(最多3轮)
50+
│ 通过
51+
52+
创建分支 + Commit
53+
54+
55+
Push + 创建 PR
56+
│ ├── @copilot(AI审查1)
57+
│ └── @coderabbitai(AI审查2)
58+
59+
CI 运行 ──── 失败 → 自动诊断+修复 → 再push(最多3轮)
60+
│ 全绿
61+
62+
Auto-Merge ──── CI+审查通过 → 自动合并
63+
64+
65+
清理分支
66+
```
67+
68+
## 📁 项目结构
69+
70+
```
71+
auto-pr-workflow/
72+
├── bin/auto-pr # 可执行入口
73+
├── src/
74+
│ ├── auto-pr.sh # 主逻辑
75+
│ ├── checks.sh # 本地检查模块
76+
│ ├── submit.sh # PR 提交模块
77+
│ ├── watch.sh # CI 监控模块
78+
│ └── fix.sh # 自动修复模块
79+
├── tests/
80+
│ ├── test_init.sh # 初始化测试
81+
│ ├── test_checks.sh # 检查模块测试
82+
│ └── test_submit.sh # 提交模块测试
83+
├── templates/
84+
│ ├── copilot-instructions.md
85+
│ ├── pr-template.md
86+
│ └── coderabbit.yaml
87+
└── .github/
88+
├── workflows/ci.yml
89+
└── dependabot.yml
90+
```
91+
92+
## 🤖 AI 审查额度
93+
94+
| 工具 | 免费额度 | 省额度策略 |
95+
|------|----------|------------|
96+
| Copilot | 包含在订阅中 | 小PR不@,大PR才用 |
97+
| CodeRabbit | 公共仓库免费无限 | 公共仓库放心用 |
98+
99+
## 📝 最佳实践
100+
101+
1. **原子化提交** — 一个 PR 解决一个问题
102+
2. **小步快跑** — PR < 300 行
103+
3. **先跑 CI** — 本地检查通过再 push
104+
4. **善用 Draft** — 不确定的 PR 先标 draft
105+
5. **双重审查** — 大功能同时 @copilot@coderabbitai
106+
6. **及时合并** — CI 全绿就合并
107+
108+
## 📄 License
109+
110+
MIT

0 commit comments

Comments
 (0)