Skip to content

Commit e046fe4

Browse files
author
Tom Softreck
committed
update
1 parent 182f33d commit e046fe4

File tree

20 files changed

+397
-16
lines changed

20 files changed

+397
-16
lines changed

.github/workflows/publish.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Publish Python Package
2+
3+
on:
4+
release:
5+
types: [created]
6+
7+
jobs:
8+
deploy:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- uses: actions/checkout@v3
13+
14+
- name: Set up Python
15+
uses: actions/setup-python@v4
16+
with:
17+
python-version: '3.x'
18+
19+
- name: Install Poetry
20+
uses: snok/install-poetry@v1
21+
with:
22+
version: 1.5.1
23+
virtualenvs-create: true
24+
virtualenvs-in-project: true
25+
26+
- name: Install dependencies
27+
run: |
28+
poetry install --no-dev --no-interaction --no-ansi
29+
30+
- name: Build and publish
31+
env:
32+
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
33+
run: |
34+
poetry config pypi-token.pypi $PYPI_TOKEN
35+
poetry publish --build

.github/workflows/tests.yml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
schedule:
9+
- cron: '0 0 * * *' # Daily at midnight UTC
10+
11+
defaults:
12+
run:
13+
shell: bash
14+
15+
jobs:
16+
test:
17+
name: Python ${{ matrix.python-version }} on ${{ matrix.os }}
18+
runs-on: ${{ matrix.os }}
19+
strategy:
20+
fail-fast: false
21+
matrix:
22+
os: [ubuntu-latest]
23+
python-version: ['3.8', '3.9', '3.10', '3.11']
24+
25+
steps:
26+
- uses: actions/checkout@v3
27+
28+
- name: Set up Python ${{ matrix.python-version }}
29+
uses: actions/setup-python@v4
30+
with:
31+
python-version: ${{ matrix.python-version }}
32+
33+
- name: Install Poetry
34+
uses: snok/install-poetry@v1
35+
with:
36+
version: 1.5.1
37+
virtualenvs-create: true
38+
virtualenvs-in-project: true
39+
40+
- name: Install dependencies
41+
run: |
42+
poetry install --with dev,test --no-interaction --no-ansi
43+
44+
- name: Run tests with coverage
45+
run: |
46+
poetry run pytest --cov=dialogchain --cov-report=xml
47+
48+
- name: Upload coverage to Codecov
49+
uses: codecov/codecov-action@v3
50+
with:
51+
token: ${{ secrets.CODECOV_TOKEN }}
52+
file: ./coverage.xml
53+
fail_ci_if_error: false
54+
55+
- name: Run type checking
56+
run: |
57+
poetry run mypy src/dialogchain tests
58+
59+
- name: Lint with flake8
60+
run: |
61+
poetry run flake8 src/dialogchain tests
62+
63+
- name: Check formatting with black
64+
run: |
65+
poetry run black --check src tests
66+
67+
- name: Check import sorting with isort
68+
run: |
69+
poetry run isort --check-only src tests

.pre-commit-config.yaml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v4.4.0
4+
hooks:
5+
- id: trailing-whitespace
6+
- id: end-of-file-fixer
7+
- id: check-yaml
8+
- id: check-added-large-files
9+
- id: debug-statements
10+
11+
- repo: https://github.com/psf/black
12+
rev: 23.7.0
13+
hooks:
14+
- id: black
15+
language_version: python3
16+
17+
- repo: https://github.com/pycqa/isort
18+
rev: 5.12.0
19+
hooks:
20+
- id: isort
21+
name: isort (python)
22+
additional_dependencies: [toml]
23+
24+
- repo: https://github.com/pycqa/flake8
25+
rev: 6.1.0
26+
hooks:
27+
- id: flake8
28+
additional_dependencies: [flake8-bugbear]
29+
30+
- repo: https://github.com/pre-commit/mirrors-mypy
31+
rev: v1.5.0
32+
hooks:
33+
- id: mypy
34+
additional_dependencies: [types-PyYAML, types-requests, types-python-dateutil]
35+
args: [--strict, --ignore-missing-imports]
36+
37+
- repo: https://github.com/pre-commit/pygrep-hooks
38+
rev: v1.10.0
39+
hooks:
40+
- id: python-check-blanket-noqa
41+
- id: python-check-blanket-type-ignore
42+
- id: python-use-type-annotations
43+
44+
- repo: https://github.com/pre-commit/mirrors-prettier
45+
rev: v3.0.0
46+
hooks:
47+
- id: prettier
48+
types_or: [yaml, json, markdown, md]

README.md

Lines changed: 70 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
[![License: Apache 2.0](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
77
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
88
[![Imports: isort](https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat&labelColor=ef8336)](https://pycqa.github.io/isort/)
9+
[![Tests](https://github.com/dialogchain/python/actions/workflows/tests.yml/badge.svg)](https://github.com/dialogchain/python/actions/workflows/tests.yml)
10+
[![codecov](https://codecov.io/gh/dialogchain/python/graph/badge.svg?token=YOUR-TOKEN-HERE)](https://codecov.io/gh/dialogchain/python)
911

1012
## 📦 Installation
1113

@@ -17,8 +19,8 @@
1719

1820
1. Clone the repository:
1921
```bash
20-
git clone https://github.com/taskinity/dialogchain.git
21-
cd dialogchain
22+
git clone https://github.com/dialogchain/python.git
23+
cd python
2224
```
2325

2426
2. Install dependencies:
@@ -33,9 +35,9 @@
3335

3436
### Development Setup
3537

36-
1. Install development dependencies:
38+
1. Install development and test dependencies:
3739
```bash
38-
poetry install --with dev
40+
poetry install --with dev,test
3941
```
4042

4143
2. Set up pre-commit hooks:
@@ -45,8 +47,71 @@
4547

4648
3. Run tests:
4749
```bash
48-
poetry run pytest
50+
make test
4951
```
52+
53+
Or with coverage report:
54+
```bash
55+
make coverage
56+
```
57+
58+
## 🏗️ Project Structure
59+
60+
```
61+
dialogchain/
62+
├── src/
63+
│ └── dialogchain/ # Main package
64+
│ ├── __init__.py
65+
│ ├── cli.py # Command-line interface
66+
│ ├── config.py # Configuration handling
67+
│ ├── connectors/ # Connector implementations
68+
│ ├── engine.py # Core engine
69+
│ ├── exceptions.py # Custom exceptions
70+
│ ├── processors/ # Processor implementations
71+
│ └── utils.py # Utility functions
72+
├── tests/ # Test files
73+
│ ├── unit/ # Unit tests
74+
│ │ ├── core/ # Core functionality tests
75+
│ │ ├── connectors/ # Connector tests
76+
│ │ └── ...
77+
│ └── integration/ # Integration tests
78+
├── .github/ # GitHub workflows
79+
├── docs/ # Documentation
80+
├── .gitignore
81+
├── .pre-commit-config.yaml
82+
├── Makefile # Common development commands
83+
├── pyproject.toml # Project metadata and dependencies
84+
└── README.md
85+
```
86+
87+
## 🧪 Testing
88+
89+
Run the full test suite:
90+
```bash
91+
make test
92+
```
93+
94+
Run specific test categories:
95+
```bash
96+
# Unit tests
97+
make test-unit
98+
99+
# Integration tests
100+
make test-integration
101+
102+
# With coverage report
103+
make coverage
104+
```
105+
106+
## 🧹 Code Quality
107+
108+
Format and check code style:
109+
```bash
110+
make format # Auto-format code
111+
make lint # Run linters
112+
make typecheck # Run type checking
113+
make check-all # Run all checks
114+
```
50115

51116
## 🚀 Quick Start
52117

pyproject.toml

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,6 @@ license = "Apache-2.0"
1212
packages = [
1313
{ include = "dialogchain", from = "src" },
1414
]
15-
16-
[tool.poetry.urls]
17-
"Homepage" = "https://github.com/dialogchain/python"
18-
"Bug Tracker" = "https://github.com/dialogchain/python/issues"
19-
20-
[tool.poetry.dependencies]
21-
python = "^3.8,<3.12"
2215
classifiers = [
2316
"Development Status :: 4 - Beta",
2417
"Intended Audience :: Developers",
@@ -34,6 +27,10 @@ classifiers = [
3427
"Topic :: Text Processing :: Linguistic",
3528
]
3629

30+
[tool.poetry.urls]
31+
"Homepage" = "https://github.com/dialogchain/python"
32+
"Bug Tracker" = "https://github.com/dialogchain/python/issues"
33+
3734
[tool.poetry.dependencies]
3835
python = "^3.8,<3.12"
3936
click = "^8.0.0"
@@ -48,15 +45,21 @@ jinja2 = "^3.1.0"
4845
numpy = "^1.21.0"
4946

5047
[tool.poetry.group.dev.dependencies]
51-
pytest = "^7.0.0"
52-
pytest-asyncio = "^0.21.0"
53-
pytest-cov = "^4.0.0"
5448
black = "^23.0.0"
5549
flake8 = "^5.0.0"
56-
mypy = "^1.0.0"
50+
flake8-bugbear = "^23.7.0"
5751
isort = "^5.12.0"
52+
mypy = "^1.0.0"
5853
pre-commit = "^3.0.0"
5954

55+
[tool.poetry.group.test.dependencies]
56+
pytest = "^7.0.0"
57+
pytest-asyncio = "^0.21.0"
58+
pytest-cov = "^4.0.0"
59+
pytest-mock = "^3.10.0"
60+
coverage = {extras = ["toml"], version = "^7.0.0"}
61+
codecov = "^2.1.0"
62+
6063
[tool.poetry.group.docs.dependencies]
6164
sphinx = "^5.0.0"
6265
sphinx-rtd-theme = "^1.2.0"

pytest.ini

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[pytest]
2+
testpaths = tests
3+
python_files = test_*.py
4+
python_classes = Test*
5+
python_functions = test_*
6+
addopts = -v --cov=dialogchain --cov-report=term-missing
7+
asyncio_mode = auto

src/dialogchain/py.typed

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# This file marks the package as type-annotated.

tests/__init__.py

Whitespace-only changes.

tests/conftest.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
"""
2+
Test configuration and fixtures
3+
"""
4+
import pytest
5+
import asyncio
6+
from unittest.mock import AsyncMock
7+
8+
# This makes event loop available in test functions
9+
@pytest.fixture
10+
def event_loop():
11+
loop = asyncio.get_event_loop()
12+
yield loop
13+
loop.close()
14+
15+
# Common test fixtures
16+
@pytest.fixture
17+
def mock_config():
18+
"""Sample configuration for testing"""
19+
return {
20+
'routes': [
21+
{
22+
'name': 'test_route',
23+
'from': 'timer://5s',
24+
'processors': [
25+
{
26+
'type': 'log',
27+
'message': 'Processing message'
28+
}
29+
]
30+
}
31+
]
32+
}

tests/integration/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)