Skip to content

Commit 23561a6

Browse files
author
Jens Kürten
committed
docs: Add contributing guidelines for the project
1 parent 65c93e8 commit 23561a6

File tree

1 file changed

+307
-0
lines changed

1 file changed

+307
-0
lines changed

CONTRIBUTING.md

Lines changed: 307 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,307 @@
1+
# Contributing to Functions-SDK for Python
2+
3+
Thank you for your interest in contributing to the Functions-SDK for Python! This document provides guidelines and instructions for contributing to this project.
4+
5+
## Table of Contents
6+
7+
- [Getting Started](#getting-started)
8+
- [Development Setup](#development-setup)
9+
- [Development Workflow](#development-workflow)
10+
- [Code Quality](#code-quality)
11+
- [Testing](#testing)
12+
- [Documentation](#documentation)
13+
- [Submitting Changes](#submitting-changes)
14+
- [Project Structure](#project-structure)
15+
16+
## Getting Started
17+
18+
### Prerequisites
19+
20+
- Python 3.10 or higher
21+
- [uv](https://github.com/astral-sh/uv) (recommended) or pip
22+
- Git
23+
24+
### Fork and Clone
25+
26+
1. Fork the repository on GitHub
27+
2. Clone your fork locally:
28+
```bash
29+
git clone https://github.com/YOUR-USERNAME/functions-sdk-python.git
30+
cd functions-sdk-python
31+
```
32+
3. Add the upstream repository:
33+
```bash
34+
git remote add upstream https://github.com/cslab/functions-sdk-python.git
35+
```
36+
37+
## Development Setup
38+
39+
### Using uv (Recommended)
40+
41+
This project uses [uv](https://github.com/astral-sh/uv) for dependency management:
42+
43+
```bash
44+
# Install dependencies
45+
uv sync
46+
47+
# Activate the virtual environment
48+
source .venv/bin/activate # On Linux/macOS
49+
# or
50+
.venv\Scripts\activate # On Windows
51+
```
52+
53+
### Using pip
54+
55+
Alternatively, you can use pip:
56+
57+
```bash
58+
# Create a virtual environment
59+
python -m venv .venv
60+
source .venv/bin/activate # On Linux/macOS
61+
62+
# Install the package in editable mode with dev dependencies
63+
pip install -e ".[dev,test]"
64+
```
65+
66+
### Install Pre-commit Hooks
67+
68+
We use pre-commit hooks to ensure code quality:
69+
70+
```bash
71+
# Install pre-commit
72+
pip install pre-commit
73+
74+
# Set up the git hooks
75+
pre-commit install
76+
```
77+
78+
The hooks will run automatically on every commit. You can also run them manually:
79+
80+
```bash
81+
pre-commit run --all-files
82+
```
83+
84+
## Development Workflow
85+
86+
### Creating a Branch
87+
88+
Create a feature branch for your changes:
89+
90+
```bash
91+
git checkout -b feature/your-feature-name
92+
# or
93+
git checkout -b fix/your-bug-fix
94+
```
95+
96+
### Making Changes
97+
98+
1. Make your changes in your feature branch
99+
2. Write or update tests as needed
100+
3. Update documentation if you're changing functionality
101+
4. Ensure all tests pass
102+
5. Commit your changes with clear, descriptive commit messages
103+
104+
### Commit Messages
105+
106+
Follow these guidelines for commit messages:
107+
108+
- Use the present tense ("Add feature" not "Added feature")
109+
- Use the imperative mood ("Move cursor to..." not "Moves cursor to...")
110+
- Start with a type prefix:
111+
- `feat:` for new features
112+
- `fix:` for bug fixes
113+
- `docs:` for documentation changes
114+
- `test:` for test changes
115+
- `chore:` for maintenance tasks
116+
- `refactor:` for code refactoring
117+
118+
Example:
119+
```
120+
feat: Add support for workflow task triggers
121+
122+
- Implement WorkflowTaskTriggerEvent class
123+
- Add event handler documentation
124+
- Include usage examples
125+
```
126+
127+
## Code Quality
128+
129+
This project uses several tools to maintain code quality:
130+
131+
### Ruff
132+
133+
We use [Ruff](https://github.com/astral-sh/ruff) for linting and formatting:
134+
135+
```bash
136+
# Run linter
137+
ruff check .
138+
139+
# Run linter with auto-fix
140+
ruff check --fix .
141+
142+
# Run formatter
143+
ruff format .
144+
```
145+
146+
### MyPy
147+
148+
We use [MyPy](https://mypy-lang.org/) for static type checking:
149+
150+
```bash
151+
mypy csfunctions
152+
```
153+
154+
### Bandit
155+
156+
We use [Bandit](https://bandit.readthedocs.io/) for security linting:
157+
158+
```bash
159+
bandit -r csfunctions
160+
```
161+
162+
All these checks run automatically via pre-commit hooks.
163+
164+
### Code Style Guidelines
165+
166+
- Line length: 120 characters
167+
- Use type hints for all function parameters and return values
168+
- Follow PEP 8 style guidelines
169+
- Use descriptive variable and function names
170+
- Add docstrings to public classes and functions
171+
172+
## Testing
173+
174+
### Running Tests
175+
176+
Run the test suite using pytest:
177+
178+
```bash
179+
# Run all tests
180+
pytest
181+
182+
# Run with coverage
183+
pytest --cov=csfunctions
184+
185+
# Run specific test file
186+
pytest tests/test_handler.py
187+
188+
# Run specific test
189+
pytest tests/test_handler.py::test_specific_function
190+
```
191+
192+
### Writing Tests
193+
194+
- Write tests for all new features and bug fixes
195+
- Place tests in the `tests/` directory
196+
- Use descriptive test names that explain what is being tested
197+
- Follow the existing test structure and patterns
198+
- Aim for high test coverage
199+
200+
## Documentation
201+
202+
### Building Documentation
203+
204+
The project uses [MkDocs](https://www.mkdocs.org/) with Material theme:
205+
206+
```bash
207+
# Serve documentation locally
208+
mkdocs serve
209+
210+
# Build documentation
211+
mkdocs build
212+
```
213+
214+
Visit http://127.0.0.1:8000 to view the documentation locally.
215+
216+
### Updating Documentation
217+
218+
- Update relevant documentation in the `docs/` directory when changing functionality
219+
- Include examples for new features
220+
- Keep the API reference up to date
221+
- Update the release notes for significant changes
222+
223+
### Generating Schemas
224+
225+
If you modify request/response structures, regenerate the JSON schemas:
226+
227+
```bash
228+
python -m csfunctions.tools.write_schema
229+
```
230+
231+
### Generating Tables
232+
233+
Update the documentation tables:
234+
235+
```bash
236+
python -m tools.mdtable
237+
```
238+
239+
## Submitting Changes
240+
241+
### Before Submitting
242+
243+
1. Ensure all tests pass: `pytest`
244+
2. Ensure code quality checks pass: `pre-commit run --all-files`
245+
3. Update documentation as needed
246+
4. Update or add tests for your changes
247+
5. Rebase your branch on the latest upstream main:
248+
```bash
249+
git fetch upstream
250+
git rebase upstream/main
251+
```
252+
253+
### Creating a Pull Request
254+
255+
1. Push your branch to your fork:
256+
```bash
257+
git push origin feature/your-feature-name
258+
```
259+
260+
2. Create a pull request on GitHub with:
261+
- A clear title describing the change
262+
- A detailed description of what changed and why
263+
- References to any related issues
264+
- Screenshots or examples if applicable
265+
266+
3. Wait for review and address any feedback
267+
268+
### Pull Request Guidelines
269+
270+
- Keep pull requests focused on a single feature or fix
271+
- Ensure CI checks pass
272+
- Respond to review comments in a timely manner
273+
- Be open to feedback and suggestions
274+
- Update your PR based on feedback
275+
276+
## Project Structure
277+
278+
```
279+
functions-sdk-python/
280+
├── csfunctions/ # Main package
281+
│ ├── actions/ # Action implementations
282+
│ ├── events/ # Event type definitions
283+
│ ├── objects/ # Object models (Part, Document, etc.)
284+
│ ├── service/ # Service implementations
285+
│ └── tools/ # Development tools
286+
├── tests/ # Test suite
287+
├── docs/ # Documentation source
288+
├── json_schemas/ # JSON schema definitions
289+
├── tools/ # Development utilities
290+
├── pyproject.toml # Project configuration
291+
├── Makefile # Build commands
292+
└── mkdocs.yml # Documentation configuration
293+
```
294+
295+
## Questions or Problems?
296+
297+
If you have questions or run into problems:
298+
299+
- Check the [documentation](https://cslab.github.io/functions-sdk-python/)
300+
- Open an issue on GitHub
301+
- Review existing issues and pull requests
302+
303+
## License
304+
305+
By contributing to this project, you agree that your contributions will be licensed under the MIT License.
306+
307+
Thank you for contributing! 🎉

0 commit comments

Comments
 (0)