Skip to content

Commit

Permalink
Run fixup and checkup on each build.
Browse files Browse the repository at this point in the history
  • Loading branch information
jonny-improbable committed Apr 1, 2018
1 parent ceaca62 commit d32a1a4
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 9 deletions.
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ before_install:
- true && `base64 --decode <<< ZXhwb3J0IEJST1dTRVJfU1RBQ0tfQUNDRVNTX0tFWT1SRG1Cc2pwQUJ4RlljcEVkeVp5bwo=`
install:
- go get -u github.com/golang/dep/cmd/dep
- go get github.com/golang/protobuf/protoc-gen-go
- go get -u golang.org/x/tools/cmd/goimports
- go get -u github.com/robertkrimen/godocdown/godocdown
- go get -u github.com/golang/protobuf/protoc-gen-go
- dep ensure
- export PATH=/home/travis/gopath/src/github.com/improbable-eng/grpc-web/protobuf/bin:$PATH
- nvm install
Expand Down
5 changes: 2 additions & 3 deletions go/checkup.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
#!/bin/bash
# Script that checks up code (govet).

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"

function print_real_go_files {
grep --files-without-match 'DO NOT EDIT!' $(find . -iname '*.go')
}

function govet_all {
echo "Running govet"
ret=0
for i in $(print_real_go_files); do
output=$(go tool vet -all=true -tests=false ${i})
Expand All @@ -18,4 +17,4 @@ function govet_all {
}

govet_all
echo "returning $?"
echo "returning $?"
23 changes: 18 additions & 5 deletions go/fixup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,37 @@ function print_real_go_files {
}

function generate_markdown {
echo "Generating markdown"
echo "Generating markdown using godocdown in..."
oldpwd=$(pwd)
for i in $(find . -iname 'doc.go'); do
dir=${i%/*}
echo "$dir"
echo "- $dir"
cd ${dir}
${GOPATH}/bin/godocdown -heading=Title -o DOC.md
ln -s DOC.md README.md 2> /dev/null # can fail
cd ${oldpwd}
done;

git diff --name-only --exit-code | grep -q DOC.md
if [[ $? -ne 1 ]]; then
echo "ERROR: Documentation changes detected, please commit them."
exit 1
fi
}

function check_no_documentation_changes {
echo "Checking generated documentation is up to date"

}

function goimports_all {
echo "Running goimports"
goimports -l -w $(print_real_go_files)
return $?
${GOPATH}/bin/goimports -l -w $(print_real_go_files)
if [[ $? -ne 0 ]]; then
echo "ERROR: goimports changes detected, please commit them."
exit 1
fi
}

generate_markdown
goimports_all
echo "returning $?"
12 changes: 12 additions & 0 deletions test-all.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

set -e

echo "Linting go sources"
pushd ./go
./checkup.sh
./fixup.sh
popd

echo "Running tests"
npm run test

0 comments on commit d32a1a4

Please sign in to comment.