mirror of
https://github.com/taiki-e/install-action.git
synced 2026-04-21 15:10:27 +00:00
Update tools/tidy.sh
This commit is contained in:
4
.github/.cspell/organization-dictionary.txt
vendored
4
.github/.cspell/organization-dictionary.txt
vendored
@@ -67,6 +67,7 @@ openwrt
|
|||||||
riscv
|
riscv
|
||||||
softfloat
|
softfloat
|
||||||
sparcv
|
sparcv
|
||||||
|
spirv
|
||||||
thumbeb
|
thumbeb
|
||||||
thumbebv
|
thumbebv
|
||||||
thumbv
|
thumbv
|
||||||
@@ -89,12 +90,14 @@ bools
|
|||||||
builtins
|
builtins
|
||||||
bytecount
|
bytecount
|
||||||
canonicalize
|
canonicalize
|
||||||
|
concat
|
||||||
consts
|
consts
|
||||||
ctypes
|
ctypes
|
||||||
dealloc
|
dealloc
|
||||||
deque
|
deque
|
||||||
docsrs
|
docsrs
|
||||||
doctest
|
doctest
|
||||||
|
doctests
|
||||||
hasher
|
hasher
|
||||||
impls
|
impls
|
||||||
inlateout
|
inlateout
|
||||||
@@ -148,6 +151,7 @@ powerset
|
|||||||
proto
|
proto
|
||||||
ranlib
|
ranlib
|
||||||
readelf
|
readelf
|
||||||
|
shellcheckrc
|
||||||
SIGABRT
|
SIGABRT
|
||||||
SIGILL
|
SIGILL
|
||||||
SIGINT
|
SIGINT
|
||||||
|
|||||||
7
.github/.cspell/project-dictionary.txt
vendored
7
.github/.cspell/project-dictionary.txt
vendored
@@ -1,5 +1,4 @@
|
|||||||
binstall
|
binstall
|
||||||
bytecodealliance
|
|
||||||
coreutils
|
coreutils
|
||||||
distro
|
distro
|
||||||
doas
|
doas
|
||||||
@@ -7,21 +6,15 @@ dprint
|
|||||||
enablerepo
|
enablerepo
|
||||||
epel
|
epel
|
||||||
grcov
|
grcov
|
||||||
jfrimmel
|
|
||||||
koalaman
|
|
||||||
libc
|
libc
|
||||||
linkcheck
|
linkcheck
|
||||||
mdbook
|
mdbook
|
||||||
microdnf
|
microdnf
|
||||||
mvdan
|
|
||||||
nextest
|
nextest
|
||||||
protobuf
|
|
||||||
protoc
|
protoc
|
||||||
protocolbuffers
|
|
||||||
pwsh
|
pwsh
|
||||||
quickinstall
|
quickinstall
|
||||||
rockylinux
|
rockylinux
|
||||||
rustwasm
|
|
||||||
shellcheck
|
shellcheck
|
||||||
shfmt
|
shfmt
|
||||||
udeps
|
udeps
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
# SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||||
# shellcheck disable=SC2046
|
# shellcheck disable=SC2046
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
IFS=$'\n\t'
|
IFS=$'\n\t'
|
||||||
@@ -33,6 +34,9 @@ check_diff() {
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
info() {
|
||||||
|
echo >&2 "info: $*"
|
||||||
|
}
|
||||||
warn() {
|
warn() {
|
||||||
if [[ -n "${GITHUB_ACTIONS:-}" ]]; then
|
if [[ -n "${GITHUB_ACTIONS:-}" ]]; then
|
||||||
echo "::warning::$*"
|
echo "::warning::$*"
|
||||||
@@ -171,7 +175,9 @@ fi
|
|||||||
# Spell check (if config exists)
|
# Spell check (if config exists)
|
||||||
if [[ -f .cspell.json ]]; then
|
if [[ -f .cspell.json ]]; then
|
||||||
if type -P npm &>/dev/null; then
|
if type -P npm &>/dev/null; then
|
||||||
|
has_rust=''
|
||||||
if [[ -n "$(git ls-files '*Cargo.toml')" ]]; then
|
if [[ -n "$(git ls-files '*Cargo.toml')" ]]; then
|
||||||
|
has_rust='1'
|
||||||
dependencies=''
|
dependencies=''
|
||||||
for manifest_path in $(git ls-files '*Cargo.toml'); do
|
for manifest_path in $(git ls-files '*Cargo.toml'); do
|
||||||
if [[ "${manifest_path}" != "Cargo.toml" ]] && ! grep -Eq '\[workspace\]' "${manifest_path}"; then
|
if [[ "${manifest_path}" != "Cargo.toml" ]] && ! grep -Eq '\[workspace\]' "${manifest_path}"; then
|
||||||
@@ -179,24 +185,27 @@ if [[ -f .cspell.json ]]; then
|
|||||||
fi
|
fi
|
||||||
metadata=$(cargo metadata --format-version=1 --all-features --no-deps --manifest-path "${manifest_path}")
|
metadata=$(cargo metadata --format-version=1 --all-features --no-deps --manifest-path "${manifest_path}")
|
||||||
for id in $(jq <<<"${metadata}" '.workspace_members[]'); do
|
for id in $(jq <<<"${metadata}" '.workspace_members[]'); do
|
||||||
dependencies+=$'\n'
|
dependencies+="$(jq <<<"${metadata}" ".packages[] | select(.id == ${id})" | jq -r '.dependencies[].name')"$'\n'
|
||||||
dependencies+=$(jq <<<"${metadata}" ".packages[] | select(.id == ${id})" | jq -r '.dependencies[].name')
|
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
# shellcheck disable=SC2001
|
# shellcheck disable=SC2001
|
||||||
dependencies=$(sed <<<"${dependencies}" 's/[0-9_-]/\n/g' | LC_ALL=C sort -f -u)
|
dependencies=$(sed <<<"${dependencies}" 's/[0-9_-]/\n/g' | LC_ALL=C sort -f -u)
|
||||||
config_old=$(<.cspell.json)
|
|
||||||
config_new=$(grep <<<"${config_old}" -v ' *//' | jq 'del(.dictionaries[] | select(index("organization-dictionary") | not))' | jq 'del(.dictionaryDefinitions[] | select(.name == "organization-dictionary" | not))')
|
|
||||||
echo "${config_new}" >.cspell.json
|
|
||||||
words=$(npx <<<"${dependencies}" cspell stdin --no-progress --no-summary --words-only --unique || true)
|
|
||||||
echo "${config_old}" >.cspell.json
|
|
||||||
fi
|
fi
|
||||||
|
config_old=$(<.cspell.json)
|
||||||
|
config_new=$(grep <<<"${config_old}" -v ' *//' | jq 'del(.dictionaries[] | select(index("organization-dictionary") | not))' | jq 'del(.dictionaryDefinitions[] | select(.name == "organization-dictionary" | not))')
|
||||||
|
echo "${config_new}" >.cspell.json
|
||||||
|
if [[ -n "${has_rust}" ]]; then
|
||||||
|
dependencies_words=$(npx <<<"${dependencies}" cspell stdin --no-progress --no-summary --words-only --unique || true)
|
||||||
|
fi
|
||||||
|
all_words=$(npx cspell --no-progress --no-summary --words-only --unique $(git ls-files | (grep -v '\.github/\.cspell/project-dictionary\.txt' || true)) || true)
|
||||||
|
# TODO: handle SIGINT
|
||||||
|
echo "${config_old}" >.cspell.json
|
||||||
cat >.github/.cspell/rust-dependencies.txt <<EOF
|
cat >.github/.cspell/rust-dependencies.txt <<EOF
|
||||||
// This file is @generated by $(basename "$0").
|
// This file is @generated by $(basename "$0").
|
||||||
// It is not intended for manual editing.
|
// It is not intended for manual editing.
|
||||||
EOF
|
EOF
|
||||||
if [[ -n "${words:-}" ]]; then
|
if [[ -n "${dependencies_words:-}" ]]; then
|
||||||
echo $'\n'"${words}" >>.github/.cspell/rust-dependencies.txt
|
echo $'\n'"${dependencies_words}" >>.github/.cspell/rust-dependencies.txt
|
||||||
fi
|
fi
|
||||||
check_diff .github/.cspell/rust-dependencies.txt
|
check_diff .github/.cspell/rust-dependencies.txt
|
||||||
if ! grep -Eq "^\.github/\.cspell/rust-dependencies.txt linguist-generated" .gitattributes; then
|
if ! grep -Eq "^\.github/\.cspell/rust-dependencies.txt linguist-generated" .gitattributes; then
|
||||||
@@ -204,8 +213,11 @@ EOF
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
echo "+ npx cspell --no-progress --no-summary \$(git ls-files)"
|
echo "+ npx cspell --no-progress --no-summary \$(git ls-files)"
|
||||||
npx cspell --no-progress --no-summary $(git ls-files)
|
if ! npx cspell --no-progress --no-summary $(git ls-files); then
|
||||||
|
error "spellcheck failed: please fix uses of above words or add to .github/.cspell/project-dictionary.txt if correct"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Make sure the project-specific dictionary does not contain duplicated words.
|
||||||
for dictionary in .github/.cspell/*.txt; do
|
for dictionary in .github/.cspell/*.txt; do
|
||||||
if [[ "${dictionary}" == .github/.cspell/project-dictionary.txt ]]; then
|
if [[ "${dictionary}" == .github/.cspell/project-dictionary.txt ]]; then
|
||||||
continue
|
continue
|
||||||
@@ -218,6 +230,20 @@ EOF
|
|||||||
echo "======================================="
|
echo "======================================="
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
# Make sure the project-specific dictionary does not contain unused words.
|
||||||
|
unused=''
|
||||||
|
for word in $(grep -v '//.*' .github/.cspell/project-dictionary.txt || true); do
|
||||||
|
if ! grep <<<"${all_words}" -Eq -i "^${word}$"; then
|
||||||
|
unused+="${word}"$'\n'
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
if [[ -n "${unused}" ]]; then
|
||||||
|
error "unused words in dictionaries; please remove the following words from .github/.cspell/project-dictionary.txt"
|
||||||
|
echo "======================================="
|
||||||
|
echo -n "${unused}"
|
||||||
|
echo "======================================="
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
warn "'npm' is not installed"
|
warn "'npm' is not installed"
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user