Skip to content

fix(git-diff): run every test when only babel.config changes - #108

Merged
adityankale190895 merged 3 commits into
DiffCI:mainfrom
sarankumar1325:fix/babel-config-change-full-run
Nov 11, 2026
Merged

adityankale190895 merged 3 commits into
DiffCI:mainfrom
sarankumar1325:fix/babel-config-change-full-run

Conversation

@sarankumar1325

@sarankumar1325 sarankumar1325 commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #99

What DiffCI did before this PR

I built the fixture the issue asks for: a Jest project that uses babel-jest, with two source files, two tests and a Babel config. The head commit changes only the Babel config. Then I ran analyzeCheckout on it.

Changed file Before After
.babelrc FULL, "Unknown changed file: .babelrc" unchanged (FULL)
babel.config.js / .cjs / .mjs / .ts SELECTIVE, 0 tests selected, both tests skipped FULL, "Configuration file(s) changed; full validation required: babel.config.js"
babel.config.json FULL, "Unknown changed file" FULL (config reason added)
.babelrc.js / .cjs / .mjs SELECTIVE, 0 tests selected FULL (config reason)

The babel.config.{js,cjs,mjs,ts} and .babelrc.{js,cjs,mjs} cases were not safe. babel-jest transforms every test with that config, but the file is a code file that nothing imports. So it was classified as source with no dependents, and the plan skipped every test with no fallback reason. .babelrc was safe, but only through the generic unknown-file fallback.

Fix

babel.config.* is now configuration, like jest.config.*:

  • CONFIG_PATTERNS in src/git/git-diff.ts gets /^(?:babel\.config\.|\.babelrc)/, so configChanged triggers the existing CONFIG_GLOBAL full fallback.
  • isConfigFile in src/repo/impact.ts classifies babel.config* and .babelrc* as config instead of source.

.babelrc.* was added in 3f5a6dc after the Codex review.

babel.config was already listed as implicitly loaded in file-references.ts, so reference resolution was skipped. But nothing turned that into a fallback for code-file extensions.

Tests

  • New tests/repo/babel-config-change.test.ts. It builds a temporary git repository for each case and runs analyzeCheckout. It checks that a change to only babel.config.{js,cjs,mjs,ts}, .babelrc.{js,cjs,mjs,json} or .babelrc gives mode FULL, fallbackRequired, both tests selected, nothing skipped, and a fallback reason that names the file. Without the source change, the babel.config.* and .babelrc.{js,cjs,mjs} cases fail. The .babelrc and .babelrc.json cases pass either way.
  • tests/repo/config-patterns.test.ts: added the babel.config.js example for the new entry.
  • Registered the new test in release-files.json.

npm test: 909 passed. npm run typecheck is clean, and so are npm run build and npm run audit:boundary.

Not covered: a babel.config.* in a subdirectory. CONFIG_PATTERNS matches only at the root, the same as jest.config.*.

babel-jest transforms every test file with babel.config.*, but a .js,
.cjs, .mjs or .ts babel.config is a code file that nothing imports, so a
change to it alone was classified as source with no dependents and the
plan was SELECTIVE with zero tests. Treat babel.config.* as configuration,
like jest.config.*, so it falls back to a full run.

Adds a Jest + babel-jest fixture that changes only babel.config.* (four
extensions) or only .babelrc and asserts a full run.

Fixes DiffCI#99

Signed-off-by: sarankumar1325 <[email protected]>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-11T08:06:50.981389Z cf44802 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: cf448027a2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/git/git-diff.ts Outdated
/^jest\.config\./,
// babel-jest transforms every test file with it; without this a .js/.ts babel.config was classified as
// source with no importers and selected no tests (2026-11-11, #99).
/^babel\.config\./,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Add .babelrc.* variants to the global fallback

When a Jest project uses a JavaScript-style Babel config such as .babelrc.js or .babelrc.cjs and only that file changes, this pattern still misses it. isConfigFile likewise recognizes only babel.config*, so the file remains source code and an unimported config can produce a selective plan with no tests selected or fallback required, even though Babel applies it while transforming tests. The existing .babelrc.* implicit-load handling in file-references.ts confirms these files are treated as runtime-loaded configs; include them in the global config handling too.

Useful? React with 👍 / 👎.

@adityankale190895

adityankale190895 commented Nov 11, 2026 •

Copy link
Copy Markdown
Member

Thanks @sarankumar1325, this is a real fix: the before/after table makes the unsafe babel.config.js case very clear. #109 and #110 are merged.

One thing before this one lands: the Codex comment above is right. .babelrc.js (and .cjs/.mjs) at the root is a code file that nothing imports, so by the same reasoning as your table it is still classified as source with no dependents, and a change to only that file runs zero tests. Could you add:

  • /^\.babelrc/ to CONFIG_PATTERNS (with a config-patterns.test.ts example), and
  • .babelrc to isConfigFile in impact.ts,

plus .babelrc.js, .babelrc.cjs and .babelrc.mjs cases in babel-config-change.test.ts? .babelrc and .babelrc.json would then fall back with the config reason too, instead of "Unknown changed file".

Separately, and not for this PR: a babel.config.js (or jest.config.js) in a subdirectory looks like it gets no fallback either, since the config category only records evidence and CONFIG_PATTERNS is root-anchored. That's tracked in #117.

.babelrc.js, .babelrc.cjs and .babelrc.mjs are code files that nothing
imports, so a change to only one of them still selected no tests. The
config pattern and isConfigFile now cover every .babelrc form.

Signed-off-by: sarankumar1325 <[email protected]>
@adityankale190895
adityankale190895 merged commit 843e07a into DiffCI:main Nov 11, 2026
11 checks passed
adityankale190895 added a commit that referenced this pull request Nov 11, 2026
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: adityankale190895 <[email protected]>
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.

Fixture: change only babel.config.js or .babelrc in a Jest project

2 participants