OpenCamp 训练营通用学习工具
这是一个用于在本地对多种编程课程练习进行评测的工具,支持 Rust、C++ 等多种语言的课程,无需依赖 GitHub Actions。
learning-lm-rs、learning-cxx、rustlings 等多种课程类型| 课程类型 | 语言 | 评测方式 | 描述 |
|---|---|---|---|
learning-lm-rs | Rust | cargo test | 大语言模型相关的 Rust 练习 |
learning-cxx | C++ | xmake run summary | C++ 编程练习 |
rustlings | Rust | rustc 编译测试 | Rust 语言学习练习 |
| 其他 | Rust | rustc 编译测试 | 默认使用 Rustlings 评测方式 |
# Ubuntu24.04/Debian
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source ~/.cargo/env
sudo apt install rustup
# Ubuntu/Debian
sudo apt install git
# macOS
brew install git
# 安装 XMake
curl -fsSL https://xmake.io/shget.text | bash
git clone https://github.com/yourusername/learning-tools.git
cd learning-tools
cargo build --release
请先将练习仓库 fork 到您自己的 GitHub 账户,然后使用您自己的仓库链接进行配置,例如您fork后的rustlings仓库链接为https://github.com/user/rustlings.git 使用 learn 命令来添加新的课程仓库:
# 配置 learning-lm-rs 课程
cargo xtask learn learning-lm-rs --submodule https://github.com/user/learning-lm-rs.git
# 配置 learning-cxx 课程
cargo xtask learn learning-cxx --submodule https://github.com/user/learning-cxx.git
# 配置 rustlings 课程
cargo xtask learn rustlings --submodule https://github.com/user/rustlings.git
# 评测 exercises 目录下的所有课程
cargo xtask eval
# 显示详细输出
cargo xtask eval --verbose
# 评测指定课程
cargo xtask eval --course learning-cxx
cargo xtask eval --course rustlings
# 评测指定路径的课程
cargo xtask eval --path ./my-exercises --verbose
评测完成后,工具会在项目根目录生成 eval_result.json 文件,包含以下信息:
{
"exercises": [
{
"name": "exercise01",
"result": true
}
],
"statistics": {
"total_exercations": 42,
"total_succeeds": 40,
"total_failures": 2,
"total_time": 15
}
}
exercises: 每个练习的详细结果
name: 练习名称result: 是否通过(true/false)statistics: 统计信息
total_exercations: 总练习数total_succeeds: 通过数量total_failures: 失败数量total_time: 总耗时(秒)learning-tools/ ├── Cargo.toml # 工作空间配置 ├── README.md # 项目说明 ├── LICENSE # 许可证 ├── .gitmodules # Git 子模块配置 ├── exercises/ # 课程练习目录(Git 子模块) │ ├── learning-lm-rs/ # Rust 大语言模型课程 │ ├── learning-cxx/ # C++ 课程 │ └── rustlings/ # Rustlings 课程 ├── xtask/ # 主要工具实现 │ ├── src/ │ │ ├── main.rs # 命令行入口 │ │ ├── eval.rs # 评测逻辑 │ │ ├── learn.rs # 课程配置 │ │ └── setup.rs # 环境配置 │ └── Cargo.toml ├── environment/ # 环境配置模块 └── eval_result.json # 评测结果文件
A: 使用 cargo xtask learn --course <课程名> --submodule <仓库地址> 命令。
A: 使用 --verbose 参数查看详细输出,检查课程目录和依赖是否正确安装。
A: 目前支持 learning-lm-rs、learning-cxx、rustlings 等,可以通过扩展代码支持更多类型。
我们欢迎各种形式的贡献!
# 克隆项目
git clone https://github.com/yourusername/learning-in-opencamp.git
cd learning-in-opencamp
# 安装依赖并编译
cargo build
# 运行测试
cargo test
# 运行工具
cargo xtask --help
本项目采用 MIT 许可证。