Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update CI, lint, prepare 1.1.0 release #16

Merged
merged 14 commits into from
Nov 30, 2024
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.12'
python-version: '3.13'

- name: Set up Poetry
uses: snok/install-poetry@v1
Expand Down
16 changes: 8 additions & 8 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,29 +21,29 @@ jobs:
# Architectures
- os: ubuntu-latest
arch: amd64
python-version: '3.12'
python-version: '3.13'
- os: ubuntu-latest
arch: arm64
python-version: '3.12'
python-version: '3.13'
- os: macos-latest
arch: amd64
python-version: '3.12'
python-version: '3.13'
- os: macos-latest
arch: arm64
python-version: '3.12'
# Python versions
python-version: '3.13'
# Python versions
- os: ubuntu-latest
arch: amd64
python-version: '3.8'
python-version: '3.12'
- os: ubuntu-latest
arch: amd64
python-version: '3.9'
python-version: '3.11'
- os: ubuntu-latest
arch: amd64
python-version: '3.10'
- os: ubuntu-latest
arch: amd64
python-version: '3.11'
python-version: '3.9'
steps:
- name: Check out the repo
uses: actions/checkout@v3
Expand Down
35 changes: 29 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,28 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog], and this project adheres to [Semantic Versioning].

## [1.1.0] - 2024-11-30

### Fixed

- Fixed reconnection logic ([olalid](https://github.com/olalid))

### Added

- Added `access_token_factory` argument to allow custom token generation. ([caiolombello](https://github.com/caiolombello))
- Added an option to supply external `ssl` context. ([olalid](https://github.com/olalid))
- Added example ASP server with role-based JWT authentication for testing purposes. ([caiolombello](https://github.com/caiolombello))
- Added support for 3.13.

### Removed

- Dropped support for Python 3.8.

### Other

- Significantly improved user and internal documentation, test coverage. ([caiolombello](https://github.com/caiolombello))
- Loosened version constraints for `websockets` and other dependencies. ([MichaelMKKelly](https://github.com/MichaelMKKelly))

## [1.0.0] - 2024-03-07

### Added
Expand Down Expand Up @@ -60,9 +82,10 @@ Initial release.
[semantic versioning]: https://semver.org/spec/v2.0.0.html

<!-- Versions -->
[Unreleased]: https://github.com/dipdup-io/dipdup/compare/1.0.0...HEAD
[1.0.0]: https://github.com/dipdup-io/dipdup/compare/0.2.0...1.0.0
[0.2.0]: https://github.com/dipdup-io/dipdup/compare/0.1.2...0.2.0
[0.1.2]: https://github.com/dipdup-io/dipdup/compare/0.1.1...0.1.2
[0.1.1]: https://github.com/dipdup-io/dipdup/compare/0.1.0...0.1.1
[0.1.0]: https://github.com/dipdup-io/dipdup/releases/tag/0.1.0
[Unreleased]: https://github.com/baking-bad/pysignalr/compare/1.1.0...HEAD
[1.1.0]: https://github.com/baking-bad/pysignalr/compare/1.0.0...1.1.0
[1.0.0]: https://github.com/baking-bad/pysignalr/compare/0.2.0...1.0.0
[0.2.0]: https://github.com/baking-bad/pysignalr/compare/0.1.2...0.2.0
[0.1.2]: https://github.com/baking-bad/pysignalr/compare/0.1.1...0.1.2
[0.1.1]: https://github.com/baking-bad/pysignalr/compare/0.1.0...0.1.1
[0.1.0]: https://github.com/baking-bad/pysignalr/releases/tag/0.1.0
30 changes: 16 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,41 +1,43 @@
.ONESHELL:
.PHONY: $(MAKECMDGOALS)
MAKEFLAGS += --no-print-directory
##
## 🚧 pysignalr developer tools
##

##
SOURCE = src tests example.py example_with_token.py

help: ## Show this help (default)
@grep -F -h "##" $(MAKEFILE_LIST) | grep -F -v fgrep | sed -e 's/\\$$//' | sed -e 's/##//'

all: ## Run a whole CI pipeline: formatters, linters, tests and docs
make lint test docs
install: ## Install dependencies
poetry sync

update: ## Update dependencies
poetry update

all: ## Run a whole CI pipeline: formatters, linters, tests
make lint test

lint: ## Lint with all tools
make black ruff mypy

test: ## Run test suite
docker-compose up --build --exit-code-from test_runner test_runner || docker compose down

docs: ## Generate documentation
docker-compose run --rm docs sphinx-build -b html docs/source docs/build || docker compose down
pytest --cov-report=term-missing --cov=pysignalr --cov-report=xml --asyncio-mode=auto -s -v tests

##

black: ## Format with black
docker-compose run --rm formatter 'pip install black && black src tests example.py' || docker compose down
black $(SOURCE)

ruff: ## Lint with ruff
docker-compose run --rm linter 'pip install ruff && ruff check --fix --unsafe-fixes src tests example.py' || docker compose down
ruff check --fix --unsafe-fixes $(SOURCE)

mypy: ## Lint with mypy
docker-compose run --rm linter 'pip install mypy && mypy --strict src tests example.py' || docker compose down
mypy --strict $(SOURCE)

cover: ## Print coverage for the current branch
docker-compose run --rm coverage 'pip install diff-cover && diff-cover --compare-branch `git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@'` coverage.xml' || docker compose down
diff-cover --compare-branch origin/master coverage.xml

##

clean: ## Remove all files from .gitignore except for `.venv`
sudo git clean -xdf --exclude=".venv"
git clean -xdf --exclude=".venv"
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,12 @@
**pysignalr** is a modern, reliable, and async-ready client for the [SignalR protocol](https://docs.microsoft.com/en-us/aspnet/core/signalr/introduction?view=aspnetcore-5.0). This project started as an asyncio fork of mandrewcito's [signalrcore](https://github.com/mandrewcito/signalrcore) library and ended up as a complete rewrite.

## Table of Contents

1. [Installation](#installation)
2. [Basic Usage](#basic-usage)
3. [Usage with Token Authentication](#usage-with-token-authentication)
4. [API Reference](#api-reference)
5. [Roadmap](#roadmap)
6. [Contributing](#contributing)
7. [License](#license)
5. [License](#license)

## Installation

Expand Down
66 changes: 2 additions & 64 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,67 +6,5 @@ services:
environment:
- ASPNETCORE_ENVIRONMENT=Development
- ASPNETCORE_URLS=http://+:80
networks:
- app-network

test_runner:
image: python:3.10
volumes:
- .:/app
working_dir: /app
environment:
- PYTHONPATH=/app/src
depends_on:
- aspnet-server
networks:
- app-network
entrypoint: ["sh", "-c"]
command: >
"pip install --upgrade pip &&
pip install pytest pytest-cov pytest-asyncio requests &&
pip install -e . &&
pytest --cov-report=term-missing --cov=pysignalr --cov-report=xml -s -v tests"

formatter:
image: python:3.10
volumes:
- .:/app
working_dir: /app
entrypoint: ["sh", "-c"]
command: >
pip install black &&
black src tests example.py

linter:
image: python:3.10
volumes:
- .:/app
working_dir: /app
entrypoint: ["sh", "-c"]
command: >
pip install ruff mypy &&
ruff check --fix --unsafe-fixes src tests example.py &&
mypy --strict src tests example.py

docs:
image: python:3.10
volumes:
- .:/app
working_dir: /app
entrypoint: ["sh", "-c"]
command: >
pip install sphinx &&
sphinx-build -b html docs/source docs/build

coverage:
image: python:3.10
volumes:
- .:/app
working_dir: /app
entrypoint: ["sh", "-c"]
command: >
pip install diff-cover &&
diff-cover --compare-branch `git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@'` coverage.xml

networks:
app-network:
ports:
- "5000:80"
5 changes: 4 additions & 1 deletion example.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@

import asyncio
from contextlib import suppress
from typing import TYPE_CHECKING
from typing import Any

from pysignalr.client import SignalRClient
from pysignalr.messages import CompletionMessage

if TYPE_CHECKING:
from pysignalr.messages import CompletionMessage


async def on_open() -> None:
Expand Down
9 changes: 6 additions & 3 deletions example_with_token.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@

import asyncio
from contextlib import suppress
from typing import TYPE_CHECKING
from typing import Any

from pysignalr.client import SignalRClient
from pysignalr.messages import CompletionMessage

if TYPE_CHECKING:
from pysignalr.messages import CompletionMessage


async def on_open() -> None:
Expand All @@ -26,14 +29,14 @@ async def on_error(message: CompletionMessage) -> None:

def token_factory() -> str:
# Replace with logic to fetch or generate the token
return "your_access_token_here"
return 'your_access_token_here'


async def main() -> None:
client = SignalRClient(
url='https://api.tzkt.io/v1/ws',
access_token_factory=token_factory,
headers={"mycustomheader": "mycustomheadervalue"},
headers={'mycustomheader': 'mycustomheadervalue'},
)

client.on_open(on_open)
Expand Down
Loading
Loading