Skip to content

Commit 26b40a8

Browse files
chore: improve tests
1 parent f9cbe0d commit 26b40a8

File tree

2 files changed

+163
-7
lines changed

2 files changed

+163
-7
lines changed

.github/workflows/ci.yml

Lines changed: 161 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
"turbo:dev": "turbo dev",
2121
"turbo:build": "turbo build",
2222
"turbo:typecheck": "turbo typecheck",
23-
"turbo:test": "turbo test",
23+
"turbo:test": "turbo test:unit && turbo test:integration --concurrency=1",
2424
"turbo:test:unit": "turbo test:unit",
25-
"turbo:test:integration": "turbo test:integration",
25+
"turbo:test:integration": "turbo test:integration --concurrency=1",
2626
"build:build-config": "npm run build -w @tm/build-config",
2727
"test": "cross-env NODE_ENV=test node --experimental-vm-modules node_modules/.bin/jest",
2828
"test:unit": "node --experimental-vm-modules node_modules/.bin/jest --testPathPattern=unit",

0 commit comments

Comments
 (0)