-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathqa-test
executable file
·77 lines (70 loc) · 2.1 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/bin/bash
set -xe
test_shell()
{
mkdir -p .shellcheck
find . \( -path ./.git -prune -o -path ./cis/src/pdfs -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
}
# fails on error and ignores other levels
test_shell_error()
{
# Shellcheck
find . \( -path ./.git -prune -o -path ./cis/src/pdfs -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 . ! -name ipaddress.py -name '*.py' | xargs ${PYLINT} -E --persistent=n --disable=C,R,import-error,no-member,no-name-in-module
}
test_typos()
{
# json file below has a name which looks like a typo in its first part, skipping it
typos --exclude 'RestDataSourceTest.scala' --exclude 'ipaddress.py' --exclude '*.css' --exclude '*-6a9f-4865-a837-95a6a0c49f04.json'
}
test_scripts()
{
# plugin packaging scripts (postinst, etc...) must have the set -e enabled
RESULT=0
find . -name "packaging" -type d -not -path "./src/*"|
while IFS="" read -r directory
do
for file in $directory/*; do
if sed -n '1p' $file | grep -q "#\!/bin/bash"; then
if ! grep -q "set -e" "$file"; then
echo "$file does not seem to contain mandatory 'set -e' line"
RESULT=1
fi
fi
done
done
exit $RESULT
}
if [ "$1" = "--python" ]; then
test_python_error
elif [ "$1" = "--typos" ]; then
test_typos
elif [ "$1" = "--shell" ]; then
test_shell
elif [ "$1" = "--scripts" ]; then
test_scripts
else
test_shell_error
test_python_error
fi