Skip to content

Commit

Permalink
Add workflow to update protos (#73)
Browse files Browse the repository at this point in the history
  • Loading branch information
njooma authored Jul 27, 2023
1 parent 6d213c9 commit 4055398
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 8 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/update_protos.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
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
21 changes: 13 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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:
Expand Down

0 comments on commit 4055398

Please sign in to comment.