Skip to content
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

Allow go-leak linter to fail CI #5316

Merged
merged 1 commit into from
Apr 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
27 changes: 20 additions & 7 deletions scripts/check-goleak-files.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
set -euo pipefail

bad_pkgs=0
failed_pkgs=0

# shellcheck disable=SC2048
for dir in $*; do
Expand All @@ -12,23 +13,35 @@ for dir in $*; do
testFiles=$(find "${dir}" -maxdepth 1 -name '*_test.go')
if [[ -z "$testFiles" ]]; then
continue
fi
fi
good=0
for test in ${testFiles}; do
if grep -q "TestMain" "${test}" | grep -q "testutils.VerifyGoLeaks" "${test}"; then
if grep -q "TestMain" "${test}" && grep -q "testutils.VerifyGoLeaks" "${test}"; then
good=1
break
fi
done
if ((good == 0)); then
echo "πŸ”΄ Error(check-goleak): no goleak check in package ${dir}"
((bad_pkgs+=1))
if [[ "${dir}" == "./cmd/jaeger/internal/integration/" || "${dir}" == "./plugin/storage/integration/" ]]; then
echo " this package is temporarily allowed and will not cause linter failure"
else
((failed_pkgs+=1))
fi
fi
done

if ((bad_pkgs > 0)); then
echo "Error(check-goleak): no goleak check in ${bad_pkgs} package(s)."
echo "See https://github.com/jaegertracing/jaeger/pull/5010/files for example of adding the checks."
echo "In the future this will be a fatal error in the CI."
exit 0 # TODO change to 1 in the future
function help() {
echo " See https://github.com/jaegertracing/jaeger/pull/5010/files"
echo " for examples of adding the checks."
}

if ((failed_pkgs > 0)); then
echo "β›” Fatal(check-goleak): no goleak check in ${bad_pkgs} package(s), ${failed_pkgs} of which not allowed."
help
exit 1
elif ((bad_pkgs > 0)); then
echo "🐞 Warning(check-goleak): no goleak check in ${bad_pkgs} package(s)."
help
fi