Skip to content

Commit 118171b

Browse files
committed
Merge remote-tracking branch 'upstream/main' into migrate-to-uv
Signed-off-by: Albert Callarisa <albert@diagrid.io>
2 parents bf3b2e3 + 8daa87f commit 118171b

51 files changed

Lines changed: 1354 additions & 373 deletions

Some content is hidden

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

.github/scripts/automerge.py

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

.github/workflows/backport.yaml

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#
1313

1414
name: Backport
15+
1516
on:
1617
pull_request_target:
1718
types:
@@ -20,18 +21,6 @@ on:
2021

2122
jobs:
2223
backport:
23-
name: Backport
24-
runs-on: ubuntu-latest
25-
if: >
26-
github.event.pull_request.merged
27-
&& (
28-
github.event.action == 'closed'
29-
|| (
30-
github.event.action == 'labeled'
31-
&& contains(github.event.label.name, 'backport')
32-
)
33-
)
34-
steps:
35-
- uses: tibdex/backport@9565281eda0731b1d20c4025c43339fb0a23812e
36-
with:
37-
github_token: ${{ secrets.DAPR_BOT_TOKEN }}
24+
uses: dapr/.github/.github/workflows/backport.yaml@main
25+
secrets:
26+
dapr_bot_token: ${{ secrets.DAPR_BOT_TOKEN }}

.github/workflows/dapr-bot-schedule.yml

Lines changed: 15 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -17,53 +17,21 @@ on:
1717
schedule:
1818
- cron: '*/10 * * * *'
1919
workflow_dispatch:
20+
2021
jobs:
2122
automerge:
22-
if: github.repository_owner == 'dapr'
23-
name: Automerge and update PRs.
24-
runs-on: ubuntu-latest
25-
steps:
26-
- name: Checkout repo
27-
uses: actions/checkout@v6
28-
- name: Install dependencies
29-
run: pip install PyGithub
30-
- name: Automerge and update
31-
env:
32-
MAINTAINERS: berndverst,wcs1only
33-
GITHUB_TOKEN: ${{ secrets.DAPR_BOT_TOKEN }}
34-
run: python ./.github/scripts/automerge.py
23+
uses: dapr/.github/.github/workflows/automerge.yaml@main
24+
with:
25+
maintainer-teams: python-sdk-maintainers
26+
secrets:
27+
dapr_bot_token: ${{ secrets.DAPR_BOT_TOKEN }}
28+
3529
prune_stale:
36-
name: Prune Stale
37-
runs-on: ubuntu-latest
38-
steps:
39-
- name: Prune Stale
40-
uses: actions/stale@v5
41-
with:
42-
repo-token: ${{ secrets.DAPR_BOT_TOKEN }}
43-
# Different amounts of days for issues/PRs are not currently supported but there is a PR
44-
# open for it: https://github.com/actions/stale/issues/214
45-
days-before-stale: 60
46-
days-before-close: 7
47-
stale-issue-message: >
48-
This issue has been automatically marked as stale because it has not had activity in the
49-
last 60 days. It will be closed in the next 7 days unless it is tagged (pinned, good first issue, help wanted or triaged/resolved) or other activity
50-
occurs. Thank you for your contributions.
51-
close-issue-message: >
52-
This issue has been automatically closed because it has not had activity in the
53-
last 67 days. If this issue is still valid, please ping a maintainer and ask them to label it as pinned, good first issue, help wanted or triaged/resolved.
54-
Thank you for your contributions.
55-
stale-pr-message: >
56-
This pull request has been automatically marked as stale because it has not had
57-
activity in the last 60 days. It will be closed in 7 days if no further activity occurs. Please
58-
feel free to give a status update now, ping for review, or re-open when it's ready.
59-
Thank you for your contributions!
60-
close-pr-message: >
61-
This pull request has been automatically closed because it has not had
62-
activity in the last 67 days. Please feel free to give a status update now, ping for review, or re-open when it's ready.
63-
Thank you for your contributions!
64-
stale-issue-label: 'stale'
65-
exempt-issue-labels: 'pinned,good first issue,help wanted,triaged/resolved'
66-
stale-pr-label: 'stale'
67-
exempt-pr-labels: 'pinned'
68-
operations-per-run: 500
69-
ascending: true
30+
uses: dapr/.github/.github/workflows/prune-stale.yaml@main
31+
with:
32+
days-before-issue-stale: 60
33+
days-before-pr-stale: 60
34+
days-before-issue-close: 7
35+
days-before-pr-close: 7
36+
secrets:
37+
dapr_bot_token: ${{ secrets.DAPR_BOT_TOKEN }}

.github/workflows/validate_examples.yaml

Lines changed: 10 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,6 @@ jobs:
2929
validate:
3030
runs-on: ubuntu-latest
3131
env:
32-
GOVER: 1.21
33-
GOOS: linux
34-
GOARCH: amd64
35-
GOPROXY: https://proxy.golang.org
36-
DAPR_INSTALL_URL: https://raw.githubusercontent.com/dapr/cli/master/install/install.sh
37-
DAPR_CLI_REF: ${{ github.event.inputs.daprcli_commit }}
38-
DAPR_REF: ${{ github.event.inputs.daprdapr_commit }}
3932
CHECKOUT_REPO: ${{ github.repository }}
4033
CHECKOUT_REF: ${{ github.ref }}
4134

@@ -50,7 +43,6 @@ jobs:
5043
if [ ${{ github.event.client_payload.command }} = "ok-to-test" ]; then
5144
echo "CHECKOUT_REPO=${{ github.event.client_payload.pull_head_repo }}" >> $GITHUB_ENV
5245
echo "CHECKOUT_REF=${{ github.event.client_payload.pull_head_ref }}" >> $GITHUB_ENV
53-
echo "DAPR_REF=master" >> $GITHUB_ENV
5446
fi
5547
5648
- name: Check out code onto GOPATH
@@ -96,68 +88,21 @@ jobs:
9688
- name: Install dependencies
9789
run: uv sync --frozen --all-packages --group examples
9890
- name: Set up Dapr CLI
99-
run: |
100-
wget -q "https://github.com/dapr/cli/releases/download/v${{ env.DAPR_CLI_VER }}/dapr_${{ env.GOOS }}_${{ env.GOARCH }}.tar.gz" -O /tmp/dapr.tar.gz
101-
sudo tar xzf /tmp/dapr.tar.gz -C /usr/local/bin dapr
102-
dapr --version
103-
- name: Set up Go ${{ env.GOVER }}
104-
if: env.DAPR_REF != '' || env.DAPR_CLI_REF != ''
105-
uses: actions/setup-go@v6
91+
uses: dapr/.github/.github/actions/setup-dapr-cli@main
92+
with:
93+
commit: ${{ github.event.inputs.daprcli_commit }}
94+
github-token: ${{ secrets.GITHUB_TOKEN }}
95+
- name: Set up Dapr runtime
96+
uses: dapr/.github/.github/actions/setup-dapr-runtime@main
10697
with:
107-
go-version: ${{ env.GOVER }}
98+
commit: ${{ github.event.inputs.daprdapr_commit }}
99+
github-token: ${{ secrets.GITHUB_TOKEN }}
108100
- name: Set up Llama
109101
run: |
110102
curl -fsSL https://ollama.com/install.sh | sh
111103
nohup ollama serve &
112104
sleep 10
113105
ollama pull llama3.2:latest
114-
- name: Checkout Dapr CLI repo to override dapr command.
115-
uses: actions/checkout@v6
116-
if: env.DAPR_CLI_REF != ''
117-
with:
118-
repository: dapr/cli
119-
ref: ${{ env.DAPR_CLI_REF }}
120-
path: cli
121-
- name: Checkout Dapr repo to override daprd.
122-
uses: actions/checkout@v6
123-
if: env.DAPR_REF != ''
124-
with:
125-
repository: dapr/dapr
126-
ref: ${{ env.DAPR_REF }}
127-
path: dapr_runtime
128-
- name: Build and override dapr cli with referenced commit.
129-
if: env.DAPR_CLI_REF != ''
130-
run: |
131-
cd cli
132-
make
133-
sudo cp dist/linux_amd64/release/dapr /usr/local/bin/dapr
134-
cd ..
135-
- name: Initialize Dapr runtime ${{ env.DAPR_RUNTIME_VER }}
136-
run: |
137-
dapr uninstall --all
138-
dapr init --runtime-version ${{ env.DAPR_RUNTIME_VER }}
139-
- name: Build and override daprd with referenced commit.
140-
if: env.DAPR_REF != ''
141-
run: |
142-
cd dapr_runtime
143-
make
144-
mkdir -p $HOME/.dapr/bin/
145-
cp dist/linux_amd64/release/daprd $HOME/.dapr/bin/daprd
146-
cd ..
147-
- name: Override placement service.
148-
if: env.DAPR_REF != ''
149-
run: |
150-
docker stop dapr_placement
151-
cd dapr_runtime
152-
./dist/linux_amd64/release/placement --healthz-port 9091 &
153-
cd ..
154-
- name: Check Examples
106+
- name: Check examples
155107
run: |
156-
cd examples
157-
for dir in */; do
158-
dir="${dir%/}"
159-
if [ -f "$dir/README.md" ]; then
160-
./validate.sh "$dir"
161-
fi
162-
done
163-
./validate.sh ../
108+
uv run pytest tests/integration/

AGENTS.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,14 @@ Each extension is a **separate PyPI package** with its own `pyproject.toml`, `se
6161

6262
## Examples (integration test suite)
6363

64-
The `examples/` directory serves as both user-facing documentation and the project's integration test suite. Examples are validated in CI using [mechanical-markdown](https://pypi.org/project/mechanical-markdown/), which executes bash code blocks from README files and asserts expected output.
64+
The `examples/` directory serves as both user-facing documentation and the project's integration test suite. Examples are validated by pytest-based integration tests in `tests/integration/`.
6565

66-
**See `examples/AGENTS.md`** for the full guide on example structure, validation, mechanical-markdown STEP blocks, and how to add new examples.
66+
**See `examples/AGENTS.md`** for the full guide on example structure and how to add new examples.
6767

6868
Quick reference:
6969
```bash
70-
cd examples && ./validate.sh state_store # Run a single example
71-
cd examples && ./validate.sh conversation # Run another example
70+
uv run pytest tests/integration/ # Run all examples (needs Dapr runtime)
71+
uv run pytest tests/integration/test_state_store.py # Run a single example
7272
```
7373

7474
## Python version support
@@ -108,8 +108,8 @@ uv run ruff check --fix && uv run ruff format
108108
# Run type checking
109109
uv run mypy
110110

111-
# Validate examples (requires Dapr runtime)
112-
cd examples && ./validate.sh <example-name>
111+
# Run integration tests / validate examples (requires Dapr runtime)
112+
uv run pytest tests/integration/
113113
```
114114

115115
## Code style and linting
@@ -175,8 +175,8 @@ When completing any task on this project, work through this checklist. Not every
175175
### Examples (integration tests)
176176

177177
- [ ] If you added a new user-facing feature or building block, add or update an example in `examples/`
178-
- [ ] Ensure the example README has `<!-- STEP -->` blocks with `expected_stdout_lines` so it is validated in CI
179-
- [ ] If you changed output format of existing functionality, update `expected_stdout_lines` in affected example READMEs
178+
- [ ] Add a corresponding pytest integration test in `tests/integration/`
179+
- [ ] If you changed output format of existing functionality, update expected output in the affected integration tests
180180
- [ ] See `examples/AGENTS.md` for full details on writing examples
181181

182182
### Documentation
@@ -188,7 +188,7 @@ When completing any task on this project, work through this checklist. Not every
188188

189189
- [ ] Run `uv run ruff check --fix && uv run ruff format` — linting must be clean
190190
- [ ] Run `uv run python -m unittest discover -v ./tests` — all unit tests must pass
191-
- [ ] If you touched examples: `cd examples && ./validate.sh <example-name>` to validate locally
191+
- [ ] If you touched examples: `uv run pytest tests/integration/test_<example-name>.py` to validate locally
192192
- [ ] Commits must be signed off for DCO: `git commit -s`
193193

194194
## Important files
@@ -200,7 +200,7 @@ When completing any task on this project, work through this checklist. Not every
200200
| `setup.py` | PyPI publish helper (handles dev version suffixing) |
201201
| `ext/*/pyproject.toml` | Extension package metadata and dependencies |
202202
| `dapr/version/version.py` | SDK version string |
203-
| `examples/validate.sh` | Entry point for mechanical-markdown example validation |
203+
| `tests/integration/` | Pytest-based integration tests that validate examples |
204204

205205
## Gotchas
206206

@@ -209,6 +209,6 @@ When completing any task on this project, work through this checklist. Not every
209209
- **Extension independence**: Each extension is a separate PyPI package. Core SDK changes should not break extensions; extension changes should not require core SDK changes unless intentional.
210210
- **DCO signoff**: PRs will be blocked by the DCO bot if commits lack `Signed-off-by`. Always use `git commit -s`.
211211
- **Ruff version pinned**: `pyproject.toml` pins `ruff==0.14.1` in `[dependency-groups].dev`. Use `uv sync --all-packages --group dev` to get the exact version.
212-
- **Examples are integration tests**: Changing output format (log messages, print statements) can break example validation. Always check `expected_stdout_lines` in example READMEs when modifying user-visible output.
212+
- **Examples are integration tests**: Changing output format (log messages, print statements) can break integration tests. Always check expected output in `tests/integration/` when modifying user-visible output.
213213
- **Background processes in examples**: Examples that start background services (servers, subscribers) must include a cleanup step to stop them, or CI will hang.
214214
- **Workflow is the most active area**: See `ext/dapr-ext-workflow/AGENTS.md` for workflow-specific architecture and constraints.

CLAUDE.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,14 @@
11
@AGENTS.md
2+
3+
Use pathlib instead of os.path.
4+
Use httpx instead of urllib.
5+
subprocess(`shell=True`) is used only when it makes the code more readable. Use either shlex or args lists.
6+
subprocess calls should have a reasonable timeout.
7+
Use modern Python (3.10+) features.
8+
Make all code strongly typed.
9+
Keep conditional nesting to a minimum, and use guard clauses when possible.
10+
Aim for medium "visual complexity": use intermediate variables to store results of nested/complex function calls, but don't create a new variable for everything.
11+
Avoid comments unless there is a gotcha, a complex algorithm or anything an experienced code reviewer needs to be aware of. Focus on making better Google-style docstrings instead.
12+
13+
The user is not always right. Be skeptical and do not blindly comply if something doesn't make sense.
14+
Code should be cross-platform and production ready.

README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,18 +105,17 @@ uv run python -m unittest discover -v ./tests
105105
uv run mypy
106106
```
107107

108-
7. Run examples
108+
7. Run integration tests (validates the examples)
109109

110110
```bash
111-
cd examples && ./validate.sh state_store
111+
uv run pytest tests/integration/
112112
```
113113

114-
[Dapr Mechanical Markdown](https://github.com/dapr/mechanical-markdown) is used to test the examples.
115-
116114
If you need to run the examples against a pre-released version of the runtime, you can use the following command:
117115
- Get your daprd runtime binary from [here](https://github.com/dapr/dapr/releases) for your platform.
118116
- Copy the binary to your dapr home folder at $HOME/.dapr/bin/daprd.
119117
Or using dapr cli directly: `dapr init --runtime-version <release version>`
118+
- Now you can run the examples with `uv run pytest tests/integration/`.
120119

121120

122121
## Documentation

0 commit comments

Comments
 (0)