Skip to content

Commit 838762f

Browse files
authored
ci: move slow checkers last (#6668)
This PR reorders the checkers so that the slow ones are run last to give the user more useful feedback quicker. It also makes the `shellcheck` step run in parallel, which cuts its time in half. Moved a couple other checks to more logical places in the order.
1 parent 687f667 commit 838762f

File tree

1 file changed

+30
-31
lines changed

1 file changed

+30
-31
lines changed

ci/cloudbuild/builds/checkers.sh

Lines changed: 30 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -99,14 +99,6 @@ time {
9999
xargs -0 awk -f "ci/check-include-guards.gawk"
100100
}
101101

102-
# Apply cmake_format to all the CMake list files.
103-
# https://github.com/cheshirekow/cmake_format
104-
printf "%-30s" "Running cmake-format:" >&2
105-
time {
106-
git ls-files -z | grep -zE '((^|/)CMakeLists\.txt|\.cmake)$' |
107-
xargs -P "$(nproc)" -n 1 -0 cmake-format -i
108-
}
109-
110102
# TODO(#4501) - this fixup can be removed if #include <absl/...> works
111103
# Apply transformations to fix errors on MSVC+x86. See the bug for a detailed
112104
# explanation as to why this is needed:
@@ -123,13 +115,28 @@ time {
123115
xargs -P "$(nproc)" -n 50 -0 bash -c "sed_edit ${expressions[*]} \"\$0\" \"\$@\""
124116
}
125117

126-
# Apply clang-format(1) to fix whitespace and other formatting rules.
127-
# The version of clang-format is important, different versions have slightly
128-
# different formatting output (sigh).
129-
printf "%-30s" "Running clang-format:" >&2
118+
# Apply several transformations that cannot be enforced by clang-format:
119+
# - Replace any #include for grpc++/* with grpcpp/*. The paths with grpc++
120+
# are obsoleted by the gRPC team, so we should not use them in our code.
121+
# - Replace grpc::<BLAH> with grpc::StatusCode::<BLAH>, the aliases in the
122+
# `grpc::` namespace do not exist inside google.
123+
printf "%-30s" "Running include fixes:" >&2
130124
time {
125+
expressions=("-e" "'s/grpc::\([A-Z][A-Z_]\+\)/grpc::StatusCode::\1/g'")
126+
expressions+=("-e" "'s;#include <grpc++/grpc++.h>;#include <grpcpp/grpcpp.h>;'")
127+
expressions+=("-e" "'s;#include <grpc++/;#include <grpcpp/;'")
131128
git ls-files -z | grep -zE '\.(cc|h)$' |
132-
xargs -P "$(nproc)" -n 50 -0 clang-format -i
129+
xargs -P "$(nproc)" -n 50 -0 bash -c "sed_edit ${expressions[*]} \"\$0\" \"\$@\""
130+
}
131+
132+
# Apply transformations to fix whitespace formatting in files not handled by
133+
# clang-format(1) above. For now we simply remove trailing blanks. Note that
134+
# we do not expand TABs (they currently only appear in Makefiles and Makefile
135+
# snippets).
136+
printf "%-30s" "Running whitespace fixes:" >&2
137+
time {
138+
git ls-files -z | grep -zv '\.gz$' |
139+
xargs -P "$(nproc)" -n 50 -0 bash -c "sed_edit -e 's/[[:blank:]]\+$//' \"\$0\" \"\$@\""
133140
}
134141

135142
# Apply buildifier to fix the BUILD and .bzl formatting rules.
@@ -158,36 +165,28 @@ time {
158165
printf "%-30s" "Running shellcheck:" >&2
159166
time {
160167
git ls-files -z | grep -z '\.sh$' |
161-
xargs -0 shellcheck \
168+
xargs -P "$(nproc)" -n 1 -0 shellcheck \
162169
--exclude=SC1090 \
163170
--exclude=SC1091 \
164171
--exclude=SC2034 \
165172
--exclude=SC2153 \
166173
--exclude=SC2181
167174
}
168175

169-
# Apply several transformations that cannot be enforced by clang-format:
170-
# - Replace any #include for grpc++/* with grpcpp/*. The paths with grpc++
171-
# are obsoleted by the gRPC team, so we should not use them in our code.
172-
# - Replace grpc::<BLAH> with grpc::StatusCode::<BLAH>, the aliases in the
173-
# `grpc::` namespace do not exist inside google.
174-
printf "%-30s" "Running include fixes:" >&2
176+
# The version of clang-format is important, different versions have slightly
177+
# different formatting output (sigh).
178+
printf "%-30s" "Running clang-format:" >&2
175179
time {
176-
expressions=("-e" "'s/grpc::\([A-Z][A-Z_]\+\)/grpc::StatusCode::\1/g'")
177-
expressions+=("-e" "'s;#include <grpc++/grpc++.h>;#include <grpcpp/grpcpp.h>;'")
178-
expressions+=("-e" "'s;#include <grpc++/;#include <grpcpp/;'")
179180
git ls-files -z | grep -zE '\.(cc|h)$' |
180-
xargs -P "$(nproc)" -n 50 -0 bash -c "sed_edit ${expressions[*]} \"\$0\" \"\$@\""
181+
xargs -P "$(nproc)" -n 1 -0 clang-format -i
181182
}
182183

183-
# Apply transformations to fix whitespace formatting in files not handled by
184-
# clang-format(1) above. For now we simply remove trailing blanks. Note that
185-
# we do not expand TABs (they currently only appear in Makefiles and Makefile
186-
# snippets).
187-
printf "%-30s" "Running whitespace fixes:" >&2
184+
# Apply cmake_format to all the CMake list files.
185+
# https://github.com/cheshirekow/cmake_format
186+
printf "%-30s" "Running cmake-format:" >&2
188187
time {
189-
git ls-files -z | grep -zv '\.gz$' |
190-
xargs -P "$(nproc)" -n 50 -0 bash -c "sed_edit -e 's/[[:blank:]]\+$//' \"\$0\" \"\$@\""
188+
git ls-files -z | grep -zE '((^|/)CMakeLists\.txt|\.cmake)$' |
189+
xargs -P "$(nproc)" -n 1 -0 cmake-format -i
191190
}
192191

193192
# Report the differences, which should break the build.

0 commit comments

Comments
 (0)