Skip to content

Commit 113d389

Browse files
committed
[引入CodeQL安全扫描并迁移至uv包管理器]: 新增GitHub CodeQL安全分析工作流,将项目依赖管理从pip迁移到uv包管理器以提升性能和可靠性
- **安全扫描增强**: 新增CodeQL安全分析工作流,每月自动执行代码安全扫描,覆盖Python代码漏洞检测,提升项目安全性 - **依赖管理现代化**: 将项目依赖管理从传统pip迁移到uv包管理器,提供更快的依赖安装速度和更可靠的依赖解析 - **工具链更新**: 升级GitHub Actions中的setup-node动作到v6版本,保持CI/CD工具链的时效性和稳定性 - **文档同步更新**: 全面更新README文档,详细说明uv的安装使用方法,提供跨平台安装指南和国内镜像加速配置 - **版本控制完善**: 在.gitignore中添加uv.lock文件,确保依赖锁文件不被意外提交到版本库
1 parent 0b5e741 commit 113d389

File tree

4 files changed

+104
-15
lines changed

4 files changed

+104
-15
lines changed

.github/workflows/codeql.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: CodeQL Security Analysis
2+
3+
on:
4+
push:
5+
paths-ignore:
6+
- '**/*.md'
7+
- '**/*.txt'
8+
- '**/.gitignore'
9+
- '**/LICENSE*'
10+
- '**/README*'
11+
branches-ignore:
12+
- 'dependabot/**'
13+
pull_request:
14+
paths-ignore:
15+
- '**/*.md'
16+
- '**/*.txt'
17+
- '**/.gitignore'
18+
- '**/LICENSE*'
19+
- '**/README*'
20+
branches-ignore:
21+
- 'dependabot/**'
22+
schedule:
23+
- cron: '0 0 1 * *' # 每月1号运行
24+
workflow_dispatch:
25+
26+
jobs:
27+
analyze:
28+
name: CodeQL Analysis
29+
runs-on: ubuntu-latest
30+
permissions:
31+
security-events: write
32+
actions: read
33+
contents: read
34+
35+
steps:
36+
- name: Checkout repository
37+
uses: actions/checkout@v5
38+
with:
39+
fetch-depth: 1
40+
41+
- name: Setup Python
42+
uses: actions/setup-python@v6
43+
44+
- name: Install uv and dependencies
45+
run: |
46+
pip install uv
47+
uv sync --dev
48+
49+
- name: Initialize CodeQL
50+
uses: github/codeql-action/init@v4
51+
with:
52+
languages: python
53+
54+
- name: Autobuild
55+
uses: github/codeql-action/autobuild@v4
56+
57+
- name: Perform CodeQL Analysis
58+
uses: github/codeql-action/analyze@v4

.github/workflows/readme.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
steps:
1515
- uses: actions/checkout@v5
1616
- name: Setup Node.js
17-
uses: actions/setup-node@v5
17+
uses: actions/setup-node@v6
1818
# ISO Langusge Codes: https://cloud.google.com/translate/docs/languages
1919
- name: Adding README - English
2020
uses: dephraiim/translate-readme@main

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,4 +162,5 @@ cython_debug/
162162
# Others
163163
.vscode
164164
logs
165-
movie.parts
165+
movie.parts
166+
uv.lock

README.md

Lines changed: 43 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,39 @@
2323

2424
## 🚀 快速开始
2525

26-
### 安装依赖
26+
### 安装 uv
2727

28-
推荐使用虚拟环境:
28+
首先需要安装 uv - 极速的 Python 包管理器和项目工具链:
29+
30+
**使用 pip 安装(跨平台):**
31+
32+
```bash
33+
pip install uv -i https://pypi.tuna.tsinghua.edu.cn/simple
34+
```
35+
36+
**验证安装:**
37+
38+
```bash
39+
uv --version
40+
```
41+
42+
### 安装项目依赖
43+
44+
使用 uv 管理项目依赖:
2945

3046
```bash
31-
# 创建虚拟环境
32-
python -m venv venv
47+
# 使用 uv 创建虚拟环境并安装所有依赖(一步完成)
48+
uv sync --dev
3349

34-
# 激活虚拟环境 (Linux/macOS)
35-
source venv/bin/activate
50+
# 或者分步执行:
51+
# 1. 创建虚拟环境(默认在 .venv 目录)
52+
uv venv
3653

37-
# 或使用提供的脚本激活
38-
source activate_venv.sh
54+
# 2. 激活虚拟环境 (Linux/macOS)
55+
source .venv/bin/activate
3956

40-
# 安装依赖
41-
pip install -e . -i https://pypi.tuna.tsinghua.edu.cn/simple
57+
# 3. 安装项目依赖(可编辑模式)
58+
uv pip install -e .
4259
```
4360

4461
### 同步依赖文件
@@ -49,10 +66,23 @@ pip install -e . -i https://pypi.tuna.tsinghua.edu.cn/simple
4966
# 生成 requirements.txt
5067
python sync_req.py
5168

52-
# 使用生成的 requirements.txt 安装依赖
53-
pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple
69+
# 使用 uv 通过 requirements.txt 安装依赖
70+
uv pip install -r requirements.txt
71+
```
72+
73+
### 使用清华镜像加速(可选)
74+
75+
如果需要使用国内镜像源:
76+
77+
```bash
78+
# 设置环境变量使用清华镜像
79+
export UV_INDEX_URL=https://pypi.tuna.tsinghua.edu.cn/simple
80+
uv sync --dev
81+
82+
# 或者单次命令指定镜像
83+
uv pip install -e . -i https://pypi.tuna.tsinghua.edu.cn/simple
5484
```
5585

5686
### 使用说明
5787

58-
👉 直接 `cd` 进对应目录,`python xxx.py -h` 即可开玩
88+
👉 直接 `cd` 进对应目录,`uv run python xxx.py -h` 查看具体用法

0 commit comments

Comments
 (0)