-
Notifications
You must be signed in to change notification settings - Fork 392
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor our build pipeline for the protobuf API to use buf[1] to do our code generation. This approach has a few key advantages: 1. Simpler and more maintainable. We no longer need to maintain a complex makefile that gets more complex with every new .proto file. 2. Automatic checking for API breakages including JSON and wire compatibility. 3. Linting and automatic code formatting to improve code consistency and enforce best practices. Note: linting is currently disabled pending a larger incoming PR that will address current issues. [1]: https://buf.build/docs/cli/ Signed-off-by: William Findlay <william.findlay@isovalent.com>
- Loading branch information
1 parent
030e9ae
commit eea39fd
Showing
56 changed files
with
7,856 additions
and
12,627 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,53 @@ | ||
# Copyright 2017-2020 Authors of Cilium | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
# renovate: datasource=docker | ||
BUILDER_IMAGE=quay.io/cilium/cilium-builder@sha256:a2036a3f6420647e6702695dabd2ffa4d2832db45157042d0255bdc707b8e1f2 | ||
GO ?= go | ||
include ../Makefile.defs | ||
|
||
EXTRA_BUF_FLAGS ?= | ||
|
||
.PHONY: all | ||
all: proto | ||
all: | ||
|
||
# FIXME: re-enable lint on the all target once we have a chance to fix the lints | ||
.PHONY: __all_local | ||
__all_local: __format_local __check-breaking_local __proto_local #__lint_local | ||
|
||
.PHONY: __proto_local | ||
__proto_local: | ||
$(BUF) generate $(EXTRA_BUF_FLAGS) | ||
|
||
.PHONY: __lint_local | ||
__lint_local: | ||
$(BUF) lint $(EXTRA_BUF_FLAGS) | ||
|
||
.PHONY: __format_local | ||
__format_local: | ||
$(BUF) format -w $(EXTRA_BUF_FLAGS) | ||
|
||
.PHONY: proto | ||
proto: v1 | ||
.PHONY: __check-breaking_local | ||
__check-breaking_local: | ||
$(BUF) breaking /src/api --against "$(CURDIR)/../.git#branch=$(BUF_BREAKING_AGAINST_BRANCH),subdir=api/v1" $(EXTRA_BUF_FLAGS) | ||
|
||
.PHONY: proto lint format check-breaking | ||
all proto lint format check-breaking: | ||
$(CONTAINER_ENGINE) container run --rm \ | ||
--volume $(CURDIR)/..:/src \ | ||
--workdir /src/api \ | ||
--user "$(shell id -u):$(shell id -g)" \ | ||
$(BUILDER_IMAGE) \ | ||
make -C /src/api __$@_local BUF_BREAKING_AGAINST_BRANCH=$(BUF_BREAKING_AGAINST_BRANCH) | ||
|
||
.PHONY: v1 | ||
v1: | ||
docker container run --rm \ | ||
.PHONY: debug | ||
debug: | ||
@echo $(CONTAINER_ENGINE) container run --rm \ | ||
--volume $(CURDIR)/..:/src \ | ||
--workdir /src/api \ | ||
--user "$(shell id -u):$(shell id -g)" \ | ||
$(BUILDER_IMAGE) \ | ||
make -C /src/api/v1 -f Makefile.protoc | ||
./export-doc.sh ../docs/content/en/docs/reference/grpc-api.md | ||
buf $(EXTRA_BUF_FLAGS) | ||
|
||
.PHONY: vendor | ||
vendor: | ||
$(GO) mod tidy | ||
$(GO) mod vendor | ||
$(GO) mod verify | ||
$(GO) mod verify |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
version: v2 | ||
plugins: | ||
- local: protoc-gen-go | ||
out: ./v1 | ||
opt: | ||
- paths=source_relative | ||
- local: protoc-gen-go-json | ||
out: ./v1 | ||
opt: | ||
- paths=source_relative | ||
- orig_name=true | ||
- local: protoc-gen-doc | ||
out: ./v1 | ||
opt: | ||
- markdown | ||
- README.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
version: v2 | ||
|
||
modules: | ||
- path: v1 | ||
|
||
lint: | ||
use: | ||
# See full list here: https://buf.build/docs/lint/rules/ | ||
# TODO: it's going to take a lot of work to document everything before enabling this. | ||
# - COMMENTS | ||
- STANDARD | ||
enum_zero_value_suffix: UNDEF | ||
except: | ||
# Too late to do this without breaking. | ||
- ENUM_VALUE_PREFIX | ||
# Might be too late to do this without breaking. | ||
- PACKAGE_VERSION_SUFFIX | ||
disallow_comment_ignores: false | ||
|
||
breaking: | ||
use: | ||
- FILE | ||
- WIRE_JSON | ||
except: | ||
- FILE_SAME_GO_PACKAGE | ||
# Ignores packages with a last component that's one of the unstable forms | ||
# (e.g. foo.bar.v1alpha foo.bar.v1beta) | ||
ignore_unstable_packages: true |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.