render-lab-tasks-gitlab 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ """Import .tasks explicitly to register durable tasks."""
@@ -0,0 +1,3 @@
1
+ from render import Workflows
2
+
3
+ app = Workflows()
@@ -0,0 +1,187 @@
1
+ """Injected vendor interface and one-attempt async HTTP adapter."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import os
6
+ from collections.abc import AsyncIterator, Mapping
7
+ from contextlib import asynccontextmanager
8
+ from dataclasses import dataclass
9
+ from typing import Any, Protocol
10
+
11
+ import httpx
12
+ from render_lab_tasks_core.http import HttpClient, enc, js_string, nullish, pick, query, required
13
+
14
+ from . import types as t
15
+
16
+
17
+ def to_issue(raw: Mapping[str, Any]) -> dict[str, Any]:
18
+ return {
19
+ "iid": nullish(raw.get("iid"), 0),
20
+ "title": nullish(raw.get("title"), ""),
21
+ "state": nullish(raw.get("state"), ""),
22
+ "webUrl": nullish(raw.get("web_url"), ""),
23
+ }
24
+
25
+
26
+ def to_mr(raw: Mapping[str, Any]) -> dict[str, Any]:
27
+ return {
28
+ **to_issue(raw),
29
+ "sourceBranch": nullish(raw.get("source_branch"), ""),
30
+ "targetBranch": nullish(raw.get("target_branch"), ""),
31
+ }
32
+
33
+
34
+ def to_pipeline(raw: Mapping[str, Any]) -> dict[str, Any]:
35
+ return {
36
+ "id": nullish(raw.get("id"), 0),
37
+ "status": nullish(raw.get("status"), ""),
38
+ "webUrl": nullish(raw.get("web_url"), ""),
39
+ }
40
+
41
+
42
+ class Port(Protocol):
43
+ async def close_issue(self, input: t.CloseIssueInput) -> t.CloseIssueResult: ...
44
+ async def comment(self, input: t.CommentInput) -> t.CommentResult: ...
45
+ async def create_issue(self, input: t.CreateIssueInput) -> t.CreateIssueResult: ...
46
+ async def create_merge_request(self, input: t.CreateMergeRequestInput) -> t.MergeRequest: ...
47
+ async def get_issue(self, input: t.GetIssueInput) -> t.Issue: ...
48
+ async def get_merge_request(self, input: t.GetMergeRequestInput) -> t.MergeRequest: ...
49
+ async def get_pipeline_status(self, input: t.GetPipelineStatusInput) -> t.Pipeline: ...
50
+ async def list_merge_requests(
51
+ self, input: t.ListMergeRequestsInput
52
+ ) -> list[t.MergeRequest]: ...
53
+ async def merge_when_green(self, input: t.MergeWhenGreenInput) -> t.MergeResult: ...
54
+ async def trigger_pipeline(self, input: t.TriggerPipelineInput) -> t.Pipeline: ...
55
+
56
+
57
+ @dataclass(frozen=True)
58
+ class Deps:
59
+ gitlab: Port
60
+
61
+
62
+ class Client:
63
+ def __init__(self, http: httpx.AsyncClient, env: Mapping[str, str] | None = None) -> None:
64
+ self.env = os.environ if env is None else env
65
+ self.http = HttpClient(
66
+ http,
67
+ lambda: (self.env.get("GITLAB_URL") or "https://gitlab.com").rstrip("/") + "/api/v4",
68
+ auth=lambda: {"PRIVATE-TOKEN": required(self.env, "GITLAB_TOKEN")},
69
+ label="GitLab API",
70
+ )
71
+
72
+ def _project(self, input: Mapping[str, Any]) -> str:
73
+ return f"/projects/{enc(input['project'])}"
74
+
75
+ async def list_merge_requests(self, input: t.ListMergeRequestsInput) -> Any:
76
+ params: dict[str, Any] = {}
77
+ if "state" in input:
78
+ params["state"] = input["state"]
79
+ if "limit" in input:
80
+ params["per_page"] = input["limit"]
81
+ data = await self.http.call(
82
+ self._project(input) + "/merge_requests" + ("?" + query(params) if params else "")
83
+ )
84
+ return [to_mr(r) for r in data] if isinstance(data, list) else []
85
+
86
+ async def merge_when_green(self, input: t.MergeWhenGreenInput) -> Any:
87
+ path = self._project(input) + f"/merge_requests/{js_string(input['iid'])}"
88
+ data = await self.http.call(path)
89
+ status = nullish(
90
+ ((data or {}).get("head_pipeline") or {}).get("status"),
91
+ ((data or {}).get("pipeline") or {}).get("status"),
92
+ )
93
+ if status in ("failed", "canceled"):
94
+ raise RuntimeError(f"MR !{js_string(input['iid'])} checks failing")
95
+ if status not in ("success", "manual"):
96
+ raise RuntimeError(f"MR !{js_string(input['iid'])} checks pending")
97
+ data = await self.http.call(path + "/merge", method="PUT")
98
+ state = nullish((data or {}).get("state"), "")
99
+ return {"iid": input["iid"], "merged": state == "merged", "state": state}
100
+
101
+ async def create_issue(self, input: t.CreateIssueInput) -> Any:
102
+ body = pick(input, "title", "description")
103
+ if "labels" in input:
104
+ body["labels"] = ",".join(input["labels"])
105
+ data = await self.http.call(self._project(input) + "/issues", method="POST", body=body)
106
+ return {
107
+ "iid": nullish((data or {}).get("iid"), 0),
108
+ "url": nullish((data or {}).get("web_url"), ""),
109
+ }
110
+
111
+ async def comment(self, input: t.CommentInput) -> Any:
112
+ resource = "merge_requests" if input.get("kind") == "merge_request" else "issues"
113
+ data = await self.http.call(
114
+ self._project(input) + f"/{resource}/{js_string(input['iid'])}/notes",
115
+ method="POST",
116
+ body={"body": input["body"]},
117
+ )
118
+ return {"iid": input["iid"], "noteId": nullish((data or {}).get("id"), 0)}
119
+
120
+ async def create_merge_request(self, input: t.CreateMergeRequestInput) -> Any:
121
+ body = {
122
+ "source_branch": input["sourceBranch"],
123
+ "target_branch": input["targetBranch"],
124
+ **pick(input, "title", "description"),
125
+ }
126
+ data = await self.http.call(
127
+ self._project(input) + "/merge_requests", method="POST", body=body
128
+ )
129
+ return to_mr(data or {})
130
+
131
+ async def get_merge_request(self, input: t.GetMergeRequestInput) -> Any:
132
+ return to_mr(
133
+ (
134
+ await self.http.call(
135
+ self._project(input) + f"/merge_requests/{js_string(input['iid'])}"
136
+ )
137
+ )
138
+ or {}
139
+ )
140
+
141
+ async def trigger_pipeline(self, input: t.TriggerPipelineInput) -> Any:
142
+ return to_pipeline(
143
+ (
144
+ await self.http.call(
145
+ self._project(input) + "/pipeline", method="POST", body={"ref": input["ref"]}
146
+ )
147
+ )
148
+ or {}
149
+ )
150
+
151
+ async def get_pipeline_status(self, input: t.GetPipelineStatusInput) -> Any:
152
+ return to_pipeline(
153
+ (await self.http.call(self._project(input) + f"/pipelines/{js_string(input['id'])}"))
154
+ or {}
155
+ )
156
+
157
+ async def get_issue(self, input: t.GetIssueInput) -> Any:
158
+ return to_issue(
159
+ (await self.http.call(self._project(input) + f"/issues/{js_string(input['iid'])}"))
160
+ or {}
161
+ )
162
+
163
+ async def close_issue(self, input: t.CloseIssueInput) -> Any:
164
+ data = await self.http.call(
165
+ self._project(input) + f"/issues/{js_string(input['iid'])}?state_event=close",
166
+ method="PUT",
167
+ )
168
+ return {
169
+ "iid": nullish((data or {}).get("iid"), input["iid"]),
170
+ "state": nullish((data or {}).get("state"), ""),
171
+ }
172
+
173
+
174
+ @asynccontextmanager
175
+ async def dependencies(deps: Deps | None) -> AsyncIterator[Deps]:
176
+ if deps is not None:
177
+ yield deps
178
+ else:
179
+ async with httpx.AsyncClient(
180
+ timeout=30, transport=httpx.AsyncHTTPTransport(retries=0)
181
+ ) as http:
182
+ yield Deps(gitlab=Client(http))
183
+
184
+
185
+ GitLabPort = Port
186
+ GitLabClient = Client
187
+ GitLabDeps = Deps
@@ -0,0 +1,18 @@
1
+ from render import TaskContext
2
+
3
+ from ._app import app
4
+ from .client import Deps, dependencies
5
+ from .retry import GITLAB_RETRY
6
+ from .types import CloseIssueInput, CloseIssueResult
7
+
8
+
9
+ async def close_issue_impl(
10
+ ctx: TaskContext, input: CloseIssueInput, *, deps: Deps | None = None
11
+ ) -> CloseIssueResult:
12
+ async with dependencies(deps) as resolved:
13
+ return await resolved.gitlab.close_issue(input)
14
+
15
+
16
+ @app.task(name="gitlab.closeIssue", retry=GITLAB_RETRY)
17
+ async def close_issue(ctx: TaskContext, input: CloseIssueInput) -> CloseIssueResult:
18
+ return await close_issue_impl(ctx, input)
@@ -0,0 +1,18 @@
1
+ from render import TaskContext
2
+
3
+ from ._app import app
4
+ from .client import Deps, dependencies
5
+ from .retry import GITLAB_RETRY
6
+ from .types import CommentInput, CommentResult
7
+
8
+
9
+ async def comment_impl(
10
+ ctx: TaskContext, input: CommentInput, *, deps: Deps | None = None
11
+ ) -> CommentResult:
12
+ async with dependencies(deps) as resolved:
13
+ return await resolved.gitlab.comment(input)
14
+
15
+
16
+ @app.task(name="gitlab.comment", retry=GITLAB_RETRY)
17
+ async def comment(ctx: TaskContext, input: CommentInput) -> CommentResult:
18
+ return await comment_impl(ctx, input)
@@ -0,0 +1,18 @@
1
+ from render import TaskContext
2
+
3
+ from ._app import app
4
+ from .client import Deps, dependencies
5
+ from .retry import GITLAB_RETRY
6
+ from .types import CreateIssueInput, CreateIssueResult
7
+
8
+
9
+ async def create_issue_impl(
10
+ ctx: TaskContext, input: CreateIssueInput, *, deps: Deps | None = None
11
+ ) -> CreateIssueResult:
12
+ async with dependencies(deps) as resolved:
13
+ return await resolved.gitlab.create_issue(input)
14
+
15
+
16
+ @app.task(name="gitlab.createIssue", retry=GITLAB_RETRY)
17
+ async def create_issue(ctx: TaskContext, input: CreateIssueInput) -> CreateIssueResult:
18
+ return await create_issue_impl(ctx, input)
@@ -0,0 +1,18 @@
1
+ from render import TaskContext
2
+
3
+ from ._app import app
4
+ from .client import Deps, dependencies
5
+ from .retry import GITLAB_RETRY
6
+ from .types import CreateMergeRequestInput, MergeRequest
7
+
8
+
9
+ async def create_merge_request_impl(
10
+ ctx: TaskContext, input: CreateMergeRequestInput, *, deps: Deps | None = None
11
+ ) -> MergeRequest:
12
+ async with dependencies(deps) as resolved:
13
+ return await resolved.gitlab.create_merge_request(input)
14
+
15
+
16
+ @app.task(name="gitlab.createMergeRequest", retry=GITLAB_RETRY)
17
+ async def create_merge_request(ctx: TaskContext, input: CreateMergeRequestInput) -> MergeRequest:
18
+ return await create_merge_request_impl(ctx, input)
@@ -0,0 +1,18 @@
1
+ from render import TaskContext
2
+
3
+ from ._app import app
4
+ from .client import Deps, dependencies
5
+ from .retry import GITLAB_RETRY
6
+ from .types import GetIssueInput, Issue
7
+
8
+
9
+ async def get_issue_impl(
10
+ ctx: TaskContext, input: GetIssueInput, *, deps: Deps | None = None
11
+ ) -> Issue:
12
+ async with dependencies(deps) as resolved:
13
+ return await resolved.gitlab.get_issue(input)
14
+
15
+
16
+ @app.task(name="gitlab.getIssue", retry=GITLAB_RETRY)
17
+ async def get_issue(ctx: TaskContext, input: GetIssueInput) -> Issue:
18
+ return await get_issue_impl(ctx, input)
@@ -0,0 +1,18 @@
1
+ from render import TaskContext
2
+
3
+ from ._app import app
4
+ from .client import Deps, dependencies
5
+ from .retry import GITLAB_RETRY
6
+ from .types import GetMergeRequestInput, MergeRequest
7
+
8
+
9
+ async def get_merge_request_impl(
10
+ ctx: TaskContext, input: GetMergeRequestInput, *, deps: Deps | None = None
11
+ ) -> MergeRequest:
12
+ async with dependencies(deps) as resolved:
13
+ return await resolved.gitlab.get_merge_request(input)
14
+
15
+
16
+ @app.task(name="gitlab.getMergeRequest", retry=GITLAB_RETRY)
17
+ async def get_merge_request(ctx: TaskContext, input: GetMergeRequestInput) -> MergeRequest:
18
+ return await get_merge_request_impl(ctx, input)
@@ -0,0 +1,18 @@
1
+ from render import TaskContext
2
+
3
+ from ._app import app
4
+ from .client import Deps, dependencies
5
+ from .retry import GITLAB_RETRY
6
+ from .types import GetPipelineStatusInput, Pipeline
7
+
8
+
9
+ async def get_pipeline_status_impl(
10
+ ctx: TaskContext, input: GetPipelineStatusInput, *, deps: Deps | None = None
11
+ ) -> Pipeline:
12
+ async with dependencies(deps) as resolved:
13
+ return await resolved.gitlab.get_pipeline_status(input)
14
+
15
+
16
+ @app.task(name="gitlab.getPipelineStatus", retry=GITLAB_RETRY)
17
+ async def get_pipeline_status(ctx: TaskContext, input: GetPipelineStatusInput) -> Pipeline:
18
+ return await get_pipeline_status_impl(ctx, input)
@@ -0,0 +1,20 @@
1
+ from render import TaskContext
2
+
3
+ from ._app import app
4
+ from .client import Deps, dependencies
5
+ from .retry import GITLAB_RETRY
6
+ from .types import ListMergeRequestsInput, MergeRequest
7
+
8
+
9
+ async def list_merge_requests_impl(
10
+ ctx: TaskContext, input: ListMergeRequestsInput, *, deps: Deps | None = None
11
+ ) -> list[MergeRequest]:
12
+ async with dependencies(deps) as resolved:
13
+ return await resolved.gitlab.list_merge_requests(input)
14
+
15
+
16
+ @app.task(name="gitlab.listMergeRequests", retry=GITLAB_RETRY)
17
+ async def list_merge_requests(
18
+ ctx: TaskContext, input: ListMergeRequestsInput
19
+ ) -> list[MergeRequest]:
20
+ return await list_merge_requests_impl(ctx, input)
@@ -0,0 +1,18 @@
1
+ from render import TaskContext
2
+
3
+ from ._app import app
4
+ from .client import Deps, dependencies
5
+ from .retry import GITLAB_RETRY
6
+ from .types import MergeResult, MergeWhenGreenInput
7
+
8
+
9
+ async def merge_when_green_impl(
10
+ ctx: TaskContext, input: MergeWhenGreenInput, *, deps: Deps | None = None
11
+ ) -> MergeResult:
12
+ async with dependencies(deps) as resolved:
13
+ return await resolved.gitlab.merge_when_green(input)
14
+
15
+
16
+ @app.task(name="gitlab.mergeWhenGreen", retry=GITLAB_RETRY)
17
+ async def merge_when_green(ctx: TaskContext, input: MergeWhenGreenInput) -> MergeResult:
18
+ return await merge_when_green_impl(ctx, input)
File without changes
@@ -0,0 +1,3 @@
1
+ from render import Retry
2
+
3
+ GITLAB_RETRY = Retry(max_retries=3, wait_duration_ms=1000, backoff_scaling=2)
@@ -0,0 +1,35 @@
1
+ from ._app import app
2
+ from .close_issue import close_issue, close_issue_impl
3
+ from .comment import comment, comment_impl
4
+ from .create_issue import create_issue, create_issue_impl
5
+ from .create_merge_request import create_merge_request, create_merge_request_impl
6
+ from .get_issue import get_issue, get_issue_impl
7
+ from .get_merge_request import get_merge_request, get_merge_request_impl
8
+ from .get_pipeline_status import get_pipeline_status, get_pipeline_status_impl
9
+ from .list_merge_requests import list_merge_requests, list_merge_requests_impl
10
+ from .merge_when_green import merge_when_green, merge_when_green_impl
11
+ from .trigger_pipeline import trigger_pipeline, trigger_pipeline_impl
12
+
13
+ __all__ = [
14
+ "app",
15
+ "close_issue",
16
+ "close_issue_impl",
17
+ "comment",
18
+ "comment_impl",
19
+ "create_issue",
20
+ "create_issue_impl",
21
+ "create_merge_request",
22
+ "create_merge_request_impl",
23
+ "get_issue",
24
+ "get_issue_impl",
25
+ "get_merge_request",
26
+ "get_merge_request_impl",
27
+ "get_pipeline_status",
28
+ "get_pipeline_status_impl",
29
+ "list_merge_requests",
30
+ "list_merge_requests_impl",
31
+ "merge_when_green",
32
+ "merge_when_green_impl",
33
+ "trigger_pipeline",
34
+ "trigger_pipeline_impl",
35
+ ]
@@ -0,0 +1,18 @@
1
+ from render import TaskContext
2
+
3
+ from ._app import app
4
+ from .client import Deps, dependencies
5
+ from .retry import GITLAB_RETRY
6
+ from .types import Pipeline, TriggerPipelineInput
7
+
8
+
9
+ async def trigger_pipeline_impl(
10
+ ctx: TaskContext, input: TriggerPipelineInput, *, deps: Deps | None = None
11
+ ) -> Pipeline:
12
+ async with dependencies(deps) as resolved:
13
+ return await resolved.gitlab.trigger_pipeline(input)
14
+
15
+
16
+ @app.task(name="gitlab.triggerPipeline", retry=GITLAB_RETRY)
17
+ async def trigger_pipeline(ctx: TaskContext, input: TriggerPipelineInput) -> Pipeline:
18
+ return await trigger_pipeline_impl(ctx, input)
@@ -0,0 +1,106 @@
1
+ """JSON contracts ported from the pinned TypeScript pack."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Literal, NotRequired, TypedDict
6
+
7
+
8
+ class MergeRequest(TypedDict):
9
+ iid: float
10
+ title: str
11
+ state: str
12
+ webUrl: str
13
+ sourceBranch: str
14
+ targetBranch: str
15
+
16
+
17
+ class ListMergeRequestsInput(TypedDict):
18
+ project: str
19
+ state: NotRequired[Literal["opened"] | Literal["merged"] | Literal["closed"]]
20
+ limit: NotRequired[float]
21
+
22
+
23
+ class MergeWhenGreenInput(TypedDict):
24
+ project: str
25
+ iid: float
26
+
27
+
28
+ class MergeResult(TypedDict):
29
+ iid: float
30
+ merged: bool
31
+ state: str
32
+
33
+
34
+ class CreateIssueInput(TypedDict):
35
+ project: str
36
+ title: str
37
+ description: NotRequired[str]
38
+ labels: NotRequired[list[str]]
39
+
40
+
41
+ class CreateIssueResult(TypedDict):
42
+ iid: float
43
+ url: str
44
+
45
+
46
+ class CommentInput(TypedDict):
47
+ project: str
48
+ iid: float
49
+ body: str
50
+ kind: NotRequired[Literal["issue"] | Literal["merge_request"]]
51
+
52
+
53
+ class CommentResult(TypedDict):
54
+ iid: float
55
+ noteId: float
56
+
57
+
58
+ class CreateMergeRequestInput(TypedDict):
59
+ project: str
60
+ sourceBranch: str
61
+ targetBranch: str
62
+ title: str
63
+ description: NotRequired[str]
64
+
65
+
66
+ class GetMergeRequestInput(TypedDict):
67
+ project: str
68
+ iid: float
69
+
70
+
71
+ class Pipeline(TypedDict):
72
+ id: float
73
+ status: str
74
+ webUrl: str
75
+
76
+
77
+ class TriggerPipelineInput(TypedDict):
78
+ project: str
79
+ ref: str
80
+
81
+
82
+ class GetPipelineStatusInput(TypedDict):
83
+ project: str
84
+ id: float
85
+
86
+
87
+ class Issue(TypedDict):
88
+ iid: float
89
+ title: str
90
+ state: str
91
+ webUrl: str
92
+
93
+
94
+ class GetIssueInput(TypedDict):
95
+ project: str
96
+ iid: float
97
+
98
+
99
+ class CloseIssueInput(TypedDict):
100
+ project: str
101
+ iid: float
102
+
103
+
104
+ class CloseIssueResult(TypedDict):
105
+ iid: float
106
+ state: str
@@ -0,0 +1,32 @@
1
+ """Registration-free gitlab webhook verification and event mapping."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import os
6
+ from collections.abc import Callable
7
+
8
+ from render_lab_tasks_core.signatures import safe_equal
9
+ from render_lab_triggers.types import Adapter, Json, WebhookContext, WebhookDispatch, WebhookRequest
10
+
11
+ type OnEvent = Callable[[dict[str, Json]], WebhookDispatch | None]
12
+
13
+
14
+ def verify_gitlab_token(secret: str, token: str | None) -> bool:
15
+ return bool(token) and safe_equal(token, secret)
16
+
17
+
18
+ def gitlab_adapter(
19
+ on_event: OnEvent, *, secret: str | None = None, header_name: str = "x-gitlab-token"
20
+ ) -> Adapter:
21
+ def verify(req: WebhookRequest) -> bool:
22
+ key = secret if secret is not None else os.getenv("GITLAB_WEBHOOK_SECRET")
23
+ return bool(key) and (
24
+ verify_gitlab_token(key or "", req["headers"].get(header_name.lower()))
25
+ )
26
+
27
+ def map_event(ctx: WebhookContext) -> WebhookDispatch | None:
28
+ payload = ctx["body"] if ctx["body"] is not None else {}
29
+ headers = ctx["headers"]
30
+ return on_event({"event": headers.get("x-gitlab-event", ""), "payload": payload})
31
+
32
+ return Adapter(verify, map_event)
@@ -0,0 +1,80 @@
1
+ Metadata-Version: 2.5
2
+ Name: render-lab-tasks-gitlab
3
+ Version: 0.1.0
4
+ Summary: gitlab tasks for Render Workflows
5
+ Project-URL: Repository, https://github.com/render-lab/render-tasks-python
6
+ License-Expression: MIT
7
+ License-File: LICENSE
8
+ Requires-Python: >=3.12
9
+ Requires-Dist: httpx<0.29,>=0.28
10
+ Requires-Dist: render-lab-tasks-core<0.2,>=0.1.1
11
+ Requires-Dist: render-lab-triggers<0.2,>=0.1.0
12
+ Requires-Dist: render==1.0.1
13
+ Description-Content-Type: text/markdown
14
+
15
+ # render-lab-tasks-gitlab
16
+
17
+ Python port of all 10 registered tasks in the pinned TypeScript pack at
18
+ `45f9c2d44bd28e01ae9813e0d2ff56ee6c533816`. Python 3.12+.
19
+
20
+ From the repository, install this pack and its supporting core together:
21
+
22
+ ```sh
23
+ pip install render-lab-tasks-gitlab==0.1.0
24
+ ```
25
+
26
+ Import task definitions from `render_lab_tasks_gitlab.tasks`. Combine its `app` with
27
+ other pack apps using `Workflows.from_workflows(...)` and call tasks with
28
+ `await ctx.run(task, input)`. Package roots do not register tasks. JSON fields
29
+ retain the TS spelling; Python functions use snake_case.
30
+
31
+ ## Tasks
32
+
33
+ | Registered name | Python export (also exposes `_impl`) |
34
+ | --- | --- |
35
+ | `gitlab.closeIssue` | `close_issue` |
36
+ | `gitlab.comment` | `comment` |
37
+ | `gitlab.createIssue` | `create_issue` |
38
+ | `gitlab.createMergeRequest` | `create_merge_request` |
39
+ | `gitlab.getIssue` | `get_issue` |
40
+ | `gitlab.getMergeRequest` | `get_merge_request` |
41
+ | `gitlab.getPipelineStatus` | `get_pipeline_status` |
42
+ | `gitlab.listMergeRequests` | `list_merge_requests` |
43
+ | `gitlab.mergeWhenGreen` | `merge_when_green` |
44
+ | `gitlab.triggerPipeline` | `trigger_pipeline` |
45
+
46
+ ## Dependencies and retries
47
+
48
+ Raw implementations accept context first and keyword-only `deps`. The `.client`
49
+ module exports typed `Port`, `Deps`, and `Client` classes (also vendor-named aliases).
50
+ Inject a fake port, or pass a caller-owned `httpx.AsyncClient` to `Client` for custom
51
+ transport/configuration. Default dependencies close their HTTP clients after the
52
+ operation. Credentials resolve at first use. HTTP and SDK retries are disabled;
53
+ `retry.py` owns durable retry settings. DTO types live in `.types`.
54
+
55
+ ## Environment
56
+
57
+ | Variable | Contract |
58
+ | --- | --- |
59
+ | `GITLAB_TOKEN` | Required on API calls. |
60
+ | `GITLAB_URL` | Optional GitLab site URL; defaults to https://gitlab.com. |
61
+
62
+ ## Verification and limitations
63
+
64
+ mergeWhenGreen preserves the TS behavior: success and manual pipelines permit a merge, failed/canceled pipelines throw a failure, and other/missing states throw a pending error. It inherits the normal three-retry policy, not an hour-long wait. Project paths are URL-encoded. The optional TS webhook adapter is deferred until the Python triggers contract is ported.
65
+
66
+ Shared JSON fixtures compare the Python task output with the actual pinned TS
67
+ implementation. REST fixtures also compare HTTP requests; HubSpot and Linear
68
+ fixtures compare source SDK arguments with HTTP payloads/GraphQL variables.
69
+ No live vendor calls were made for this batch. Registered-task parity does not
70
+ claim live readiness or all supporting TS exports. See the root verification
71
+ tracker and docs/porting-batches.md. Licensed under MIT.
72
+
73
+ ## Webhook adapter
74
+
75
+ `render_lab_tasks_gitlab.webhooks.gitlab_adapter(on_event, ...)` returns a
76
+ registration-free adapter for `render_lab_triggers`. The callback receives the
77
+ verified event and returns `{"task": "namespace.task", "args": [event]}` or `None`.
78
+ The signing credential `GITLAB_WEBHOOK_SECRET` is read inside verification unless
79
+ provided explicitly. Importing this module does not register tasks. Signature
80
+ checks use the raw body; live delivery remains in the testing backlog.
@@ -0,0 +1,22 @@
1
+ render_lab_tasks_gitlab/__init__.py,sha256=fGcyw3Sxjue9wB_1RdFbEFKm5DXSlw_6vD2ud03a6og,58
2
+ render_lab_tasks_gitlab/_app.py,sha256=nkWSD_6eq3xzdPJ_G7z6d5mv8tSB-Rq21yp07usJihA,48
3
+ render_lab_tasks_gitlab/client.py,sha256=vdtZvDmx4slehgmXNc86TNErdlC9POwBb5fNJCZgAso,7081
4
+ render_lab_tasks_gitlab/close_issue.py,sha256=yaKRkBxO0qW_UamzPiM0q96NIHyHYH_uAWulHPOayZs,597
5
+ render_lab_tasks_gitlab/comment.py,sha256=PxxILvTgwhtD-qZU6kmZestuy-tOUPa3xrOFYoSuAmo,560
6
+ render_lab_tasks_gitlab/create_issue.py,sha256=9YmjRWzfo9TsnYGGWxwIzDYNTfL0vTttDPY0BKSaX8U,608
7
+ render_lab_tasks_gitlab/create_merge_request.py,sha256=uH33A41SFLim8zUmRGFFtAX4JFtqR9zoI7QrRW2GSC0,653
8
+ render_lab_tasks_gitlab/get_issue.py,sha256=OzAkCWqfjHC3iwEf9DyTn6M2Y8mGKcXnFINGbZi60kA,548
9
+ render_lab_tasks_gitlab/get_merge_request.py,sha256=anXG8RqRyoujEQTiq-im6ZO9FsPZmHt04t8az48elu8,629
10
+ render_lab_tasks_gitlab/get_pipeline_status.py,sha256=VVmzuFRWcQpyT9kauqFG0SG-GKb2l48HXlGPkMH9EfA,633
11
+ render_lab_tasks_gitlab/list_merge_requests.py,sha256=C0v5KxpseLiI8oEsoYuVv2_fKLAbPR5IMOOX8gpwXlk,663
12
+ render_lab_tasks_gitlab/merge_when_green.py,sha256=mcq9CyQ3iSbImG9d6Gesbc1Vy2yzlLVSziDpFHHAqBQ,618
13
+ render_lab_tasks_gitlab/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
14
+ render_lab_tasks_gitlab/retry.py,sha256=gP-xrgdnn6IZFFJXJ2eisJQaao2NsoWPLE7BLerwzrg,104
15
+ render_lab_tasks_gitlab/tasks.py,sha256=gqyTkXVBQUvrGEm9IvHNqRU3S1OMWAJwkcYAlae0aRI,1208
16
+ render_lab_tasks_gitlab/trigger_pipeline.py,sha256=ffqSzwXz5jiU4ETLgj2uCvtGDrBMdgrb6NR8rfwasR0,613
17
+ render_lab_tasks_gitlab/types.py,sha256=gciroR02ypC3qOAYIKdnEhnc0IjYaNG9sbapy1dzU3Q,1762
18
+ render_lab_tasks_gitlab/webhooks.py,sha256=PvJtFKRkDK47WN-vIdhXnGNGgJUnNtc_VZHTzR7AfGM,1173
19
+ render_lab_tasks_gitlab-0.1.0.dist-info/METADATA,sha256=vfUQB7tnb_5lEEjjTcJ1a7ScEodfrNtytgk0koXTlB0,3609
20
+ render_lab_tasks_gitlab-0.1.0.dist-info/WHEEL,sha256=zOwg4jB6zX2kU910N-cMawjivD6tO8NEWvE12je1bVk,87
21
+ render_lab_tasks_gitlab-0.1.0.dist-info/licenses/LICENSE,sha256=LvmsuKGkhvlSISJRqvBIPUQ_BqVDFRe0RghPSmDebzU,1067
22
+ render_lab_tasks_gitlab-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.32.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Render Lab
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.