Skip to content

feat(github): add flyteplugins-github (webhooks + review_pr gate) - #1513

Merged
cosmicBboy merged 2 commits into
nielsb/webhooks-corefrom
nielsb/webhooks-github
Sep 2, 2026
Merged

feat(github): add flyteplugins-github (webhooks + review_pr gate)#1513
cosmicBboy merged 2 commits into
nielsb/webhooks-corefrom
nielsb/webhooks-github

Conversation

@cosmicBboy

Copy link
Copy Markdown
Collaborator

Part of the webhook plugin stack. Requires #1512 (flyteplugins-webhooks-core), which is this PR's base — the diff here is just this package.

Receive GitHub webhooks in Flyte.

What it implements

The Provider contract from core: which environment variable holds the secret, how to verify a delivery, how to parse one into a WebhookEvent, plus typed constants for every event GitHub sends.

Verification: HMAC-SHA256 over the raw body (X-Hub-Signature-256).

Answers GitHub's ping automatically, so a green check in Recent Deliveries means the app is reachable.

Comment and review events fold the comment id into resource_id, so two comments on one issue are two events rather than a redelivery of the first — the bug that prompted this whole restructure.

Conformance

Runs the shared assert_provider_conforms, which replays this plugin's SAMPLE_DELIVERY — a real GitHub payload — through verify and parse rather than trusting them to agree with each other. It also asserts the verifier returns False rather than raising on a hostile header, that event constants render as wire values rather than enum names, and that the sample parses to something the constants actually spell.

7 tests. make fmt, make mypy, make ty, ruff, and codespell pass.

What it does not do

Call the GitHub API. Use PyGithub directly from your tasks — the recipes are in the examples PR at the end of this stack. This plugin owns only the part that is Flyte's: authenticating an inbound delivery and turning it into a run.

@cosmicBboy
cosmicBboy force-pushed the nielsb/webhooks-github branch from aea3037 to b343898 Compare September 1, 2026 17:35
@cosmicBboy
cosmicBboy marked this pull request as ready for review September 1, 2026 17:54
@cosmicBboy
cosmicBboy force-pushed the nielsb/webhooks-github branch from b343898 to 0c00cc4 Compare September 1, 2026 18:29
@cosmicBboy
cosmicBboy force-pushed the nielsb/webhooks-github branch from 0c00cc4 to 08c96a7 Compare September 1, 2026 18:54
@cosmicBboy
cosmicBboy force-pushed the nielsb/webhooks-github branch from 08c96a7 to ab54b78 Compare September 2, 2026 00:55
@cosmicBboy cosmicBboy changed the title feat(webhooks): flyteplugins-webhooks-github feat(github): add flyteplugins-github Sep 2, 2026
@cosmicBboy
cosmicBboy force-pushed the nielsb/webhooks-github branch from ab54b78 to 78f4523 Compare September 2, 2026 01:03
Receive GitHub webhooks in Flyte, and gate a workflow on a human PR review.

Exports GitHubProvider, a Provider subclass with its defaults pre-wired, so
wiring up the receiver reads:

    WebhookAppEnvironment(providers=[GitHubProvider()])

The receiver itself ships with flyte, at flyte.extras.webhooks; this package
contributes what is specific to GitHub -- which environment variable holds the
secret, how to verify a delivery, how to parse one into a WebhookEvent, and
typed constants for every event GitHub sends.

It also exports review_pr, which parks a run on a flyte.new_condition carrying
the pull request's metadata as JSON and returns a typed decision. That is the
shape of method worth putting in a plugin: the condition is the part no vendor
SDK can provide. Reading the pull request is PyGithub's job, called directly
behind a [review] extra rather than wrapped, so a webhook-only install stays on
flyte alone.

examples/github_webhooks.py runs with no GitHub account at all: --local replays
this plugin's own SAMPLE_DELIVERY through the app, so you can watch a delivery
be verified, normalized, and dispatched before wiring anything up. The shared
conformance check exercises that same sample.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VKZrTNjjWVzTZUxDFbn4Nk
Signed-off-by: Niels Bantilan <niels.bantilan@gmail.com>
@cosmicBboy
cosmicBboy force-pushed the nielsb/webhooks-github branch from 78f4523 to 538223a Compare September 2, 2026 01:32
@cosmicBboy cosmicBboy changed the title feat(github): add flyteplugins-github feat(github): add flyteplugins-github (webhooks + review_pr gate) Sep 2, 2026
Part of the webhook plugin stack. Requires #1512
(`flyteplugins-webhooks-core`), which is this PR's base — the diff here
is just this package.

Receive Slack webhooks in Flyte.

## What it implements

The `Provider` contract from core: which environment variable holds the
secret, how to verify a delivery, how to parse one into a
`WebhookEvent`, plus typed constants for every event Slack sends.

**Verification:** HMAC-SHA256 over `v0:{timestamp}:{body}`, with a
five-minute replay window.

Echoes the `url_verification` challenge, so Slack's Request URL field
verifies itself.

The signature covers the **raw bytes**. Decoding the body and
re-encoding it would corrupt any byte Slack signed but Python cannot
decode, and running the timestamp through `int()` would drop whatever
formatting Slack signed — a test pins both.

## Conformance

Runs the shared `assert_provider_conforms`, which replays this plugin's
`SAMPLE_DELIVERY` — a real Slack payload — through `verify` and `parse`
rather than trusting them to agree with each other. It also asserts the
verifier returns False rather than raising on a hostile header, that
event constants render as wire values rather than enum names, and that
the sample parses to something the constants actually spell.

6 tests. `make fmt`, `make mypy`, `make ty`, ruff, and codespell pass.

## What it does not do

Call the Slack API. Use `slack_sdk` directly from your tasks — the
recipes are in the examples PR at the end of this stack. This plugin
owns only the part that is Flyte's: authenticating an inbound delivery
and turning it into a run.

---------

Signed-off-by: Niels Bantilan <niels.bantilan@gmail.com>
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
@cosmicBboy
cosmicBboy merged commit 7fcbaa8 into nielsb/webhooks-core Sep 2, 2026
62 checks passed
@cosmicBboy
cosmicBboy deleted the nielsb/webhooks-github branch September 2, 2026 02:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant