Skip to content

Commit

Permalink
Merge pull request #4 from zerlok/feature/buf-actions
Browse files Browse the repository at this point in the history
feature/buf-actions
  • Loading branch information
zerlok authored Nov 26, 2024
2 parents c417efe + a25015e commit 6b2b230
Show file tree
Hide file tree
Showing 11 changed files with 205 additions and 109 deletions.
34 changes: 34 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file

version: 2
updates:
- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "weekly"
day: sunday
time: "12:00"
reviewers:
- "zerlok"
groups:
main-dependencies:
applies-to: version-updates
dependency-type: production
patterns:
- "^protobuf$"
- "^yarl$"
- "^aiormq$"
- "^aiofiles$"
dev-dependencies:
applies-to: version-updates
dependency-type: development
patterns:
- "*"
exclude-patterns:
- "^protobuf$"
- "^yarl$"
- "^aiormq$"
- "^aiofiles$"
19 changes: 17 additions & 2 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,27 @@
name: Publish Python Package
name: publish release

on:
release:
types: [published]

jobs:
publish:
buf:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v4
- uses: bufbuild/buf-action@v1
with:
lint: false
format: false
breaking: false
push: true
token: ${{ secrets.BUF_TOKEN }}

pypi:
runs-on: ubuntu-latest
environment: release
permissions:
id-token: write
steps:
Expand Down
17 changes: 14 additions & 3 deletions .github/workflows/pull-request.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Check On Pull Request
name: pull request checks

on:
pull_request:
Expand All @@ -9,14 +9,24 @@ on:
- main

jobs:
buf:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- uses: actions/checkout@v4
- uses: bufbuild/buf-action@v1
with:
breaking_against: 'https://github.com/zerlok/BrokRPC.git#branch=main'
token: ${{ secrets.BUF_TOKEN }}

static:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: [ "3.12" ]
# TODO: enable buf lint & format
# buf-version: [ "1.31.0" ]
steps:
- uses: actions/checkout@v4
- name: Install Python ${{ matrix.python-version }}
Expand Down Expand Up @@ -44,6 +54,7 @@ jobs:
run: poetry run ruff check
- name: Run ruff format
run: poetry run ruff format --check

test:
runs-on: ubuntu-latest
services:
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# BrokRPC

[![Latest Version](https://img.shields.io/pypi/v/BrokRPC.svg)](https://pypi.python.org/pypi/BrokRPC)
[![Python Supported versions](https://img.shields.io/pypi/pyversions/BrokRPC.svg)](https://pypi.python.org/pypi/BrokRPC)
[![MyPy Strict](https://img.shields.io/badge/mypy-strict-blue)](https://mypy.readthedocs.io/en/stable/getting_started.html#strict-mode-and-configuration)
[![Test Coverage](https://codecov.io/gh/zerlok/BrokRPC/branch/main/graph/badge.svg)](https://codecov.io/gh/zerlok/BrokRPC)
Expand Down Expand Up @@ -27,6 +28,8 @@ You can generate python code for server & client from `.proto` files.
The [pyprotostuben](https://github.com/zerlok/pyprotostuben) project provides protoc plugin `protoc-gen-brokrpc`. See
pyprotostuben project example for more details.

You may configure codegen output using protobuf extensions from [buf schema registry](https://buf.build/zerlok/brokrpc).

## supported brokers & protocols

* [AMQP](https://www.rabbitmq.com/tutorials/amqp-concepts)
Expand Down
4 changes: 3 additions & 1 deletion buf.gen.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ managed:
plugins:
- protoc_builtin: python
out: src
- protoc_builtin: pyprotostuben
- protoc_builtin: mypy-stub
out: src
strategy: all
opt:
- include-descriptors
172 changes: 86 additions & 86 deletions poetry.lock

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "BrokRPC"
version = "0.2.0"
version = "0.2.1"
description = "framework for gRPC like server-client communication over message brokers"
authors = ["zerlok <[email protected]>"]
readme = "README.md"
Expand Down Expand Up @@ -47,12 +47,12 @@ types-protobuf = "^5.26.0.20240422"
mypy = "^1.13.0"
pytest = "^8.3.3"
pytest-cov = "^5.0.0"
ruff = "^0.7.4"
ruff = "^0.8.0"
pytest-asyncio = "^0.24.0"
pytest-timeout = "^2.3.1"
pytest-mypy-plugins = "^3.1.2"
types-aiofiles = "^24.1.0.20240626"
pyprotostuben = "0.2.1"
pyprotostuben = "^0.3.1"


[build-system]
Expand Down
22 changes: 11 additions & 11 deletions src/brokrpc/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,22 +130,22 @@ def app_id(self) -> str | None:

class AppMessage[T](Message[T]):
__slots__ = (
"__app_id",
"__body",
"__routing_key",
"__exchange",
"__content_type",
"__content_encoding",
"__headers",
"__content_type",
"__correlation_id",
"__delivery_mode",
"__exchange",
"__headers",
"__message_id",
"__message_type",
"__priority",
"__correlation_id",
"__reply_to",
"__routing_key",
"__timeout",
"__message_id",
"__timestamp",
"__message_type",
"__user_id",
"__app_id",
)

# NOTE: message constructor has a lot of options to set up a structure (dataclass)
Expand Down Expand Up @@ -276,12 +276,12 @@ def app_id(self) -> str | None:
@t.final
class PackedMessage[T](Message[T]):
__slots__ = (
"__original",
"__body",
"__content_type",
"__content_encoding",
"__content_type",
"__headers",
"__message_type",
"__original",
)

# NOTE: message constructor has a lot of options to set up a structure (dataclass)
Expand Down Expand Up @@ -382,8 +382,8 @@ def app_id(self) -> str | None:
@t.final
class UnpackedMessage[T](Message[T]):
__slots__ = (
"__original",
"__body",
"__original",
)

def __init__(self, original: Message[object], body: T) -> None:
Expand Down
13 changes: 12 additions & 1 deletion src/brokrpc/spec/v1/amqp_pb2.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import builtins
import enum
import google.protobuf.descriptor
import google.protobuf.descriptor_pb2
import google.protobuf.message
import pyprotostuben.protobuf.extension
import typing

class ExchangeType(enum.IntEnum):
Expand All @@ -21,6 +24,7 @@ class ArgumentListValue(google.protobuf.message.Message):
def HasField(self, field_name: typing.NoReturn) -> typing.NoReturn:...

def WhichOneof(self, oneof_group: typing.NoReturn) -> typing.NoReturn:...
DESCRIPTOR: google.protobuf.descriptor.Descriptor

class ArgumentMapValue(google.protobuf.message.Message):

Expand All @@ -32,6 +36,7 @@ class ArgumentMapValue(google.protobuf.message.Message):
def HasField(self, field_name: typing.NoReturn) -> typing.NoReturn:...

def WhichOneof(self, oneof_group: typing.NoReturn) -> typing.NoReturn:...
DESCRIPTOR: google.protobuf.descriptor.Descriptor

class ArgumentValue(google.protobuf.message.Message):

Expand Down Expand Up @@ -61,6 +66,7 @@ class ArgumentValue(google.protobuf.message.Message):
def HasField(self, field_name: typing.NoReturn) -> typing.NoReturn:...

def WhichOneof(self, oneof_group: typing.Literal['value']) -> typing.Optional[typing.Literal['null_value', 'bool_value', 'int_value', 'float_value', 'str_value', 'list_value', 'map_value']]:...
DESCRIPTOR: google.protobuf.descriptor.Descriptor

class ExchangeOptions(google.protobuf.message.Message):
"""A set of attributes of exchange entity in AMQP"""
Expand All @@ -85,6 +91,7 @@ class ExchangeOptions(google.protobuf.message.Message):
def HasField(self, field_name: typing.Literal['name', 'type', 'durable', 'auto_delete']) -> builtins.bool:...

def WhichOneof(self, oneof_group: typing.NoReturn) -> typing.NoReturn:...
DESCRIPTOR: google.protobuf.descriptor.Descriptor

class QueueOptions(google.protobuf.message.Message):
"""A set of attributes of queue entity in AMQP"""
Expand All @@ -108,4 +115,8 @@ class QueueOptions(google.protobuf.message.Message):

def HasField(self, field_name: typing.Literal['name', 'durable', 'exclusive', 'auto_delete']) -> builtins.bool:...

def WhichOneof(self, oneof_group: typing.NoReturn) -> typing.NoReturn:...
def WhichOneof(self, oneof_group: typing.NoReturn) -> typing.NoReturn:...
DESCRIPTOR: google.protobuf.descriptor.Descriptor
exchange: typing.Final[pyprotostuben.protobuf.extension.ExtensionDescriptor[google.protobuf.descriptor_pb2.ServiceOptions, ExchangeOptions]]
queue: typing.Final[pyprotostuben.protobuf.extension.ExtensionDescriptor[google.protobuf.descriptor_pb2.MethodOptions, QueueOptions]]
DESCRIPTOR: google.protobuf.descriptor.FileDescriptor
15 changes: 14 additions & 1 deletion src/brokrpc/spec/v1/call_pb2.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import builtins
import google.protobuf.any_pb2
import google.protobuf.descriptor
import google.protobuf.message
import google.rpc.code_pb2
import typing
Expand All @@ -17,6 +18,7 @@ class Error(google.protobuf.message.Message):
def HasField(self, field_name: typing.Literal['message']) -> builtins.bool:...

def WhichOneof(self, oneof_group: typing.NoReturn) -> typing.NoReturn:...
DESCRIPTOR: google.protobuf.descriptor.Descriptor

class UnaryRequest(google.protobuf.message.Message):

Expand All @@ -31,6 +33,7 @@ class UnaryRequest(google.protobuf.message.Message):
def HasField(self, field_name: typing.NoReturn) -> typing.NoReturn:...

def WhichOneof(self, oneof_group: typing.NoReturn) -> typing.NoReturn:...
DESCRIPTOR: google.protobuf.descriptor.Descriptor

class UnaryResponse(google.protobuf.message.Message):

Expand All @@ -51,6 +54,7 @@ class UnaryResponse(google.protobuf.message.Message):
def HasField(self, field_name: typing.Literal['payload', 'error']) -> builtins.bool:...

def WhichOneof(self, oneof_group: typing.NoReturn) -> typing.NoReturn:...
DESCRIPTOR: google.protobuf.descriptor.Descriptor

class StreamRequest(google.protobuf.message.Message):

Expand All @@ -61,6 +65,7 @@ class StreamRequest(google.protobuf.message.Message):
def HasField(self, field_name: typing.NoReturn) -> typing.NoReturn:...

def WhichOneof(self, oneof_group: typing.NoReturn) -> typing.NoReturn:...
DESCRIPTOR: google.protobuf.descriptor.Descriptor

class Part(google.protobuf.message.Message):

Expand All @@ -72,6 +77,7 @@ class StreamRequest(google.protobuf.message.Message):
def HasField(self, field_name: typing.NoReturn) -> typing.NoReturn:...

def WhichOneof(self, oneof_group: typing.NoReturn) -> typing.NoReturn:...
DESCRIPTOR: google.protobuf.descriptor.Descriptor

class End(google.protobuf.message.Message):

Expand All @@ -80,6 +86,7 @@ class StreamRequest(google.protobuf.message.Message):
def HasField(self, field_name: typing.NoReturn) -> typing.NoReturn:...

def WhichOneof(self, oneof_group: typing.NoReturn) -> typing.NoReturn:...
DESCRIPTOR: google.protobuf.descriptor.Descriptor

def __init__(self, *, uuid: builtins.bytes, index: builtins.int, start: typing.Optional[StreamRequest.Start]=None, part: typing.Optional[StreamRequest.Part]=None, end: typing.Optional[StreamRequest.End]=None) -> None:...

Expand All @@ -101,6 +108,7 @@ class StreamRequest(google.protobuf.message.Message):
def HasField(self, field_name: typing.NoReturn) -> typing.NoReturn:...

def WhichOneof(self, oneof_group: typing.Literal['event']) -> typing.Optional[typing.Literal['start', 'part', 'end']]:...
DESCRIPTOR: google.protobuf.descriptor.Descriptor

class StreamResponse(google.protobuf.message.Message):

Expand All @@ -111,6 +119,7 @@ class StreamResponse(google.protobuf.message.Message):
def HasField(self, field_name: typing.NoReturn) -> typing.NoReturn:...

def WhichOneof(self, oneof_group: typing.NoReturn) -> typing.NoReturn:...
DESCRIPTOR: google.protobuf.descriptor.Descriptor

class Part(google.protobuf.message.Message):

Expand All @@ -122,6 +131,7 @@ class StreamResponse(google.protobuf.message.Message):
def HasField(self, field_name: typing.NoReturn) -> typing.NoReturn:...

def WhichOneof(self, oneof_group: typing.NoReturn) -> typing.NoReturn:...
DESCRIPTOR: google.protobuf.descriptor.Descriptor

class End(google.protobuf.message.Message):

Expand All @@ -136,6 +146,7 @@ class StreamResponse(google.protobuf.message.Message):
def HasField(self, field_name: typing.Literal['error']) -> builtins.bool:...

def WhichOneof(self, oneof_group: typing.NoReturn) -> typing.NoReturn:...
DESCRIPTOR: google.protobuf.descriptor.Descriptor

def __init__(self, *, uuid: builtins.bytes, index: builtins.int, start: typing.Optional[StreamResponse.Start]=None, part: typing.Optional[StreamResponse.Part]=None, end: typing.Optional[StreamResponse.End]=None) -> None:...

Expand All @@ -156,4 +167,6 @@ class StreamResponse(google.protobuf.message.Message):

def HasField(self, field_name: typing.NoReturn) -> typing.NoReturn:...

def WhichOneof(self, oneof_group: typing.Literal['event']) -> typing.Optional[typing.Literal['start', 'part', 'end']]:...
def WhichOneof(self, oneof_group: typing.Literal['event']) -> typing.Optional[typing.Literal['start', 'part', 'end']]:...
DESCRIPTOR: google.protobuf.descriptor.Descriptor
DESCRIPTOR: google.protobuf.descriptor.FileDescriptor
9 changes: 8 additions & 1 deletion src/brokrpc/spec/v1/consumer_pb2.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import builtins
import google.protobuf.descriptor
import google.protobuf.descriptor_pb2
import google.protobuf.message
import pyprotostuben.protobuf.extension
import typing

class Void(google.protobuf.message.Message):
Expand All @@ -11,6 +14,7 @@ class Void(google.protobuf.message.Message):
def HasField(self, field_name: typing.NoReturn) -> typing.NoReturn:...

def WhichOneof(self, oneof_group: typing.NoReturn) -> typing.NoReturn:...
DESCRIPTOR: google.protobuf.descriptor.Descriptor

class ConsumerOptions(google.protobuf.message.Message):

Expand All @@ -23,4 +27,7 @@ class ConsumerOptions(google.protobuf.message.Message):

def HasField(self, field_name: typing.Literal['fading']) -> builtins.bool:...

def WhichOneof(self, oneof_group: typing.NoReturn) -> typing.NoReturn:...
def WhichOneof(self, oneof_group: typing.NoReturn) -> typing.NoReturn:...
DESCRIPTOR: google.protobuf.descriptor.Descriptor
consumer: typing.Final[pyprotostuben.protobuf.extension.ExtensionDescriptor[google.protobuf.descriptor_pb2.MethodOptions, ConsumerOptions]]
DESCRIPTOR: google.protobuf.descriptor.FileDescriptor

0 comments on commit 6b2b230

Please sign in to comment.