Skip to content

Commit 7bb18bc

Browse files
committed
update with async client changes
1 parent 7c23f4b commit 7bb18bc

7 files changed

Lines changed: 41 additions & 5 deletions

File tree

ddev/src/ddev/cli/ci/tests/task_test_runner.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414

1515
from ddev.cli.ci.tests.messages import BatchFinished, TestBatch
1616
from ddev.event_bus.orchestrator import AsyncProcessor
17-
from ddev.utils.github_async import AsyncGitHubClient, GitHubResponse, WorkflowRun
17+
from ddev.utils.github_async import AsyncGitHubClient, GitHubResponse
18+
from ddev.utils.github_async.models import WorkflowRun
1819

1920

2021
def _conclusion_to_status(conclusion: str | None) -> Literal["success", "failure", "skipped"]:

ddev/src/ddev/utils/github_async/client.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,12 @@
1919

2020
from .models import (
2121
ArtifactsList,
22+
CheckRun,
2223
IssueComment,
2324
Label,
2425
PullRequest,
2526
PullRequestReviewComment,
27+
WorkflowDispatchResult,
2628
WorkflowRun,
2729
)
2830

ddev/src/ddev/utils/github_async/models/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
# execute at runtime (they live behind `TYPE_CHECKING`), so they do not
2626
# break the lazy-loading guarantee. The `X as X` aliases mark these as
2727
# explicit re-exports for linters.
28+
from .check_run import CheckRun as CheckRun
2829
from .comment import IssueComment as IssueComment
2930
from .comment import PullRequestReviewComment as PullRequestReviewComment
3031
from .label import Label as Label
@@ -33,19 +34,22 @@
3334
from .user import GitHubUser as GitHubUser
3435
from .workflow import Artifact as Artifact
3536
from .workflow import ArtifactsList as ArtifactsList
37+
from .workflow import WorkflowDispatchResult as WorkflowDispatchResult
3638
from .workflow import WorkflowRun as WorkflowRun
3739

3840
# Map of exported attribute name -> submodule (relative to this package) that
3941
# defines it. Submodules are imported on demand by `__getattr__`.
4042
MODULE_BY_NAME: dict[str, str] = {
4143
'Artifact': 'workflow',
4244
'ArtifactsList': 'workflow',
45+
'CheckRun': 'check_run',
4346
'GitHubUser': 'user',
4447
'IssueComment': 'comment',
4548
'Label': 'label',
4649
'PullRequest': 'pull_request',
4750
'PullRequestRef': 'pull_request',
4851
'PullRequestReviewComment': 'comment',
52+
'WorkflowDispatchResult': 'workflow',
4953
'WorkflowRun': 'workflow',
5054
}
5155

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# (C) Datadog, Inc. 2026-present
2+
# All rights reserved
3+
# Licensed under a 3-clause BSD style license (see LICENSE)
4+
"""GitHub Checks API models."""
5+
6+
from __future__ import annotations
7+
8+
from pydantic import BaseModel, ConfigDict
9+
10+
11+
class CheckRun(BaseModel):
12+
"""A GitHub Checks API check run."""
13+
14+
model_config = ConfigDict(extra="ignore")
15+
16+
id: int
17+
name: str
18+
status: str
19+
conclusion: str | None = None
20+
html_url: str | None = None
21+
head_sha: str | None = None

ddev/src/ddev/utils/github_async/models/workflow.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,14 @@ class WorkflowRun(BaseModel):
2222
updated_at: str | None = None
2323

2424

25+
class WorkflowDispatchResult(BaseModel):
26+
"""Response payload from a successful workflow dispatch."""
27+
28+
model_config = ConfigDict(extra="ignore")
29+
30+
workflow_run_id: int
31+
32+
2533
class Artifact(BaseModel):
2634
"""A GitHub Actions artifact."""
2735

ddev/tests/cli/ci/tests/test_task_test_runner.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717
from ddev.cli.ci.tests.messages import BatchFinished, BatchJob, TestBatch
1818
from ddev.cli.ci.tests.task_test_runner import TaskTestRunner, _conclusion_to_status
1919
from ddev.event_bus.orchestrator import BaseMessage
20-
from ddev.utils.github_async import (
20+
from ddev.utils.github_async import GitHubResponse
21+
from ddev.utils.github_async.models import (
2122
Artifact,
2223
ArtifactsList,
2324
CheckRun,
24-
GitHubResponse,
2525
WorkflowDispatchResult,
2626
WorkflowRun,
2727
)

ddev/tests/utils/test_github_async.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -756,7 +756,7 @@ def fake_async_client(*args: Any, **kwargs: Any) -> httpx.AsyncClient:
756756
kwargs["transport"] = httpx.MockTransport(signed_handler)
757757
return real_async_client(*args, **kwargs)
758758

759-
monkeypatch.setattr("ddev.utils.github_async.httpx.AsyncClient", fake_async_client)
759+
monkeypatch.setattr("ddev.utils.github_async.client.httpx.AsyncClient", fake_async_client)
760760

761761
client = AsyncGitHubClient(token=TOKEN, transport=httpx.MockTransport(github_handler))
762762
await client.download_artifact("/repos/o/r/actions/artifacts/1/zip", tmp_path / "out")
@@ -800,7 +800,7 @@ def fake_async_client(*args: Any, **kwargs: Any) -> httpx.AsyncClient:
800800
kwargs["transport"] = httpx.MockTransport(signed_handler)
801801
return real_async_client(*args, **kwargs)
802802

803-
monkeypatch.setattr("ddev.utils.github_async.httpx.AsyncClient", fake_async_client)
803+
monkeypatch.setattr("ddev.utils.github_async.client.httpx.AsyncClient", fake_async_client)
804804

805805
client = AsyncGitHubClient(token=TOKEN, transport=httpx.MockTransport(github_handler))
806806
dest = tmp_path / "out"

0 commit comments

Comments
 (0)