Skip to content

Commit befab4e

Browse files
committed
fix: 更新 GitHub Actions 工作流使用 Ruff
- ci.yml: 将 black/isort 检查替换为 ruff format/check - auto-format.yml: 使用 Ruff 进行自动格式化 - 修复 CI 构建失败问题 (black 命令不存在)
1 parent 3af9a91 commit befab4e

File tree

2 files changed

+38
-38
lines changed

2 files changed

+38
-38
lines changed

.github/workflows/auto-format.yml

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,33 +11,33 @@ jobs:
1111
permissions:
1212
contents: write
1313
pull-requests: write
14-
14+
1515
steps:
1616
- uses: actions/checkout@v5
1717
with:
1818
ref: ${{ github.head_ref }}
1919
token: ${{ secrets.GITHUB_TOKEN }}
20-
20+
2121
- name: Install uv
2222
uses: astral-sh/setup-uv@v7
2323
with:
2424
version: "latest"
25-
25+
2626
- name: Set up Python
2727
run: uv python install 3.12
28-
28+
2929
- name: Install dependencies
3030
run: |
3131
uv sync --all-extras --dev
32-
33-
- name: Run black
32+
33+
- name: Run Ruff formatter
3434
run: |
35-
uv run black .
36-
37-
- name: Run isort
35+
uv run ruff format .
36+
37+
- name: Run Ruff linter with auto-fix
3838
run: |
39-
uv run isort .
40-
39+
uv run ruff check --fix .
40+
4141
- name: Check for changes
4242
id: check_changes
4343
run: |
@@ -46,16 +46,16 @@ jobs:
4646
else
4747
echo "has_changes=false" >> $GITHUB_OUTPUT
4848
fi
49-
49+
5050
- name: Commit and push changes
5151
if: steps.check_changes.outputs.has_changes == 'true'
5252
run: |
5353
git config --local user.email "github-actions[bot]@users.noreply.github.com"
5454
git config --local user.name "github-actions[bot]"
5555
git add .
56-
git commit -m "style: auto-format code with black and isort [skip ci]"
56+
git commit -m "style: auto-format code with Ruff [skip ci]"
5757
git push
58-
58+
5959
- name: Comment on PR
6060
if: steps.check_changes.outputs.has_changes == 'true'
6161
uses: actions/github-script@v8
@@ -65,5 +65,5 @@ jobs:
6565
issue_number: context.issue.number,
6666
owner: context.repo.owner,
6767
repo: context.repo.repo,
68-
body: '✨ Code has been automatically formatted with `black` and `isort`.'
68+
body: '✨ Code has been automatically formatted with `Ruff`.'
6969
})

.github/workflows/ci.yml

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -13,85 +13,85 @@ jobs:
1313
strategy:
1414
matrix:
1515
python-version: ['3.10', '3.11', '3.12', '3.13']
16-
16+
1717
steps:
1818
- uses: actions/checkout@v5
19-
19+
2020
- name: Install uv
2121
uses: astral-sh/setup-uv@v7
2222
with:
2323
version: "latest"
24-
24+
2525
- name: Set up Python ${{ matrix.python-version }}
2626
run: uv python install ${{ matrix.python-version }}
27-
27+
2828
- name: Install dependencies
2929
run: |
3030
uv sync --all-extras --dev
31-
31+
3232
- name: Run unit tests
3333
run: |
3434
uv run pytest tests/unit -v
35-
35+
3636
- name: Run validators tests
3737
run: |
3838
uv run pytest tests/unit/test_validators.py -v
39-
39+
4040
- name: Run constants tests
4141
run: |
4242
uv run pytest tests/unit/test_constants.py -v
4343
4444
lint:
4545
name: lint
4646
runs-on: ubuntu-latest
47-
47+
4848
steps:
4949
- uses: actions/checkout@v5
50-
50+
5151
- name: Install uv
5252
uses: astral-sh/setup-uv@v7
5353
with:
5454
version: "latest"
55-
55+
5656
- name: Set up Python
5757
run: uv python install 3.12
58-
58+
5959
- name: Install dependencies
6060
run: |
6161
uv sync --all-extras --dev
62-
63-
- name: Check code formatting with black
62+
63+
- name: Check code formatting with Ruff
6464
run: |
65-
uv run black --check .
66-
67-
- name: Check imports with isort
65+
uv run ruff format --check .
66+
67+
- name: Check code with Ruff linter
6868
run: |
69-
uv run isort --check-only .
69+
uv run ruff check .
7070
7171
build:
7272
name: build
7373
runs-on: ubuntu-latest
7474
needs: [test, lint]
75-
75+
7676
steps:
7777
- uses: actions/checkout@v5
78-
78+
7979
- name: Install uv
8080
uses: astral-sh/setup-uv@v7
8181
with:
8282
version: "latest"
83-
83+
8484
- name: Set up Python
8585
run: uv python install 3.12
86-
86+
8787
- name: Install build dependencies
8888
run: |
8989
uv sync --all-extras --dev
90-
90+
9191
- name: Build package
9292
run: |
9393
uv run python -m build
94-
94+
9595
- name: Upload artifacts
9696
uses: actions/upload-artifact@v5
9797
with:

0 commit comments

Comments
 (0)