From 716e8ca39a3c360901bab4c1edc82dcd6e6ee279 Mon Sep 17 00:00:00 2001 From: hyusap Date: Wed, 14 Feb 2024 12:56:26 -0500 Subject: [PATCH 01/11] =?UTF-8?q?=F0=9F=A7=AA=20autogenerate=20sync=20test?= =?UTF-8?q?s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/syncronizer.py | 20 ++++++++++++++++++++ sdk/tests/test_sync.py | 31 +++++++++++++++---------------- 2 files changed, 35 insertions(+), 16 deletions(-) diff --git a/scripts/syncronizer.py b/scripts/syncronizer.py index 758f3eb..0630b8f 100644 --- a/scripts/syncronizer.py +++ b/scripts/syncronizer.py @@ -16,3 +16,23 @@ destination_file_path = os.path.join(this_dir, "../sdk/honcho/sync_client.py") with open(destination_file_path, "w") as destination_file: destination_file.write(sync_code) + + +# tests + +# Open the source file +source_file_path = os.path.join(this_dir, "../sdk/tests/test_async.py") +with open(source_file_path, "r") as source_file: + source_code = source_file.read() + +# Use regex to remove async mentions +sync_code = re.sub(r"@pytest.mark.asyncio\n", "", source_code) +sync_code = re.sub(r"async\s", "", sync_code) +sync_code = re.sub(r"await\s", "", sync_code) +sync_code = re.sub(r"__anext__", "__next__", sync_code) +sync_code = re.sub(r"Async", "", sync_code) + +# Write the modified code to the destination file +destination_file_path = os.path.join(this_dir, "../sdk/tests/test_sync.py") +with open(destination_file_path, "w") as destination_file: + destination_file.write(sync_code) diff --git a/sdk/tests/test_sync.py b/sdk/tests/test_sync.py index 135cc61..aba875f 100644 --- a/sdk/tests/test_sync.py +++ b/sdk/tests/test_sync.py @@ -1,7 +1,8 @@ +import pytest from honcho import GetSessionPage, GetMessagePage, GetMetamessagePage, Session, Message, Metamessage from honcho import Client as Honcho from uuid import uuid1 -import pytest + def test_session_creation_retrieval(): app_id = str(uuid1()) @@ -30,8 +31,8 @@ def test_session_multiple_retrieval(): def test_session_update(): - app_id = str(uuid1()) user_id = str(uuid1()) + app_id = str(uuid1()) client = Honcho(app_id, "http://localhost:8000") created_session = client.create_session(user_id) assert created_session.update({"foo": "bar"}) @@ -40,8 +41,8 @@ def test_session_update(): def test_session_deletion(): - app_id = str(uuid1()) user_id = str(uuid1()) + app_id = str(uuid1()) client = Honcho(app_id, "http://localhost:8000") created_session = client.create_session(user_id) assert created_session.is_active is True @@ -53,8 +54,8 @@ def test_session_deletion(): def test_messages(): - app_id = str(uuid1()) user_id = str(uuid1()) + app_id = str(uuid1()) client = Honcho(app_id, "http://localhost:8000") created_session = client.create_session(user_id) created_session.create_message(is_user=True, content="Hello") @@ -128,13 +129,13 @@ def test_paginated_sessions_generator(): gen = client.get_sessions_generator(user_id) # print(type(gen)) - item = next(gen) + item = gen.__next__() assert item.user_id == user_id assert isinstance(item, Session) - assert next(gen) is not None - assert next(gen) is not None + assert gen.__next__() is not None + assert gen.__next__() is not None with pytest.raises(StopIteration): - next(gen) + gen.__next__() def test_paginated_out_of_bounds(): app_id = str(uuid1()) @@ -183,7 +184,6 @@ def test_paginated_messages(): assert next_page is None - def test_paginated_messages_generator(): app_id = str(uuid1()) user_id = str(uuid1()) @@ -193,17 +193,16 @@ def test_paginated_messages_generator(): created_session.create_message(is_user=False, content="Hi") gen = created_session.get_messages_generator() - item = next(gen) + item = gen.__next__() assert isinstance(item, Message) assert item.content == "Hello" assert item.is_user is True - item2 = next(gen) + item2 = gen.__next__() assert item2 is not None assert item2.content == "Hi" assert item2.is_user is False with pytest.raises(StopIteration): - next(gen) - + gen.__next__() def test_paginated_metamessages(): app_id = str(uuid1()) @@ -246,16 +245,16 @@ def test_paginated_metamessages_generator(): created_session.create_metamessage(message=message, metamessage_type="thought", content="Test 2") gen = created_session.get_metamessages_generator() - item = next(gen) + item = gen.__next__() assert isinstance(item, Metamessage) assert item.content == "Test 1" assert item.metamessage_type == "thought" - item2 = next(gen) + item2 = gen.__next__() assert item2 is not None assert item2.content == "Test 2" assert item2.metamessage_type == "thought" with pytest.raises(StopIteration): - next(gen) + gen.__next__() From 735d780a256675ced80aca98357029bb958e8329 Mon Sep 17 00:00:00 2001 From: hyusap Date: Wed, 14 Feb 2024 14:50:10 -0500 Subject: [PATCH 02/11] test one --- .github/workflows/api_testing.yml | 32 +++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 .github/workflows/api_testing.yml diff --git a/.github/workflows/api_testing.yml b/.github/workflows/api_testing.yml new file mode 100644 index 0000000..0ae177b --- /dev/null +++ b/.github/workflows/api_testing.yml @@ -0,0 +1,32 @@ +name: Run Tests +on: [push, pull_request] +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Set up Python 3.10 + uses: actions/setup-python@v3 + with: + python-version: "3.10" + - name: Install poetry + run: | + pip install poetry + - name: Start Server + run: | + cd api + poetry install --no-root + poetry run uvicorn src.main:app & + sleep 5 + cd .. + - name: Run Tests + run: | + cd sdk + poetry install + poetry run pytest + - name: Stop Server + run: | + kill $(jobs -p) || true + + + From 783156f61f381b6a742ffaaaa0ab225a2c9f3cde Mon Sep 17 00:00:00 2001 From: hyusap Date: Wed, 14 Feb 2024 14:52:31 -0500 Subject: [PATCH 03/11] add db type --- .github/workflows/api_testing.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/api_testing.yml b/.github/workflows/api_testing.yml index 0ae177b..cf6514e 100644 --- a/.github/workflows/api_testing.yml +++ b/.github/workflows/api_testing.yml @@ -19,6 +19,9 @@ jobs: poetry run uvicorn src.main:app & sleep 5 cd .. + env: + DATABASE_TYPE: sqlite + CONNECTION_URI: sqlite:///api.db - name: Run Tests run: | cd sdk From 287db71751c7d22716a0434e19393481695c7561 Mon Sep 17 00:00:00 2001 From: hyusap Date: Wed, 14 Feb 2024 15:34:39 -0500 Subject: [PATCH 04/11] sync client --- .github/workflows/api_testing.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/api_testing.yml b/.github/workflows/api_testing.yml index cf6514e..f5e6780 100644 --- a/.github/workflows/api_testing.yml +++ b/.github/workflows/api_testing.yml @@ -12,6 +12,9 @@ jobs: - name: Install poetry run: | pip install poetry + - name: Syncify Client + run: | + python scripts/syncronizer.py - name: Start Server run: | cd api From 811c7268a839ea5b0d26a3a122f93b539995138b Mon Sep 17 00:00:00 2001 From: hyusap Date: Wed, 14 Feb 2024 15:38:22 -0500 Subject: [PATCH 05/11] add status badge --- README.md | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 47c9441..0aa1a9a 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,13 @@ # Honcho + ![Static Badge](https://img.shields.io/badge/Version-0.0.2-blue) [![Discord](https://img.shields.io/discord/1016845111637839922?style=flat&logo=discord&logoColor=23ffffff&label=Plastic%20Labs&labelColor=235865F2)](https://discord.gg/plasticlabs) ![GitHub License](https://img.shields.io/github/license/plastic-labs/honcho) ![GitHub Repo stars](https://img.shields.io/github/stars/plastic-labs/honcho) [![X (formerly Twitter) URL](https://img.shields.io/twitter/url?url=https%3A%2F%2Ftwitter.com%2Fplastic_labs)](https://twitter.com/plastic_labs) +[![Run Tests](https://github.com/plastic-labs/honcho/actions/workflows/api_testing.yml/badge.svg?branch=staging)](https://github.com/plastic-labs/honcho/actions/workflows/api_testing.yml) + A User context management solution for building AI Agents and LLM powered applications. @@ -48,7 +51,7 @@ poetry install # install dependencies 2. Copy the `.env.template` file and specify the type of database and connection_uri. For testing sqlite is fine. The below example uses an - in-memory sqlite database. + in-memory sqlite database. > Honcho has been tested with Postgresql and SQLite @@ -83,8 +86,7 @@ docker run --env-file .env -p 8000:8000 honcho-api:latest The API can also be deployed on fly.io. Follow the [Fly.io Docs](https://fly.io/docs/getting-started/) to setup your environment and the -`flyctl`. - +`flyctl`. Once `flyctl` is set up use the the following commands to launch the application: @@ -127,12 +129,12 @@ See more information [here](https://python-poetry.org/docs/cli/#add) This project is completely open source and welcomes any and all open source contributions. The workflow for contributing is to make a fork of the repository. You can claim an issue in the issues tab or start a new thread to -indicate a feature or bug fix you are working on. +indicate a feature or bug fix you are working on. Once you have finished your contribution make a PR pointed at the `staging` branch, and it will be reviewed by a project manager. Feel free to join us in our [discord](http://discord.gg/plasticlabs) to discuss your changes or get -help. +help. Once your changes are accepted and merged into staging they will undergo a period of live testing before entering the upstream into `main` From cb42724f721b6e13c7f578182c4c95fb3c368748 Mon Sep 17 00:00:00 2001 From: hyusap Date: Wed, 14 Feb 2024 15:52:02 -0500 Subject: [PATCH 06/11] add coverage --- .github/workflows/api_testing.yml | 17 +++++- sdk/poetry.lock | 92 +++++++++++++++++++++++-------- sdk/pyproject.toml | 1 + 3 files changed, 87 insertions(+), 23 deletions(-) diff --git a/.github/workflows/api_testing.yml b/.github/workflows/api_testing.yml index f5e6780..52eed8c 100644 --- a/.github/workflows/api_testing.yml +++ b/.github/workflows/api_testing.yml @@ -29,7 +29,22 @@ jobs: run: | cd sdk poetry install - poetry run pytest + poetry run coverage run -m pytest + poetry run coverage xml coverage.xml + cd .. + - name: Code Coverage + uses: irongut/CodeCoverageSummary@v1.3.0 + with: + filename: sdk/coverage.xml + badge: true + format: markdown + + - name: Add Coverage PR Comment + uses: marocchino/sticky-pull-request-comment@v2 + if: github.event_name == 'pull_request' + with: + recreate: true + path: code-coverage-results.md - name: Stop Server run: | kill $(jobs -p) || true diff --git a/sdk/poetry.lock b/sdk/poetry.lock index e450ca8..965b0ac 100644 --- a/sdk/poetry.lock +++ b/sdk/poetry.lock @@ -1,10 +1,9 @@ -# This file is automatically @generated by Poetry 1.4.1 and should not be changed by hand. +# This file is automatically @generated by Poetry 1.7.1 and should not be changed by hand. [[package]] name = "anyio" version = "4.2.0" description = "High level compatibility layer for multiple asynchronous event loop implementations" -category = "main" optional = false python-versions = ">=3.8" files = [ @@ -27,7 +26,6 @@ trio = ["trio (>=0.23)"] name = "certifi" version = "2023.11.17" description = "Python package for providing Mozilla's CA Bundle." -category = "main" optional = false python-versions = ">=3.6" files = [ @@ -39,7 +37,6 @@ files = [ name = "colorama" version = "0.4.6" description = "Cross-platform colored terminal text." -category = "dev" optional = false python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,>=2.7" files = [ @@ -47,11 +44,74 @@ files = [ {file = "colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44"}, ] +[[package]] +name = "coverage" +version = "7.4.1" +description = "Code coverage measurement for Python" +optional = false +python-versions = ">=3.8" +files = [ + {file = "coverage-7.4.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:077d366e724f24fc02dbfe9d946534357fda71af9764ff99d73c3c596001bbd7"}, + {file = "coverage-7.4.1-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:0193657651f5399d433c92f8ae264aff31fc1d066deee4b831549526433f3f61"}, + {file = "coverage-7.4.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d17bbc946f52ca67adf72a5ee783cd7cd3477f8f8796f59b4974a9b59cacc9ee"}, + {file = "coverage-7.4.1-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:a3277f5fa7483c927fe3a7b017b39351610265308f5267ac6d4c2b64cc1d8d25"}, + {file = "coverage-7.4.1-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6dceb61d40cbfcf45f51e59933c784a50846dc03211054bd76b421a713dcdf19"}, + {file = "coverage-7.4.1-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:6008adeca04a445ea6ef31b2cbaf1d01d02986047606f7da266629afee982630"}, + {file = "coverage-7.4.1-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:c61f66d93d712f6e03369b6a7769233bfda880b12f417eefdd4f16d1deb2fc4c"}, + {file = "coverage-7.4.1-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:b9bb62fac84d5f2ff523304e59e5c439955fb3b7f44e3d7b2085184db74d733b"}, + {file = "coverage-7.4.1-cp310-cp310-win32.whl", hash = "sha256:f86f368e1c7ce897bf2457b9eb61169a44e2ef797099fb5728482b8d69f3f016"}, + {file = "coverage-7.4.1-cp310-cp310-win_amd64.whl", hash = "sha256:869b5046d41abfea3e381dd143407b0d29b8282a904a19cb908fa24d090cc018"}, + {file = "coverage-7.4.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:b8ffb498a83d7e0305968289441914154fb0ef5d8b3157df02a90c6695978295"}, + {file = "coverage-7.4.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:3cacfaefe6089d477264001f90f55b7881ba615953414999c46cc9713ff93c8c"}, + {file = "coverage-7.4.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:5d6850e6e36e332d5511a48a251790ddc545e16e8beaf046c03985c69ccb2676"}, + {file = "coverage-7.4.1-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:18e961aa13b6d47f758cc5879383d27b5b3f3dcd9ce8cdbfdc2571fe86feb4dd"}, + {file = "coverage-7.4.1-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:dfd1e1b9f0898817babf840b77ce9fe655ecbe8b1b327983df485b30df8cc011"}, + {file = "coverage-7.4.1-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:6b00e21f86598b6330f0019b40fb397e705135040dbedc2ca9a93c7441178e74"}, + {file = "coverage-7.4.1-cp311-cp311-musllinux_1_1_i686.whl", hash = "sha256:536d609c6963c50055bab766d9951b6c394759190d03311f3e9fcf194ca909e1"}, + {file = "coverage-7.4.1-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:7ac8f8eb153724f84885a1374999b7e45734bf93a87d8df1e7ce2146860edef6"}, + {file = "coverage-7.4.1-cp311-cp311-win32.whl", hash = "sha256:f3771b23bb3675a06f5d885c3630b1d01ea6cac9e84a01aaf5508706dba546c5"}, + {file = "coverage-7.4.1-cp311-cp311-win_amd64.whl", hash = "sha256:9d2f9d4cc2a53b38cabc2d6d80f7f9b7e3da26b2f53d48f05876fef7956b6968"}, + {file = "coverage-7.4.1-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:f68ef3660677e6624c8cace943e4765545f8191313a07288a53d3da188bd8581"}, + {file = "coverage-7.4.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:23b27b8a698e749b61809fb637eb98ebf0e505710ec46a8aa6f1be7dc0dc43a6"}, + {file = "coverage-7.4.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:3e3424c554391dc9ef4a92ad28665756566a28fecf47308f91841f6c49288e66"}, + {file = "coverage-7.4.1-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:e0860a348bf7004c812c8368d1fc7f77fe8e4c095d661a579196a9533778e156"}, + {file = "coverage-7.4.1-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:fe558371c1bdf3b8fa03e097c523fb9645b8730399c14fe7721ee9c9e2a545d3"}, + {file = "coverage-7.4.1-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:3468cc8720402af37b6c6e7e2a9cdb9f6c16c728638a2ebc768ba1ef6f26c3a1"}, + {file = "coverage-7.4.1-cp312-cp312-musllinux_1_1_i686.whl", hash = "sha256:02f2edb575d62172aa28fe00efe821ae31f25dc3d589055b3fb64d51e52e4ab1"}, + {file = "coverage-7.4.1-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:ca6e61dc52f601d1d224526360cdeab0d0712ec104a2ce6cc5ccef6ed9a233bc"}, + {file = "coverage-7.4.1-cp312-cp312-win32.whl", hash = "sha256:ca7b26a5e456a843b9b6683eada193fc1f65c761b3a473941efe5a291f604c74"}, + {file = "coverage-7.4.1-cp312-cp312-win_amd64.whl", hash = "sha256:85ccc5fa54c2ed64bd91ed3b4a627b9cce04646a659512a051fa82a92c04a448"}, + {file = "coverage-7.4.1-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:8bdb0285a0202888d19ec6b6d23d5990410decb932b709f2b0dfe216d031d218"}, + {file = "coverage-7.4.1-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:918440dea04521f499721c039863ef95433314b1db00ff826a02580c1f503e45"}, + {file = "coverage-7.4.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:379d4c7abad5afbe9d88cc31ea8ca262296480a86af945b08214eb1a556a3e4d"}, + {file = "coverage-7.4.1-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:b094116f0b6155e36a304ff912f89bbb5067157aff5f94060ff20bbabdc8da06"}, + {file = "coverage-7.4.1-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f2f5968608b1fe2a1d00d01ad1017ee27efd99b3437e08b83ded9b7af3f6f766"}, + {file = "coverage-7.4.1-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:10e88e7f41e6197ea0429ae18f21ff521d4f4490aa33048f6c6f94c6045a6a75"}, + {file = "coverage-7.4.1-cp38-cp38-musllinux_1_1_i686.whl", hash = "sha256:a4a3907011d39dbc3e37bdc5df0a8c93853c369039b59efa33a7b6669de04c60"}, + {file = "coverage-7.4.1-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:6d224f0c4c9c98290a6990259073f496fcec1b5cc613eecbd22786d398ded3ad"}, + {file = "coverage-7.4.1-cp38-cp38-win32.whl", hash = "sha256:23f5881362dcb0e1a92b84b3c2809bdc90db892332daab81ad8f642d8ed55042"}, + {file = "coverage-7.4.1-cp38-cp38-win_amd64.whl", hash = "sha256:a07f61fc452c43cd5328b392e52555f7d1952400a1ad09086c4a8addccbd138d"}, + {file = "coverage-7.4.1-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:8e738a492b6221f8dcf281b67129510835461132b03024830ac0e554311a5c54"}, + {file = "coverage-7.4.1-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:46342fed0fff72efcda77040b14728049200cbba1279e0bf1188f1f2078c1d70"}, + {file = "coverage-7.4.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:9641e21670c68c7e57d2053ddf6c443e4f0a6e18e547e86af3fad0795414a628"}, + {file = "coverage-7.4.1-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:aeb2c2688ed93b027eb0d26aa188ada34acb22dceea256d76390eea135083950"}, + {file = "coverage-7.4.1-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d12c923757de24e4e2110cf8832d83a886a4cf215c6e61ed506006872b43a6d1"}, + {file = "coverage-7.4.1-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:0491275c3b9971cdbd28a4595c2cb5838f08036bca31765bad5e17edf900b2c7"}, + {file = "coverage-7.4.1-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:8dfc5e195bbef80aabd81596ef52a1277ee7143fe419efc3c4d8ba2754671756"}, + {file = "coverage-7.4.1-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:1a78b656a4d12b0490ca72651fe4d9f5e07e3c6461063a9b6265ee45eb2bdd35"}, + {file = "coverage-7.4.1-cp39-cp39-win32.whl", hash = "sha256:f90515974b39f4dea2f27c0959688621b46d96d5a626cf9c53dbc653a895c05c"}, + {file = "coverage-7.4.1-cp39-cp39-win_amd64.whl", hash = "sha256:64e723ca82a84053dd7bfcc986bdb34af8d9da83c521c19d6b472bc6880e191a"}, + {file = "coverage-7.4.1-pp38.pp39.pp310-none-any.whl", hash = "sha256:32a8d985462e37cfdab611a6f95b09d7c091d07668fdc26e47a725ee575fe166"}, + {file = "coverage-7.4.1.tar.gz", hash = "sha256:1ed4b95480952b1a26d863e546fa5094564aa0065e1e5f0d4d0041f293251d04"}, +] + +[package.extras] +toml = ["tomli"] + [[package]] name = "exceptiongroup" version = "1.2.0" description = "Backport of PEP 654 (exception groups)" -category = "main" optional = false python-versions = ">=3.7" files = [ @@ -66,7 +126,6 @@ test = ["pytest (>=6)"] name = "h11" version = "0.14.0" description = "A pure-Python, bring-your-own-I/O implementation of HTTP/1.1" -category = "main" optional = false python-versions = ">=3.7" files = [ @@ -78,7 +137,6 @@ files = [ name = "httpcore" version = "1.0.2" description = "A minimal low-level HTTP client." -category = "main" optional = false python-versions = ">=3.8" files = [ @@ -93,14 +151,13 @@ h11 = ">=0.13,<0.15" [package.extras] asyncio = ["anyio (>=4.0,<5.0)"] http2 = ["h2 (>=3,<5)"] -socks = ["socksio (>=1.0.0,<2.0.0)"] +socks = ["socksio (==1.*)"] trio = ["trio (>=0.22.0,<0.23.0)"] [[package]] name = "httpx" version = "0.26.0" description = "The next generation HTTP client." -category = "main" optional = false python-versions = ">=3.8" files = [ @@ -111,21 +168,20 @@ files = [ [package.dependencies] anyio = "*" certifi = "*" -httpcore = ">=1.0.0,<2.0.0" +httpcore = "==1.*" idna = "*" sniffio = "*" [package.extras] brotli = ["brotli", "brotlicffi"] -cli = ["click (>=8.0.0,<9.0.0)", "pygments (>=2.0.0,<3.0.0)", "rich (>=10,<14)"] +cli = ["click (==8.*)", "pygments (==2.*)", "rich (>=10,<14)"] http2 = ["h2 (>=3,<5)"] -socks = ["socksio (>=1.0.0,<2.0.0)"] +socks = ["socksio (==1.*)"] [[package]] name = "idna" version = "3.6" description = "Internationalized Domain Names in Applications (IDNA)" -category = "main" optional = false python-versions = ">=3.5" files = [ @@ -137,7 +193,6 @@ files = [ name = "iniconfig" version = "2.0.0" description = "brain-dead simple config-ini parsing" -category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -149,7 +204,6 @@ files = [ name = "packaging" version = "23.2" description = "Core utilities for Python packages" -category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -161,7 +215,6 @@ files = [ name = "pluggy" version = "1.3.0" description = "plugin and hook calling mechanisms for python" -category = "dev" optional = false python-versions = ">=3.8" files = [ @@ -177,7 +230,6 @@ testing = ["pytest", "pytest-benchmark"] name = "pytest" version = "7.4.4" description = "pytest: simple powerful testing with Python" -category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -200,7 +252,6 @@ testing = ["argcomplete", "attrs (>=19.2.0)", "hypothesis (>=3.56)", "mock", "no name = "pytest-asyncio" version = "0.23.4" description = "Pytest support for asyncio" -category = "dev" optional = false python-versions = ">=3.8" files = [ @@ -219,7 +270,6 @@ testing = ["coverage (>=6.2)", "hypothesis (>=5.7.1)"] name = "sniffio" version = "1.3.0" description = "Sniff out which async library your code is running under" -category = "main" optional = false python-versions = ">=3.7" files = [ @@ -231,7 +281,6 @@ files = [ name = "tomli" version = "2.0.1" description = "A lil' TOML parser" -category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -243,7 +292,6 @@ files = [ name = "typing-extensions" version = "4.9.0" description = "Backported and Experimental Type Hints for Python 3.8+" -category = "main" optional = false python-versions = ">=3.8" files = [ @@ -254,4 +302,4 @@ files = [ [metadata] lock-version = "2.0" python-versions = "^3.10" -content-hash = "6ccea662fa5a5bae88618123d5d05e0d4955c234b7e1a688d2fae2f90cd9f7f8" +content-hash = "cfdd3c0dc8dba3a70135da5b63a3b027968bb935d4846491c7bba2f30ac20a32" diff --git a/sdk/pyproject.toml b/sdk/pyproject.toml index ff695b5..ac25ab2 100644 --- a/sdk/pyproject.toml +++ b/sdk/pyproject.toml @@ -14,6 +14,7 @@ httpx = "^0.26.0" [tool.poetry.group.test.dependencies] pytest = "^7.4.4" pytest-asyncio = "^0.23.4" +coverage = "^7.4.1" [build-system] requires = ["poetry-core"] From 77f180ae497c02c3d858c2ce3464dbdf0ad8aa9f Mon Sep 17 00:00:00 2001 From: hyusap Date: Wed, 14 Feb 2024 16:04:56 -0500 Subject: [PATCH 07/11] add file --- .github/workflows/api_testing.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/api_testing.yml b/.github/workflows/api_testing.yml index 52eed8c..31341ec 100644 --- a/.github/workflows/api_testing.yml +++ b/.github/workflows/api_testing.yml @@ -37,8 +37,8 @@ jobs: with: filename: sdk/coverage.xml badge: true + output: file format: markdown - - name: Add Coverage PR Comment uses: marocchino/sticky-pull-request-comment@v2 if: github.event_name == 'pull_request' From f359be4dcabf5ed96fb479c3f07fe725838a9f51 Mon Sep 17 00:00:00 2001 From: hyusap Date: Wed, 14 Feb 2024 16:10:10 -0500 Subject: [PATCH 08/11] give perms --- .github/workflows/api_testing.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/api_testing.yml b/.github/workflows/api_testing.yml index 31341ec..ea03bad 100644 --- a/.github/workflows/api_testing.yml +++ b/.github/workflows/api_testing.yml @@ -2,6 +2,8 @@ name: Run Tests on: [push, pull_request] jobs: test: + permissions: + pull-requests: write runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 From 178b4889c30fa73e4a27b5f4e77a6a687a1dc3b5 Mon Sep 17 00:00:00 2001 From: hyusap Date: Wed, 14 Feb 2024 16:15:15 -0500 Subject: [PATCH 09/11] properly output coverage --- .github/workflows/api_testing.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/api_testing.yml b/.github/workflows/api_testing.yml index ea03bad..e7c40a6 100644 --- a/.github/workflows/api_testing.yml +++ b/.github/workflows/api_testing.yml @@ -32,7 +32,7 @@ jobs: cd sdk poetry install poetry run coverage run -m pytest - poetry run coverage xml coverage.xml + poetry run coverage xml -o coverage.xml cd .. - name: Code Coverage uses: irongut/CodeCoverageSummary@v1.3.0 From 18241c911ee2260d3cf5389028b1e79ce5e5c819 Mon Sep 17 00:00:00 2001 From: hyusap Date: Wed, 14 Feb 2024 16:44:27 -0500 Subject: [PATCH 10/11] split test and coverage --- .../{api_testing.yml => run_coverage.yml} | 8 +--- .github/workflows/run_tests.yml | 38 +++++++++++++++++++ 2 files changed, 40 insertions(+), 6 deletions(-) rename .github/workflows/{api_testing.yml => run_coverage.yml} (91%) create mode 100644 .github/workflows/run_tests.yml diff --git a/.github/workflows/api_testing.yml b/.github/workflows/run_coverage.yml similarity index 91% rename from .github/workflows/api_testing.yml rename to .github/workflows/run_coverage.yml index e7c40a6..4b52640 100644 --- a/.github/workflows/api_testing.yml +++ b/.github/workflows/run_coverage.yml @@ -1,5 +1,5 @@ name: Run Tests -on: [push, pull_request] +on: [pull_request] jobs: test: permissions: @@ -43,13 +43,9 @@ jobs: format: markdown - name: Add Coverage PR Comment uses: marocchino/sticky-pull-request-comment@v2 - if: github.event_name == 'pull_request' with: recreate: true path: code-coverage-results.md - name: Stop Server run: | - kill $(jobs -p) || true - - - + kill $(jobs -p) || true \ No newline at end of file diff --git a/.github/workflows/run_tests.yml b/.github/workflows/run_tests.yml new file mode 100644 index 0000000..05e3aa8 --- /dev/null +++ b/.github/workflows/run_tests.yml @@ -0,0 +1,38 @@ +name: Run Tests +on: [push, pull_request] +jobs: + test: + permissions: + pull-requests: write + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Set up Python 3.10 + uses: actions/setup-python@v3 + with: + python-version: "3.10" + - name: Install poetry + run: | + pip install poetry + - name: Syncify Client + run: | + python scripts/syncronizer.py + - name: Start Server + run: | + cd api + poetry install --no-root + poetry run uvicorn src.main:app & + sleep 5 + cd .. + env: + DATABASE_TYPE: sqlite + CONNECTION_URI: sqlite:///api.db + - name: Run Tests + run: | + cd sdk + poetry install + poetry run pytest + cd .. + - name: Stop Server + run: | + kill $(jobs -p) || true \ No newline at end of file From 555c84829453023bd42e5d3d983f73f277649053 Mon Sep 17 00:00:00 2001 From: hyusap Date: Wed, 14 Feb 2024 16:45:21 -0500 Subject: [PATCH 11/11] rename action --- .github/workflows/run_coverage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/run_coverage.yml b/.github/workflows/run_coverage.yml index 4b52640..bc2d780 100644 --- a/.github/workflows/run_coverage.yml +++ b/.github/workflows/run_coverage.yml @@ -1,4 +1,4 @@ -name: Run Tests +name: Run Coverage on: [pull_request] jobs: test: