Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bumping buf to v2 to build correctly and removing out of date or unused dependencies #420

Merged
merged 2 commits into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 30 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ ARANGODB_NS=arangodb

DOCKER=docker
PROTOC=protoc
BUF_CONTAINER=buf:local

export

Expand Down Expand Up @@ -122,7 +123,6 @@ install-lint-tools:
@go install github.com/kisielk/errcheck@latest
@go install github.com/rhysd/actionlint/cmd/actionlint@latest
@go install github.com/client9/misspell/cmd/misspell@latest
@go install github.com/bufbuild/buf/cmd/[email protected]
andream16 marked this conversation as resolved.
Show resolved Hide resolved
@npm ci

install-go-test-tools:
Expand All @@ -140,10 +140,6 @@ migration-tests: cmd/draconctl/bin

test: go-tests migration-tests

fmt-proto:
@echo "Tidying up Proto files"
@buf format -w ./api/proto

install-go-fmt-tools:
@go install github.com/bufbuild/buf/cmd/[email protected]
@go install golang.org/x/tools/cmd/goimports@latest
Expand Down Expand Up @@ -315,9 +311,35 @@ dev-deploy: deploy-cluster dev-infra dev-dracon
dev-teardown:
@kind delete clusters dracon-demo

generate-protos: install-lint-tools
@echo "Generating Protos"
@buf generate
build-buf-container:
$(DOCKER) build . -t $(BUF_CONTAINER) -f containers/Dockerfile.buf

run-buf: build-buf-container
$(eval BUF_TMP_DP_FOLDER:=buf-tmp)
@if [ ! -d "$(BUF_TMP_DP_FOLDER)" ]; then mkdir $(BUF_TMP_DP_FOLDER); fi
$(DOCKER) run \
--volume "$(shell pwd):/workspace" \
--volume $(BUF_TMP_DP_FOLDER):/tmp \
--workdir /workspace \
$(BUF_CONTAINER) \
$(ARGS)
@rm -rf $(BUF_TMP_DP_FOLDER)

fmt-proto: build-buf-container
@echo "Tidying up Proto files"
$(MAKE) run-buf ARGS="format -w --exclude-path vendor/"

lint-proto: build-buf-container
@echo "Linting Proto files"
$(MAKE) run-buf ARGS="lint --exclude-path vendor/"

generate-proto: build-buf-container
@echo "Generating Proto files"
$(MAKE) run-buf ARGS="generate"

dep-update-proto: build-buf-container
@echo "Updating buf.lock deps"
$(MAKE) run-buf ARGS="dep update"

########################################
########### RELEASE UTILITIES ##########
Expand Down
74 changes: 15 additions & 59 deletions api/proto/v1/engine.pb.go

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

2 changes: 1 addition & 1 deletion api/proto/v1/engine.proto
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ message ScanInfo {
map<string, string> scan_tags = 3;
}

/* LaunchToolReponse consists of a response built by a producer,
/* LaunchToolResponse consists of a response built by a producer,
* to be interpreted by a consumer */
message LaunchToolResponse {
// The scan information, see above for details
Expand Down
52 changes: 11 additions & 41 deletions api/proto/v1/issue.pb.go

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

11 changes: 1 addition & 10 deletions buf.lock
Original file line number Diff line number Diff line change
@@ -1,11 +1,2 @@
# Generated by buf. DO NOT EDIT.
version: v1
deps:
- remote: buf.build
owner: googleapis
repository: googleapis
commit: 75b4300737fb4efca0831636be94e517
- remote: buf.build
owner: grpc-ecosystem
repository: grpc-gateway
commit: a1ecdc58eccd49aa8bea2a7a9022dc27
version: v2
12 changes: 2 additions & 10 deletions buf.yaml
Original file line number Diff line number Diff line change
@@ -1,20 +1,12 @@
---
version: v1
version: v2
lint:
use:
- DEFAULT
andream16 marked this conversation as resolved.
Show resolved Hide resolved
- STANDARD
- COMMENTS
- UNARY_RPC
- PACKAGE_NO_IMPORT_CYCLE
except:
# we use Please to run protoc where we only need the last part of the
# package name to match the directory name.
- PACKAGE_DIRECTORY_MATCH

deps:
andream16 marked this conversation as resolved.
Show resolved Hide resolved
# buf requires us to add the third party protos here as deps.
# Run:
# $ ./pleasew run "//third_party/binary/bufbuild/buf:buf|buf" -- mod update
# when you update this to update the lock file.
- buf.build/googleapis/googleapis
- buf.build/grpc-ecosystem/grpc-gateway
14 changes: 14 additions & 0 deletions containers/Dockerfile.buf
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Setup Go alpine to install buf protoc-gen-go plugin.
# At the time of this changes, the buf image doesn't have a way to customise the plugins, so this is a more concise
# solution.
FROM golang:alpine AS golang
ENV GO111MODULE=on
RUN go install github.com/bufbuild/buf/cmd/[email protected]
RUN go install google.golang.org/protobuf/cmd/[email protected]

# Wrap everything together in a scratch container to do all things buf.
FROM scratch
COPY --from=golang /go/bin/buf /go/bin/buf
COPY --from=golang /go/bin/protoc-gen-go /go/bin/protoc-gen-go
ENV PATH="/go/bin:${PATH}"
ENTRYPOINT ["/go/bin/buf"]
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ require (
go.mongodb.org/mongo-driver v1.10.0
golang.org/x/crypto v0.18.0
golang.org/x/oauth2 v0.16.0
golang.org/x/sync v0.6.0
google.golang.org/api v0.156.0
google.golang.org/protobuf v1.34.1
google.golang.org/protobuf v1.35.1
helm.sh/helm/v3 v3.14.4
k8s.io/api v0.29.0
k8s.io/apimachinery v0.29.0
Expand Down Expand Up @@ -77,7 +78,7 @@ require (
github.com/goccy/go-json v0.9.11 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/btree v1.0.1 // indirect
github.com/google/cel-go v0.20.0 // indirect
Expand Down Expand Up @@ -142,7 +143,6 @@ require (
golang.org/x/exp v0.0.0-20230515195305-f3d0a9c9a5cc // indirect
golang.org/x/mod v0.14.0 // indirect
golang.org/x/net v0.20.0 // indirect
golang.org/x/sync v0.6.0 // indirect
golang.org/x/term v0.16.0 // indirect
golang.org/x/time v0.5.0 // indirect
golang.org/x/tools v0.16.1 // indirect
Expand Down
Loading