Skip to content

Commit 2540d61

Browse files
committed
WIP
1 parent e46a70d commit 2540d61

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+4326
-4611
lines changed

.env.EXAMPLE

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
OPENAI_API_KEY=
2+
OPENAI_ORG=

CONTRIBUTING.md

Lines changed: 65 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Before starting development, ensure you have the following installed:
99

1010
- [Docker](https://docs.docker.com/get-docker/) and Docker Compose
1111
- [uv](https://docs.astral.sh/uv/getting-started/installation/) for Python package management
12-
- Python 3.10+ (project supports 3.10, 3.11, 3.12, and 3.13)
12+
- Python 3.11+ (project supports 3.11, 3.12, and 3.13)
1313

1414
## Install the library for development
1515

@@ -24,7 +24,7 @@ source .venv/bin/activate
2424

2525
Then use uv to install all dev packages:
2626
```bash
27-
uv sync
27+
uv sync --all-extras
2828
```
2929

3030
### Using tox for complete environment testing
@@ -40,7 +40,7 @@ uv tool install tox
4040
tox
4141

4242
# Run tests for a specific environment
43-
tox -e py310-django5
43+
tox -e py311
4444

4545
# Run only the linting checks
4646
tox -e lint
@@ -51,26 +51,37 @@ tox -e coverage
5151

5252
## Understanding the project structure
5353

54-
The project uses a `sandbox` directory which serves two main purposes:
54+
The project has several key directories for development and testing:
55+
56+
### Sandbox Directories
57+
- **`sandbox_django`** - Django integration sandbox for development and testing
58+
- **`sandbox_fastapi`** - FastAPI integration sandbox for development and testing
59+
60+
These serve two main purposes:
5561

5662
1. **Testing Environment**: Write and run tests for the package
5763
- Contains test applications and configurations
5864
- Used with pytest to validate package functionality
5965

60-
2. **Development Playground**: Run as a Django application to test features
66+
2. **Development Playground**: Run as Django/FastAPI applications to test features
6167
- Run Django commands like `makemigrations` and `migrate`
6268
- Interact with API endpoints for manual testing
6369
- Test UI components and integrations
6470

71+
### Test Directories
72+
- **`tests/core`** - Core functionality tests
73+
- **`tests/ext/channels`** - Django Channels extension tests
74+
- **`tests/ext/fast_channels`** - FastAPI and other framework extension tests
75+
6576
## Prepare the environment
6677

6778
Before working with the sandbox or running tests, ensure:
6879
- Docker is running
69-
- Run `docker compose up` to create necessary databases/services
80+
- Run `docker compose up -d` to create necessary databases/services (Redis and PostgreSQL) in detached mode
7081

71-
## Working with the sandbox project
82+
## Working with the sandbox projects
7283

73-
### Setting up and running the sandbox
84+
### Django Sandbox Setup
7485

7586
```bash
7687
# Apply database migrations
@@ -83,18 +94,33 @@ python sandbox_django/manage.py createsuperuser
8394
python sandbox_django/manage.py runserver
8495
```
8596

86-
Once the server is running, you can:
87-
- Access the admin interface at http://127.0.0.1:8000/admin/
88-
- Test API endpoints
89-
- Verify your package functionality in a real Django environment
97+
Once the Django server is running, you can access:
98+
- **Admin interface**: http://localhost:8000/admin/
99+
- **Login/Registration**: http://localhost:8000/login
100+
- **Chat (Assistants/Discussions)**: http://localhost:8000/chat (requires authentication)
101+
- Test API endpoints and verify package functionality
90102

91-
### Development commands
103+
#### Django Development Commands
92104

93105
```bash
94106
# Create migrations for your changes
95107
python sandbox_django/manage.py makemigrations
96108
```
97109

110+
### FastAPI Sandbox Setup
111+
112+
```bash
113+
# Start both FastAPI app and ARQ worker
114+
python sandbox_fastapi/start_dev.py
115+
```
116+
117+
This development script will start:
118+
1. ARQ worker in the background for task processing
119+
2. FastAPI application with live reload on port 8080
120+
121+
Once running, you can access:
122+
- **FastAPI application**: http://localhost:8080
123+
98124
## Code quality tools
99125

100126
Chanx uses several tools to ensure code quality. You should run these tools before submitting a pull request.
@@ -104,7 +130,7 @@ Chanx uses several tools to ensure code quality. You should run these tools befo
104130
We use pre-commit hooks to automatically check and format your code on commit. Install them with:
105131

106132
```bash
107-
pip install pre-commit
133+
uv tool install pre-commit
108134
pre-commit install
109135
```
110136

@@ -134,7 +160,13 @@ We use multiple type checking tools for maximum safety:
134160
bash scripts/mypy.sh
135161

136162
# Run mypy on the sandbox_django
137-
bash scripts/mypy.sh --sandbox_django
163+
bash scripts/mypy.sh --django
164+
165+
# Run mypy on the sandbox_fastapi
166+
bash scripts/mypy.sh --fastapi
167+
168+
# Run mypy on the tests
169+
bash scripts/mypy.sh --tests
138170

139171
# Run pyright
140172
pyright
@@ -159,15 +191,22 @@ The project requires at least 80% docstring coverage as configured in the projec
159191

160192
```bash
161193
# Run all tests
162-
pytest sandbox_django
194+
bash scripts/test_all.sh
163195

164196
# Run tests with coverage report
165-
pytest --cov-report term-missing --cov=chanx sandbox_django
197+
bash scripts/test_all.sh --cov
166198
```
167199

200+
The test script runs tests for:
201+
- `sandbox_django` - Django integration tests
202+
- `sandbox_fastapi` - FastAPI integration tests
203+
- `tests/ext/channels` - Django Channels extension tests
204+
- `tests/ext/fast_channels` - FastAPI and other framework extension tests
205+
- `tests/core` - Core functionality tests
206+
168207
### Writing tests
169208

170-
When adding new features, please include appropriate tests in the `sandbox` directory. Tests should:
209+
When adding new features, please include appropriate tests in the `tests/` or relevant sandbox directories. Tests should:
171210

172211
- Verify the expected behavior of your feature
173212
- Include both success and failure cases
@@ -180,14 +219,16 @@ Before creating a pull request, please ensure your code meets the project's stan
180219
### 1. Run the test suite
181220

182221
```bash
183-
pytest --cov-report term-missing --cov=chanx sandbox_django
222+
bash scripts/test_all.sh --cov
184223
```
185224

186225
### 2. Run type checkers
187226

188227
```bash
189228
bash scripts/mypy.sh
190-
bash scripts/mypy.sh --sandbox_django
229+
bash scripts/mypy.sh --django
230+
bash scripts/mypy.sh --fastapi
231+
bash scripts/mypy.sh --tests
191232
pyright
192233
```
193234

@@ -215,6 +256,10 @@ For committing code, use the [Commitizen](https://commitizen-tools.github.io/com
215256
commit best practices:
216257

217258
```bash
259+
# Install commitizen if not already installed
260+
uv tool install commitizen
261+
262+
# Create a conventional commit
218263
cz commit
219264
```
220265

0 commit comments

Comments
 (0)