spellcheck.yml

Spellcheck an R package’s prose with the {spelling} package. The package’s own inst/WORDLIST is the accepted vocabulary, so a repo migrating from a bespoke check-spelling.yaml keeps its wordlist unchanged – that file is {spelling}’s own format.

What it reads

spell_check_package() decides the population, and it is narrower than “the repo’s prose” in one direction and wider in another. Read off spell_check_package()’s source at {spelling} 2.3.2 and confirmed against a fixture (2026-08-21):

  • DESCRIPTION’s Title and Description fields, and no other field.
  • Every man/*.Rd help page.
  • Vignette sources under vignettes/, matched as .md/.Rmd/.qmd, plus .Rnw/.Snw. These are parsed as text, never rendered, which is why install-quarto defaults to 'false' even for a .qmd vignette.
  • Root-level Markdown whose name matches readme, news, changes, or index, case-insensitively. So a package’s own README.md and NEWS.md are checked.

Everything else is out of reach of spellcheck.yml: a Quarto site’s other pages, CONTRIBUTING.md, code comments, YAML, and any repository that is not an R package at all. check-typos.yml covers those with crate-ci/typos.

The package’s own name and its authors’ names are added to the accepted vocabulary automatically, so neither needs a WORDLIST entry.

Add a newly-accepted word with spelling::update_wordlist() in the package, and commit the result.

Inputs

Input Type Default Description
path string '.' Path to the package root, relative to the repository.
exclude string '' Comma-separated files or folders to skip. Accepts globs.
fail string 'true' Whether to fail the job on misspelled words ('true', 'false').
additional-options string '--vanilla' Options passed to Rscript. Pass '' to let R read its profiles.
install-quarto string 'false' Whether dependency setup installs Quarto.
runs-on string ubuntu-latest Runner label for the job.

Permissions

Only contents: read (the default), so no permissions: block is needed.

Example

name: Spellcheck
on:
  push: { branches: [main] }
  pull_request:
jobs:
  spellcheck:
    uses: Morrison-Lab/gha/.github/workflows/spellcheck.yml@v2
    # with:
    #   path: '.'
    #   exclude: 'vignettes/*.Rmd'
    #   fail: 'true'
    #   additional-options: ''
    #   install-quarto: 'auto'

See the examples/ directory for the full caller stub (spellcheck.yml).

Why it sets up R instead of running in a container

The bespoke workflows this replaces run inside a rocker image. This one calls r-lib/actions/setup-r, matching every other R capability here, so a consumer already paying for setup-r in its other jobs reuses that toolchain cache.

It also installs {spelling} through setup-r-dependencies rather than compiling {spelling} and its {hunspell} C++ dependency on every run. Going through setup-r-dependencies takes the public RSPM binaries instead and caches them across runs.

Only {spelling} is installed, not the consumer package’s own dependencies: spell_check_package() reads a package’s files without loading it, so resolving its dependency tree would be pure cost. RENV_CONFIG_AUTOLOADER_ENABLED: 'FALSE' is set during dependency setup so {spelling} installs to the site library even in renv projects; additional-options: '--vanilla' default then finds it without requiring .Rprofile activation (#620). For the same reason install-quarto defaults to 'false' – {spelling} reads vignette sources and never renders them.

Handling of exclusions and finding counts

spellcheck directly invokes spelling::spell_check_package(), providing:

  • Safe file exclusion: Excluded files matching glob patterns are temporarily staged out of the package root during analysis and restored unconditionally on exit (resolving gha#556).
  • Consistent exit codes: When misspellings are found, the step exits with code 1 under fail: 'true' or 0 under fail: 'false' (with GitHub Actions warning annotations for each finding), avoiding modulo-256 process exit code truncation (gha#556, gha#560).