2
0
mirror of https://gitlab.com/apparmor/apparmor synced 2025-08-22 01:57:43 +00:00
apparmor/tests/bin/shellcheck-tree
intrigeri 5a6f6c2fc8 CI: add shellcheck job, with minimum severity set to error
We have way too many warnings to enable lower severity levels,
but let's at least we don't introduce new errors.
2022-02-13 19:43:48 +00:00

33 lines
717 B
Python
Executable File

#!/usr/bin/python3
import glob
import re
import subprocess
import sys
from pathlib import Path
def is_excluded(f):
return re.match(r"^([.]git)/",
f) or Path(f).is_dir()
def mimetype(f):
return subprocess.run(['file', '--brief', '--mime-type', f],
stdout=subprocess.PIPE,
universal_newlines=True,
check=True).stdout.rstrip()
def is_shell_script(f):
return mimetype(f) == "text/x-shellscript"
shell_scripts = [
f for f in glob.glob("**/*", recursive=True)
if not is_excluded(f) and is_shell_script(f)
]
sys.exit(
subprocess.run(['shellcheck'] + sys.argv[1:] + shell_scripts).returncode)