Skip to content

Commit

Permalink
Add CI workflows (#79)
Browse files Browse the repository at this point in the history
* add lint workflow and test workflow

* update workflow test
  • Loading branch information
mandrewcito authored Feb 28, 2022
1 parent fabcf53 commit e78b63b
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 5 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/python-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: Linter - flake8

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Python 3.6
uses: actions/setup-python@v2
with:
python-version: 3.6
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --exclude test,venv --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --exclude test,venv --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
33 changes: 33 additions & 0 deletions .github/workflows/python-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: Integration tests

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
build:

runs-on: ubuntu-latest

steps:
- run: git clone https://github.com/mandrewcito/signalrcore-containertestservers containers
- run: docker-compose -f containers/docker-compose.yml up -d
- uses: actions/checkout@v2
- name: Set up Python 3.6
uses: actions/setup-python@v2
with:
python-version: 3.6
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 coverage
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Test and coverage
run: |
# Test
coverage run -m unittest discover -s test/ -p "*_test.py"
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name="signalrcore",
version="0.9.3",
version="0.9.4",
author="mandrewcito",
author_email="anbaalo@gmail.com",
description="A Python SignalR Core client(json and messagepack), with invocation auth and two way streaming. Compatible with azure / serverless functions. Also with automatic reconnect and manually reconnect.",
Expand Down
9 changes: 5 additions & 4 deletions test/reconnection_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,19 +87,20 @@ def test_no_reconnect(self):
del _lock

def reconnect_test(self, connection):
self._lock = threading.Lock()
_lock = threading.RLock()

connection.on_open(lambda: self._lock.release())
connection.on_open(lambda: _lock.release())

connection.start()

self.assertTrue(self._lock.acquire(timeout=10)) # Release on Open
self.assertTrue(_lock.acquire(timeout=10)) # Release on Open

connection.send("DisconnectMe", [])

self.assertTrue(self._lock.acquire(timeout=10)) # released on open
self.assertTrue(_lock.acquire(timeout=10)) # released on open

connection.stop()
del _lock

def test_raw_reconnection(self):
connection = HubConnectionBuilder()\
Expand Down

0 comments on commit e78b63b

Please sign in to comment.