Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions .github/workflows/ci-go.yml
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'
Comment thread
yordis marked this conversation as resolved.

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

Comment thread
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
17 changes: 15 additions & 2 deletions .mise.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[tools]
buf = "1.70.0"
go = "1.26.5"
"ubi:open-telemetry/weaver" = { version = "0.24.2", exe = "weaver" }
"cargo:cargo-dylint" = "6.0.1"
"cargo:dylint-link" = "6.0.1"
Expand All @@ -20,7 +21,11 @@ run = "docker compose -f devops/docker/compose/compose.yml up -d"

[tasks.build]
description = "Build all"
depends = ["build:rust", "build:docs", "build:web"]
depends = ["build:rust", "build:go", "build:docs", "build:web"]

[tasks."build:go"]
dir = "goworkspace"
run = "go build ./..."

[tasks."build:docs"]
dir = "docs"
Expand All @@ -40,7 +45,15 @@ run = "cargo build"

[tasks.check]
description = "Check workspaces"
depends = ["check:rust", "check:web"]
depends = ["check:rust", "check:go", "check:web"]

[tasks."check:go"]
dir = "goworkspace"
run = "test -z \"$(gofmt -l .)\" && go test ./... && go vet ./... && find internal/protowit/testdata/snapshots -name '*.wit' -exec dirname {} \\; | sort -u | xargs -n1 wasm-tools component wit >/dev/null"

[tasks."test:go:race"]
dir = "goworkspace"
run = "go test -race ./..."

[tasks."check:rust"]
dir = "rsworkspace"
Expand Down
15 changes: 15 additions & 0 deletions goworkspace/cmd/protoc-gen-wit/main.go
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)
}
}
14 changes: 14 additions & 0 deletions goworkspace/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module github.com/TrogonStack/trogonai/goworkspace

go 1.26.0

Comment thread
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
)
14 changes: 14 additions & 0 deletions goworkspace/go.sum
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=
72 changes: 72 additions & 0 deletions goworkspace/internal/protowit/errors.go
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"
Comment thread
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"
}
}
Loading
Loading