mirror of
https://github.com/taiki-e/install-action.git
synced 2026-04-21 15:10:27 +00:00
Add spell-check to CI
This commit is contained in:
49
.cspell.json
Normal file
49
.cspell.json
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
{
|
||||||
|
"version": "0.2",
|
||||||
|
"gitignoreRoot": ".",
|
||||||
|
"useGitignore": true,
|
||||||
|
"dictionaryDefinitions": [
|
||||||
|
{
|
||||||
|
"name": "organization-dictionary",
|
||||||
|
"path": "./.github/.cspell/organization-dictionary.txt",
|
||||||
|
"addWords": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "project-dictionary",
|
||||||
|
"path": "./.github/.cspell/project-dictionary.txt",
|
||||||
|
"addWords": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "rust-dependencies",
|
||||||
|
"path": "./.github/.cspell/rust-dependencies.txt",
|
||||||
|
"addWords": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"dictionaries": [
|
||||||
|
"organization-dictionary",
|
||||||
|
"project-dictionary",
|
||||||
|
"rust-dependencies"
|
||||||
|
],
|
||||||
|
"ignoreRegExpList": [
|
||||||
|
// Copyright notice
|
||||||
|
"Copyright ((\\(c\\)|\\(C\\)|©) )?.*",
|
||||||
|
// GHA actions/workflows
|
||||||
|
"uses: .+@",
|
||||||
|
// GHA context (repo name, owner name, etc.)
|
||||||
|
"github.\\w+ (=|!)= '.+'",
|
||||||
|
// GH username
|
||||||
|
"( |\\[)@[\\w_-]+",
|
||||||
|
// Git config username
|
||||||
|
"git config user.name .*",
|
||||||
|
// Cargo.toml authors
|
||||||
|
"authors *= *\\[.*\\]",
|
||||||
|
"\".* <[\\w_.+-]+@[\\w.-]+>\""
|
||||||
|
],
|
||||||
|
"languageSettings": [
|
||||||
|
{
|
||||||
|
"languageId": ["*"],
|
||||||
|
"dictionaries": ["rust"]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"ignorePaths": []
|
||||||
|
}
|
||||||
109
.github/.cspell/organization-dictionary.txt
vendored
Normal file
109
.github/.cspell/organization-dictionary.txt
vendored
Normal file
@@ -0,0 +1,109 @@
|
|||||||
|
// This is a dictionary shared by projects under https://github.com/taiki-e.
|
||||||
|
// It is not intended for manual editing.
|
||||||
|
|
||||||
|
endo
|
||||||
|
taiki
|
||||||
|
|
||||||
|
// tool name and its configs or options
|
||||||
|
asan
|
||||||
|
cflags
|
||||||
|
clippy
|
||||||
|
codegen
|
||||||
|
cxxflags
|
||||||
|
exitcode
|
||||||
|
miri
|
||||||
|
miriflags
|
||||||
|
msan
|
||||||
|
retag
|
||||||
|
rustc
|
||||||
|
rustdoc
|
||||||
|
rustdocflags
|
||||||
|
rustflags
|
||||||
|
rustfmt
|
||||||
|
rustsec
|
||||||
|
rustup
|
||||||
|
valgrind
|
||||||
|
xcompile
|
||||||
|
Zdoctest
|
||||||
|
Zmiri
|
||||||
|
|
||||||
|
// Rust target triple
|
||||||
|
aarch
|
||||||
|
androideabi
|
||||||
|
armeb
|
||||||
|
armebv
|
||||||
|
armv
|
||||||
|
asmjs
|
||||||
|
atmega
|
||||||
|
bpfeb
|
||||||
|
bpfel
|
||||||
|
cuda
|
||||||
|
eabi
|
||||||
|
eabihf
|
||||||
|
emscripten
|
||||||
|
espidf
|
||||||
|
fortanix
|
||||||
|
gnuabi
|
||||||
|
gnueabi
|
||||||
|
gnueabihf
|
||||||
|
gnullvm
|
||||||
|
gnuspe
|
||||||
|
gnux
|
||||||
|
illumos
|
||||||
|
imac
|
||||||
|
macabi
|
||||||
|
mipsel
|
||||||
|
mipsisa
|
||||||
|
msvc
|
||||||
|
muslabi
|
||||||
|
musleabi
|
||||||
|
musleabihf
|
||||||
|
nvptx
|
||||||
|
openwrt
|
||||||
|
riscv
|
||||||
|
softfloat
|
||||||
|
sparcv
|
||||||
|
thumbeb
|
||||||
|
thumbebv
|
||||||
|
thumbv
|
||||||
|
tvos
|
||||||
|
uclibc
|
||||||
|
uclibceabi
|
||||||
|
uclibceabihf
|
||||||
|
uefi
|
||||||
|
vxworks
|
||||||
|
wasi
|
||||||
|
watchos
|
||||||
|
xous
|
||||||
|
|
||||||
|
// Rust other
|
||||||
|
alloc
|
||||||
|
canonicalize
|
||||||
|
consts
|
||||||
|
deque
|
||||||
|
doctest
|
||||||
|
hasher
|
||||||
|
inlateout
|
||||||
|
intrinsics
|
||||||
|
lateout
|
||||||
|
msrv
|
||||||
|
peekable
|
||||||
|
punct
|
||||||
|
repr
|
||||||
|
rfind
|
||||||
|
rfold
|
||||||
|
splitn
|
||||||
|
uninit
|
||||||
|
|
||||||
|
// Other
|
||||||
|
connrefused
|
||||||
|
cygwin
|
||||||
|
euxo
|
||||||
|
msys
|
||||||
|
noninteractive
|
||||||
|
noprofile
|
||||||
|
norc
|
||||||
|
pipefail
|
||||||
|
powerset
|
||||||
|
proto
|
||||||
|
tlsv
|
||||||
19
.github/.cspell/project-dictionary.txt
vendored
Normal file
19
.github/.cspell/project-dictionary.txt
vendored
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
binstall
|
||||||
|
bytecodealliance
|
||||||
|
jfrimmel
|
||||||
|
koalaman
|
||||||
|
libc
|
||||||
|
linkcheck
|
||||||
|
mdbook
|
||||||
|
mvdan
|
||||||
|
nextest
|
||||||
|
protobuf
|
||||||
|
protoc
|
||||||
|
protocolbuffers
|
||||||
|
quickinstall
|
||||||
|
rustwasm
|
||||||
|
shellcheck
|
||||||
|
shfmt
|
||||||
|
toolchains
|
||||||
|
udeps
|
||||||
|
wasmtime
|
||||||
0
.github/.cspell/rust-dependencies.txt
vendored
Normal file
0
.github/.cspell/rust-dependencies.txt
vendored
Normal file
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1,8 +1,5 @@
|
|||||||
target
|
target
|
||||||
Cargo.lock
|
Cargo.lock
|
||||||
node_modules
|
|
||||||
package-lock.json
|
|
||||||
package.json
|
|
||||||
|
|
||||||
# For platform and editor specific settings, it is recommended to add to
|
# For platform and editor specific settings, it is recommended to add to
|
||||||
# a global .gitignore file.
|
# a global .gitignore file.
|
||||||
|
|||||||
@@ -3,6 +3,9 @@ set -euo pipefail
|
|||||||
IFS=$'\n\t'
|
IFS=$'\n\t'
|
||||||
cd "$(dirname "$0")"/..
|
cd "$(dirname "$0")"/..
|
||||||
|
|
||||||
|
# shellcheck disable=SC2154
|
||||||
|
trap 's=$?; echo >&2 "$0: Error on line "${LINENO}": ${BASH_COMMAND}"; exit ${s}' ERR
|
||||||
|
|
||||||
# Publish a new release.
|
# Publish a new release.
|
||||||
#
|
#
|
||||||
# USAGE:
|
# USAGE:
|
||||||
|
|||||||
@@ -4,13 +4,16 @@ set -euo pipefail
|
|||||||
IFS=$'\n\t'
|
IFS=$'\n\t'
|
||||||
cd "$(dirname "$0")"/..
|
cd "$(dirname "$0")"/..
|
||||||
|
|
||||||
|
# shellcheck disable=SC2154
|
||||||
|
trap 's=$?; echo >&2 "$0: Error on line "${LINENO}": ${BASH_COMMAND}"; exit ${s}' ERR
|
||||||
|
|
||||||
# USAGE:
|
# USAGE:
|
||||||
# ./tools/tidy.sh
|
# ./tools/tidy.sh
|
||||||
#
|
#
|
||||||
# Note: This script requires the following tools:
|
# Note: This script requires the following tools:
|
||||||
# - shfmt
|
# - shfmt
|
||||||
# - shellcheck
|
# - shellcheck
|
||||||
# - npm (if any of YAML/JavaScript/JSON exists)
|
# - npm
|
||||||
# - jq and yq (if this repository uses bors)
|
# - jq and yq (if this repository uses bors)
|
||||||
# - clang-format (if any of C/C++ exists)
|
# - clang-format (if any of C/C++ exists)
|
||||||
#
|
#
|
||||||
@@ -21,14 +24,10 @@ cd "$(dirname "$0")"/..
|
|||||||
x() {
|
x() {
|
||||||
local cmd="$1"
|
local cmd="$1"
|
||||||
shift
|
shift
|
||||||
if [[ -n "${verbose:-}" ]]; then
|
|
||||||
(
|
(
|
||||||
set -x
|
set -x
|
||||||
"${cmd}" "$@"
|
"${cmd}" "$@"
|
||||||
)
|
)
|
||||||
else
|
|
||||||
"${cmd}" "$@"
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
check_diff() {
|
check_diff() {
|
||||||
if [[ -n "${CI:-}" ]]; then
|
if [[ -n "${CI:-}" ]]; then
|
||||||
@@ -50,17 +49,10 @@ warn() {
|
|||||||
should_fail=1
|
should_fail=1
|
||||||
}
|
}
|
||||||
|
|
||||||
if [[ "${1:-}" == "-v" ]]; then
|
|
||||||
shift
|
|
||||||
verbose=1
|
|
||||||
fi
|
|
||||||
if [[ -n "${CI:-}" ]]; then
|
|
||||||
verbose=1
|
|
||||||
fi
|
|
||||||
if [[ $# -gt 0 ]]; then
|
if [[ $# -gt 0 ]]; then
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
USAGE:
|
USAGE:
|
||||||
$0 [-v]
|
$0
|
||||||
EOF
|
EOF
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
@@ -81,15 +73,12 @@ fi
|
|||||||
# YAML/JavaScript/JSON (if exists)
|
# YAML/JavaScript/JSON (if exists)
|
||||||
if [[ -n "$(git ls-files '*.yml')$(git ls-files '*.js')$(git ls-files '*.json')" ]]; then
|
if [[ -n "$(git ls-files '*.yml')$(git ls-files '*.js')$(git ls-files '*.json')" ]]; then
|
||||||
if type -P npm &>/dev/null; then
|
if type -P npm &>/dev/null; then
|
||||||
if [[ ! -e node_modules/.bin/prettier ]]; then
|
|
||||||
x npm install prettier &>/dev/null
|
|
||||||
fi
|
|
||||||
x npx prettier -l -w $(git ls-files '*.yml') $(git ls-files '*.js') $(git ls-files '*.json')
|
x npx prettier -l -w $(git ls-files '*.yml') $(git ls-files '*.js') $(git ls-files '*.json')
|
||||||
check_diff $(git ls-files '*.yml') $(git ls-files '*.js') $(git ls-files '*.json')
|
check_diff $(git ls-files '*.yml') $(git ls-files '*.js') $(git ls-files '*.json')
|
||||||
else
|
else
|
||||||
warn "'npm' is not installed"
|
warn "'npm' is not installed"
|
||||||
fi
|
fi
|
||||||
if [[ -e .github/workflows/ci.yml ]] && grep -q '# tidy:needs' .github/workflows/ci.yml; then
|
if [[ -e .github/workflows/ci.yml ]] && grep -q '# tidy:needs' .github/workflows/ci.yml && ! grep -Eq '# *needs: \[' .github/workflows/ci.yml; then
|
||||||
if type -P jq &>/dev/null && type -P yq &>/dev/null; then
|
if type -P jq &>/dev/null && type -P yq &>/dev/null; then
|
||||||
# shellcheck disable=SC2207
|
# shellcheck disable=SC2207
|
||||||
jobs_actual=($(yq '.jobs' .github/workflows/ci.yml | jq -r 'keys_unsorted[]'))
|
jobs_actual=($(yq '.jobs' .github/workflows/ci.yml | jq -r 'keys_unsorted[]'))
|
||||||
@@ -133,6 +122,47 @@ else
|
|||||||
warn "'shellcheck' is not installed"
|
warn "'shellcheck' is not installed"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Spell check (if config exists)
|
||||||
|
if [[ -f .cspell.json ]]; then
|
||||||
|
if type -P npm &>/dev/null; then
|
||||||
|
if [[ -f Cargo.toml ]]; then
|
||||||
|
metadata=$(cargo metadata --format-version=1 --all-features --no-deps)
|
||||||
|
dependencies=''
|
||||||
|
for id in $(jq <<<"${metadata}" '.workspace_members[]'); do
|
||||||
|
dependencies+=$'\n'
|
||||||
|
dependencies+=$(jq <<<"${metadata}" ".packages[] | select(.id == ${id})" | jq -r '.dependencies[].name')
|
||||||
|
done
|
||||||
|
cat >.github/.cspell/rust-dependencies.txt <<EOF
|
||||||
|
// This file is @generated by $(basename "$0").
|
||||||
|
// It is not intended for manual editing.
|
||||||
|
|
||||||
|
EOF
|
||||||
|
# shellcheck disable=SC2001
|
||||||
|
sed <<<"${dependencies}" 's/[0-9_-]/\n/g' | LC_ALL=C sort -f -u | (grep -E '.{4,}' || true) >>.github/.cspell/rust-dependencies.txt
|
||||||
|
check_diff .github/.cspell/rust-dependencies.txt
|
||||||
|
else
|
||||||
|
touch .github/.cspell/rust-dependencies.txt
|
||||||
|
fi
|
||||||
|
|
||||||
|
x npx cspell --no-progress $(git ls-files)
|
||||||
|
|
||||||
|
for dictionary in .github/.cspell/*.txt; do
|
||||||
|
if [[ "${dictionary}" == .github/.cspell/project-dictionary.txt ]]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
dup=$(sed '/^$/d' .github/.cspell/project-dictionary.txt "${dictionary}" | LC_ALL=C sort -f | uniq -d -i | (grep -v '//.*' || true))
|
||||||
|
if [[ -n "${dup}" ]]; then
|
||||||
|
warn "duplicated words in dictionaries; please remove the following words from .github/.cspell/project-dictionary.txt"
|
||||||
|
echo "======================================="
|
||||||
|
echo "${dup}"
|
||||||
|
echo "======================================="
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
else
|
||||||
|
warn "'npm' is not installed"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ -n "${should_fail:-}" ]]; then
|
if [[ -n "${should_fail:-}" ]]; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user