Skip to content

Commit 2096e11

Browse files
committed
Added some linting and tooling update
Signed-off-by: Albert Callarisa <[email protected]>
1 parent f87ba19 commit 2096e11

File tree

7 files changed

+100
-33
lines changed

7 files changed

+100
-33
lines changed

.flake8

Lines changed: 0 additions & 6 deletions
This file was deleted.

.github/workflows/pr-validation.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,13 @@ jobs:
2828
- name: Install dependencies
2929
run: |
3030
python -m pip install --upgrade pip
31-
pip install flake8 pytest pytest-cov pytest-asyncio
32-
pip install -r requirements.txt
33-
- name: Lint with flake8
31+
pip install .[dev]
32+
- name: Lint with ruff
3433
run: |
35-
flake8 . --count --show-source --statistics --exit-zero
34+
ruff check
3635
- name: Pytest unit tests
3736
run: |
38-
pytest -m "not e2e" --verbose
37+
tox -e py${{ matrix.python-version }}
3938
# Sidecar for running e2e tests requires Go SDK
4039
- name: Install Go SDK
4140
uses: actions/setup-go@v5
@@ -47,6 +46,7 @@ jobs:
4746
go install github.com/dapr/durabletask-go@main
4847
durabletask-go --port 4001 &
4948
pytest -m "e2e" --verbose
49+
tox -e py${{ matrix.python-version }} -- e2e
5050
publish:
5151
needs: build
5252
if: startswith(github.ref, 'refs/tags/v')
@@ -70,4 +70,4 @@ jobs:
7070
TWINE_PASSWORD: ${{ secrets.PYPI_UPLOAD_PASS }}
7171
run: |
7272
python -m build
73-
twine upload dist/*
73+
twine upload dist/*

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ gen-proto:
1414
curl -o durabletask/internal/orchestrator_service.proto https://raw.githubusercontent.com/dapr/durabletask-protobuf/refs/heads/main/protos/orchestrator_service.proto
1515
curl -H "Accept: application/vnd.github.v3+json" "https://api.github.com/repos/dapr/durabletask-protobuf/commits?path=protos/orchestrator_service.proto&sha=main&per_page=1" | jq -r '.[0].sha' > durabletask/internal/PROTO_SOURCE_COMMIT_HASH
1616
# NOTE: remember to check/update pyproject.toml protobuf version to follow https://github.com/grpc/grpc/blob/v{{VERSION GRPC IO TOOL BELLOW}}/tools/distrib/python/grpcio_tools/setup.py
17-
pip install grpcio-tools==1.74.0
17+
pip install .[dev]
1818
python3 -m grpc_tools.protoc --proto_path=. --python_out=. --pyi_out=. --grpc_python_out=. ./durabletask/internal/orchestrator_service.proto
1919
rm durabletask/internal/*.proto
2020

README.md

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -162,33 +162,45 @@ The following is more information about how to develop this project. Note that d
162162
### Generating protobufs
163163

164164
```sh
165-
pip3 install -r dev-requirements.txt
166165
make gen-proto
167166
```
168167

169168
This will download the `orchestrator_service.proto` from the `microsoft/durabletask-protobuf` repo and compile it using `grpcio-tools`. The version of the source proto file that was downloaded can be found in the file `durabletask/internal/PROTO_SOURCE_COMMIT_HASH`.
170169

171170
### Running unit tests
172171

173-
Unit tests can be run using the following command from the project root. Unit tests _don't_ require a sidecar process to be running.
172+
Unit tests can be run using the following command from the project root.
173+
Unit tests _don't_ require a sidecar process to be running.
174+
175+
To run on a specific python version (eg: 3.11), run the following command from the project root:
174176

175177
```sh
176-
make test-unit
178+
tox -e py311
177179
```
178180

179181
### Running E2E tests
180182

181-
The E2E (end-to-end) tests require a sidecar process to be running. You can use the Dapr sidecar for this or run a Durable Task test sidecar using the following command:
183+
The E2E (end-to-end) tests require a sidecar process to be running.
184+
185+
For non-multi app activities test you can use the Durable Task test sidecar using the following command:
182186

183187
```sh
184188
go install github.com/dapr/durabletask-go@main
185189
durabletask-go --port 4001
186190
```
187191

188-
To run the E2E tests, run the following command from the project root:
192+
Certain aspects like multi-app activities require the full dapr runtime to be running.
193+
194+
```shell
195+
dapr init || true
196+
197+
dapr run --app-id test-app --dapr-grpc-port 4001 --components-path ./examples/components/
198+
```
199+
200+
To run the E2E tests on a specific python version (eg: 3.11), run the following command from the project root:
189201

190202
```sh
191-
make test-e2e
203+
tox -e py311 -- e2e
192204
```
193205

194206
## Contributing
@@ -207,8 +219,8 @@ contact [[email protected]](mailto:[email protected]) with any additio
207219

208220
## Trademarks
209221

210-
This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft
211-
trademarks or logos is subject to and must follow
222+
This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft
223+
trademarks or logos is subject to and must follow
212224
[Microsoft's Trademark & Brand Guidelines](https://www.microsoft.com/en-us/legal/intellectualproperty/trademarks/usage/general).
213225
Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship.
214226
Any use of third-party trademarks or logos are subject to those third-party's policies.

pyproject.toml

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,16 @@ keywords = [
1717
"workflow"
1818
]
1919
classifiers = [
20-
"Development Status :: 3 - Alpha",
21-
"Programming Language :: Python :: 3",
22-
"License :: OSI Approved :: MIT License",
20+
"Development Status :: 3 - Alpha",
21+
"Programming Language :: Python :: 3",
22+
"License :: OSI Approved :: MIT License",
2323
]
2424
requires-python = ">=3.9"
2525
license = {file = "LICENSE"}
2626
readme = "README.md"
2727
dependencies = [
2828
"grpcio",
29-
"protobuf>=6.31.1,<7.0.0", # follows grpcio generation version https://github.com/grpc/grpc/blob/v1.74.0/tools/distrib/python/grpcio_tools/setup.py
29+
"protobuf>=6.31.1,<7.0.0", # follows grpcio generation version https://github.com/grpc/grpc/blob/v1.75.1/tools/distrib/python/grpcio_tools/setup.py
3030
"asyncio"
3131
]
3232

@@ -48,3 +48,37 @@ pythonpath = ["."]
4848
markers = [
4949
"e2e: mark a test as an end-to-end test that requires a running sidecar"
5050
]
51+
52+
[project.optional-dependencies]
53+
dev = [
54+
"pytest",
55+
"pytest-asyncio>=0.23",
56+
"tox>=4.0.0",
57+
"pytest-cov",
58+
"ruff",
59+
60+
# grpc gen
61+
"grpcio-tools==1.75.1",
62+
]
63+
64+
[tool.ruff]
65+
target-version = "py310" # TODO: update to py310 when we drop support for py39
66+
line-length = 100
67+
extend-exclude = [".github", "durabletask/internal/orchestrator_service_*.*"]
68+
69+
[tool.ruff.lint]
70+
select = [
71+
"I", # isort
72+
"W", # pycodestyle warnings
73+
"F", # pyflakes
74+
75+
# TODO: Add those back progressively as we fix the issues
76+
# "E", # pycodestyle errors
77+
# "C", # flake8-comprehensions
78+
# "B", # flake8-bugbear
79+
# "UP", # pyupgrade
80+
]
81+
82+
[tool.ruff.format]
83+
# follow upstream quote-style instead of dapr/python-sdk to reduce diff
84+
quote-style = "double"

requirements.txt

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1 @@
1-
autopep8
2-
grpcio>=1.60.0 # 1.60.0 is the version introducing protobuf 1.25.X support, newer versions are backwards compatible
3-
protobuf
4-
asyncio
5-
pytest
6-
pytest-cov
7-
pytest-asyncio
8-
flake8
1+
# requirements in pyproject.toml

tox.ini

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
[tox]
2+
skipsdist = True
3+
minversion = 3.10.0
4+
envlist =
5+
py{39,310,311,312,313,314}
6+
ruff,
7+
mypy,
8+
# TODO: switch runner to uv (tox-uv plugin)
9+
runner = virtualenv
10+
11+
[testenv]
12+
# you can run tox with the e2e pytest marker using tox factors:
13+
# tox -e py39,py310,py311,py312,py313,py314 -- e2e
14+
# or single one with:
15+
# tox -e py310-e2e
16+
# to use custom grpc endpoint and not capture print statements (-s arg in pytest):
17+
# DAPR_GRPC_ENDPOINT=localhost:12345 tox -e py310-e2e -- -s
18+
setenv =
19+
PYTHONDONTWRITEBYTECODE=1
20+
deps = .[dev]
21+
commands =
22+
!e2e: pytest {posargs} -m "not e2e" --verbose
23+
e2e: pytest {posargs} -m e2e --verbose
24+
commands_pre =
25+
pip3 install -e {toxinidir}/
26+
allowlist_externals = pip3
27+
pass_env = DAPR_GRPC_ENDPOINT,DAPR_HTTP_ENDPOINT,DAPR_RUNTIME_HOST,DAPR_GRPC_PORT,DAPR_HTTP_PORT
28+
29+
[testenv:ruff]
30+
basepython = python3
31+
usedevelop = False
32+
commands =
33+
ruff check --fix
34+
ruff format

0 commit comments

Comments
 (0)