-
Notifications
You must be signed in to change notification settings - Fork 5
41 lines (35 loc) · 1.2 KB
/
ruff.yml
File metadata and controls
41 lines (35 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
name: Ruff
on: [ push, pull_request ]
jobs:
ruff-format:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
- name: Set up Python
run: uv python install 3.12
- name: Format Code
run: uv run ruff format .
- name: Lint Code
run: uv run ruff check .
# - name: Commit and Push Changes (Optional) # 自动格式化后提交并推送更改
# if: github.event_name == 'push' # 仅在 Push 时提交更改
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# run: |
# # 配置 Git 用户信息
# git config --global user.name "github-actions[bot]"
# git config --global user.email "github-actions[bot]@users.noreply.github.com"
# # 检查是否有格式化修改
# if git diff --quiet; then
# echo "No changes to commit."
# else
# # 提交并推送格式化后的代码
# git add .
# git commit -m "Auto-format code via Ruff"
# git push origin HEAD:$GITHUB_REF
# fi