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

Extract env setup to a script #305

Merged
merged 9 commits into from Dec 5, 2018
11 changes: 1 addition & 10 deletions .travis.yml
Expand Up @@ -3,16 +3,7 @@ go: 1.9.x


before_install:
- bash ci/install-protobuf.sh
- go get -u github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway
- go get -u github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger
- rm -rf $GOPATH/src/github.com/golang/protobuf
- git clone -b v1.2.0 https://github.com/golang/protobuf $GOPATH/src/github.com/golang/protobuf
- go install github.com/golang/protobuf/protoc-gen-go
- protoc --version
- bash ci/genproto.sh
- go get -u github.com/kardianos/govendor
- govendor sync
- bash setup_env.sh


branches:
Expand Down
2 changes: 1 addition & 1 deletion ci/genproto.sh
@@ -1,4 +1,4 @@
#!bin/bash
#!/bin/bash -e
res=$(find . -not -path ./vendor/ -not -path ./.git/ -not -path ./.idea/ -type d -name "pb")
#echo $res
while read -r p; do
Expand Down
29 changes: 25 additions & 4 deletions ci/install-protobuf.sh 100644 → 100755
@@ -1,12 +1,33 @@
#!/bin/sh
#!/bin/bash -e
# Detect OS and architecture
if [[ $(uname -s) == "Linux" ]]; then
os="linux";
elif [[ $(uname -s) == "Darwin" ]]; then # MacOS
os="osx";
else
echo "unsupported OS, protoc not installed"
exit 1;
fi
arch=$(uname -m)
protoc_url=https://github.com/protocolbuffers/protobuf/releases/download/v3.6.1/protoc-3.6.1-${os}-${arch}.zip

# Make sure you grab the latest version
curl -OL https://github.com/protocolbuffers/protobuf/releases/download/v3.6.1/protoc-3.6.1-linux-x86_64.zip
echo "fetching ${protoc_url}"
curl -L -o "protoc.zip" ${protoc_url}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what if this fails? maybe put in && or $? && cmd

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

solved in 597e6a8


# Unzip
unzip protoc-3.6.1-linux-x86_64.zip -d protoc3
echo "extracting..."
unzip -u protoc.zip -d protoc3

# Move protoc to /usr/local/bin/
echo "moving bin to /usr/local/"
sudo mv protoc3/bin/* /usr/local/bin/

# Move protoc3/include to /usr/local/include/
sudo mv protoc3/include/* /usr/local/include/
echo "syncing include to /usr/local/include"
sudo rsync -a protoc3/include/ /usr/local/include/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove sudo


# Cleanup
echo "cleaning up..."
rm protoc.zip
rm -rf protoc3
16 changes: 16 additions & 0 deletions setup_env.sh
@@ -0,0 +1,16 @@
#!/bin/bash -e
./ci/install-protobuf.sh

go get -u github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you are accessing github.com a lot, i'd put it in a pramaeter $GITHUB

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the readability and code complexity tradeoff isn't worth the DRY-ness

go get -u github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger

rm -rf $GOPATH/src/github.com/golang/protobuf
git clone -b v1.2.0 https://github.com/golang/protobuf $GOPATH/src/github.com/golang/protobuf

go install github.com/golang/protobuf/protoc-gen-go
protoc --version

./ci/genproto.sh

go get -u github.com/kardianos/govendor
govendor sync