diff --git a/.circleci/config.yml b/.circleci/config.yml index 0c39dffb814a..4704c0295fc5 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -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 diff --git a/ci/do_ci.sh b/ci/do_ci.sh index 82126ab2f22b..95722aa6b23b 100755 --- a/ci/do_ci.sh +++ b/ci/do_ci.sh @@ -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..." diff --git a/tools/proto_format.sh b/tools/proto_format.sh index 71cfea2d0eb7..0271584e9e54 100755 --- a/tools/proto_format.sh +++ b/tools/proto_format.sh @@ -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 @@ -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