-
Notifications
You must be signed in to change notification settings - Fork 25
/
run-linters
executable file
·107 lines (96 loc) · 2.92 KB
/
run-linters
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#!/bin/bash
SCRIPT=${0##*/}
. "$(pwd)"/.github/utils/util-functions.sh
# Must be run from top directory
for dir_to_check in .git vdostream; do
found=$(find . -maxdepth 1 -type d -name $dir_to_check)
[ "$found" ] || {
printf '%s\n%s\n' \
"Error: Script needs to be called from top directory of repository" \
" .github/run-all-linters"
exit 1
}
done
usage() {
echo "
--------------------------------------------------------------------------------
Run repository linters
--------------------------------------------------------------------------------
Usage:
$SCRIPT [--all] [--super-linter] [--custom-linter] [--help]
Options:
-a, --all Run all linters
-sl, --super-linter Run super-linter
-rl, --renovate-linter Run Renovate linter
-cl, --custom-linter Run custom linter
-h, --help Show this help
"
}
# Check input
run_all=no
run_sl=no
run_rl=no
run_cl=no
exitcode_super_linter=0
exitcode_renovate_linter=0
exitcode_custom_linters=0
[ $# -gt 0 ] || {
usage
exit 0
}
while [ $# -gt 0 ]; do
case $1 in
-a | --all) run_all=yes ;;
-sl | --super-linter) run_sl=yes ;;
-rl | --renovate-linter) run_rl=yes ;;
-cl | --custom-linter) run_cl=yes ;;
h | -h | help | --help) usage && exit 0 ;;
*) usage && exit 1 ;;
esac
shift
done
[ "$run_all" = yes ] || [ "$run_sl" = yes ] && {
printf '%s\n' "### RUN SUPER-LINTER"
docker run --rm \
-e RUN_LOCAL=true \
--env-file .github/super-linter.env \
-v "$(pwd)":/tmp/lint \
-w /tmp/lint ghcr.io/super-linter/super-linter:slim-v6
exitcode_super_linter=$?
}
[ "$run_all" = yes ] || [ "$run_rl" = yes ] && {
printf '\n%s\n' "### RUN RENOVATE LINTER"
docker run --rm \
-v "$(pwd)"/.github/renovate.json:/usr/src/app/renovate.json \
-e RENOVATE_CONFIG_FILE=/usr/src/app/renovate.json \
-e LOG_LEVEL=debug \
-t renovate/renovate:latest \
renovate-config-validator
exitcode_renovate_linter=$?
}
[ "$run_all" = yes ] || [ "$run_cl" = yes ] && {
printf '\n%s' "### RUN CUSTOM LINTERS"
.github/run-custom-linters
exitcode_custom_linters=$?
}
printf '\n\n%s\n\n' "### LINT RESULT"
if [ "$exitcode_super_linter" -eq 0 ] &&
[ "$exitcode_renovate_linter" -eq 0 ] &&
[ "$exitcode_custom_linters" -eq 0 ]; then
print_bullet_pass "All linters passed."
exit 0
else
[ "$run_all" = yes ] || [ "$run_sl" = yes ] && {
sl_error="super-linter has one or more errors, see above."
[ "$exitcode_super_linter" -eq 0 ] || print_bullet_error "$sl_error"
}
[ "$run_all" = yes ] || [ "$run_rl" = yes ] && {
rl_error="Renovate linter has one or more errors, see above."
[ "$exitcode_renovate_linter" -eq 0 ] || print_bullet_error "$rl_error"
}
[ "$run_all" = yes ] || [ "$run_cl" = yes ] && {
cl_error="custom linters has one or more errors, see above."
[ "$exitcode_custom_linters" -eq 0 ] || print_bullet_error "$cl_error"
}
exit 1
fi