From 1fb9b9ee079c8384abff74f3ee7539f83502d910 Mon Sep 17 00:00:00 2001 From: Bright Hsu <64823610+bright2227@users.noreply.github.com> Date: Sun, 13 Apr 2025 23:47:47 +0800 Subject: [PATCH 1/6] Create publish.yml --- .github/workflows/publish.yml | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..b55df26 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,35 @@ +name: Upload Package (testing) + +on: + release: + types: [published] + +permissions: + contents: read + +jobs: + release-build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-python@v5 + with: + python-version: "3.12" + + - name: Install the latest version of uv + uses: astral-sh/setup-uv@v5 + with: + version: "0.6.2" + enable-cache: true + + - name: Build release distributions + run: uv build -v --no-binary + + - name: Upload distributions + env: + TWINE_USERNAME: __token__ + TWINE_PASSWORD: ${{ secrets.TEST_PYPI_API_TOKEN }} # + run: | + python3 -m twine upload --repository testpypi dist/* From a34140ec9ffdb6abdbe7f4b01ba67eaec1d610c4 Mon Sep 17 00:00:00 2001 From: bright Date: Thu, 17 Apr 2025 22:12:51 +0800 Subject: [PATCH 2/6] =?UTF-8?q?chore=1B[C:=20test?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/publish.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index b55df26..acb46d5 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -3,6 +3,9 @@ name: Upload Package (testing) on: release: types: [published] + pull_request: + branches: + - '*' permissions: contents: read @@ -17,7 +20,7 @@ jobs: - uses: actions/setup-python@v5 with: python-version: "3.12" - + - name: Install the latest version of uv uses: astral-sh/setup-uv@v5 with: From dd521f3d02aa0905d3eaa94270c7598b9a03a8c9 Mon Sep 17 00:00:00 2001 From: bright Date: Thu, 17 Apr 2025 22:45:01 +0800 Subject: [PATCH 3/6] fix: install the liburing --- .github/workflows/publish.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index acb46d5..5d123b1 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -20,6 +20,14 @@ jobs: - uses: actions/setup-python@v5 with: python-version: "3.12" + submodules: recursive # Initializes and fetches submodules + fetch-depth: 0 # Needed for submodule hashes + + - name: Install the liburing + run: | + cd libs + ./configure + make - name: Install the latest version of uv uses: astral-sh/setup-uv@v5 From d71f82b7c7f9a4cda6aeb079ebd08678825ccea4 Mon Sep 17 00:00:00 2001 From: bright Date: Thu, 17 Apr 2025 22:50:24 +0800 Subject: [PATCH 4/6] fix: workflow --- .github/workflows/publish.yml | 13 ++++++++----- pyproject.toml | 2 +- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 5d123b1..6fbad34 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -16,18 +16,20 @@ jobs: steps: - uses: actions/checkout@v4 + with: + submodules: recursive # Initializes and fetches submodules + fetch-depth: 0 # Needed for submodule hashes - uses: actions/setup-python@v5 with: python-version: "3.12" - submodules: recursive # Initializes and fetches submodules - fetch-depth: 0 # Needed for submodule hashes - name: Install the liburing run: | cd libs ./configure make + sudo make install - name: Install the latest version of uv uses: astral-sh/setup-uv@v5 @@ -36,11 +38,12 @@ jobs: enable-cache: true - name: Build release distributions - run: uv build -v --no-binary - + run: | + uv sync --group dev + uv build -v --sdist - name: Upload distributions env: TWINE_USERNAME: __token__ TWINE_PASSWORD: ${{ secrets.TEST_PYPI_API_TOKEN }} # run: | - python3 -m twine upload --repository testpypi dist/* + uv run twine upload --verbose --repository testpypi dist/* diff --git a/pyproject.toml b/pyproject.toml index 6671f00..457d807 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "uringloop" -version = "0.1.0" +version = "0.1.1" description = "" readme = "README.md" license-files = ["LICENSE"] From a111b4098e7af6f8272d9ce4444269db5011311f Mon Sep 17 00:00:00 2001 From: bright Date: Sat, 19 Apr 2025 16:58:42 +0800 Subject: [PATCH 5/6] chore: remove testing --- .github/workflows/publish.yml | 8 +++----- pyproject.toml | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 6fbad34..c953efa 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,11 +1,8 @@ -name: Upload Package (testing) +name: Upload Package on: release: types: [published] - pull_request: - branches: - - '*' permissions: contents: read @@ -41,9 +38,10 @@ jobs: run: | uv sync --group dev uv build -v --sdist + - name: Upload distributions env: TWINE_USERNAME: __token__ - TWINE_PASSWORD: ${{ secrets.TEST_PYPI_API_TOKEN }} # + TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} # run: | uv run twine upload --verbose --repository testpypi dist/* diff --git a/pyproject.toml b/pyproject.toml index 457d807..6671f00 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "uringloop" -version = "0.1.1" +version = "0.1.0" description = "" readme = "README.md" license-files = ["LICENSE"] From 6285f08c19427d858ed3792ba53ded9721682144 Mon Sep 17 00:00:00 2001 From: bright Date: Sat, 19 Apr 2025 20:02:34 +0800 Subject: [PATCH 6/6] refactor: seperate tests --- tests/{ => e2e/loop}/__init__.py | 0 tests/{ => e2e/loop}/conftest.py | 13 +++++++++++-- tests/e2e/{ => loop}/test_subprocess.py | 0 tests/e2e/{ => loop}/test_unix.py | 0 tests/e2e/{ => proactor}/__init__.py | 0 tests/e2e/{ => proactor}/conftest.py | 13 +++++++++++++ tests/e2e/{ => proactor}/test_tcp.py | 0 tests/e2e/{ => proactor}/test_udp.py | 0 8 files changed, 24 insertions(+), 2 deletions(-) rename tests/{ => e2e/loop}/__init__.py (100%) rename tests/{ => e2e/loop}/conftest.py (53%) rename tests/e2e/{ => loop}/test_subprocess.py (100%) rename tests/e2e/{ => loop}/test_unix.py (100%) rename tests/e2e/{ => proactor}/__init__.py (100%) rename tests/e2e/{ => proactor}/conftest.py (87%) rename tests/e2e/{ => proactor}/test_tcp.py (100%) rename tests/e2e/{ => proactor}/test_udp.py (100%) diff --git a/tests/__init__.py b/tests/e2e/loop/__init__.py similarity index 100% rename from tests/__init__.py rename to tests/e2e/loop/__init__.py diff --git a/tests/conftest.py b/tests/e2e/loop/conftest.py similarity index 53% rename from tests/conftest.py rename to tests/e2e/loop/conftest.py index 3723ae9..4eeeaea 100644 --- a/tests/conftest.py +++ b/tests/e2e/loop/conftest.py @@ -1,17 +1,26 @@ import asyncio +import os +import tempfile from typing import cast import pytest +import pytest_asyncio from uringloop.loop import IouringProactorEventLoop, IouringProactorEventLoopPolicy -@pytest.fixture(scope="session", autouse=True) -def event_loop_policy(): +@pytest_asyncio.fixture(scope="package", autouse=True) +async def event_loop_policy(): asyncio.set_event_loop_policy(IouringProactorEventLoopPolicy()) +# TODO: remove pytest_asyncio warning @pytest.fixture def event_loop(): loop = asyncio.get_event_loop() yield cast(IouringProactorEventLoop, loop) loop.close() + +@pytest.fixture +def unix_socket_path(): + with tempfile.TemporaryDirectory() as f: + yield os.path.join(f, "test.sock") diff --git a/tests/e2e/test_subprocess.py b/tests/e2e/loop/test_subprocess.py similarity index 100% rename from tests/e2e/test_subprocess.py rename to tests/e2e/loop/test_subprocess.py diff --git a/tests/e2e/test_unix.py b/tests/e2e/loop/test_unix.py similarity index 100% rename from tests/e2e/test_unix.py rename to tests/e2e/loop/test_unix.py diff --git a/tests/e2e/__init__.py b/tests/e2e/proactor/__init__.py similarity index 100% rename from tests/e2e/__init__.py rename to tests/e2e/proactor/__init__.py diff --git a/tests/e2e/conftest.py b/tests/e2e/proactor/conftest.py similarity index 87% rename from tests/e2e/conftest.py rename to tests/e2e/proactor/conftest.py index b0058ef..0479a31 100644 --- a/tests/e2e/conftest.py +++ b/tests/e2e/proactor/conftest.py @@ -91,6 +91,19 @@ async def _run_proactor_task(): await asyncio.sleep(0.1) task = loop.create_task(_run_proactor_task()) + + def stop_all_coro_if_raise_exception(task: asyncio.Task[None]): + if task.exception(): # If task failed + # Cancel all other tasks + for t in asyncio.all_tasks(loop): + if t != task and not t.done(): + t.cancel() + + loop.run_until_complete(loop.shutdown_asyncgens()) + + # Add failure callback + task.add_done_callback(stop_all_coro_if_raise_exception) + yield proactor # Cleanup diff --git a/tests/e2e/test_tcp.py b/tests/e2e/proactor/test_tcp.py similarity index 100% rename from tests/e2e/test_tcp.py rename to tests/e2e/proactor/test_tcp.py diff --git a/tests/e2e/test_udp.py b/tests/e2e/proactor/test_udp.py similarity index 100% rename from tests/e2e/test_udp.py rename to tests/e2e/proactor/test_udp.py