Skip to content

fix: use org-repo cspell config for spell check in check-pr-title#83

Merged
shenxianpeng merged 2 commits into
mainfrom
bugfix/cspell-use-org-config
Jun 11, 2026
Merged

fix: use org-repo cspell config for spell check in check-pr-title#83
shenxianpeng merged 2 commits into
mainfrom
bugfix/cspell-use-org-config

Conversation

@shenxianpeng

@shenxianpeng shenxianpeng commented Jun 10, 2026

Copy link
Copy Markdown
Member

Problem

The check-pr-title job's spell check step was running with working-directory: project-repo, so cspell-cli looked for cspell.config.yml in the calling repo (e.g., cpp-linter-hooks). Most repos in the org don't have their own cspell config, causing false positives where words already defined in the org-repo's cspell.config.yml (like setuptools, pyproject) were flagged as unknown.

Fixes #76.

Solution

Pass --config pointing to the org-repo's cspell.config.yml, matching the pattern already used by the committed step (which uses --config "${COMMITTED_CONFIG}").

Before

- name: spell check
  working-directory: project-repo
  env:
    PR_TITLE: "${{ steps.get-title.outputs.title }}"
  run: echo "${PR_TITLE}" | npx cspell-cli lint stdin

After

- name: spell check
  env:
    PR_TITLE: "${{ steps.get-title.outputs.title }}"
    CSPELL_CONFIG: ${{ github.workspace }}/org-repo/cspell.config.yml
  run: echo "${PR_TITLE}" | npx cspell-cli lint --config "${CSPELL_CONFIG}" stdin

CSpell supports --config flag

CSpell CLI has a -c, --config option to specify a configuration file to use, so no need to replace it with another tool.

Summary by CodeRabbit

  • Chores
    • Enhanced the spell check workflow in pull request validation to support flexible configuration file selection, improving CI/CD reliability and configuration management across projects.

The spell check step was running in the project-repo working directory,
so cspell would look for cspell.config.yml in the calling repo (which
often doesn't have one). This caused false positives where words already
defined in the org-repo's cspell.config.yml (like 'setuptools',
'pyproject') were flagged as unknown.

Now pass --config pointing to the org-repo's cspell.config.yml, matching
the pattern already used by the committed step with committed.toml.

Fixes #76
@coderabbitai

coderabbitai Bot commented Jun 10, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

The check-pr-title workflow's spell check step now dynamically selects a cspell configuration file at runtime, preferring a project-specific config and falling back to an organization-wide config if the project config does not exist.

Changes

Spell check configuration fallback

Layer / File(s) Summary
Spell check configuration selection
.github/workflows/pre-commit.yml
The spell check step sets a CSPELL_CONFIG variable based on whether project-repo/cspell.config.yml exists, otherwise defaults to org-repo/cspell.config.yml, and runs npx cspell-cli lint --config with the selected configuration file.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Possibly related PRs

  • cpp-linter/.github#51: Updates the same check-pr-title workflow spell check logic in .github/workflows/pre-commit.yml.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: the spell check step now uses the org-repo cspell config as a fallback when project-repo config is missing, which directly addresses fixing the issue.
Linked Issues check ✅ Passed The PR implements the solution to issue #76: dynamic selection of cspell configuration (project-repo if present, otherwise org-repo) prevents false positives from missing org-level dictionary words.
Out of Scope Changes check ✅ Passed All changes are directly scoped to fixing the spell-check step in the check-pr-title workflow; no unrelated modifications are present.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch bugfix/cspell-use-org-config

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@shenxianpeng shenxianpeng requested a review from 2bndy5 June 10, 2026 18:06
@shenxianpeng shenxianpeng added the bug Something isn't working label Jun 10, 2026
@shenxianpeng

Copy link
Copy Markdown
Member Author

Hopefully this change will work

@2bndy5

2bndy5 commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

It should work, but I don't want this.

  • The misspellings are different for each project.
  • The conventional commit patterns are not different for each project.

Keeping the list of misspellings in the org repo

  1. does not follow the best practice called "separation of concerns".
  2. will lead to a rediculously long list.
  3. can cause confusion if the pr-title is checked with the org's cspell config and the rest of the project uses the project's cspell config.

The pre-commit workflow is the only reusable workflow that cpp-linter-rs is still using. If you merge this, then I'll have to switch to a project-specific copy.

@2bndy5

2bndy5 commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

BTW, I don't really care if a dependency name causes a spelling error in the PR title. I've been merging those dependabot PRs without adding the dep name to the cspell config's list.

I added the "check PR title" so we could prevent misspellings in the release notes and change logs. But I also added the change logs to cspell's list of ignored files. Only the cpp-linter-rs keeps proper change logs because it is deploying 4 packages from 1 repo.

@shenxianpeng

Copy link
Copy Markdown
Member Author

It should work, but I don't want this.

  • The misspellings are different for each project.
  • The conventional commit patterns are not different for each project.

Keeping the list of misspellings in the org repo

  1. does not follow the best practice called "separation of concerns".
  2. will lead to a rediculously long list.
  3. can cause confusion if the pr-title is checked with the org's cspell config and the rest of the project uses the project's cspell config.

The pre-commit workflow is the only reusable workflow that cpp-linter-rs is still using. If you merge this, then I'll have to switch to a project-specific copy.

I see. I was just do not introduce cspell.config.yml to the project, so want to maitain it here. If so, I am good to leave it for now.

@2bndy5

2bndy5 commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

That's a lot of effort to avoid creating 1 file. If you want, we can add an input option to skip the spell-check in the pre-commit workflow.

@shenxianpeng

shenxianpeng commented Jun 11, 2026

Copy link
Copy Markdown
Member Author

Spell-check in the pre-commit is useful. If some input or condition can point to the cspell.config.yml here(org-level), that would be great. (by default it sitll point to project level cspell.config.yml)

@shenxianpeng

Copy link
Copy Markdown
Member Author

Spell-check in the pre-commit is useful. If some input or condition can point to the cspell.config.yml here(org-level), that would be great. (by default it sitll point to project level cspell.config.yml)

How about

          - name: spell check                                                                                                            
            env:                                                                                                                         
              PR_TITLE: "${{ steps.get-title.outputs.title }}"                                                                           
   -          CSPELL_CONFIG: ${{ github.workspace }}/org-repo/cspell.config.yml                                                          
   -        run: echo "${PR_TITLE}" | npx cspell-cli lint --config "${CSPELL_CONFIG}" stdin                                              
   +        run: |                                                                                                                       
   +          if [ -f project-repo/cspell.config.yml ]; then                                                                             
   +            CSPELL_CONFIG="project-repo/cspell.config.yml"                                                                           
   +          else                                                                                                                       
   +            CSPELL_CONFIG="org-repo/cspell.config.yml"                                                                               
   +          fi                                                                                                                         
   +          echo "${PR_TITLE}" | npx cspell-cli lint --config "${CSPELL_CONFIG}" stdin                                                 

@2bndy5

2bndy5 commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Ah, that would be more agreeable, yes.

If project-repo/cspell.config.yml exists, use it for spell check.
Otherwise, fall back to org-repo/cspell.config.yml.

This addresses the concern that each project should be able to
maintain its own cspell dictionary rather than accumulating all
words in the org-level config.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
.github/workflows/pre-commit.yml (1)

88-93: 💤 Low value

Consider defensive validation for missing org config.

The conditional correctly prefers project config and falls back to org config. If the org config is also missing, cspell-cli will fail with a config-not-found error. While unlikely (the org repo is under maintainer control), adding an explicit check could provide a clearer failure message.

🛡️ Optional defensive check
 run: |
   if [ -f project-repo/cspell.config.yml ]; then
     CSPELL_CONFIG="project-repo/cspell.config.yml"
   else
     CSPELL_CONFIG="org-repo/cspell.config.yml"
   fi
+  if [ ! -f "${CSPELL_CONFIG}" ]; then
+    echo "Error: cspell config not found at ${CSPELL_CONFIG}"
+    exit 1
+  fi
   echo "${PR_TITLE}" | npx cspell-cli lint --config "${CSPELL_CONFIG}" stdin
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/pre-commit.yml around lines 88 - 93, The current if/else
that sets CSPELL_CONFIG prefers project-repo/cspell.config.yml then
org-repo/cspell.config.yml but does not handle the case where neither exists;
update the block that sets CSPELL_CONFIG to check both locations and, if both
are missing, emit a clear error message (e.g. via echo) and exit non‑zero so the
workflow fails with a readable message; ensure the variable CSPELL_CONFIG is
only used after this validation so cspell-cli won’t receive a missing-config
path.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In @.github/workflows/pre-commit.yml:
- Around line 88-93: The current if/else that sets CSPELL_CONFIG prefers
project-repo/cspell.config.yml then org-repo/cspell.config.yml but does not
handle the case where neither exists; update the block that sets CSPELL_CONFIG
to check both locations and, if both are missing, emit a clear error message
(e.g. via echo) and exit non‑zero so the workflow fails with a readable message;
ensure the variable CSPELL_CONFIG is only used after this validation so
cspell-cli won’t receive a missing-config path.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 02de58bf-0ac9-442a-97f9-f136c08bce45

📥 Commits

Reviewing files that changed from the base of the PR and between fa07a4e and 9a0b515.

📒 Files selected for processing (1)
  • .github/workflows/pre-commit.yml

@2bndy5 2bndy5 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm glad we could reach a compromise here. 🎉 for teamwork!

@shenxianpeng shenxianpeng merged commit 40e4d6c into main Jun 11, 2026
6 checks passed
@shenxianpeng shenxianpeng deleted the bugfix/cspell-use-org-config branch June 11, 2026 21:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Check title failed but the unknown works already in cspell.config.yml

2 participants