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

ci: add spellcheck.dic validation #33

Merged
merged 3 commits into from
Jan 2, 2025
Merged
Show file tree
Hide file tree
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
29 changes: 27 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,38 @@ repos:
args:
- -c
- |
FILE="spellcheck.dic"

# Verify the first line is an integer.
first_line=$(head -n 1 "$FILE")
if ! [[ "$first_line" =~ ^[0-9]+$ ]]; then
echo "Error: The first line of $FILE must be an integer, but got: '$first_line'"
exit 1
fi
expected_count="$first_line"

# Verify the last line is completely empty (no spaces).
last_line=$(tail -n 1 "$FILE")
if [ -n "$last_line" ]; then
echo "Error: The last line of $FILE must be empty (without spaces)."
exit 1
fi

# Check that the number of lines between the first and last matches the integer.
# xargs (with no arguments) will strip leading/trailing whitespace from wc's output.
actual_count=$(sed '1d;$d' "$FILE" | wc -l | xargs)
if [ "$expected_count" -ne "$actual_count" ]; then
echo "Error: The number of lines between the first and last ($actual_count) does not match $expected_count."
exit 1
fi

(
# Remove the first and last lines
sed '1d; $d' spellcheck.dic | LC_ALL=C sort -uc
sed '1d; $d' $FILE | LC_ALL=C sort -uc
) || {
echo "Dictionary is not in sorted order. Correct order is:"
# Show the correct order
LC_ALL=C sort -u <(sed '1d; $d' spellcheck.dic)
LC_ALL=C sort -u <(sed '1d; $d' $FILE)
false
}
pass_filenames: false
Expand Down
5 changes: 3 additions & 2 deletions spellcheck.dic
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
298
301
&
+
0o777
Expand Down Expand Up @@ -293,10 +293,11 @@ waker
wakers
wakeup
wakeups
workstealing
~
~12
~4
±1m
±1ms
workstealing

7 changes: 6 additions & 1 deletion utilities/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,9 @@ mv cargo-spellcheck-v0.14.0-x86_64-unknown-linux-gnu cargo-spellcheck

# install commitlint
apt install -y nodejs npm
npm install --save-dev @commitlint/{cli,config-conventional}
npm install --save-dev @commitlint/{cli,config-conventional}
npm install --save-dev husky
prefligit install # BEFORE npx husky init
npx husky init
echo "npx --no -- commitlint --edit \$1" > .husky/commit-msg
mv .git/hooks/pre-commit .husky/pre-commit
Loading