Skip to content

fix: fall back for Mocha configuration, and say so - #156

Merged
adityankale190895 merged 1 commit into
DiffCI:mainfrom
tyza66:fix/142-mocharc-fallback-reasons
Nov 17, 2026
Merged

adityankale190895 merged 1 commit into
DiffCI:mainfrom
tyza66:fix/142-mocharc-fallback-reasons

Conversation

@tyza66

@tyza66 tyza66 commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

Fixes #142, second half — the split you asked for after #144 merged.

.mocharc.json fell back as an asset, and .mocharc.js was worse: it is code that nothing imports, so
the graph found no dependents and the plan was SELECTIVE with no tests at all. Both decide how the
suite runs, so a change has to fall back.

What changed

  • CONFIG_PATTERNS gains .mocharc(?:\.[^/]+)?, so every form Mocha reads is configuration: .mocharc,
    .mocharc.json, .mocharc.yml, .mocharc.js, .mocharc.cjs.
  • toolConfigurationSubject names them: Tool configuration changed: Mocha settings (.mocharc.json); full validation required.

Fixture (tests/repo/mocharc-config-fallback.test.ts): four files plus the extensionless .mocharc
in a real Mocha project — FULL, every test selected, nothing skipped, the named reason, no
Unknown changed file. One more case pins that a package's own packages/a/.mocharc.json gets the same
reason, since the pattern is name-anchored like the other configuration entries.

tests/repo/config-patterns.test.ts, release-files.json and the docs/using-diffci.md Fallback
reasons table move with it.

Validation: npm run typecheck and npm run audit:boundary (384 files) pass; npm test 1105 pass,
the 8 failures being the same Rust/Cargo and Python end-to-end tests main fails on this machine. No
CHANGELOG edit; signed off.

.tool-versions is not included: file-references.ts already treats it as implicitly loaded, so it
resolves by reference rather than through this reason path, and I did not want to change its behaviour
without your say-so. Happy to add it if you want it here.

Copilot AI balanced review requested due to automatic review settings November 17, 2026 00:54

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@adityankale190895

Copy link
Copy Markdown
Member

Thanks, this fixes a real silent miss: on main a change to .mocharc.js gives a SELECTIVE plan with no tests.

One change before merging: CONFIG_PATTERNS only matches at the repository root, so packages/a/.mocharc.js (and .cjs) should still select nothing. Your nested case uses .json, which already fell back as unknown. Could you add \.mocharc to NESTED_TEST_CONFIG in src/git/git-diff.ts, the way #117 handled jest and babel, and add a nested .mocharc.js fixture?

Also, text.spec.js imports shout from math.js, which doesn't export it.

This will need a rebase now that #155 is merged, since both change the same docs row. Leaving .tool-versions out is fine; it can be its own issue.

adityankale190895 added a commit that referenced this pull request Nov 17, 2026
…orts it

A change to .c8rc.js, ava.config.js, karma.conf.js or .mocharc.js reached
no test through the graph, so the plan was SELECTIVE with nothing selected,
no reason, and SAFE_TO_PROPOSE: a silent skip. CONFIG_PATTERNS only names
the common configurations, so #142 and #156 fixed them one at a time.

A JavaScript or TypeScript file with a configuration-style name
(*.config.*, *.conf.*, .*rc.js) anywhere, or any one at the repository
root, that no file imports and that reached no test now falls back with
"Code that no file imports changed: <path>; a tool may load it by name".
Declared inputs narrow it. An unused module under src/ still selects
nothing, and an imported *.config.* module is still planned through its
importers.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: adityankale190895 <[email protected]>
@adityankale190895

Copy link
Copy Markdown
Member

Update: you can skip the nested-case request. Following up on your .mocharc.js finding turned up a wider gap: any tool-loaded file that nothing imports, like karma.conf.js, .c8rc.js or ava.config.js, selected no tests. f2e6d81 on main now falls back for those, including a nested packages/a/.mocharc.js, so you don't need the NESTED_TEST_CONFIG change or the nested .js fixture.

This PR is still worth merging for the clearer "Mocha settings" reason. What's left: rebase onto main (the docs row conflicts with #155) and fix the shout import in text.spec.js. Thanks for finding this one.

A change to `.mocharc.json` fell back as an asset, and `.mocharc.js` was worse:
it is code nothing imports, so the graph found no dependents and the plan was
SELECTIVE with no tests at all. Both decide how the suite runs.

`.mocharc` and `.mocharc.*` are now configuration, and the reason names them:
`Tool configuration changed: Mocha settings (.mocharc.json); full validation
required`.

Fixes DiffCI#142

Signed-off-by: tyza66 <[email protected]>
@tyza66
tyza66 force-pushed the fix/142-mocharc-fallback-reasons branch from e500dad to f8a1bdf Compare November 17, 2026 10:19
@tyza66

tyza66 commented Nov 17, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto main and both fixes are in (f8a1bdf).

  • shout import. src/math.js now exports shout as well as add, so test/text.spec.js imports something that exists.
  • Rebase. The docs row conflicted with fix: name a tsconfig variant as TypeScript configuration instead of unknown #155; the merged row now reads .nvmrc, .node-version, .npmrc, .mocharc.*, tsconfig.base.json or tsconfig.test.json, with the new Code that no file imports changed row from f2e6d81 beside it.
  • Nested case. You said to skip it, so I did — no NESTED_TEST_CONFIG change. One thing fell out of f2e6d81 that I had to adjust: tests/repo/orphan-tool-config.test.ts listed .mocharc.cjs among the files that should get the orphan reason. A Mocha configuration is classified before that fallback now, so it gets Tool configuration changed: Mocha settings instead. I removed it from that list with a comment pointing at this PR's fixture, rather than leave the repo red. The other six entries in that list are unchanged and still pass.

npm run typecheck, npm run audit:boundary (403 files) and npm test are clean on the new head: 1146 pass, and the only two failures are the Cargo ones this machine has on main as well.

@adityankale190895

Copy link
Copy Markdown
Member

Thanks, reviewed f8a1bdf and it looks good.

  • Taking .mocharc.cjs out of the orphan list is the right call. A Mocha configuration should get the reason that names it, and your new fixture covers .cjs there, so nothing lost coverage.
  • The nested packages/a/.mocharc.json case comes out right too: toolConfigurationSubject matches on the basename, so a package's own Mocha file gets the same Mocha settings reason.
  • CI is green on every check, including both Windows jobs.

Nothing more needed from your side.

@adityankale190895
adityankale190895 merged commit 18b40b7 into DiffCI:main Nov 17, 2026
13 checks passed
@adityankale190895

Copy link
Copy Markdown
Member

Merged, thank you @tyza66. That's three merged PRs, and this one found more than it set out to: your .mocharc.js case is what turned up the wider gap fixed in f2e6d81, where any tool-loaded file that nothing imports selected no tests.

You're credited for #144, #155 and #156 in the README, on diffci.com/contributors, and next to the Tool configuration changed reasons in docs/using-diffci.md. The next release notes will thank you by name too.

If you'd like another one, .tool-versions (asdf/mise) is still unhandled: it falls back as an unknown file instead of naming the tool versions. #101 (how DiffCI compares to jest --changedSince, vitest related, nx affected and turbo) is also open. No pressure either way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Name the fallback reason for .nvmrc, .node-version, .npmrc and .mocharc changes

3 participants