@@ -173,12 +173,128 @@ jobs:
173173 path : dist/
174174 retention-days : 1
175175
176- test :
177- name : Test
178- timeout-minutes : 15
176+ # Detect which packages changed (with dependency awareness)
177+ detect-changes :
178+ name : Detect Changes
179+ runs-on : ubuntu-latest
180+ outputs :
181+ core : ${{ steps.filter.outputs.core }}
182+ cli : ${{ steps.filter.outputs.cli }}
183+ mcp : ${{ steps.filter.outputs.mcp }}
184+ root : ${{ steps.filter.outputs.root }}
185+ steps :
186+ - uses : actions/checkout@v4
187+
188+ - uses : dorny/paths-filter@v3
189+ id : filter
190+ with :
191+ filters : |
192+ core:
193+ - 'packages/tm-core/**'
194+ - 'package-lock.json'
195+ - 'tsconfig.json'
196+ - 'vitest.workspace.ts'
197+ cli:
198+ - 'apps/cli/**'
199+ - 'packages/tm-core/**'
200+ - 'package-lock.json'
201+ mcp:
202+ - 'apps/mcp/**'
203+ - 'packages/tm-core/**'
204+ - 'package-lock.json'
205+ root:
206+ - 'src/**'
207+ - 'tests/**'
208+ - 'package-lock.json'
209+ - 'jest.config.*'
210+
211+ # Test @tm/core (unit + integration)
212+ test-core :
213+ name : Test @tm/core
214+ timeout-minutes : 10
215+ runs-on : ubuntu-latest
216+ needs : [install, detect-changes, build]
217+ if : needs.detect-changes.outputs.core == 'true'
218+ steps :
219+ - uses : actions/checkout@v4
220+
221+ - uses : actions/setup-node@v4
222+ with :
223+ node-version : ${{ env.NODE_VERSION }}
224+
225+ - name : Restore node_modules cache
226+ id : cache-node-modules
227+ uses : actions/cache@v4
228+ with :
229+ path : node_modules
230+ key : node-modules-${{ runner.os }}-node${{ env.NODE_VERSION }}-${{ hashFiles('package-lock.json') }}
231+
232+ - name : Install dependencies
233+ run : npm ci
234+ if : steps.cache-node-modules.outputs.cache-hit != 'true'
235+ timeout-minutes : 5
236+
237+ - name : Unit Tests
238+ run : npm run test:unit -w @tm/core
239+ env :
240+ NODE_ENV : test
241+ CI : true
242+ FORCE_COLOR : 1
243+
244+ - name : Integration Tests
245+ run : npm run test:integration -w @tm/core
246+ env :
247+ NODE_ENV : test
248+ CI : true
249+ FORCE_COLOR : 1
250+
251+ # Test @tm/cli (unit + integration)
252+ test-cli :
253+ name : Test @tm/cli
254+ timeout-minutes : 10
255+ runs-on : ubuntu-latest
256+ needs : [install, detect-changes, build]
257+ if : needs.detect-changes.outputs.cli == 'true'
258+ steps :
259+ - uses : actions/checkout@v4
260+
261+ - uses : actions/setup-node@v4
262+ with :
263+ node-version : ${{ env.NODE_VERSION }}
264+
265+ - name : Restore node_modules cache
266+ id : cache-node-modules
267+ uses : actions/cache@v4
268+ with :
269+ path : node_modules
270+ key : node-modules-${{ runner.os }}-node${{ env.NODE_VERSION }}-${{ hashFiles('package-lock.json') }}
271+
272+ - name : Install dependencies
273+ run : npm ci
274+ if : steps.cache-node-modules.outputs.cache-hit != 'true'
275+ timeout-minutes : 5
276+
277+ - name : Unit Tests
278+ run : npm run test:unit -w @tm/cli
279+ env :
280+ NODE_ENV : test
281+ CI : true
282+ FORCE_COLOR : 1
283+
284+ - name : Integration Tests
285+ run : npm run test:integration -w @tm/cli
286+ env :
287+ NODE_ENV : test
288+ CI : true
289+ FORCE_COLOR : 1
290+
291+ # Test @tm/mcp (unit + integration)
292+ test-mcp :
293+ name : Test @tm/mcp
294+ timeout-minutes : 10
179295 runs-on : ubuntu-latest
180- needs : [format-check, typecheck , build, changeset-validation ]
181- if : always() && !cancelled() && !contains( needs.*.result, 'failure')
296+ needs : [install, detect-changes , build]
297+ if : needs.detect-changes.outputs.mcp == 'true'
182298 steps :
183299 - uses : actions/checkout@v4
184300
@@ -194,8 +310,48 @@ jobs:
194310 key : node-modules-${{ runner.os }}-node${{ env.NODE_VERSION }}-${{ hashFiles('package-lock.json') }}
195311
196312 - name : Install dependencies
313+ run : npm ci
197314 if : steps.cache-node-modules.outputs.cache-hit != 'true'
315+ timeout-minutes : 5
316+
317+ - name : Unit Tests
318+ run : npm run test:unit -w @tm/mcp
319+ env :
320+ NODE_ENV : test
321+ CI : true
322+ FORCE_COLOR : 1
323+
324+ - name : Integration Tests
325+ run : npm run test:integration -w @tm/mcp
326+ env :
327+ NODE_ENV : test
328+ CI : true
329+ FORCE_COLOR : 1
330+
331+ # Test root package (legacy Jest tests)
332+ test-root :
333+ name : Test Root
334+ timeout-minutes : 15
335+ runs-on : ubuntu-latest
336+ needs : [format-check, typecheck, build, changeset-validation, detect-changes]
337+ if : always() && !cancelled() && !contains(needs.*.result, 'failure') && needs.detect-changes.outputs.root == 'true'
338+ steps :
339+ - uses : actions/checkout@v4
340+
341+ - uses : actions/setup-node@v4
342+ with :
343+ node-version : ${{ env.NODE_VERSION }}
344+
345+ - name : Restore node_modules cache
346+ id : cache-node-modules
347+ uses : actions/cache@v4
348+ with :
349+ path : node_modules
350+ key : node-modules-${{ runner.os }}-node${{ env.NODE_VERSION }}-${{ hashFiles('package-lock.json') }}
351+
352+ - name : Install dependencies
198353 run : npm ci
354+ if : steps.cache-node-modules.outputs.cache-hit != 'true'
199355 timeout-minutes : 5
200356
201357 - name : Download build artifacts
0 commit comments