From b314cf353ed38ea16919ba4fa0029dfc5cf66c0b Mon Sep 17 00:00:00 2001 From: Tam Nhu Tran Date: Wed, 22 Apr 2026 15:12:07 -0400 Subject: [PATCH] fix(ci): keep release workflows on full test coverage --- .github/workflows/dev-release.yml | 5 ++- .github/workflows/release.yml | 5 ++- package.json | 2 +- scripts/run-test-bucket.js | 74 ++++++++++++++++++++++--------- 4 files changed, 61 insertions(+), 25 deletions(-) diff --git a/.github/workflows/dev-release.yml b/.github/workflows/dev-release.yml index 55e23f25..d3fb654c 100644 --- a/.github/workflows/dev-release.yml +++ b/.github/workflows/dev-release.yml @@ -47,9 +47,12 @@ jobs: - name: Build run: bun run build:all - - name: Validate (typecheck + lint + format + tests) + - name: Validate fast gate run: bun run validate + - name: Test slow bucket + run: bun run test:slow + - name: Test CLI e2e env: CCS_E2E_SKIP_BUILD: '1' diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 466394ec..db140f7b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -42,9 +42,12 @@ jobs: - name: Build package run: bun run build:all - - name: Validate (typecheck + lint + format + tests) + - name: Validate fast gate run: bun run validate + - name: Test slow bucket + run: bun run test:slow + - name: Test CLI e2e env: CCS_E2E_SKIP_BUILD: '1' diff --git a/package.json b/package.json index 9ef64f27..c0a95eab 100644 --- a/package.json +++ b/package.json @@ -77,7 +77,7 @@ "test:ci": "bun run test:all", "test:fast": "node scripts/run-test-bucket.js fast", "test:slow": "node scripts/run-test-bucket.js slow", - "test:all": "bun run test:fast && bun run test:slow", + "test:all": "node scripts/run-test-bucket.js all", "test:unit": "bun test tests/unit", "test:npm": "bun test tests/npm/", "test:native": "bash tests/native/unix/edge-cases.sh", diff --git a/scripts/run-test-bucket.js b/scripts/run-test-bucket.js index f17ed2f7..5c02ec75 100644 --- a/scripts/run-test-bucket.js +++ b/scripts/run-test-bucket.js @@ -23,8 +23,8 @@ const slowTests = [ 'tests/unit/web-server/websearch-routes.test.ts', ]; -if (bucket !== 'fast' && bucket !== 'slow') { - console.error('[X] Usage: node scripts/run-test-bucket.js '); +if (!['fast', 'slow', 'all'].includes(bucket)) { + console.error('[X] Usage: node scripts/run-test-bucket.js '); process.exit(1); } @@ -66,36 +66,66 @@ const forceSlow = discovered.filter((file) => { return readsBuiltDist(file); }); const slowSet = new Set([...slowTests, ...forceSlow]); -const selected = - bucket === 'slow' + +function selectBucket(name) { + return name === 'slow' ? [...slowSet].sort() : discovered.filter((file) => !slowSet.has(file)); - -if (selected.length === 0) { - console.error(`[X] No tests matched the '${bucket}' bucket.`); - process.exit(1); } -if (bucket === 'slow' && !fs.existsSync(path.join(rootDir, 'dist', 'ccs.js'))) { +function ensureBuildForSlowBucket() { + if (fs.existsSync(path.join(rootDir, 'dist', 'ccs.js'))) { + return 0; + } + const build = spawnSync('bun', ['run', 'build'], { cwd: rootDir, stdio: 'inherit', shell: process.platform === 'win32', }); - if (build.status !== 0) { - process.exit(build.status ?? 1); - } + return build.status ?? 1; } -const result = spawnSync( - 'bun', - ['test', '--max-concurrency=1', ...selected], - { - cwd: rootDir, - stdio: 'inherit', - shell: process.platform === 'win32', - }, -); +function runBucket(name) { + const selected = selectBucket(name); -process.exit(result.status ?? 1); + if (selected.length === 0) { + console.error(`[X] No tests matched the '${name}' bucket.`); + return 1; + } + + if (name === 'slow') { + const buildStatus = ensureBuildForSlowBucket(); + if (buildStatus !== 0) { + return buildStatus; + } + } + + const result = spawnSync( + 'bun', + ['test', '--max-concurrency=1', ...selected], + { + cwd: rootDir, + stdio: 'inherit', + shell: process.platform === 'win32', + }, + ); + + return result.status ?? 1; +} + +if (bucket === 'all') { + let exitCode = 0; + + for (const name of ['fast', 'slow']) { + const status = runBucket(name); + if (status !== 0) { + exitCode = status; + } + } + + process.exit(exitCode); +} + +process.exit(runBucket(bucket));