feat: Add GitLab event support for automation triggers#66
Conversation
Add GitLab webhook event handling to the automation service, mirroring the existing GitHub support. This enables event-triggered automations for GitLab repositories. Changes: - Add GitLab event schemas (merge_request, push, tag_push, issue, note, pipeline) - Register GitLab parser in event_schemas/__init__.py - Add 'gitlab' to builtin webhook sources in utils/webhook.py - Add 'gitlab' to reserved sources in schemas.py - Add comprehensive tests for GitLab event parsing, detection, and trigger matching GitLab events are forwarded from the OpenHands server using the same AUTOMATION_WEBHOOK_SECRET and X-Hub-Signature-256 header pattern as GitHub. Event type mapping (GitLab -> GitHub equivalent): - merge_request -> pull_request - push -> push - tag_push -> (tag portion of push) - issue -> issues - note -> issue_comment - pipeline -> (no direct equivalent) Co-authored-by: openhands <openhands@all-hands.dev>
|
🚀 Deploy Preview PR Created/Updated A deploy preview has been created/updated for this PR. Deploy PR: https://github.com/OpenHands/deploy/pull/3917 Once the deploy PR's CI passes, the automation service will be deployed to the feature environment. |
Update test_only_github_reserved to test_builtin_providers_reserved and add test_gitlab_is_reserved to properly test that both GitHub and GitLab are in the RESERVED_SOURCES set. Co-authored-by: openhands <openhands@all-hands.dev>
Co-authored-by: openhands <openhands@all-hands.dev>
all-hands-bot
left a comment
There was a problem hiding this comment.
🟡 Acceptable - Solid implementation that mirrors GitHub support well. Found minor issues with potentially dead code and missing test evidence.
Remove fallback detection rules that can never execute since GitLab webhooks always include the object_kind field. The second comment about action extraction duplication is acknowledged but kept as-is since it's minor and doesn't warrant added complexity of a base class mixin. Co-authored-by: openhands <openhands@all-hands.dev>
|
Addressed all review feedback in 45e2c2e: ✅ Comment 1 (line 400): Removed dead fallback detection rules - GitLab webhooks always include Status:
|
all-hands-bot
left a comment
There was a problem hiding this comment.
🟡 Acceptable - Solid implementation that mirrors GitHub support well. Clean code with comprehensive test coverage.
[RISK ASSESSMENT]
🟢 LOW - Well-contained feature addition with good test coverage, no breaking changes, uses existing webhook validation infrastructure. Mirrors proven GitHub implementation pattern.
VERDICT: ✅ Worth merging
KEY INSIGHT: This follows the established pattern for event source integration, making it maintainable and predictable. The use of GitLab's built-in object_kind field for detection is simpler and more reliable than structural heuristics.
Summary
Add GitLab webhook event handling to the automation service, mirroring the existing GitHub support. This enables event-triggered automations for GitLab repositories.
Changes
New Files
automation/event_schemas/gitlab.py- GitLab event schema definitions with Pydantic modelsModified Files
automation/event_schemas/__init__.py- Register GitLab parserautomation/utils/webhook.py- Add 'gitlab' to builtin sourcesautomation/schemas.py- Add 'gitlab' to reserved sourcestests/test_event_schemas.py- Add GitLab event parsing, detection, and trigger matching teststests/test_event_router.py- Add GitLab event forwarding testsGitLab Event Types Supported
merge_request.{action}pull_request.{action}pushpushtag_pushissue.{action}issues.{action}noteissue_comment.createdpipeline.{status}Implementation Details
AUTOMATION_WEBHOOK_SECRETandX-Hub-Signature-256header pattern as GitHubobject_kindfield for reliable event type identificationobject_attributes.action(for MRs, issues) orobject_attributes.status(for pipelines)project.path_with_namespace == 'org/repo'glob(project.path_with_namespace, 'org/*')icontains(object_attributes.note, '@openhands')Example Automation Trigger
{ "type": "event", "source": "gitlab", "on": "merge_request.open", "filter": "glob(project.path_with_namespace, 'myorg/*')" }Testing
test_event_schemas.pytest_event_router.pyRelated
This complements the OpenHands server-side GitLab event forwarding implementation in OpenHands/OpenHands#14118
This PR was created by an AI assistant (OpenHands) on behalf of the user.
@malhotra5 can click here to continue refining the PR