Skip to content

Commit 082d2d1

Browse files
intel352claude
andauthored
feat: adopt strict-contracts typed proto (closes #10) (#11)
* chore: bump workflow v0.3.56 → v0.51.7 Update minEngineVersion in plugin.json to 0.51.7. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * feat: adopt strict-contracts proto + ContractRegistry (closes #10) - proto/github/v1/github.proto: typed messages for 3 module types (git.webhook, github.app, github.runner_provider) and 17 step types - gen/github.pb.go: protoc-gen-go v1.36.11 generated bindings - internal/contracts.go: ContractRegistry() on githubPlugin; 20 STRICT_PROTO contract descriptors (3 modules + 17 steps) - internal/contracts_test.go: 4 passing tests (NonNil, AllModuleTypes, AllStepTypes, ContractCount) - plugin.contracts.json: 20 strict_proto contract entries - plugin.json: add contracts array with full workflow.plugin.github.v1.* type names - go.mod: promote google.golang.org/protobuf v1.36.11 to direct dependency - Makefile: add proto-gen target - .goreleaser.yaml: include plugin.contracts.json and LICENSE in release archives - .github/workflows/wfctl-validate.yml: strict-contracts CI gate Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix: pass RELEASES_TOKEN to setup-wfctl for private module access Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * chore: simplify ci.yml — remove stale strict-contracts job (superseded by wfctl-validate.yml) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix: use latest wfctl instead of go.mod version (v0.51.7 has no binary asset) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix: add downloads array to plugin.json (required by wfctl external plugin validation) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix: assert against sdk.ContractProvider interface directly Replace anonymous interface assertion with typed sdk.ContractProvider so any future SDK interface additions are caught at compile time. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent e3068ce commit 082d2d1

11 files changed

Lines changed: 5429 additions & 34 deletions

File tree

.github/workflows/ci.yml

Lines changed: 5 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -10,44 +10,17 @@ jobs:
1010
permissions:
1111
contents: read
1212
steps:
13-
- uses: actions/checkout@v6
14-
- uses: actions/setup-go@v6
13+
- uses: actions/checkout@v4
14+
- uses: actions/setup-go@v5
1515
with:
1616
go-version-file: go.mod
17+
- name: Configure git for private modules
18+
run: git config --global url."https://${{ secrets.RELEASES_TOKEN }}@github.com/".insteadOf "https://github.com/"
1719
- run: go build ./...
18-
- run: go test ./... -v -race -count=1
1920
env:
2021
GOPRIVATE: github.com/GoCodeAlone/*
2122
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}"
23+
- run: go test ./... -v -race -count=1
5124
env:
5225
GOPRIVATE: github.com/GoCodeAlone/*
5326
GONOSUMCHECK: github.com/GoCodeAlone/*
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# .github/workflows/wfctl-validate.yml
2+
name: wfctl strict contracts
3+
4+
on:
5+
pull_request:
6+
push:
7+
branches: [main, master]
8+
9+
jobs:
10+
wfctl-strict-contracts:
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: read
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- name: Check plugin.json and plugin.contracts.json exist
18+
run: |
19+
if [ ! -f plugin.json ]; then
20+
echo "::error::plugin.json is missing — add a plugin manifest to enable strict contract validation"
21+
exit 1
22+
fi
23+
if [ ! -f plugin.contracts.json ]; then
24+
echo "::error::plugin.contracts.json is missing — add a contracts file to pass strict contract validation"
25+
exit 1
26+
fi
27+
28+
- uses: GoCodeAlone/setup-wfctl@bcd880980f5bbe8d192d0c20ff6279d25331f956
29+
with:
30+
version: latest
31+
token: ${{ secrets.RELEASES_TOKEN }}
32+
33+
- name: Validate strict plugin contracts
34+
run: wfctl plugin validate --file plugin.json --strict-contracts

.goreleaser.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ archives:
4545
name_template: "{{ .ProjectName }}-{{ .Os }}-{{ .Arch }}"
4646
files:
4747
- plugin.json
48+
- plugin.contracts.json
49+
- LICENSE
4850

4951
checksum:
5052
name_template: "checksums.txt"

Makefile

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,15 @@
1-
.PHONY: build test install clean
1+
.PHONY: build test install clean proto-gen
2+
3+
# Regenerate Go bindings from proto/github/v1/github.proto.
4+
# Requires: protoc + protoc-gen-go
5+
# brew install protobuf
6+
# go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
7+
proto-gen:
8+
protoc \
9+
--proto_path=proto/github/v1 \
10+
--go_out=gen \
11+
--go_opt=paths=source_relative \
12+
proto/github/v1/github.proto
213

314
BINARY_NAME = workflow-plugin-github
415
PROVIDER_BINARY_NAME = github-runner-provider

0 commit comments

Comments
 (0)