mirror of
https://github.com/taiki-e/install-action.git
synced 2026-05-09 14:20:29 +00:00
tools: Update tidy.sh
This commit is contained in:
@@ -122,8 +122,9 @@ if [[ -n "$(git ls-files '*.rs')" ]]; then
|
|||||||
echo "${new}" >"${lib}"
|
echo "${new}" >"${lib}"
|
||||||
check_diff "${lib}"
|
check_diff "${lib}"
|
||||||
done
|
done
|
||||||
# Make sure that public Rust crates don't contain executables.
|
# Make sure that public Rust crates don't contain executables and binaries.
|
||||||
failed_files=''
|
executables=''
|
||||||
|
binaries=''
|
||||||
metadata=$(cargo metadata --format-version=1 --no-deps)
|
metadata=$(cargo metadata --format-version=1 --no-deps)
|
||||||
has_public_crate=''
|
has_public_crate=''
|
||||||
for id in $(jq <<<"${metadata}" '.workspace_members[]'); do
|
for id in $(jq <<<"${metadata}" '.workspace_members[]'); do
|
||||||
@@ -140,7 +141,7 @@ if [[ -n "$(git ls-files '*.rs')" ]]; then
|
|||||||
has_public_crate='1'
|
has_public_crate='1'
|
||||||
done
|
done
|
||||||
if [[ -n "${has_public_crate}" ]]; then
|
if [[ -n "${has_public_crate}" ]]; then
|
||||||
info "checking file permissions"
|
info "checking public crates don't contain executables and binaries"
|
||||||
if [[ -f Cargo.toml ]]; then
|
if [[ -f Cargo.toml ]]; then
|
||||||
root_manifest=$(cargo locate-project --message-format=plain --manifest-path Cargo.toml)
|
root_manifest=$(cargo locate-project --message-format=plain --manifest-path Cargo.toml)
|
||||||
root_pkg=$(jq <<<"${metadata}" ".packages[] | select(.manifest_path == \"${root_manifest}\")")
|
root_pkg=$(jq <<<"${metadata}" ".packages[] | select(.manifest_path == \"${root_manifest}\")")
|
||||||
@@ -167,13 +168,24 @@ if [[ -n "$(git ls-files '*.rs')" ]]; then
|
|||||||
.* | tools/*) continue ;;
|
.* | tools/*) continue ;;
|
||||||
esac
|
esac
|
||||||
if [[ -x "${p}" ]]; then
|
if [[ -x "${p}" ]]; then
|
||||||
failed_files+="${p}"$'\n'
|
executables+="${p}"$'\n'
|
||||||
|
fi
|
||||||
|
# Use diff instead of file because file treats an empty file as a binary
|
||||||
|
# https://unix.stackexchange.com/questions/275516/is-there-a-convenient-way-to-classify-files-as-binary-or-text#answer-402870
|
||||||
|
if (diff .gitattributes "${p}" || true) | grep -q '^Binary file'; then
|
||||||
|
binaries+="${p}"$'\n'
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
if [[ -n "${failed_files}" ]]; then
|
if [[ -n "${executables}" ]]; then
|
||||||
error "file-permissions-check failed: executable should be in tools/ directory"
|
error "file-permissions-check failed: executables are only allowed to be present in directories that are excluded from crates.io"
|
||||||
echo "======================================="
|
echo "======================================="
|
||||||
echo -n "${failed_files}"
|
echo -n "${executables}"
|
||||||
|
echo "======================================="
|
||||||
|
fi
|
||||||
|
if [[ -n "${binaries}" ]]; then
|
||||||
|
error "file-permissions-check failed: binaries are only allowed to be present in directories that are excluded from crates.io"
|
||||||
|
echo "======================================="
|
||||||
|
echo -n "${binaries}"
|
||||||
echo "======================================="
|
echo "======================================="
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user