forked from envoyproxy/envoy
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathformat_pre.sh
executable file
·55 lines (43 loc) · 1.31 KB
/
format_pre.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/bin/bash -E
# Pre-checks for validation and linting
#
# These checks do not provide a fix and are quicker to run,
# allowing CI to fail quickly on basic linting or validation errors
FAILED=()
CURRENT=""
DIFF_OUTPUT="${DIFF_OUTPUT:-/build/fix_format_pre.diff}"
read -ra BAZEL_BUILD_OPTIONS <<< "${BAZEL_BUILD_OPTIONS:-}"
trap_errors () {
local frame=0 command line sub file
if [[ -n "$CURRENT" ]]; then
command=" (${CURRENT})"
fi
set +v
while read -r line sub file < <(caller "$frame"); do
if [[ "$frame" -ne "0" ]]; then
FAILED+=(" > ${sub}@ ${file} :${line}")
else
FAILED+=("${sub}@ ${file} :${line}${command}")
fi
((frame++))
done
set -v
}
trap trap_errors ERR
trap exit 1 INT
# TODO: move these to bazel
CURRENT=glint
"${ENVOY_SRCDIR}"/tools/code_format/glint.sh
CURRENT=shellcheck
"${ENVOY_SRCDIR}"/tools/code_format/check_shellcheck_format.sh check
CURRENT=configs
bazel run "${BAZEL_BUILD_OPTIONS[@]}" //configs:example_configs_validation
CURRENT=python
bazel run "${BAZEL_BUILD_OPTIONS[@]}" //tools/code_format:python_check -- --diff-file="$DIFF_OUTPUT" --fix "$(pwd)"
if [[ "${#FAILED[@]}" -ne "0" ]]; then
echo "TESTS FAILED:" >&2
for failed in "${FAILED[@]}"; do
echo " $failed" >&2
done
exit 1
fi