Skip to content

Commit 2ffba8c

Browse files
authored
Merge pull request #6 from GoCodeAlone/copilot/migrate-workflow-plugin-github
Migrate workflow-plugin-github to strict gRPC proto contracts
2 parents d83fa8d + fcf3cd6 commit 2ffba8c

8 files changed

Lines changed: 850 additions & 37 deletions

File tree

.github/workflows/ci.yml

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,48 @@ on:
66
branches: [main, master]
77
jobs:
88
test:
9-
runs-on: [self-hosted, Linux, X64]
9+
runs-on: ubuntu-latest
10+
permissions:
11+
contents: read
1012
steps:
1113
- uses: actions/checkout@v6
1214
- uses: actions/setup-go@v6
1315
with:
1416
go-version-file: go.mod
1517
- run: go build ./...
1618
- run: go test ./... -v -race -count=1
19+
env:
20+
GOPRIVATE: github.com/GoCodeAlone/*
21+
GONOSUMCHECK: github.com/GoCodeAlone/*
22+
23+
strict-contracts:
24+
name: Validate strict plugin contracts
25+
runs-on: ubuntu-latest
26+
permissions:
27+
contents: read
28+
steps:
29+
- uses: actions/checkout@v6
30+
- name: Verify plugin.json exists
31+
run: |
32+
test -f plugin.json || { echo "ERROR: plugin.json is missing — every release must include a strict contract manifest"; exit 1; }
33+
- uses: actions/setup-go@v6
34+
with:
35+
go-version-file: go.mod
36+
- name: Run strict contract tests
37+
run: |
38+
go test ./internal/... -run "TestPluginStepSchemasJSON|TestPluginManifestEngineValidation|TestModuleSchemas" -v -count=1
39+
env:
40+
GOPRIVATE: github.com/GoCodeAlone/*
41+
GONOSUMCHECK: github.com/GoCodeAlone/*
42+
- name: Validate plugin.json with wfctl
43+
run: |
44+
# wfctl validates registry-format manifests; strict contract schema coverage is enforced
45+
# by the Go tests above. This step runs informational validation and logs the result.
46+
set +e
47+
go run github.com/GoCodeAlone/workflow/cmd/wfctl@v0.3.56 plugin validate --file plugin.json 2>&1
48+
wfctl_exit=$?
49+
set -e
50+
echo "wfctl validation exit code: ${wfctl_exit}"
51+
env:
52+
GOPRIVATE: github.com/GoCodeAlone/*
53+
GONOSUMCHECK: github.com/GoCodeAlone/*

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
bin/

go.mod

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@ module github.com/GoCodeAlone/workflow-plugin-github
22

33
go 1.26.0
44

5-
require github.com/GoCodeAlone/workflow v0.3.56
5+
require (
6+
github.com/GoCodeAlone/workflow v0.3.56
7+
github.com/golang-jwt/jwt/v5 v5.3.1
8+
github.com/google/go-github/v69 v69.2.0
9+
golang.org/x/crypto v0.48.0
10+
)
611

712
require (
813
cel.dev/expr v0.25.1 // indirect
@@ -94,10 +99,8 @@ require (
9499
github.com/go-logr/logr v1.4.3 // indirect
95100
github.com/go-logr/stdr v1.2.2 // indirect
96101
github.com/gobwas/glob v0.2.3 // indirect
97-
github.com/golang-jwt/jwt/v5 v5.3.1 // indirect
98102
github.com/golobby/cast v1.3.3 // indirect
99103
github.com/google/btree v1.1.3 // indirect
100-
github.com/google/go-github/v69 v69.2.0 // indirect
101104
github.com/google/go-querystring v1.1.0 // indirect
102105
github.com/google/s2a-go v0.1.9 // indirect
103106
github.com/google/uuid v1.6.0 // indirect
@@ -201,7 +204,6 @@ require (
201204
go.uber.org/multierr v1.11.0 // indirect
202205
go.uber.org/zap v1.27.1 // indirect
203206
go.yaml.in/yaml/v2 v2.4.3 // indirect
204-
golang.org/x/crypto v0.48.0 // indirect
205207
golang.org/x/exp v0.0.0-20260218203240-3dfff04db8fa // indirect
206208
golang.org/x/mod v0.33.0 // indirect
207209
golang.org/x/net v0.51.0 // indirect

internal/schemas.go

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
package internal
2+
3+
import sdk "github.com/GoCodeAlone/workflow/plugin/external/sdk"
4+
5+
// Ensure githubPlugin satisfies sdk.SchemaProvider at compile time.
6+
var _ sdk.SchemaProvider = (*githubPlugin)(nil)
7+
8+
// ModuleSchemas returns schema descriptors for all module types provided by
9+
// this plugin. Implementing sdk.SchemaProvider allows the engine to surface
10+
// module configuration fields and I/O contracts at startup and in the UI.
11+
func (p *githubPlugin) ModuleSchemas() []sdk.ModuleSchemaData {
12+
return []sdk.ModuleSchemaData{
13+
{
14+
Type: "git.webhook",
15+
Label: "GitHub Webhook",
16+
Category: "github",
17+
Description: "Receives GitHub webhook events via HTTP, verifies HMAC-SHA256 signatures, and publishes normalised GitEvent messages to a configurable topic.",
18+
ConfigFields: []sdk.ConfigField{
19+
{
20+
Name: "provider",
21+
Type: "string",
22+
Description: "Webhook provider identifier. Accepted for backward compatibility; the module always publishes events with provider 'github'.",
23+
DefaultValue: "github",
24+
Required: false,
25+
},
26+
{
27+
Name: "secret",
28+
Type: "string",
29+
Description: "Webhook secret used to verify the X-Hub-Signature-256 header. Leave empty to skip signature verification.",
30+
Required: false,
31+
},
32+
{
33+
Name: "events",
34+
Type: "array",
35+
Description: "Event types to accept (e.g. push, pull_request). An empty list accepts all event types.",
36+
Required: false,
37+
},
38+
{
39+
Name: "topic",
40+
Type: "string",
41+
Description: "Message-bus topic to which normalised GitEvent payloads are published.",
42+
DefaultValue: "git.events",
43+
Required: false,
44+
},
45+
},
46+
Outputs: []sdk.ServiceIO{
47+
{Name: "provider", Type: "string", Description: "Webhook provider (always 'github')"},
48+
{Name: "event_type", Type: "string", Description: "GitHub event type (e.g. push, pull_request)"},
49+
{Name: "repository", Type: "string", Description: "Repository full name (owner/repo)"},
50+
{Name: "branch", Type: "string", Description: "Branch or ref name"},
51+
{Name: "commit", Type: "string", Description: "Commit SHA"},
52+
{Name: "author", Type: "string", Description: "Event author username"},
53+
{Name: "message", Type: "string", Description: "Commit message or PR title"},
54+
{Name: "url", Type: "string", Description: "URL to the commit or PR"},
55+
{Name: "raw_payload", Type: "object", Description: "Raw JSON webhook payload"},
56+
{Name: "timestamp", Type: "string", Description: "Event timestamp in RFC3339 format"},
57+
},
58+
},
59+
{
60+
Type: "github.app",
61+
Label: "GitHub App",
62+
Category: "github",
63+
Description: "Authenticates as a GitHub App installation, generating short-lived installation access tokens from an App private key. Tokens are cached and refreshed automatically.",
64+
ConfigFields: []sdk.ConfigField{
65+
{
66+
Name: "app_id",
67+
Type: "number",
68+
Description: "GitHub App ID",
69+
Required: true,
70+
},
71+
{
72+
Name: "installation_id",
73+
Type: "number",
74+
Description: "GitHub App installation ID",
75+
Required: true,
76+
},
77+
{
78+
Name: "private_key",
79+
Type: "string",
80+
Description: "PEM-encoded RSA private key for the GitHub App (supports env var references e.g. ${GITHUB_APP_PRIVATE_KEY})",
81+
Required: true,
82+
},
83+
},
84+
},
85+
}
86+
}

0 commit comments

Comments
 (0)