-
Notifications
You must be signed in to change notification settings - Fork 77
/
Copy pathqa-test
executable file
·58 lines (52 loc) · 1.88 KB
/
qa-test
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
56
57
58
#!/bin/bash
set -ex
test_shell()
{
mkdir -p .shellcheck
find . \( -path ./.git -prune -o -path "*node_modules/*" -prune -o -path "*/10_ncf_internals/modules/*" -prune -o -path "*target/*" -prune \) -o -type f -exec grep -Eq '^#!(.*/|.*env +)(sh|bash|ksh)' {} \; -print |
while IFS="" read -r file
do
# collect all warnings
shellcheck --format=checkstyle "$file" > .shellcheck/$(basename ${file}).log || true
# fail on >=error
shellcheck --severity error "$file"
done
# special case for API docs examples
# allow absent shebang, prevent warnings
for src in relay webapp; do
find "${src}/sources/api-doc/code_samples/curl" -name "*.sh" | xargs shellcheck --shell=bash --severity=warning --exclude=SC2148
done
}
# fails on error and ignores other levels
test_shell_error()
{
# Shellcheck
find . \( -path ./.git -prune -o -path "*node_modules/*" -prune -o -path "*/10_ncf_internals/modules/*" -prune -o -path "*target/*" -prune \) -o -type f -exec grep -Eq '^#!(.*/|.*env +)(sh|bash|ksh)' {} \; -print |
while IFS="" read -r file
do
# with recent shellcheck, "-S error" replaces this hack
# kept as this runs on machines running rudder-dev
shellcheck --format gcc "$file" | grep " error: " && exit 1 || true
done
}
# fails on error and ignores other levels
test_python_error()
{
PYLINT="pylint"
if type pylint3 >/dev/null; then
PYLINT="pylint3"
fi
find . ! -wholename '*language/repos/*' ! -wholename '*rudder-pkg/lib/*' ! -name 'convertOpenLDAPSchema.py' ! -name 'systemctl3.py' ! -wholename '*jsondiff/*' -name '*.py' | xargs ${PYLINT} -E --persistent=n --disable=C,R,import-error,no-member,no-name-in-module
}
#####
if [ "$1" = "--shell" ]; then
test_shell
exit 0
elif [ "$1" = "--python" ]; then
test_python_error
exit 0
else
# quick tests to be launched during merge
test_shell_error
test_python_error
fi