realtime-py
realtime-py copied to clipboard
Add github action with trivial test cases with pytest
regarding issue #14
- added github action workflow to run continuous integrations tests
- added trivial test case with pytest to assert the type of socket instance
- run pytest with poetry in ci workflow
need to setup env variables API_KEY and SUPABASE_ID in action secrets
github action workflow log

action secrets

Why are we fixing python version to 3.8 when testing?
This lib should be compatible with python >=3.7, therefore tests should run in 3.7, 3.8, 3.9 and 3.10.
hi @dreinon , i that case we could use a matrix build .
shall i update the pr with matrix build for
3.7, 3.8, 3.9 and 3.10
versions thanks
Yes please! Remember to put 3.10 as a string '3.10'
Please, tell me when you get it done @RizkyRajitha :)
hi @dreinon sorry for the delay . i added the matrix build strategy. seems there some error in python 3.10 version .
bellow is the error log from github action run.
============================= test session starts ==============================
platform linux -- Python 3.10.0, pytest-6.2.5, py-1.11.0, pluggy-1.0.0
rootdir: /home/runner/work/realtime-py/realtime-py
collected 1 item
tests/type_test.py F [100%]
=================================== FAILURES ===================================
_____________________________________ test _____________________________________
def test():
> sock = getSock()
tests/type_test.py:15:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/type_test.py:10: in getSock
s.connect()
realtime_py/connection.py:79: in connect
loop.run_until_complete(self._connect())
/opt/hostedtoolcache/Python/3.10.0/x64/lib/python3.10/asyncio/base_events.py:641: in run_until_complete
return future.result()
realtime_py/connection.py:84: in _connect
ws_connection = await websockets.connect(self.url)
../../../.cache/pypoetry/virtualenvs/realtime-py-Wow5SDVc-py3.10/lib/python3.10/site-packages/websockets/client.py:535: in __await_impl__
transport, protocol = await self._create_connection()
/opt/hostedtoolcache/Python/3.10.0/x64/lib/python3.10/asyncio/base_events.py:1080: in create_connection
transport, protocol = await self._create_connection_transport(
/opt/hostedtoolcache/Python/3.10.0/x64/lib/python3.10/asyncio/base_events.py:1098: in _create_connection_transport
protocol = protocol_factory()
../../../.cache/pypoetry/virtualenvs/realtime-py-Wow5SDVc-py3.10/lib/python3.10/site-packages/websockets/client.py:69: in __init__
super().__init__(**kwargs)
../../../.cache/pypoetry/virtualenvs/realtime-py-Wow5SDVc-py3.10/lib/python3.10/site-packages/websockets/protocol.py:235: in __init__
self._drain_lock = asyncio.Lock(
/opt/hostedtoolcache/Python/3.10.0/x64/lib/python3.10/asyncio/locks.py:77: in __init__
super().__init__(loop=loop)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <[AttributeError("'Lock' object has no attribute '_locked'") raised in repr()] Lock object at 0x7f496c8b7550>
def __init__(self, *, loop=_marker):
if loop is not _marker:
> raise TypeError(
f'As of 3.10, the *loop* parameter was removed from '
f'{type(self).__name__}() since it is no longer necessary'
)
E TypeError: As of 3.10, the *loop* parameter was removed from Lock() since it is no longer necessary
/opt/hostedtoolcache/Python/3.10.0/x64/lib/python3.10/asyncio/mixins.py:17: TypeError
=============================== warnings summary ===============================
tests/type_test.py::test
/home/runner/work/realtime-py/realtime-py/realtime_py/connection.py:78: DeprecationWarning: There is no current event loop
loop = asyncio.get_event_loop()
-- Docs: https://docs.pytest.org/en/stable/warnings.html
=========================== short test summary info ============================
FAILED tests/type_test.py::test - TypeError: As of 3.10, the *loop* parameter...
========================= 1 failed, 1 warning in 0.31s =========================
updated workflow file. i used python version as "3.10" as mentioned in the comments.
name: CI (Python)
on: [push]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
pythonV: [3.7, 3.8, 3.9, "3.10"]
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.pythonV }}
- name: Cache Pip
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('pyproject.toml') }}
restore-keys: |
${{ runner.os }}-pip-
${{ runner.os }}-
- name: Install dependencies
run: |
pip install poetry
poetry install
- name: Test with Pytest
env:
SUPABASE_ID: ${{ secrets.SUPABASE_ID }}
API_KEY: ${{ secrets.API_KEY }}
run: poetry run pytest
This workflow can serve as a reference. I think it would be nice to use a supabase instance internally in the GitHub Action using Docker so that all developers can test without depending on a specific instance. The gotrue-py library can serve as a reference.
@leynier thanks for the reference material , i will make the necessary changes and update this pr.
the error seems to be a problem in websockets package. https://github.com/aaugustin/websockets/issues/916
@RizkyRajitha maybe you can update the websockets version to 10.1, it adds support for Python 3.10.
@dreinon thanks , i will check it
@dreinon now actions are passing in all python versions . i will try to run supabase in the workflow as well using @leynier references thanks .
This pull request contains the version number bump to 10.1 for websocket, which is necessary to run the library with Python 3.10, which is the new default version on Ubuntu 22.04.
So do you have an update, when you will complete this pull request and perhaps release a new version?
Can I help with that in some way?
Hi @J0 What is the holdup on this pull request? It has been over a year. It would be nice to have websockets 10.1.
Hm the master branch seems to already be using websockets 10.3 which seems to be causing a merge conflict here, everything else looks fine
Addressed the merge conflict and merged. Thanks for your patience everyone!
Hi @J0 , Can we now get a release please? The code in master has websockets version 10.3. But when I try to actually run the code with websockets 10.3.
SolverProblemError
Because no versions of supabase match >0.5.8,<0.6.0
and supabase (0.5.8) depends on realtime (>=0.0.4,<0.0.5), supabase (>=0.5.8,<0.6.0) requires realtime (>=0.0.4,<0.0.5).
Because realtime (0.0.4) depends on websockets (>=9.1,<10.0)
and no versions of realtime match >0.0.4,<0.0.5, realtime (>=0.0.4,<0.0.5) requires websockets (>=9.1,<10.0).
Thus, supabase (>=0.5.8,<0.6.0) requires websockets (>=9.1,<10.0).
So, because your repo depends on both supabase (^0.5.8) and websockets (^10.3.0), version solving failed.