Skip to content

Commit b6d20fb

Browse files
author
Martin Taillefer
committed
ci: Add spell checker
1 parent e095f6a commit b6d20fb

File tree

29 files changed

+461
-322
lines changed

29 files changed

+461
-322
lines changed

.github/license-check/config.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444

4545
{
4646
"include": [
47+
"**/*.dic",
4748
"**/*.j2",
4849
"**/*.svg",
4950
"**/*.png",

.github/workflows/main.yml

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

.spelling

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ Clippy
6767
codebase
6868
composability
6969
config
70+
contoso
7071
const
7172
CONTRIBUTING.md
7273
coverage.json
@@ -99,6 +100,7 @@ filesystem
99100
fn
100101
foldhash
101102
footguns
103+
formatter
102104
fundle
103105
Fundle
104106
getsockopt
@@ -133,6 +135,7 @@ macros
133135
Macros
134136
Makefile
135137
metadata
138+
metadata
136139
Metas
137140
Microservices
138141
microsoft.com
@@ -245,4 +248,5 @@ wildcard
245248
wildcards
246249
Win32
247250
winsock
251+
workspace
248252
Xamarin

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Licensed under the MIT License.
33

44
[workspace]
5-
resolver = "3"
5+
resolver = "2"
66
members = ["crates/*"]
77

88
[workspace.package]

crates/bytesbuf/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ use bytesbuf::BytesView;
422422

423423
pub fn write(&mut self, message: BytesView) {
424424
// We now need to identify whether the message actually uses memory that allows us to
425-
// ues the optimal I/O path. There is no requirement that the data passed to us contains
425+
// use the optimal I/O path. There is no requirement that the data passed to us contains
426426
// only memory with our preferred configuration.
427427

428428
let use_optimal_path = message.iter_slice_metas().all(|meta| {

crates/bytesbuf/examples/bb_optimal_path.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ impl Connection {
6161

6262
pub fn write(&mut self, message: BytesView) {
6363
// We now need to identify whether the message actually uses memory that allows us to
64-
// ues the optimal I/O path. There is no requirement that the data passed to us contains
64+
// use the optimal I/O path. There is no requirement that the data passed to us contains
6565
// only memory with our preferred configuration.
6666

6767
let use_optimal_path = message.iter_slice_metas().all(|meta| {

crates/bytesbuf/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@
456456
//! # impl Foo {
457457
//! pub fn write(&mut self, message: BytesView) {
458458
//! // We now need to identify whether the message actually uses memory that allows us to
459-
//! // ues the optimal I/O path. There is no requirement that the data passed to us contains
459+
//! // use the optimal I/O path. There is no requirement that the data passed to us contains
460460
//! // only memory with our preferred configuration.
461461
//!
462462
//! let use_optimal_path = message.iter_slice_metas().all(|meta| {

crates/bytesbuf/src/span_builder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ impl SpanBuilder {
167167
// This cannot overflow - guarded by assertion above.
168168
self.filled_bytes = self.filled_bytes.wrapping_sub(len.get());
169169

170-
// SAFETY: We only seeked over filled bytes, so we must still be in-bounds.
170+
// SAFETY: We only skipped over filled bytes, so we must still be in-bounds.
171171
self.start = unsafe { self.start.add(len.get() as usize) };
172172

173173
span

crates/data_privacy/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373

7474
- ✨ Features
7575

76-
- Make RedactionEngine clonable. ([#13](https://github.com/microsoft/oxidizer/pull/13))
76+
- Make RedactionEngine cloneable. ([#13](https://github.com/microsoft/oxidizer/pull/13))
7777

7878
- 📚 Documentation
7979

crates/data_privacy/src/data_class.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ impl DataClass {
2525
///
2626
/// # Panics
2727
///
28-
/// Panics if `taxonomy` or `name` are not valid ASCII identifiers. Valid identifiers must
28+
/// Panics if `taxonomy` or `name` are not valid identifiers. Valid identifiers must
2929
/// start with `_` or an ASCII letter, followed by zero or more `_`, ASCII letters, or ASCII
3030
/// digits (e.g., `foo`, `_bar`, `Baz123`)
3131
#[must_use]

0 commit comments

Comments
 (0)