From 405539882d0c88a3704fe4a44220f559e0106c71 Mon Sep 17 00:00:00 2001 From: Naveed Jooma Date: Thu, 27 Jul 2023 14:53:31 -0400 Subject: [PATCH] Add workflow to update protos (#73) --- .github/workflows/update_protos.yml | 47 +++++++++++++++++++++++++++++ Makefile | 21 ++++++++----- 2 files changed, 60 insertions(+), 8 deletions(-) create mode 100644 .github/workflows/update_protos.yml diff --git a/.github/workflows/update_protos.yml b/.github/workflows/update_protos.yml new file mode 100644 index 0000000000..2ca26c0bbe --- /dev/null +++ b/.github/workflows/update_protos.yml @@ -0,0 +1,47 @@ +name: Update Protos + Open PR + +on: + workflow_dispatch: + repository_dispatch: + types: + - protos-updated + +jobs: + update-protos: + if: github.repository_owner == 'viamrobotics' + runs-on: [self-hosted, x64] + container: + image: ghcr.io/cirruslabs/flutter:3.10.6 + steps: + - uses: actions/checkout@v3 + - uses: bufbuild/buf-setup-action@v1.25.0 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + - uses: arduino/setup-protoc@v2 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + + - name: Setup Flutter + run: flutter pub get + + - run: make setup + + - name: Generate buf + run: make buf + env: + BUF_TOKEN: ${{ secrets.BUF_TOKEN }} + + - name: Format + run: make format + + - name: Add + Commit + Open PR + uses: peter-evans/create-pull-request@v5 + with: + commit-message: "[WORKFLOW] Updating protos from ${{ github.event.client_payload.repo_name }}, commit: ${{ github.event.client_payload.sha }}" + branch: "workflow/update-protos" + delete-branch: true + base: main + title: Automated Protos Update + body: This is an auto-generated PR to update proto definitions. Check the commits to see which repos and commits are responsible for the changes + assignees: viamrobotics/sdk-netcode + reviewers: viamrobotics/sdk-netcode diff --git a/Makefile b/Makefile index 038dd2f3ba..bd99350dc0 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,10 @@ PATH_WITH_TOOLS="${PATH}:${HOME}/.pub-cache/bin" -PROTOBUF=$(shell readlink -f $$(brew --prefix protobuf))/include +UNAME := $(shell uname -s) +ifeq ($(UNAME), Darwin) + SED := sed -i '' +else + SED := sed -i +endif .PHONY: buf setup format test analyze @@ -9,14 +14,14 @@ buf: buf.yaml buf.gen.yaml PATH=$(PATH_WITH_TOOLS) buf generate buf.build/viamrobotics/api PATH=$(PATH_WITH_TOOLS) buf generate buf.build/erdaniels/gostream PATH=$(PATH_WITH_TOOLS) buf generate buf.build/googleapis/googleapis - PATH=$(PATH_WITH_TOOLS) protoc --dart_out=grpc:lib/src/gen -I$(PROTOBUF) $(PROTOBUF)/google/protobuf/any.proto - PATH=$(PATH_WITH_TOOLS) protoc --dart_out=grpc:lib/src/gen -I$(PROTOBUF) $(PROTOBUF)/google/protobuf/duration.proto - PATH=$(PATH_WITH_TOOLS) protoc --dart_out=grpc:lib/src/gen -I$(PROTOBUF) $(PROTOBUF)/google/protobuf/empty.proto - PATH=$(PATH_WITH_TOOLS) protoc --dart_out=grpc:lib/src/gen -I$(PROTOBUF) $(PROTOBUF)/google/protobuf/struct.proto - PATH=$(PATH_WITH_TOOLS) protoc --dart_out=grpc:lib/src/gen -I$(PROTOBUF) $(PROTOBUF)/google/protobuf/timestamp.proto - PATH=$(PATH_WITH_TOOLS) protoc --dart_out=grpc:lib/src/gen -I$(PROTOBUF) $(PROTOBUF)/google/protobuf/wrappers.proto + PATH=$(PATH_WITH_TOOLS) buf generate buf.build/protocolbuffers/wellknowntypes --path google/protobuf/any.proto + PATH=$(PATH_WITH_TOOLS) buf generate buf.build/protocolbuffers/wellknowntypes --path google/protobuf/duration.proto + PATH=$(PATH_WITH_TOOLS) buf generate buf.build/protocolbuffers/wellknowntypes --path google/protobuf/empty.proto + PATH=$(PATH_WITH_TOOLS) buf generate buf.build/protocolbuffers/wellknowntypes --path google/protobuf/struct.proto + PATH=$(PATH_WITH_TOOLS) buf generate buf.build/protocolbuffers/wellknowntypes --path google/protobuf/timestamp.proto + PATH=$(PATH_WITH_TOOLS) buf generate buf.build/protocolbuffers/wellknowntypes --path google/protobuf/wrappers.proto # There's a bug in dart protoc where it doesn't understand that `call` is already taken - sed -i '' 's/yield\* call(call, await request);/yield\* this\.call(call, await request);/g' ./lib/src/gen/proto/rpc/webrtc/v1/signaling.pbgrpc.dart + $(SED) 's/yield\* call(call, await request);/yield\* this\.call(call, await request);/g' ./lib/src/gen/proto/rpc/webrtc/v1/signaling.pbgrpc.dart dart run tool/export_protos.dart setup: