Skip to content

Commit 610f245

Browse files
committed
feat(workers-runtime-sdk-): add workers-runtime-sdk
1 parent 476d76d commit 610f245

25 files changed

+2046
-67
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ repos:
4141
rev: "v1.14.1"
4242
hooks:
4343
- id: mypy
44-
exclude: (.*test.*)
44+
exclude: (.*test.*|workers-runtime-sdk)
4545
additional_dependencies:
4646
- click
4747
ci:

CONTRIBUTING.md

Lines changed: 53 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,21 @@ Thank you for your interest in contributing to workers-py! This document provide
2323

2424
## Development Setup
2525

26-
Follow the [Development section](https://github.com/cloudflare/workers-py#development) of the README for setting up your development environment.
26+
This is a monorepo containing multiple Python packages. Each package is located in the `packages/` directory:
27+
28+
- `packages/workers-py/` - The main workers-py package
29+
- `packages/workers-runtime-sdk/` - Python SDK for Cloudflare Workers
30+
31+
### Working with a specific package
32+
33+
```bash
34+
cd packages/<package-name>
35+
uv sync
36+
```
2737

2838
### Development Dependencies
2939

30-
The project includes these development tools:
40+
Each package includes these development tools:
3141
- **pytest**: Testing framework
3242
- **ruff**: Fast Python linter
3343
- **mypy**: Static type checking
@@ -39,33 +49,52 @@ The project includes these development tools:
3949
git checkout -b your-username/your-change-name
4050
```
4151

42-
2. Run our code formatter via `uvx ruff format` and linter via `uvx ruff fix .`
52+
2. Navigate to the package you're modifying:
53+
```bash
54+
cd packages/<package-name>
55+
```
56+
57+
3. Run our code formatter via `uvx ruff format` and linter via `uvx ruff fix .`
4358

44-
3. Add or update tests as needed
59+
4. Add or update tests as needed
4560

46-
4. Run the test suite: `uv clean cache && uv run pytest`
61+
5. Run the test suite: `uv run pytest`
4762

4863
## Commit Message Guidelines
4964

50-
This project uses automated semantic versioning via `python-semantic-release` which relies on
51-
tags in the commit message to determine whether a release should be made.
65+
This project uses automated semantic versioning via `python-semantic-release` with the
66+
**conventional-monorepo** parser, which relies on tags and scopes in the commit message
67+
to determine whether a release should be made for each package.
5268

5369
### Commit Format
5470

5571
The format parsed by python-semantic-release is https://www.conventionalcommits.org/en/v1.0.0/#summary.
56-
It looks something like this:
72+
For monorepo support, use the package-specific scope prefix:
5773

5874
```
59-
<tag>(<optional scope>): <subject>
75+
<tag>(<package-prefix>): <subject>
6076
6177
<body>
6278
6379
<footer>
6480
```
6581

82+
### Package Scope Prefixes
83+
84+
- `workers-py-` - For changes to the workers-py package
85+
- `workers-runtime-sdk-` - For changes to the workers-runtime-sdk package
86+
87+
### Examples
88+
89+
```
90+
feat(workers-py-): add new CLI command for syncing
91+
fix(workers-runtime-sdk-): handle edge case in API client
92+
docs(workers-py-): update README with new usage examples
93+
```
94+
6695
### Commit Tags
6796

68-
Including "BREAKING CHANGE" in the commit message (either in the body or footer) will trigger a release.
97+
Including "BREAKING CHANGE" in the commit message (either in the body or footer) will trigger a major release.
6998

7099
The following tags will trigger a release:
71100

@@ -83,7 +112,7 @@ The following tags will not trigger a release:
83112

84113
## Release Process
85114

86-
This project uses **python-semantic-release** for automated versioning and releases. Here's how it works:
115+
This project uses **python-semantic-release** with monorepo support for automated versioning and releases. Each package is released independently.
87116

88117
### Automated Releases
89118

@@ -94,12 +123,21 @@ This project uses **python-semantic-release** for automated versioning and relea
94123

95124
2. **Release Trigger**: Releases are created automatically when changes are pushed to the `main` branch
96125

97-
3. **Release Artifacts**:
98-
- Git tag (format: `v{version}`)
126+
3. **Release Artifacts** (per package):
127+
- Git tag (format: `<package-name>-v{version}`, e.g., `workers-py-v1.7.0`)
99128
- Updated `pyproject.toml` version
100129
- Changelog generation
101130
- PyPI package publication (via GitHub Actions)
102131

132+
### Manual Release
133+
134+
To manually release a specific package:
135+
136+
```bash
137+
cd packages/<package-name>
138+
semantic-release version
139+
```
140+
103141
## Submitting Changes
104142

105143
1. **Push your branch** to your fork:
@@ -108,7 +146,7 @@ This project uses **python-semantic-release** for automated versioning and relea
108146
```
109147

110148
2. **Create a Pull Request** on GitHub with:
111-
- Clear title following conventional commit format
149+
- Clear title following conventional commit format with package scope
112150
- Description of changes made
113151
- Any breaking changes clearly documented
114152
- Explanation of how you tested your changes under a "Test Plan" section
@@ -125,4 +163,4 @@ This project uses **python-semantic-release** for automated versioning and relea
125163
- Check existing issues before creating new ones
126164
- For questions, use GitHub Discussions or open an issue
127165

128-
Thank you for contributing to workers-py! 🚀
166+
Thank you for contributing to workers-py!

README.md

Lines changed: 32 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,54 @@
1-
# workers-py
1+
# workers-py Monorepo
22

3-
A set of libraries and tools for Python Workers.
3+
A monorepo containing Python libraries and tools for Cloudflare Workers.
44

5+
## Packages
56

6-
## Pywrangler
7+
| Package | Description |
8+
|---------|-------------|
9+
| [workers-py](./packages/workers-py/) | A set of libraries and tools for Python Workers |
10+
| [workers-runtime-sdk](./packages/workers-runtime-sdk/) | Python SDK for Cloudflare Workers |
711

8-
A CLI tool for managing vendored packages in a Python Workers project.
12+
## Development
913

10-
### Installation
14+
### Prerequisites
1115

12-
On Linux, you may be able to install the tool globally by running:
16+
- Python 3.12+
17+
- [uv](https://github.com/astral-sh/uv) for package management
1318

14-
```
15-
uv tool install workers-py
16-
```
17-
18-
Alternatively, you can add `workers-py` to your pyproject.toml:
19+
### Working with packages
1920

20-
```
21-
[dependency-groups]
22-
dev = ["workers-py"]
23-
```
24-
25-
Then run via `uv run pywrangler`.
26-
27-
### Usage
21+
Each package is self-contained with its own `pyproject.toml`. To work on a specific package:
2822

2923
```bash
30-
uv run pywrangler --help
31-
uv run pywrangler sync
24+
cd packages/<package-name>
25+
uv sync
26+
uv run pytest
3227
```
3328

34-
### Development
29+
### Releasing
3530

36-
To run the CLI tool while developing it, install it globally:
31+
This project uses [python-semantic-release](https://python-semantic-release.readthedocs.io/) with the monorepo configuration. Each package is released independently.
3732

38-
```
39-
uv tool install -e .
40-
```
41-
42-
Then run it via `pywrangler`.
43-
44-
Alternatively, you can add `workers-py` to your pyproject.toml:
33+
To release a specific package:
4534

35+
```bash
36+
cd packages/<package-name>
37+
semantic-release version
4638
```
47-
[dependency-groups]
48-
dev = ["workers-py"]
4939

50-
[tool.uv.sources]
51-
workers-py = { path = "../workers-py" }
52-
```
40+
### Commit Conventions
5341

54-
Then run via `uv run pywrangler`.
42+
This project uses [Conventional Commits](https://www.conventionalcommits.org/) with package-scoped commits for the monorepo. For package-specific changes, use the scope prefix:
5543

56-
#### Lint
44+
- `feat(workers-py-): add new feature` - Feature for workers-py
45+
- `fix(workers-runtime-sdk-): fix bug` - Bug fix for workers-runtime-sdk
5746

58-
```
59-
uv run ruff check --fix
60-
uv run ruff format
61-
```
47+
Tags:
48+
- `feat`: New feature (triggers minor version bump)
49+
- `fix`: Bug fix (triggers patch version bump)
50+
- `docs`, `style`, `refactor`, `test`, `chore`, `ci`: Non-release commits
6251

63-
#### Tests
52+
## License
6453

65-
```
66-
$ uv cache clean
67-
$ uv run pytest
68-
$ uv run pytest tests/test_cli.py::test_sync_command_handles_missing_pyproject -v # Specific test
69-
```
54+
MIT
File renamed without changes.

packages/workers-py/README.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# workers-py
2+
3+
A set of libraries and tools for Python Workers.
4+
5+
6+
## Pywrangler
7+
8+
A CLI tool for managing vendored packages in a Python Workers project.
9+
10+
### Installation
11+
12+
On Linux, you may be able to install the tool globally by running:
13+
14+
```
15+
uv tool install workers-py
16+
```
17+
18+
Alternatively, you can add `workers-py` to your pyproject.toml:
19+
20+
```
21+
[dependency-groups]
22+
dev = ["workers-py"]
23+
```
24+
25+
Then run via `uv run pywrangler`.
26+
27+
### Usage
28+
29+
```bash
30+
uv run pywrangler --help
31+
uv run pywrangler sync
32+
```
33+
34+
### Development
35+
36+
To run the CLI tool while developing it, install it globally:
37+
38+
```
39+
uv tool install -e .
40+
```
41+
42+
Then run it via `pywrangler`.
43+
44+
Alternatively, you can add `workers-py` to your pyproject.toml:
45+
46+
```
47+
[dependency-groups]
48+
dev = ["workers-py"]
49+
50+
[tool.uv.sources]
51+
workers-py = { path = "../workers-py" }
52+
```
53+
54+
Then run via `uv run pywrangler`.
55+
56+
#### Lint
57+
58+
```
59+
uv run ruff check --fix
60+
uv run ruff format
61+
```
62+
63+
#### Tests
64+
65+
```
66+
$ uv cache clean
67+
$ uv run pytest
68+
$ uv run pytest tests/test_cli.py::test_sync_command_handles_missing_pyproject -v # Specific test
69+
```
Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,17 @@ packages = ["src/pywrangler"]
8686
[tool.semantic_release]
8787
assets = []
8888
build_command_env = []
89-
commit_message = "{version}\n\nAutomatically generated by python-semantic-release"
90-
commit_parser = "conventional"
89+
commit_message = """\
90+
chore(release): workers-py@{version}
91+
92+
Automatically generated by python-semantic-release
93+
"""
94+
commit_parser = "conventional-monorepo"
9195
logging_use_named_masks = false
9296
major_on_zero = true
9397
allow_zero_version = false
9498
no_git_verify = false
95-
tag_format = "v{version}"
99+
tag_format = "workers-py-v{version}"
96100
version_toml = ["pyproject.toml:project.version"]
97101
build_command = """
98102
python -m pip install -e .[build]
@@ -144,6 +148,8 @@ env = "GIT_COMMIT_AUTHOR"
144148
default = "semantic-release <semantic-release>"
145149

146150
[tool.semantic_release.commit_parser_options]
151+
path_filters = ["."]
152+
scope_prefix = "workers-py-"
147153
minor_tags = ["feat"]
148154
patch_tags = ["fix", "perf"]
149155
other_allowed_tags = ["build", "chore", "ci", "docs", "style", "refactor", "test"]
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)