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

NOISSUE - Add Protobuf generated files check #601

Merged
merged 1 commit into from
Feb 17, 2019
Merged
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
36 changes: 29 additions & 7 deletions scripts/ci.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# This script contains commands to be executed by the CI tool.

setup_protoc() {
echo "Setup protoc..."
echo "Setting up protoc..."
PROTOC_ZIP=protoc-3.6.1-linux-x86_64.zip
curl -0L https://github.com/google/protobuf/releases/download/v3.6.1/$PROTOC_ZIP -o $PROTOC_ZIP
unzip -o $PROTOC_ZIP -d protoc3
Expand All @@ -15,10 +15,23 @@ setup_protoc() {
}

setup_mf() {
echo "Setup Mainflux..."
go get -d github.com/mainflux/mainflux
cd $GOPATH/src/github.com/mainflux/mainflux
echo "Setting up Mainflux..."
MF_PATH=$GOPATH/src/github.com/mainflux/mainflux
if test $PWD != $MF_PATH; then
mkdir -p $MF_PATH
mv ./* $MF_PATH
fi
cd $MF_PATH
for p in $(ls *.pb.go); do
mv $p $p.tmp
done
make proto
for p in $(ls *.pb.go); do
if ! cmp -s $p $p.tmp; then
echo "Proto file and generated Go file $p are out of cync!"
exit 1
fi
done
}

setup() {
Expand All @@ -29,16 +42,25 @@ setup() {

run_test() {
echo "Running tests..."
set -e; echo "" > coverage.txt; for d in $(go list ./... | grep -v 'vendor\|cmd'); do GOCACHE=off go test -v -race -tags test -coverprofile=profile.out -covermode=atomic $d; if [ -f profile.out ]; then cat profile.out >> coverage.txt; rm profile.out; fi done
echo "" > coverage.txt;
for d in $(go list ./... | grep -v 'vendor\|cmd'); do
GOCACHE=off
go test -v -race -tags test -coverprofile=profile.out -covermode=atomic $d
if [ -f profile.out ]; then
cat profile.out >> coverage.txt
rm profile.out
fi
done
}

push() {
echo "Pushing Docker images..."
if test -n "$BRANCH_NAME" && test "$BRANCH_NAME" = "master"; then
make latest
echo "Pushing Docker images..."
make latest
fi
}

set -e
setup
run_test
push