diff options
author | Jan Tattermusch <jtattermusch@users.noreply.github.com> | 2018-02-05 14:42:54 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-02-05 14:42:54 -0500 |
commit | f1df0c00fbfb4b71f4e8e5a731fc7744c55b0f16 (patch) | |
tree | 40b381283faa81e8cdc6c75c847310b77a9eb613 | |
parent | 3ac5b1b5d5155b99a91deffc35a2207e2df888c9 (diff) | |
parent | afc643778d6faeb52eca2c084f4c3e2f6efe6a33 (diff) |
Merge pull request #14312 from jtattermusch/format_should_not_root
Clang format and tidy shouldnt change file ownership when run locally.
-rw-r--r-- | templates/tools/dockerfile/grpc_clang_format/Dockerfile.template | 5 | ||||
-rw-r--r-- | templates/tools/dockerfile/grpc_clang_tidy/Dockerfile.template | 5 | ||||
-rwxr-xr-x | tools/distrib/clang_format_code.sh | 4 | ||||
-rwxr-xr-x | tools/distrib/clang_tidy_code.sh | 4 | ||||
-rw-r--r-- | tools/dockerfile/grpc_clang_format/Dockerfile | 5 | ||||
-rw-r--r-- | tools/dockerfile/grpc_clang_tidy/Dockerfile | 5 |
6 files changed, 26 insertions, 2 deletions
diff --git a/templates/tools/dockerfile/grpc_clang_format/Dockerfile.template b/templates/tools/dockerfile/grpc_clang_format/Dockerfile.template index 4f24a025c6..c5ec66ae29 100644 --- a/templates/tools/dockerfile/grpc_clang_format/Dockerfile.template +++ b/templates/tools/dockerfile/grpc_clang_format/Dockerfile.template @@ -18,6 +18,11 @@ <%include file="../clang5.include"/> ADD clang_format_all_the_things.sh / + + # When running locally, we'll be impersonating the current user, so we need + # to make the script runnable by everyone. + RUN chmod a+rx /clang_format_all_the_things.sh + CMD ["echo 'Run with tools/distrib/clang_format_code.sh'"] diff --git a/templates/tools/dockerfile/grpc_clang_tidy/Dockerfile.template b/templates/tools/dockerfile/grpc_clang_tidy/Dockerfile.template index f5bceaa5f3..bbdba70075 100644 --- a/templates/tools/dockerfile/grpc_clang_tidy/Dockerfile.template +++ b/templates/tools/dockerfile/grpc_clang_tidy/Dockerfile.template @@ -19,6 +19,11 @@ <%include file="../clang5.include"/> <%include file="../python_deps.include"/> ADD clang_tidy_all_the_things.sh / + + # When running locally, we'll be impersonating the current user, so we need + # to make the script runnable by everyone. + RUN chmod a+rx /clang_tidy_all_the_things.sh + CMD ["echo 'Run with tools/distrib/clang_tidy_code.sh'"] diff --git a/tools/distrib/clang_format_code.sh b/tools/distrib/clang_format_code.sh index 9233a230c9..cd7553e917 100755 --- a/tools/distrib/clang_format_code.sh +++ b/tools/distrib/clang_format_code.sh @@ -25,7 +25,9 @@ then docker build -t grpc_clang_format tools/dockerfile/grpc_clang_format # run clang-format against the checked out codebase - docker run -e TEST=$TEST -e CHANGED_FILES="$CHANGED_FILES" -e CLANG_FORMAT_ROOT="/local-code" --rm=true -v "${REPO_ROOT}":/local-code -t grpc_clang_format /clang_format_all_the_things.sh + # when modifying the checked-out files, the current user will be impersonated + # so that the updated files don't end up being owned by "root". + docker run -e TEST="$TEST" -e CHANGED_FILES="$CHANGED_FILES" -e CLANG_FORMAT_ROOT="/local-code" --rm=true -v "${REPO_ROOT}":/local-code --user "$(id -u):$(id -g)" -t grpc_clang_format /clang_format_all_the_things.sh else CLANG_FORMAT_ROOT="${REPO_ROOT}" tools/dockerfile/grpc_clang_format/clang_format_all_the_things.sh fi diff --git a/tools/distrib/clang_tidy_code.sh b/tools/distrib/clang_tidy_code.sh index 5da86aa277..9262b6bd3e 100755 --- a/tools/distrib/clang_tidy_code.sh +++ b/tools/distrib/clang_tidy_code.sh @@ -27,7 +27,9 @@ then docker build -t grpc_clang_tidy tools/dockerfile/grpc_clang_tidy # run clang-tidy against the checked out codebase - docker run -e TEST=$TEST -e CHANGED_FILES="$CHANGED_FILES" -e CLANG_TIDY_ROOT="/local-code" --rm=true -v "${REPO_ROOT}":/local-code -t grpc_clang_tidy /clang_tidy_all_the_things.sh "$@" + # when modifying the checked-out files, the current user will be impersonated + # so that the updated files don't end up being owned by "root". + docker run -e TEST="$TEST" -e CHANGED_FILES="$CHANGED_FILES" -e CLANG_TIDY_ROOT="/local-code" --rm=true -v "${REPO_ROOT}":/local-code --user "$(id -u):$(id -g)" -t grpc_clang_tidy /clang_tidy_all_the_things.sh "$@" else CLANG_TIDY_ROOT="${REPO_ROOT}" tools/dockerfile/grpc_clang_tidy/clang_tidy_all_the_things.sh "$@" fi diff --git a/tools/dockerfile/grpc_clang_format/Dockerfile b/tools/dockerfile/grpc_clang_format/Dockerfile index 8801315bc9..ecdc52ee31 100644 --- a/tools/dockerfile/grpc_clang_format/Dockerfile +++ b/tools/dockerfile/grpc_clang_format/Dockerfile @@ -23,4 +23,9 @@ RUN ln -s /clang+llvm-5.0.0-linux-x86_64-ubuntu14.04/bin/clang-tidy /usr/local/b ENV CLANG_TIDY=clang-tidy ADD clang_format_all_the_things.sh / + +# When running locally, we'll be impersonating the current user, so we need +# to make the script runnable by everyone. +RUN chmod a+rx /clang_format_all_the_things.sh + CMD ["echo 'Run with tools/distrib/clang_format_code.sh'"] diff --git a/tools/dockerfile/grpc_clang_tidy/Dockerfile b/tools/dockerfile/grpc_clang_tidy/Dockerfile index 9d9d70185b..eeba455341 100644 --- a/tools/dockerfile/grpc_clang_tidy/Dockerfile +++ b/tools/dockerfile/grpc_clang_tidy/Dockerfile @@ -38,4 +38,9 @@ RUN pip install virtualenv RUN pip install futures==2.2.0 enum34==1.0.4 protobuf==3.5.0.post1 six==1.10.0 twisted==17.5.0 ADD clang_tidy_all_the_things.sh / + +# When running locally, we'll be impersonating the current user, so we need +# to make the script runnable by everyone. +RUN chmod a+rx /clang_tidy_all_the_things.sh + CMD ["echo 'Run with tools/distrib/clang_tidy_code.sh'"] |