-
Notifications
You must be signed in to change notification settings - Fork 3
feat(wit): prevent protobuf and WIT schema drift #498
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
fff36e0
feat(wit): prevent protobuf and WIT schema drift
yordis 2cb0e64
chore(mise): extract check:go steps into a script
yordis e737c3c
fix(protowit): avoid implying valid oneofs are unsupported
yordis 79eff5e
chore(mise): move check:go to a file task
yordis 00097ea
fix(protowit): emit valid WIT for empty protobuf messages
yordis f24fe01
perf(protowit): track last identifier byte instead of rescanning the …
yordis e2eca99
ci(go): trigger on mise task script changes
yordis 6ba4bc5
fix(protowit): generalize unsupported-package error message
yordis 8de3d77
fix(protowit): validate transitively referenced same-package files
yordis 6a5abef
ci(go): install pinned rust so wasm-tools is deterministic
yordis e8ae97c
build(go): sync go.mod version with the mise toolchain pin
yordis f54154a
fix(mise): skip WIT validation when no snapshots are found
yordis File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| name: CI Go | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main] | ||
| pull_request: | ||
| types: [opened, synchronize, reopened] | ||
| branches: [main] | ||
| paths: | ||
| - 'goworkspace/**' | ||
| - 'proto/trogonai/scheduler/schedules/v1/schedule_completed.proto' | ||
| - 'proto/trogonai/scheduler/schedules/v1/schedule_paused.proto' | ||
| - 'proto/trogonai/scheduler/schedules/v1/schedule_removed.proto' | ||
| - 'proto/trogonai/scheduler/schedules/v1/schedule_resumed.proto' | ||
| - 'proto/trogonai/scheduler/schedules/v1/schedule_status.proto' | ||
| - 'buf.lock' | ||
| - 'buf.yaml' | ||
| - '.mise.toml' | ||
| - '.github/workflows/ci-go.yml' | ||
|
|
||
| concurrency: | ||
| group: ci-go-${{ github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| verify: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 | ||
| with: | ||
| persist-credentials: false | ||
|
|
||
| - name: Install Go tooling via mise | ||
| uses: jdx/mise-action@e6a8b3978addb5a52f2b4cd9d91eafa7f0ab959d # v4.2.0 | ||
| with: | ||
| install_args: go buf cargo:wasm-tools | ||
|
|
||
|
yordis marked this conversation as resolved.
|
||
| - name: Check Go workspace | ||
| run: mise run --skip-tools check:go | ||
|
|
||
| - name: Test Go workspace with race detection | ||
| run: mise run --skip-tools test:go:race | ||
|
|
||
| - name: Build Go workspace | ||
| run: mise run --skip-tools build:go | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| package main | ||
|
|
||
| import ( | ||
| "fmt" | ||
| "os" | ||
|
|
||
| "github.com/TrogonStack/trogonai/goworkspace/internal/protowit" | ||
| ) | ||
|
|
||
| func main() { | ||
| if err := protowit.Run(os.Stdin, os.Stdout); err != nil { | ||
| _, _ = fmt.Fprintln(os.Stderr, err) | ||
| os.Exit(1) | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| module github.com/TrogonStack/trogonai/goworkspace | ||
|
|
||
| go 1.26.0 | ||
|
|
||
|
yordis marked this conversation as resolved.
|
||
| require ( | ||
| github.com/stretchr/testify v1.11.1 | ||
| google.golang.org/protobuf v1.36.11 | ||
| ) | ||
|
|
||
| require ( | ||
| github.com/davecgh/go-spew v1.1.1 // indirect | ||
| github.com/pmezard/go-difflib v1.0.0 // indirect | ||
| gopkg.in/yaml.v3 v3.0.1 // indirect | ||
| ) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= | ||
| github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | ||
| github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= | ||
| github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= | ||
| github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= | ||
| github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= | ||
| github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= | ||
| github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= | ||
| google.golang.org/protobuf v1.36.11 h1:fV6ZwhNocDyBLK0dj+fg8ektcVegBBuEolpbTQyBNVE= | ||
| google.golang.org/protobuf v1.36.11/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco= | ||
| gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= | ||
| gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= | ||
| gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= | ||
| gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| package protowit | ||
|
|
||
| import ( | ||
| "fmt" | ||
|
|
||
| "google.golang.org/protobuf/reflect/protoreflect" | ||
| ) | ||
|
|
||
| type unsupportedReason uint8 | ||
|
|
||
| const ( | ||
| unsupportedParameter unsupportedReason = iota + 1 | ||
| unsupportedPackage | ||
| unsupportedEnum | ||
| unsupportedOneofShape | ||
| unsupportedMap | ||
| unsupportedFieldKind | ||
| unsupportedMessageReference | ||
| unsupportedRecursiveMessage | ||
| unsupportedExtension | ||
| unsupportedService | ||
| unsupportedIdentifier | ||
| unsupportedNameCollision | ||
| ) | ||
|
|
||
| type schemaError struct { | ||
| element protoreflect.FullName | ||
| reason unsupportedReason | ||
| detail string | ||
| } | ||
|
|
||
| func (e *schemaError) Error() string { | ||
| location := string(e.element) | ||
| if location == "" { | ||
| location = "request" | ||
| } | ||
| if e.detail == "" { | ||
| return fmt.Sprintf("%s: %s", location, e.reason) | ||
| } | ||
| return fmt.Sprintf("%s: %s: %s", location, e.reason, e.detail) | ||
| } | ||
|
|
||
| func (r unsupportedReason) String() string { | ||
| switch r { | ||
| case unsupportedParameter: | ||
| return "plugin parameters are not supported" | ||
| case unsupportedPackage: | ||
| return "protobuf package must contain a namespace and name" | ||
|
Copilot marked this conversation as resolved.
Outdated
|
||
| case unsupportedEnum: | ||
| return "enums are not supported" | ||
| case unsupportedOneofShape: | ||
| return "oneof shape is not supported" | ||
| case unsupportedMap: | ||
| return "maps are not supported" | ||
| case unsupportedFieldKind: | ||
| return "field kind is not supported" | ||
| case unsupportedMessageReference: | ||
| return "message reference is not part of the generated WIT package" | ||
| case unsupportedRecursiveMessage: | ||
| return "recursive message value types are not supported" | ||
| case unsupportedExtension: | ||
| return "extensions are not supported" | ||
| case unsupportedService: | ||
| return "services are not supported" | ||
| case unsupportedIdentifier: | ||
| return "protobuf identifier cannot be represented in WIT" | ||
| case unsupportedNameCollision: | ||
| return "normalized WIT name collision" | ||
| default: | ||
| return "unsupported schema" | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.