diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..91abb11 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,11 @@ +# 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/github/administering-a-repository/configuration-options-for-dependency-updates + +version: 2 +updates: + - package-ecosystem: "pip" # See documentation for possible values + directory: "/" # Location of package manifests + schedule: + interval: "weekly" diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml new file mode 100644 index 0000000..3cd56be --- /dev/null +++ b/.github/workflows/python-package.yml @@ -0,0 +1,37 @@ +# This workflow will install Python dependencies, run tests and lint with a variety of Python versions +# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions + +name: Python package + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + build: + + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + python-version: ["3.10","3.11"] + + steps: + - uses: actions/checkout@v3 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v3 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install ruff mypy + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + - name: Lint with ruff + run: | + ruff . + - name: Typecheck with mypy + run: | + mypy --install-types --non-interactive message_store/ diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..0a607a4 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,36 @@ +name: Publish 📦 to PyPI + +on: + release: + types: [created] + +jobs: + deploy: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@master + - name: Set up Python + uses: actions/setup-python@v3 + with: + python-version: "3.10" + - name: Install pypa/build + run: >- + python -m + pip install + build + --user + - name: Build a binary wheel and a source tarball + run: >- + python -m + build + --sdist + --wheel + --outdir dist/ + . + - name: Publish distribution 📦 to PyPI + if: startsWith(github.ref, 'refs/tags') + uses: pypa/gh-action-pypi-publish@release/v1 + with: + password: ${{ secrets.PYPI_API_TOKEN }} + diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index d99f2f3..0000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "[python]": { - "editor.defaultFormatter": "ms-python.black-formatter" - }, - "python.formatting.provider": "none" -} \ No newline at end of file diff --git a/README.md b/README.md index dd707f9..e8641b9 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,9 @@ # Zencastr Message Store for Python -Message store implementation in python +Message store implementation in Python -See: https://github.com/zencastr/nats-message-store +This package implements an event sourcing model of storing application data. It is similar to [Eventide](http://docs.eventide-project.org/core-concepts/event-sourcing.html#pub-sub). + +Authors: + +- Rui Figueiredo (@ruidfigueiredo) diff --git a/message_store/__about__.py b/message_store/__about__.py new file mode 100644 index 0000000..a4e2017 --- /dev/null +++ b/message_store/__about__.py @@ -0,0 +1 @@ +__version__ = "0.1" diff --git a/__init__.py b/message_store/__init__.py similarity index 100% rename from __init__.py rename to message_store/__init__.py diff --git a/message.py b/message_store/message.py similarity index 100% rename from message.py rename to message_store/message.py diff --git a/message_from_subscription.py b/message_store/message_from_subscription.py similarity index 100% rename from message_from_subscription.py rename to message_store/message_from_subscription.py diff --git a/message_metadata.py b/message_store/message_metadata.py similarity index 100% rename from message_metadata.py rename to message_store/message_metadata.py diff --git a/message_store.py b/message_store/message_store.py similarity index 100% rename from message_store.py rename to message_store/message_store.py diff --git a/message_store_logger.py b/message_store/message_store_logger.py similarity index 100% rename from message_store_logger.py rename to message_store/message_store_logger.py diff --git a/projections/fetch.py b/message_store/projections/fetch.py similarity index 100% rename from projections/fetch.py rename to message_store/projections/fetch.py diff --git a/projections/projection.py b/message_store/projections/projection.py similarity index 100% rename from projections/projection.py rename to message_store/projections/projection.py diff --git a/subscriptions/progress_reporter.py b/message_store/subscriptions/progress_reporter.py similarity index 100% rename from subscriptions/progress_reporter.py rename to message_store/subscriptions/progress_reporter.py diff --git a/subscriptions/subscription.py b/message_store/subscriptions/subscription.py similarity index 100% rename from subscriptions/subscription.py rename to message_store/subscriptions/subscription.py diff --git a/timeout_exception.py b/message_store/timeout_exception.py similarity index 100% rename from timeout_exception.py rename to message_store/timeout_exception.py diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..2f142e8 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,62 @@ +[build-system] +requires = ["hatchling"] +build-backend = "hatchling.build" + +[project] +name = "message-store" +description = "Message Store is an event sourcing implementation on top of NATS JetStream" +readme = "README.md" +requires-python = ">=3.10" +license = "MIT" +keywords = [] +authors = [ + { name = "Rui Figueiredo", email = "rui@zencastr.com" }, +] +classifiers = [ + "Development Status :: 4 - Beta", + "Programming Language :: Python", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: Implementation :: CPython", +] +dependencies = [ + "nats-py", +] +dynamic = ["version"] + +[project.urls] +Documentation = "https://github.com/zencastr/message-store#readme" +Issues = "https://github.com/zencastr/message-store" +Source = "https://github.com/zencastr/message-store" + +[tool.hatch.version] +path = "message_store/__about__.py" + +[tool.hatch.build.targets.wheel] +packages = ["message_store"] + +[tool.hatch.envs.default] +dependencies = [ + "pytest", + "pytest-cov", +] +[tool.hatch.envs.default.scripts] +cov = "pytest --cov-report=term-missing --cov-config=pyproject.toml --cov=message_store --cov=tests {args}" +no-cov = "cov --no-cov {args}" + +[[tool.hatch.envs.test.matrix]] +python = ["310", "311"] + +[tool.coverage.run] +branch = true +parallel = true +omit = [ + "message_store/__about__.py", +] + +[tool.coverage.report] +exclude_lines = [ + "no cov", + "if __name__ == .__main__.:", + "if TYPE_CHECKING:", +] diff --git a/pyvenv.cfg b/pyvenv.cfg deleted file mode 100644 index b236b18..0000000 --- a/pyvenv.cfg +++ /dev/null @@ -1,8 +0,0 @@ -home = /usr -implementation = CPython -version_info = 3.10.6.final.0 -virtualenv = 20.13.0+ds -include-system-site-packages = false -base-prefix = /usr -base-exec-prefix = /usr -base-executable = /usr/bin/python3 diff --git a/requirements.txt b/requirements.txt index 250b2d6..d44297c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,3 @@ ed25519==1.5 -nats-py==2.3.1 +nats-py==2.6.0 nkeys==0.1.0