Skip to content

Commit 864b208

Browse files
fllesseryanyongyu
andauthored
🧑‍💻 Develop: 迁移使用 uv 管理项目依赖 (#47)
Co-authored-by: Ju4tCode <[email protected]>
1 parent c766f85 commit 864b208

27 files changed

+2210
-1815
lines changed

.devcontainer/devcontainer.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
{
2-
"name": "Default Linux Universal",
3-
"image": "mcr.microsoft.com/devcontainers/universal:2-linux",
2+
"name": "Ubuntu",
3+
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
44
"features": {
5-
"ghcr.io/devcontainers-contrib/features/poetry:2": {}
5+
"ghcr.io/jsburckhardt/devcontainer-features/uv:1": {},
6+
"ghcr.io/meaningful-ooo/devcontainer-features/fish:2": {}
67
},
7-
"postCreateCommand": "poetry config virtualenvs.in-project true && poetry install && poetry run pre-commit install",
8+
"postCreateCommand": "uv sync && uv run pre-commit install",
89
"customizations": {
910
"vscode": {
1011
"settings": {
1112
"python.analysis.diagnosticMode": "workspace",
12-
"ruff.organizeImports": false,
1313
"[python]": {
1414
"editor.defaultFormatter": "charliermarsh.ruff",
1515
"editor.codeActionsOnSave": {
16+
"source.fixAll.ruff": "explicit",
1617
"source.organizeImports": "explicit"
1718
}
1819
},
@@ -43,7 +44,6 @@
4344
"ms-python.python",
4445
"ms-python.vscode-pylance",
4546
"charliermarsh.ruff",
46-
"ms-python.isort",
4747
"EditorConfig.EditorConfig",
4848
"esbenp.prettier-vscode"
4949
]

.github/actions/setup-python/action.yml

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,14 @@ inputs:
55
python-version:
66
description: Python version
77
required: false
8-
default: "3.10"
8+
default: "3.12"
99

1010
runs:
1111
using: "composite"
1212
steps:
13-
- name: Install poetry
14-
run: pipx install poetry
15-
shell: bash
16-
17-
- uses: actions/setup-python@v4
13+
- uses: astral-sh/setup-uv@v7
1814
with:
1915
python-version: ${{ inputs.python-version }}
20-
cache: "poetry"
2116

22-
- run: poetry install
17+
- run: uv sync --locked
2318
shell: bash

.github/workflows/codecov.yml

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,36 @@ name: Code Coverage
22

33
on:
44
push:
5+
branches:
6+
- master
57
pull_request:
68

79
jobs:
810
test:
11+
name: Test Coverage
912
runs-on: ubuntu-latest
10-
name: Run Pytest and Upload Coverage
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"]
17+
env:
18+
PYTHON_VERSION: ${{ matrix.python-version }}
19+
1120
steps:
12-
- uses: actions/checkout@v3
21+
- uses: actions/checkout@v6
1322

1423
- name: Setup Python environment
1524
uses: ./.github/actions/setup-python
25+
with:
26+
python-version: ${{ matrix.python-version }}
1627

1728
- name: Run Pytest
18-
run: poetry run pytest --cov-report xml
29+
run: uv run --no-sync pytest --cov-report xml
1930

2031
- name: Upload coverage report
2132
uses: codecov/codecov-action@v5
2233
with:
34+
env_vars: PYTHON_VERSION
2335
files: ./coverage.xml
2436
flags: unittests
2537
fail_ci_if_error: true

.github/workflows/release.yml

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,30 +12,28 @@ jobs:
1212
id-token: write
1313
contents: write
1414
steps:
15-
- uses: actions/checkout@v3
15+
- uses: actions/checkout@v6
1616

1717
- name: Setup Python environment
1818
uses: ./.github/actions/setup-python
1919

2020
- name: Get Version
2121
id: version
2222
run: |
23-
echo "VERSION=$(poetry version -s)" >> $GITHUB_OUTPUT
23+
echo "VERSION=$(uv version --short)" >> $GITHUB_OUTPUT
2424
echo "TAG_VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
2525
echo "TAG_NAME=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
2626
2727
- name: Check Version
2828
if: steps.version.outputs.VERSION != steps.version.outputs.TAG_VERSION
2929
run: exit 1
3030

31-
- name: Build Package
32-
run: poetry build
33-
34-
- name: Publish Package to PyPI
35-
uses: pypa/gh-action-pypi-publish@release/v1
31+
- name: Build and Publish Package
32+
run: |
33+
uv build
34+
uv publish
3635
3736
- name: Publish Package to GitHub
38-
run: |
39-
gh release upload --clobber ${{ steps.version.outputs.TAG_NAME }} dist/*.tar.gz dist/*.whl
37+
run: gh release upload --clobber ${{ steps.version.outputs.TAG_NAME }} dist/*.tar.gz dist/*.whl
4038
env:
4139
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/ruff.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
name: Ruff Lint
1616
runs-on: ubuntu-latest
1717
steps:
18-
- uses: actions/checkout@v3
18+
- uses: actions/checkout@v6
1919

2020
- name: Run Ruff Lint
21-
uses: chartboost/ruff-action@v1
21+
uses: astral-sh/ruff-action@v3

.pre-commit-config.yaml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,12 @@ repos:
99
- repo: https://github.com/astral-sh/ruff-pre-commit
1010
rev: v0.14.7
1111
hooks:
12-
- id: ruff
12+
- id: ruff-check
1313
args: [--fix, --exit-non-zero-on-fix]
1414
stages: [pre-commit]
1515
- id: ruff-format
1616
stages: [pre-commit]
1717

18-
- repo: https://github.com/pycqa/isort
19-
rev: 7.0.0
20-
hooks:
21-
- id: isort
22-
stages: [pre-commit]
23-
2418
- repo: https://github.com/nonebot/nonemoji
2519
rev: v0.1.4
2620
hooks:

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ _✨ NoneBot2 测试框架 ✨_
4646

4747
本工具为 [pytest](https://docs.pytest.org/en/stable/) 插件,需要配合 pytest 异步插件使用。
4848

49+
```bash
50+
uv add nonebug pytest-asyncio --group test
51+
# 或者使用 anyio
52+
uv add nonebug anyio --group test
53+
```
54+
4955
```bash
5056
poetry add nonebug pytest-asyncio -G test
5157
# 或者使用 anyio

nonebug/app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from .mixin import DriverMixin, CallApiMixin, ProcessMixin, DependentMixin
1+
from .mixin import CallApiMixin, DependentMixin, DriverMixin, ProcessMixin
22

33

44
class App(DependentMixin, ProcessMixin, CallApiMixin, DriverMixin): ...

nonebug/fixture.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from contextlib import asynccontextmanager
22

3-
import pytest
43
from async_asgi_testclient import TestClient
4+
import pytest
55

66
from nonebug.app import App
77
from nonebug.mixin.driver import set_global_client

nonebug/mixin/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from .driver import DriverMixin as DriverMixin
2-
from .process import ProcessMixin as ProcessMixin
31
from .call_api import CallApiMixin as CallApiMixin
42
from .dependent import DependentMixin as DependentMixin
3+
from .driver import DriverMixin as DriverMixin
4+
from .process import ProcessMixin as ProcessMixin

0 commit comments

Comments
 (0)