mirror of
https://github.com/mastra-ai/mastra.git
synced 2026-11-17 08:44:46 +00:00
## Summary CI picks which tests to run on a PR by building a module graph of the repo and walking it backwards from the changed files. That graph is built by madge, which resolves imports through enhanced-resolve using `scripts/madge.webpack.config.cjs`. That config had no `extensionAlias`. Packages written for TypeScript's NodeNext resolution import their own relative files as `'../tools.js'` even though the file on disk is `../tools.ts` — and without `extensionAlias` the resolver looks for a literal `.js` file, finds nothing, and silently drops the edge. `mastracode/sdk` is written entirely in that style (212 of 256 source files), so its portion of the graph was essentially empty and any PR touching SDK source was told no tests were affected. The full-suite jobs did not catch this either, so those changes shipped with no test signal at all. Two changes: teach the resolver to map `.js`/`.mjs`/`.cjs` specifiers onto their TypeScript sources, and let madge traverse `.mts`/`.cts` files, which this package uses for its child-process fixtures. Fixes #24218 ## Test plan Detector output for the same inputs, before and after: | changed file | before | after | | --- | --- | --- | | `mastracode/sdk/src/agent-connections/tools.ts` | 0 tests | 20 tests, including its own colocated `__tests__/tools.test.ts` | | `mastracode/sdk/src/index.ts` | 0 tests | 19 tests | | `packages/core/src/agent/index.ts` (control) | 1229 tests | 1470 tests | The control case was already working but was also under-selecting, since workspace packages consumed by core use the same import style; it now resolves those edges too. Graph is denser, so selection is slightly slower — 21.4s to 23.5s for the core case, about 10%. That is well worth the correctness. Note: registering the SDK's own vitest project is separate work, as the issue describes — `vitest.config.ts` points at a `mastracode/vitest.config.ts` that does not exist, and the SDK suite is currently red on main. This PR only fixes the detector. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## ELI5 This PR helps the test selector follow SDK imports correctly. It ensures source changes select the tests that depend on them. ## Changes - Added Madge aliases for `.js`, `.mjs`, and `.cjs` imports. - Added `.mts` and `.cts` files to Madge traversal. - Added a NodeNext import-resolution test. - Added a guard for missing colocated tests. - Added two retries for failed TUI E2E shard tests. ## Reported results - SDK tool changes select 20 tests instead of none. - SDK index changes select 19 tests instead of none. - A core control case selects 1,470 tests, up from 1,229. - Runtime increased from 21.4 to 23.5 seconds. - SDK Vitest project registration remains out of scope. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: tyler-mastra[bot] <331730378+tyler-mastra[bot]@users.noreply.github.com> Co-authored-by: Tyler Barnes <tylerdbarnes@gmail.com>
38 lines
1.2 KiB
38 lines
1.2 KiB