-
Notifications
You must be signed in to change notification settings - Fork 0
/
lint.sh
executable file
·73 lines (59 loc) · 1.4 KB
/
lint.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/bin/bash
# shellcheck disable=SC2015,SC1091
set -e
usage(){
echo "
usage: $0
"
}
py_setup_venv(){
python3 -m venv venv
source venv/bin/activate
pip install -q -U pip
py_check_venv || usage
}
py_check_venv(){
# activate python venv
[ -d venv ] && . venv/bin/activate || py_setup_venv
[ -e requirements.txt ] && pip install -q -r requirements.txt
}
py_bin_checks(){
which python || exit 0
which pip || exit 0
}
lint_spelling(){
which aspell || return
which pyspelling || return
[ -e .pyspelling.yml ] || return
[ -e .wordlist-md ] || return
pyspelling -c .pyspelling.yml
}
lint_scripts(){
which shellcheck || return
find . -not \( -path '*/venv/*' -o -path '*/scratch/*' -o -path '*/container/src/*' \) -name '*.sh' -print0 | xargs -0 shellcheck
}
lint_dockerfiles(){
which hadolint || return
find . -not -path "./scratch/*" \( -name Dockerfile -o -name Containerfile \) -exec hadolint {} \;
}
lint_yaml(){
which yamllint || return
yamllint . || return
echo "YAML check passed :)"
}
lint_kustomize(){
[ -e scripts/validate_kustomize.sh ] || return
scripts/validate_kustomize.sh
}
lint_helm(){
[ -e scripts/validate_helm.sh ] || return
scripts/validate_helm.sh
}
py_check_venv
py_bin_checks
lint_spelling || exit 1
lint_scripts || exit 1
lint_dockerfiles || exit 1
lint_yaml || exit 1
lint_kustomize || exit 1
lint_helm || exit 1