Skip to content

Commit

Permalink
refactor(storage): build/lint with buf
Browse files Browse the repository at this point in the history
Signed-off-by: Artsiom Koltun <artsiom.koltun@intel.com>
  • Loading branch information
artek-koltun committed Jan 18, 2024
1 parent cae3027 commit 94da5a8
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 16 deletions.
2 changes: 1 addition & 1 deletion buf.work.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ directories:
- common
- inventory
- security
# - storage
- storage
- network/opinetcommon
- network/cloud
- network/evpn-gw
Expand Down
22 changes: 12 additions & 10 deletions storage/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,22 @@
# Copyright (C) 2022 Intel Corporation
# Copyright (c) 2022 Dell Inc, or its subsidiaries.

all:
all: buflint bufgen doc

doc:
rm -rf ./google
rm -rf ./v1alpha1/{autogen.md,gen,google}
mkdir -p ./v1alpha1/gen/{go,cpp,python,java}
rm -f ./v1alpha1/autogen.md
mkdir -p ./v1alpha1

# protoc doesn't include annotation and http googleapis, so we have to get them here
curl -kL https://github.com/googleapis/googleapis/archive/master.tar.gz | tar --strip=1 -zxvf - googleapis-master/google/api

docker run --user=$$(id -u):$$(id -g) --rm -v "${PWD}":/defs -v "${PWD}/../common/v1":/common -v ${PWD}/google/api:/opt/include/google/api namely/protoc-all:1.51_2 -i /common --lint -d v1alpha1 -l go -o ./v1alpha1/gen/go/ --go-source-relative
docker run --user=$$(id -u):$$(id -g) --rm -v "${PWD}":/defs -v "${PWD}/../common/v1":/common -v ${PWD}/google/api:/opt/include/google/api namely/protoc-all:1.51_2 -i /common --lint -d v1alpha1 -l python -o ./v1alpha1/gen/python/ --go-source-relative
docker run --user=$$(id -u):$$(id -g) --rm --entrypoint=sh -v "${PWD}"/v1alpha1/:/out -w /out -v "${PWD}":/protos pseudomuto/protoc-gen-doc:1.5.1 -c "protoc -I /protos --doc_out=/out --doc_opt=markdown,autogen.md /protos/*.proto"

rm -rf "${PWD}"/google

mv google "${PWD}"/v1alpha1/google
buflint:
docker run --rm -v "${PWD}":/out -w /out bufbuild/buf lint

docker run --user=$$(id -u):$$(id -g) --rm --entrypoint=sh -v "${PWD}/../common/v1":/common -v "${PWD}"/v1alpha1/:/out -w /out -v "${PWD}"/v1alpha1:/protos pseudomuto/protoc-gen-doc:1.5.1 -c "protoc -I /common -I /protos --doc_out=/out --doc_opt=markdown,autogen.md /protos/*.proto /common/*.proto"
docker run --user=$$(id -u):$$(id -g) --rm --entrypoint=sh -v "${PWD}/../common/v1":/common -v "${PWD}"/v1alpha1/:/out -w /out ghcr.io/docker-multiarch/google-api-linter:1.63.1 -c "api-linter -I /common /out/*.proto --output-format summary"
docker run --user=$$(id -u):$$(id -g) --rm --entrypoint=sh -v "${PWD}/../common/v1":/common -v "${PWD}"/v1alpha1/:/out -w /out ghcr.io/docker-multiarch/google-api-linter:1.63.1 -c "api-linter -I /common /out/*.proto --output-format github --set-exit-status"
rm -rf "${PWD}"/v1alpha1/google
bufgen:
docker run --rm -v "${PWD}/..":/base -v "${PWD}":/out -w /out msandersdell/bufbuild-go-gen:1.1.0 generate --template /base/buf.gen.yaml -o v1alpha1
8 changes: 4 additions & 4 deletions storage/buf.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ deps:
- remote: buf.build
owner: googleapis
repository: googleapis
commit: 28151c0d0a1641bf938a7672c500e01d
digest: shake256:49215edf8ef57f7863004539deff8834cfb2195113f0b890dd1f67815d9353e28e668019165b9d872395871eeafcbab3ccfdb2b5f11734d3cca95be9e8d139de
commit: a86849a25cc04f4dbe9b15ddddfbc488
digest: shake256:e19143328f8cbfe13fc226aeee5e63773ca494693a72740a7560664270039a380d94a1344234b88c7691311460df9a9b1c2982190d0a2612eae80368718e1943
- remote: buf.build
owner: grpc-ecosystem
repository: grpc-gateway
commit: f460f71081c14a80b66cc72526e0b322
digest: shake256:122def85e91fc3ef4ab351680060b8f70e9d09a7ae6d1412aeb2bddfeee5c4d3fc8819da33fef56192cec0a817ac0c3e6d49bb2acf02eb5c9e9131739a60ddfc
commit: 3f42134f4c564983838425bc43c7a65f
digest: shake256:3d11d4c0fe5e05fda0131afefbce233940e27f0c31c5d4e385686aea58ccd30f72053f61af432fa83f1fc11cda57f5f18ca3da26a29064f73c5a0d076bba8d92
11 changes: 10 additions & 1 deletion storage/buf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,13 @@ name: buf.build/opiproject/storage
deps:
- buf.build/googleapis/googleapis
- buf.build/grpc-ecosystem/grpc-gateway

lint:
use:
- DEFAULT
- COMMENTS
except:
- PACKAGE_DIRECTORY_MATCH
# Don't check standard name as that causes google aip issues
- RPC_RESPONSE_STANDARD_NAME
# Allow same name used in request/response type for multiple RPCs
- RPC_REQUEST_RESPONSE_UNIQUE

0 comments on commit 94da5a8

Please sign in to comment.