Skip to content

Commit

Permalink
Keep working on twirptest cases, cleanup gen.go files and make sure t…
Browse files Browse the repository at this point in the history
…hey generate code on the proper destination. Cleanup make file and keep removing test python files that are unused.
  • Loading branch information
marioizquierdo committed Apr 16, 2021
1 parent 150e12d commit fc4abd9
Show file tree
Hide file tree
Showing 73 changed files with 733 additions and 2,025 deletions.
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ Generally you want to make changes and run `make`, which will install all
dependencies we know about, build the core, and run all of the tests that we
have against Go and Python code. A few notes:

* Make sure to clone the repo on `$GOPATH/src/github.com/twitchtv/twirp`
* Run Go unit tests with `make test_core`, or just the tests with `go test -race ./...` (make sure to re-generate code with `make generate` before running unit tests).
* Clone the repo on `$GOPATH/src/github.com/twitchtv/twirp` (go modules not supported yet).
* Run Go unit tests with `make test`.
* Most tests of the Go server are in `internal/twirptest/service_test.go`.
* Integration tests running the full stack in both Go and Python auto-generated clients are in the [clientcompat](./clientcompat) directory.

Expand Down
48 changes: 19 additions & 29 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
RETOOL=$(CURDIR)/_tools/bin/retool
PATH := ${PWD}/bin:${PWD}/ENV/bin:${PATH}
DOCKER_RELEASE_IMAGE := golang:1.12.0-stretch
.DEFAULT_GOAL := all
PATH := ${PWD}/_tools/bin:${PWD}/bin:${PWD}/ENV/bin:${PATH}
export GO111MODULE=off

all: setup test_all

.PHONY: test test_all test_core test_clients test_go_client test_python_client generate release_gen
.PHONY: setup generate test_all test test_clients test_go_client test_python_client

generate:
GO111MODULE=off GOBIN="$$PWD/bin" go install -v ./protoc-gen-twirp
GO111MODULE=off GOBIN="$$PWD/bin" go install -v ./protoc-gen-twirp_python
GO111MODULE=off PATH="$$PWD/bin:$$PWD/_tools/bin:$$PATH" go generate ./...
setup:
./check_protoc_version.sh
GOPATH=$(CURDIR)/_tools GOBIN=$(CURDIR)/_tools/bin go get github.com/twitchtv/retool
./_tools/bin/retool build

gen:
GO111MODULE=off PATH="$$PWD/bin:$$PWD/_tools/bin:$$PATH" go generate ./...
generate:
# Recompile and install generator
GOBIN="$$PWD/bin" go install -v ./protoc-gen-twirp
GOBIN="$$PWD/bin" go install -v ./protoc-gen-twirp_python
# Generate code from go:generate comments
go generate ./...

test_all: setup test_core test_clients
test_all: setup test test_clients

test_core: generate
GO111MODULE=off PATH="$$PWD/bin:$$PWD/_tools/bin:$$PATH" errcheck -blank ./internal/twirptest
GO111MODULE=off go test -race $(shell GO111MODULE=off go list ./... | grep -v /vendor/ | grep -v /_tools/)
test: generate
./_tools/bin/errcheck ./internal/twirptest
go test -race $(shell GO111MODULE=off go list ./... | grep -v /vendor/ | grep -v /_tools/)

test_clients: test_go_client test_python_client

Expand All @@ -29,20 +31,8 @@ test_go_client: generate build/clientcompat build/gocompat
test_python_client: generate build/clientcompat build/pycompat
./build/clientcompat -client ./build/pycompat

setup:
./install_proto.bash
GO111MODULE=off GOPATH=$(CURDIR)/_tools GOBIN=$(CURDIR)/_tools/bin go get github.com/twitchtv/retool
$(RETOOL) build

release_gen:
git clean -xdf
docker run \
--volume "$(CURDIR):/go/src/github.com/twitchtv/twirp" \
--workdir "/go/src/github.com/twitchtv/twirp" \
$(DOCKER_RELEASE_IMAGE) \
internal/release_gen.sh

# Actual files for testing clients:

# For clientcompat and testing Python
./build:
mkdir build

Expand Down
28 changes: 28 additions & 0 deletions check_protoc_version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env bash

# Copyright 2018 Twitch Interactive, Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"). You may not
# use this file except in compliance with the License. A copy of the License is
# located at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# or in the "license" file accompanying this file. This file is distributed on
# an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
# express or implied. See the License for the specific language governing
# permissions and limitations under the License.

which protoc
PROTOC_EXISTS=$?
if [ $PROTOC_EXISTS -eq 0 ]; then
PROTOC_VERSION=`protoc --version`
if [[ $PROTOC_VERSION == "libprotoc 3."* ]]; then
echo "protoc version: $PROTOC_VERSION"
exit 0
fi
echo "required protoc v3, but found: $PROTOC_VERSION"
exit 1
fi
echo "Please install protoc v3. See https://grpc.io/docs/protoc-installation/, for example in MacOS: brew install protobuf"
exit 1
51 changes: 0 additions & 51 deletions install_proto.bash

This file was deleted.

13 changes: 0 additions & 13 deletions internal/gogo_protoc_gen.sh

This file was deleted.

15 changes: 0 additions & 15 deletions internal/protoc_gen.sh

This file was deleted.

12 changes: 0 additions & 12 deletions internal/protoc_gen_source_relative.sh

This file was deleted.

50 changes: 0 additions & 50 deletions internal/release_gen.sh

This file was deleted.

47 changes: 0 additions & 47 deletions internal/twirptest/empty_service/empty_service_pb2.py

This file was deleted.

67 changes: 0 additions & 67 deletions internal/twirptest/empty_service/empty_service_pb2_twirp.py

This file was deleted.

2 changes: 1 addition & 1 deletion internal/twirptest/empty_service/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@

package empty_service

//go:generate ../../protoc_gen.sh empty_service.proto
// TODO go:generate ../../protoc_gen.sh empty_service.proto
4 changes: 3 additions & 1 deletion internal/twirptest/gogo_compat/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,6 @@

package gogo_compat

//go:generate ../../gogo_protoc_gen.sh service.proto
// github.com/gogo/protobuf/protoc-gen-gofast is an alternative generator

//go:generate protoc --gofast_out=paths=source_relative:. --twirp_out=paths=source_relative:. service.proto
Loading

0 comments on commit fc4abd9

Please sign in to comment.