@@ -153,6 +153,100 @@ jobs:
153153 if : success() || failure()
154154 run : cargo deny --all-features --workspace --color always check all
155155
156+ spell-check :
157+ needs : constants
158+ runs-on : ubuntu-latest
159+ env :
160+ CARGO_WORKSPACES_VERSION : ${{ needs.constants.outputs.CARGO_WORKSPACES_VERSION }}
161+ SCCACHE_VERSION : ${{ needs.constants.outputs.SCCACHE_VERSION }}
162+ SCCACHE_GHA_ENABLED : " true"
163+ RUSTC_WRAPPER : " sccache"
164+ steps :
165+ # prep
166+ - name : Checkout
167+ uses : actions/checkout@v6.0.0
168+ with :
169+ fetch-depth : 1
170+ - name : Cache Cargo Dependencies
171+ uses : actions/cache@v4.3.0
172+ with :
173+ path : |
174+ ~/.cargo/bin/
175+ ~/.cargo/registry/index/
176+ ~/.cargo/registry/cache/
177+ ~/.cargo/git/db/
178+ key : ${{ runner.os }}-cargo-tools-${{ hashFiles('**/Cargo.lock') }}
179+ - name : Start sccache
180+ uses : mozilla-actions/sccache-action@v0.0.9
181+ with :
182+ version : ${{ env.SCCACHE_VERSION }}
183+ - name : Install Rust
184+ uses : actions-rust-lang/setup-rust-toolchain@v1.15.2
185+ with :
186+ toolchain : ${{ env.RUST_LATEST }}
187+ - name : Install Cargo Tools
188+ uses : taiki-e/install-action@v2.62.62
189+ with :
190+ tool : cargo-spellcheck
191+
192+ # execute
193+ - name : Make sure dictionary words are sorted and unique
194+ run : |
195+ FILE="spellcheck.dic"
196+
197+ # Verify the first line is an integer.
198+ first_line=$(head -n 1 "$FILE")
199+ if ! [[ "$first_line" =~ ^[0-9]+$ ]]; then
200+ echo "Error: The first line of $FILE must be an integer, but got: '$first_line'"
201+ exit 1
202+ fi
203+ expected_count="$first_line"
204+
205+ # Check that the number of lines matches the integer.
206+ # xargs (with no arguments) will strip leading/trailing whitespacefrom wc's output.
207+ actual_count=$(sed '1d' "$FILE" | wc -l | xargs)
208+ if [ "$expected_count" -ne "$actual_count" ]; then
209+ echo "Error: The number of lines ($actual_count) does not match $expected_count."
210+ exit 1
211+ fi
212+
213+ # `sed` removes the first line (number of words).
214+ #
215+ # `sort` makes sure everything in between is sorted
216+ # and contains no duplicates.
217+ #
218+ # Since `sort` is sensitive to locale, we set it
219+ # using LC_ALL to en_US.UTF8 to be consistent in different
220+ # environments.
221+
222+ (
223+ sed '1d' $FILE | LC_ALL=en_US.UTF8 sort -uc
224+ ) || {
225+ echo "Dictionary is not in sorted order. Correct order is:"
226+ LC_ALL=en_US.UTF8 sort -u <(sed '1d' $FILE)
227+ false
228+ }
229+ - name : Run cargo-spellcheck
230+ run : |
231+ if ! cargo spellcheck --cfg spellcheck.toml --code 1
232+ then
233+ echo ''
234+ echo ''
235+ echo 'If this is a Rust method/type/variable name, then you should'
236+ echo 'enclose it in backticks like this: `MyRustType`.'
237+ echo ''
238+ echo 'If this is a real word, then you can add it to spellcheck.dic'
239+ exit 1
240+ fi
241+ - name : Detect trailing whitespace
242+ run : |
243+ if grep --exclude-dir=.git --exclude-dir=target -rne '\s$' .
244+ then
245+ echo ''
246+ echo 'Please remove trailing whitespace from these lines.'
247+ exit 1
248+ fi
249+
156250 semver :
157251 needs : constants
158252 if : github.event_name == 'pull_request'
@@ -440,3 +534,17 @@ jobs:
440534 # execute
441535 - name : Check External Type Exposure
442536 run : cargo +${{ env.RUST_NIGHTLY_EXTERNAL_TYPES }} -Zscript scripts/check-external-types.rs ${{ env.RUST_NIGHTLY_EXTERNAL_TYPES }}
537+
538+ spell-check2 :
539+ runs-on : ubuntu-latest
540+ steps :
541+ - name : Checkout
542+ uses : actions/checkout@v6.0.0
543+
544+ - name : Spell Check
545+ uses : streetsidesoftware/cspell-action@v6
546+ with :
547+ treat_flagged_words_as_errors : true
548+ incremental_files_only : false
549+ use_cspell_files : true
550+ suggestions : true
0 commit comments