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

ci: add protoxform as a check/fix_format step. #8331

Merged
merged 4 commits into from
Sep 23, 2019
Merged
Show file tree
Hide file tree
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
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 @@ -261,16 +261,22 @@ elif [[ "$CI_TARGET" == "bazel.fuzz" ]]; then
bazel_with_collection test ${BAZEL_BUILD_OPTIONS} --config=asan-fuzzer ${FUZZ_TEST_TARGETS} --test_arg="-runs=10"
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