Skip to content

Commit

Permalink
CI should check that generated code has been committed (improbable-en…
Browse files Browse the repository at this point in the history
…g#127)

* CI should check that generated code has been committed

Add a travis build step which re-generates the generated code and then checks for changes to the workspce. If any are detected it will fail the build and prompt the user to run the `./generate.sh` script.

* Patch up generation script so it can be invoked from another script.

* Use unzip instead of tar.
  • Loading branch information
Jonny Reeves authored and chrisgervang committed Nov 14, 2018
1 parent 2278ecd commit f60b1b5
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
8 changes: 6 additions & 2 deletions generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,18 @@ PROTOC_VERSION="3.5.1"
echo "Downloading protoc v${PROTOC_VERSION} for ${platform}..."
mkdir -p protoc
if [[ $platform == 'Linux' ]]; then
curl -L https://github.com/google/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-linux-x86_64.zip | tar xz -C protoc
PROTOC_URL="https://github.com/google/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-linux-x86_64.zip"
elif [[ $platform == 'Mac' ]]; then
curl -L https://github.com/google/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-osx-x86_64.zip | tar xz -C protoc
PROTOC_URL="https://github.com/google/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-osx-x86_64.zip"
else
echo "Cannot download protoc. ${platform} is not currently supported by ts-protoc-gen"
exit 1
fi

wget ${PROTOC_URL} --output-document="protoc-${PROTOC_VERSION}.zip"
unzip "protoc-${PROTOC_VERSION}.zip" -d protoc
rm "protoc-${PROTOC_VERSION}.zip"

PROTOC=./protoc/bin/protoc

echo "Generating proto definitions..."
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions travis-ci-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,12 @@ set -ex

npm run lint
npm test

./generate.sh
MODIFIED_FILES=$(git diff --name-only)
if [[ -n $MODIFIED_FILES ]]; then
echo "ERROR: Changes detected in generated code, please run './generate.sh' and check-in the changes."
exit 1
fi

bazel build //...:all

0 comments on commit f60b1b5

Please sign in to comment.