Skip to content

Commit

Permalink
chore(build) automate proto make and detect out of sync with Kong (#129)
Browse files Browse the repository at this point in the history
  • Loading branch information
StarlightIbuki authored Oct 10, 2022

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent afb8672 commit 5775452
Showing 5 changed files with 1,204 additions and 818 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -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
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
@@ -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"
Loading

0 comments on commit 5775452

Please sign in to comment.