Skip to content

tests: linters: log a bit more info #53

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions tests/patch/pylint/pylint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ then
exit 0
fi

pylint --version || exit 1

tmpfile_o=$(mktemp)
tmpfile_n=$(mktemp)

Expand Down
30 changes: 17 additions & 13 deletions tests/patch/shellcheck/shellcheck.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ then
exit 0
fi

shellcheck --version || exit 1

tmpfile_o=$(mktemp)
tmpfile_n=$(mktemp)

Expand All @@ -30,11 +32,11 @@ git checkout -q HEAD~

# Also ignore created, as not present in the parent commit
for f in $(git show --diff-filter=M --pretty="" --name-only "${HEAD}" | grep -E "\.sh$"); do
(
sha=$(echo "$f" | sha256sum | awk '{print $1}')
echo "Checking $f - $sha"
echo
sha=$(echo "$f" | sha256sum | awk '{print $1}')
echo "Checking $f - $sha"
echo

(
cd "$(dirname "$f")" || exit 1
sha="${tmpfile_o}_${sha}"
rm -f "${sha}"
Expand All @@ -51,12 +53,14 @@ incumbent_w=$(grep -c " (warning):" "$tmpfile_o")
pr "Checking the tree with the patch"
git checkout -q "$HEAD"

declare -A files
for f in $(git show --diff-filter=AM --pretty="" --name-only "${HEAD}" | grep -E "\.sh$"); do
(
sha=$(echo "$f" | sha256sum | awk '{print $1}')
echo "Checking $f - $sha"
echo
sha=$(echo "$f" | sha256sum | awk '{print $1}')
files[${sha}]="${f}"
echo "Checking $f - $sha"
echo

(
cd "$(dirname "$f")" || exit 1
sha="${tmpfile_n}_${sha}"
rm -f "${sha}"
Expand All @@ -71,17 +75,17 @@ current_w=$(grep -c " (warning):" "$tmpfile_n")

# if a file was compliant before or is new, mark everything as error to keep it good.
for f in "${tmpfile_n}_"*; do
[ ! -s "${f}" ] && continue # still compliant

sha="${f:${#tmpfile_n}+1}"
fpath="${files[${sha}]}"
[ ! -s "${f}" ] && echo "${fpath} is shellcheck compliant" && continue

old="${tmpfile_o}_${sha}"
[ -s "${old}" ] && continue # wasn't compliant

fname=$(head -n2 "${f}" | tail -n1 | sed "s/^In \(\S\+\.sh\) line [0-9]\+:/\1/g")
if [ -f "${old}" ]; then
echo "${fname} was shellcheck compliant, not anymore" 1>&2
echo "${fpath} was shellcheck compliant, not anymore" 1>&2
else
echo "${fname} is a new file, but not shellcheck compliant" 1>&2
echo "${fpath} is a new file, but not shellcheck compliant" 1>&2
fi

extra=$(grep -c -E " \((warning|info|style)\):" "${f}")
Expand Down
2 changes: 2 additions & 0 deletions tests/patch/yamllint/yamllint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ then
exit 0
fi

yamllint --version || exit 1

tmpfile_o=$(mktemp)
tmpfile_n=$(mktemp)

Expand Down