-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathchecks.sh
executable file
·64 lines (51 loc) · 1.37 KB
/
checks.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
#!/bin/bash
set -eu
FOLDER='sources'
check_python_files() {
python -m ruff format "${FOLDER}" ./*.py
python -m ruff check --fix "${FOLDER}" ./*.py
python -m mypy "${FOLDER}" ./*.py
python -m doctest 'sources/python/snippets/imaplib-suppression-des-doublons.py'
}
check_shell_file() {
shellcheck -e SC1090,SC1091,SC2164 "${1}"
}
check_shell_files() {
for file in $(/bin/find "${FOLDER}" -type f -name '*.sh'); do
check_shell_file "${file}"
done
check_shell_file 'checks.sh'
}
check_markdown_file() {
local file="${1}"
shift
python -m pymarkdown fix "${file}"
python -m pymarkdown "$@" scan "${file}"
}
check_markdown_files() {
local disabled_rules
local filename
check_markdown_file 'README.md'
for file in $(/bin/find "${FOLDER}" -type f -name '*.md'); do
disabled_rules=()
if [ "$(dirname "${file}")" = "sources/inipi" ]; then
filename="$(basename "${file}")"
[ "${filename:0:1}" = '_' ] || disabled_rules=(-d 'md003,md022,md041')
fi
check_markdown_file "${file}" "${disabled_rules[@]}"
done
}
check_yaml_file() {
python -m yamllint -s -d relaxed "${1}"
}
check_yaml_files() {
check_yaml_file "${FOLDER}"
check_yaml_file '.github'
}
main() {
check_python_files
check_shell_files
check_markdown_files
check_yaml_files
}
main