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

chore(build) automate proto make #129

Merged
merged 9 commits into from
Oct 10, 2022
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
32 changes: 32 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,38 @@ jobs:
go-version: "${{ matrix.golang }}"
cache: true
- run: go version

- name: install protobuf compiler
run: |
wget https://github.com/protocolbuffers/protobuf/releases/download/v21.7/protoc-21.7-linux-x86_64.zip
unzip protoc-21.7-linux-x86_64.zip
sudo cp bin/protoc /usr/bin/
sudo cp -Rf include/* /usr/include
wget https://github.com/protocolbuffers/protobuf-go/releases/download/v1.28.1/protoc-gen-go.v1.28.1.linux.amd64.tar.gz
tar -xf protoc-gen-go.v1.28.1.linux.amd64.tar.gz
sudo cp protoc-gen-go /usr/bin/

- name: check if proto file is synced with kong
run: |
rm ./server/kong_plugin_protocol/pluginsocket.proto
make ./server/kong_plugin_protocol/pluginsocket.proto
# see if we got the same proto file
git diff --exit-code --name-only -- '*.proto'
if [ $? -ne 0 ]; then
echo "proto file is out of sync with kong master"
exit 1
fi

- name: check if pb.go is modified manually
run: |
rm ./server/kong_plugin_protocol/pluginsocket.pb.go
make ./server/kong_plugin_protocol/pluginsocket.pb.go
# see if we can reproduce the same pb.go file
git diff --exit-code --name-only -- '*.pb.go'
if [ $? -ne 0 ]; then
echo "pb.go is modified manually"
exit 1
fi

- name: Dependency
run: make dep
Expand Down
29 changes: 22 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,13 +1,28 @@
proto_def = ./server/kong_plugin_protocol/pluginsocket.proto
proto_def_compiled = ./server/kong_plugin_protocol/pluginsocket.pb.go

.PHONY: lint
lint:
.PHONY: lint test dep sync_with_kong
lint: $(proto_def_compiled)
golangci-lint run --exclude composites

.PHONY: dep
dep:
dep: $(proto_def_compiled)
go get -v
go mod tidy

.PHONY: test
test:
go test -v -race ./...
test: dep
go test -v -race ./...

sync_with_kong: clean $(proto_def_compiled)

.PHONY: clean
clean:
rm -rf $(proto_def)
rm -rf $(proto_def_compiled)


$(proto_def):
wget https://raw.githubusercontent.com/Kong/kong/master/kong/include/kong/pluginsocket.proto -P $(shell dirname $@)

$(proto_def_compiled): $(proto_def)
mkdir -p server/kong_plugin_protocol
protoc -I . $^ --go_out=. --go_opt=paths=source_relative
2 changes: 1 addition & 1 deletion request/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ package request

import (
"errors"
"io/ioutil"
"io/ioutil" //nolint:all // TODO: update to remove deprecated dependency

"github.com/Kong/go-pdk/bridge"
"github.com/Kong/go-pdk/server/kong_plugin_protocol"
Expand Down
Loading