Skip to content

Commit dabae57

Browse files
authored
ci: add spellcheck.dic validation (#7062)
1 parent 6bd3be2 commit dabae57

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

.github/workflows/ci.yml

+21-4
Original file line numberDiff line numberDiff line change
@@ -1132,8 +1132,25 @@ jobs:
11321132
- uses: actions/checkout@v4
11331133
- name: Make sure dictionary words are sorted and unique
11341134
run: |
1135-
# `sed` removes the first line (number of words) and
1136-
# the last line (new line).
1135+
FILE="spellcheck.dic"
1136+
1137+
# Verify the first line is an integer.
1138+
first_line=$(head -n 1 "$FILE")
1139+
if ! [[ "$first_line" =~ ^[0-9]+$ ]]; then
1140+
echo "Error: The first line of $FILE must be an integer, but got: '$first_line'"
1141+
exit 1
1142+
fi
1143+
expected_count="$first_line"
1144+
1145+
# Check that the number of lines matches the integer.
1146+
# xargs (with no arguments) will strip leading/trailing whitespacefrom wc's output.
1147+
actual_count=$(sed '1d' "$FILE" | wc -l | xargs)
1148+
if [ "$expected_count" -ne "$actual_count" ]; then
1149+
echo "Error: The number of lines ($actual_count) does not match $expected_count."
1150+
exit 1
1151+
fi
1152+
1153+
# `sed` removes the first line (number of words).
11371154
#
11381155
# `sort` makes sure everything in between is sorted
11391156
# and contains no duplicates.
@@ -1143,10 +1160,10 @@ jobs:
11431160
# environments.
11441161
11451162
(
1146-
sed '1d; $d' spellcheck.dic | LC_ALL=en_US.UTF8 sort -uc
1163+
sed '1d' $FILE | LC_ALL=en_US.UTF8 sort -uc
11471164
) || {
11481165
echo "Dictionary is not in sorted order. Correct order is:"
1149-
LC_ALL=en_US.UTF8 sort -u <(sed '1d; $d' spellcheck.dic)
1166+
LC_ALL=en_US.UTF8 sort -u <(sed '1d' $FILE)
11501167
false
11511168
}
11521169
- name: Run cargo-spellcheck

spellcheck.dic

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
298
1+
299
22
&
33
+
44
<

0 commit comments

Comments
 (0)