From 1b955f4cd586936edc82a83bca33b001387f6546 Mon Sep 17 00:00:00 2001 From: Jonny Reeves Date: Tue, 16 Oct 2018 12:26:42 +0100 Subject: [PATCH 1/3] 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. --- package-lock.json | 2 +- travis-ci-build.sh | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/package-lock.json b/package-lock.json index a1dfc8d9..a6eb776b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "ts-protoc-gen", - "version": "0.7.7", + "version": "0.7.8-pre", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/travis-ci-build.sh b/travis-ci-build.sh index d8c3a26b..c81fba63 100755 --- a/travis-ci-build.sh +++ b/travis-ci-build.sh @@ -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 \ No newline at end of file From b7727176dc8049d276304e4548d8e1f847092de7 Mon Sep 17 00:00:00 2001 From: Jonny Reeves Date: Tue, 16 Oct 2018 12:36:54 +0100 Subject: [PATCH 2/3] Patch up generation script so it can be invoked from another script. --- generate.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/generate.sh b/generate.sh index 0e22382a..48d74097 100755 --- a/generate.sh +++ b/generate.sh @@ -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" +tar -C protoc -xzf "protoc-${PROTOC_VERSION}.zip" +rm "protoc-${PROTOC_VERSION}.zip" + PROTOC=./protoc/bin/protoc echo "Generating proto definitions..." From a4c8fb4574e95663495a028b10d97bc817f4f8c6 Mon Sep 17 00:00:00 2001 From: Jonny Reeves Date: Tue, 16 Oct 2018 14:22:09 +0100 Subject: [PATCH 3/3] Use unzip instead of tar. --- generate.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generate.sh b/generate.sh index 48d74097..b10b1b22 100755 --- a/generate.sh +++ b/generate.sh @@ -33,7 +33,7 @@ else fi wget ${PROTOC_URL} --output-document="protoc-${PROTOC_VERSION}.zip" -tar -C protoc -xzf "protoc-${PROTOC_VERSION}.zip" +unzip "protoc-${PROTOC_VERSION}.zip" -d protoc rm "protoc-${PROTOC_VERSION}.zip" PROTOC=./protoc/bin/protoc