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

Update conditions around unused functions #23

Merged
merged 1 commit into from
Jun 11, 2024
Merged
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
32 changes: 21 additions & 11 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,22 +70,32 @@ runs:
ret=${PIPESTATUS[0]} # can't trust $? here, apparently
fi

echo "Weeder exit code: $ret"
unused_functions_found=0

if ((WEEDER_VERCMP >= 0)); then
if ((ret == 228)); then
unused_functions_found=1
fi
else
if [[ -s "$tmp" ]]; then
unused_functions_found=1
fi
fi

if ((!ret)); then
echo "No unused functions found"
exit 0
fi

# If we're configured to fail, we can always fail regardless of version
if ${{ inputs.fail }}; then
echo "Configured to fail and unused functions found"
exit $ret
fi
if ((unused_functions_found)); then
if ${{ inputs.fail }}; then
echo "Configured to fail and unused functions found"
exit 1
fi

# Otherwise, if we know we're v2.7+ and the exit code was not
# weeds-found (228), we should still fail.
if ((WEEDER_VERCMP >= 0)) && ((ret != 228)); then
echo "Weeder encountered some other error" >&2
exit $ret
echo "Unused functions found, but not configured to fail"
exit 0
fi

echo "Weeder encountered some other error" >&2
exit $ret
Loading