Skip to content

Commit

Permalink
Generate gRPC API using buf
Browse files Browse the repository at this point in the history
* APIs are described in `/proto` using buf.build.
* Generated code is stored under `a3m/api`.
* Genearted docs can be found at https://buf.build/artefactual/a3m.
* It includes a couple of CI workflows to validate PRs and push to the BSR.
  • Loading branch information
sevein committed May 26, 2022
1 parent 567b8fc commit dd4f57e
Show file tree
Hide file tree
Showing 30 changed files with 797 additions and 1,437 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/buf-pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Buf (pull request)
on: pull_request
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: bufbuild/buf-setup-action@v1
- uses: bufbuild/buf-lint-action@v1
with:
input: proto
# - uses: bufbuild/buf-breaking-action@v1
# with:
# input: proto
# against: 'https://github.com/${GITHUB_REPOSITORY}.git#branch=main'
22 changes: 22 additions & 0 deletions .github/workflows/buf-push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Buf (push)
on:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: bufbuild/buf-setup-action@v1
- uses: bufbuild/buf-lint-action@v1
with:
input: proto
# - uses: bufbuild/buf-breaking-action@v1
# with:
# input: proto
# against: 'https://github.com/${GITHUB_REPOSITORY}.git#branch=main'
- uses: bufbuild/buf-push-action@v1
with:
input: proto
buf_token: ${{ secrets.BUF_TOKEN }}
17 changes: 7 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -134,16 +134,13 @@ amflow: ## Display the workflow in amflow.
artefactual/amflow:latest \
edit --file=/workflow.json

.PHONY: protoc
protoc: ## Generate gRPC code.
$(call compose_run, \
--entrypoint python \
a3m \
-m grpc_tools.protoc -I=. --python_out=. --grpc_python_out=. a3m/server/rpc/proto/a3m.proto)
$(call compose_run, \
--entrypoint black \
a3m \
a3m/server/rpc/proto)
.PHONY: buf
buf:
docker run \
--volume "$(CURDIR)/proto:/workspace" \
--workdir /workspace \
bufbuild/buf:1.4.0 \
$(ARG)

.PHONY: help
help: ## Print this help message.
Expand Down
12 changes: 12 additions & 0 deletions a3m/api/transferservice/v1beta1/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from . import request_response_pb2
from . import request_response_pb2_grpc
from . import service_pb2
from . import service_pb2_grpc


__all__ = [
"request_response_pb2_grpc",
"request_response_pb2",
"service_pb2_grpc",
"service_pb2",
]
53 changes: 53 additions & 0 deletions a3m/api/transferservice/v1beta1/request_response_pb2.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit dd4f57e

Please sign in to comment.