Skip to content

Commit

Permalink
ci: add protoxform as a check/fix_format step. (envoyproxy#8331)
Browse files Browse the repository at this point in the history
* ci: add protoxform as a check/fix_format step.

Part of envoyproxy#8082.

Signed-off-by: Harvey Tuch <htuch@google.com>
  • Loading branch information
htuch committed Sep 23, 2019
1 parent 2a5d0c4 commit 002f445
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
1 change: 0 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ jobs:

format:
executor: ubuntu-build
resource_class: small
steps:
- run: rm -rf /home/circleci/project/.git # CircleCI git caching is likely broken
- checkout
Expand Down
6 changes: 6 additions & 0 deletions ci/do_ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -277,16 +277,22 @@ elif [[ "$CI_TARGET" == "bazel.fuzzit_fuzzing" ]]; then
./ci/run_fuzzit.sh fuzzing
exit 0
elif [[ "$CI_TARGET" == "fix_format" ]]; then
# proto_format.sh needs to build protobuf.
setup_clang_toolchain
echo "fix_format..."
./tools/check_format.py fix
./tools/format_python_tools.sh fix
./tools/proto_format.sh fix
exit 0
elif [[ "$CI_TARGET" == "check_format" ]]; then
# proto_format.sh needs to build protobuf.
setup_clang_toolchain
echo "check_format_test..."
./tools/check_format_test_helper.py --log=WARN
echo "check_format..."
./tools/check_format.py check
./tools/format_python_tools.sh check
./tools/proto_format.sh check
exit 0
elif [[ "$CI_TARGET" == "check_repositories" ]]; then
echo "check_repositories..."
Expand Down
16 changes: 8 additions & 8 deletions tools/proto_format.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,6 @@

set -e

if [[ -n "$(git status --untracked-files=no --porcelain)" ]]
then
echo "git status is dirty, $0 requires a clean git tree"
exit 1
fi

# TODO(htuch): This script started life by cloning docs/build.sh. It depends on
# the @envoy_api//docs:protos target in a few places as a result. This is not
# the precise set of protos we want to format, but as a starting place it seems
Expand All @@ -31,7 +25,13 @@ do
declare PROTO_FILE_CANONICAL="${PROTO_FILE_WITHOUT_PREFIX/://}"
declare DEST="api/${PROTO_FILE_CANONICAL}"

[[ -f "${DEST}" ]]
cp bazel-bin/external/envoy_api/"${PROTO_TARGET_CANONICAL}/${PROTO_FILE_CANONICAL}.proto" "${DEST}"
if [[ "$1" == "fix" ]]
then
[[ -f "${DEST}" ]]
cp bazel-bin/external/envoy_api/"${PROTO_TARGET_CANONICAL}/${PROTO_FILE_CANONICAL}.proto" "${DEST}"
else
diff bazel-bin/external/envoy_api/"${PROTO_TARGET_CANONICAL}/${PROTO_FILE_CANONICAL}.proto" "${DEST}" || \
(echo "$0 mismatch, either run ./ci/do_ci.sh fix_format or $0 fix to reformat."; exit 1)
fi
done
done

0 comments on commit 002f445

Please sign in to comment.