chore: add spell checking #7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json | |
name: Spellcheck | |
on: | |
pull_request: | |
branches: | |
- main | |
concurrency: | |
# each new commit to a PR runs this workflow | |
# so we need to avoid a long running older one from overwriting the 'pr-<number>-latest' | |
group: "${{ github.workflow }} @ ${{ github.ref_name }}" | |
cancel-in-progress: true | |
jobs: | |
lint: | |
name: Spellcheck | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 | |
with: | |
show-progress: false | |
- name: Cache dependencies | |
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 | |
env: | |
CACHE_NAME: cargo-cache-dependencies | |
with: | |
path: | | |
~/.cargo | |
./target | |
key: ${{ runner.os }}-build-${{ env.CACHE_NAME }}-${{ hashFiles('Cargo.lock') }}-spellcheck | |
restore-keys: | | |
${{ runner.os }}-build-${{ env.CACHE_NAME }}-${{ hashFiles('Cargo.lock') }}- | |
${{ runner.os }}-build-${{ env.CACHE_NAME }}- | |
- name: Set up toolchain | |
shell: bash | |
run: | | |
rm ${HOME}/.cargo/bin/rustfmt | |
rm ${HOME}/.cargo/bin/cargo-fmt | |
rustup update | |
cargo --version | |
- name: Get binstall | |
shell: bash | |
run: | | |
cd /tmp | |
archive="cargo-binstall-x86_64-unknown-linux-musl.tgz" | |
wget "https://github.com/cargo-bins/cargo-binstall/releases/latest/download/${archive}" | |
tar -xvf "./${archive}" | |
rm "./${archive}" | |
mv ./cargo-binstall ~/.cargo/bin/ | |
- name: Install cargo-spellcheck to check the spelling | |
shell: bash | |
run: | | |
sudo apt install libclang-dev | |
cargo binstall --no-confirm cargo-spellcheck --target x86_64-unknown-linux-gnu --verbose | |
- name: Make sure dictionary words are sorted and unique | |
shell: bash | |
run: | | |
# `sed` removes the first line (number of words) and | |
# the last line (new line). | |
# | |
# `sort` makes sure everything in between is sorted | |
# and contains no duplicates. | |
# | |
# Since `sort` is sensitive to locale, we set it | |
# using LC_ALL to en_US.UTF8 to be consistent in different | |
# environments. | |
sed '1d; $d' spellcheck.dic | LC_ALL=en_US.UTF8 sort -uc | |
- name: Run cargo-spellcheck | |
shell: bash | |
run: cargo spellcheck --code 1 |