Skip to content

Commit 5cb21bc

Browse files
committed
cleanup: simplify selective test system
- Remove run-selective-tests.sh (logic is inline in CI workflow) - Move CI/.github from infrastructure to ignored (doesn't affect tests) - Add more ignored patterns (e2e tests, electron-builder) - Fix verbose output capture in CI workflow - Minor comment improvements
1 parent 86deac2 commit 5cb21bc

File tree

6 files changed

+22
-156
lines changed

6 files changed

+22
-156
lines changed

.github/workflows/ci.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,21 +123,22 @@ jobs:
123123
if: github.event.inputs.test_filter == '' && steps.coverage-map-cache.outputs.cache-hit != ''
124124
id: select-tests
125125
run: |
126-
# Run selection script and capture output
127126
set +e
128127
SELECTED=$(bun scripts/selective-tests/select-affected-tests.ts \
129128
--map coverage-map.json \
130129
--base origin/${{ github.base_ref || 'main' }} \
131130
--head ${{ github.sha }} \
132131
--output jest \
133-
--verbose)
132+
--verbose 2>&1)
134133
EXIT_CODE=$?
135134
set -e
136135
137-
echo "exit_code=$EXIT_CODE" >> $GITHUB_OUTPUT
136+
# Extract just the test list (last line of output)
137+
TEST_LIST=$(echo "$SELECTED" | tail -1)
138138
139+
echo "exit_code=$EXIT_CODE" >> $GITHUB_OUTPUT
139140
if [[ $EXIT_CODE -eq 0 ]]; then
140-
echo "selected_tests=$SELECTED" >> $GITHUB_OUTPUT
141+
echo "selected_tests=$TEST_LIST" >> $GITHUB_OUTPUT
141142
echo "run_selective=true" >> $GITHUB_OUTPUT
142143
else
143144
echo "run_selective=false" >> $GITHUB_OUTPUT

scripts/selective-tests/README.md

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,9 @@ This system reduces CI time by running only the integration tests affected by co
2121

2222
## Files
2323

24-
- `types.ts` - Shared types and constants
24+
- `types.ts` - Shared types and infrastructure file patterns
2525
- `generate-coverage-map.ts` - Generates the coverage map by running tests with coverage
2626
- `select-affected-tests.ts` - Selects tests based on changed files
27-
- `run-selective-tests.sh` - CI wrapper script with fallback handling
2827

2928
## Usage
3029

@@ -86,14 +85,6 @@ These files trigger a full test run when changed (see `INFRASTRUCTURE_PATTERNS`
8685
- Service container: `src/node/services/serviceContainer.ts`
8786
- Shared types: `src/types/**`, `src/constants/**`
8887

89-
## Shadow Mode
90-
91-
For validation, run with `--shadow-mode` to log what would have been selected while still running all tests:
92-
93-
```bash
94-
./scripts/selective-tests/run-selective-tests.sh --shadow-mode
95-
```
96-
9788
## Debugging
9889

9990
Use `--verbose` for detailed logging:

scripts/selective-tests/generate-coverage-map.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import { createHash } from "crypto";
2020
import type { CoverageMap } from "./types";
2121
import { INFRASTRUCTURE_PATTERNS } from "./types";
2222

23+
// Directories and defaults
2324
const TESTS_DIR = "tests/integration";
2425
const COVERAGE_DIR = "coverage";
2526
const DEFAULT_OUTPUT = "coverage-map.json";

scripts/selective-tests/run-selective-tests.sh

Lines changed: 0 additions & 132 deletions
This file was deleted.

scripts/selective-tests/select-affected-tests.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,11 @@ const minimatch = require("minimatch") as (
3939
options?: { matchBase?: boolean }
4040
) => boolean;
4141

42+
// Defaults
4243
const DEFAULT_MAP_PATH = "coverage-map.json";
4344
const DEFAULT_BASE_REF = "origin/main";
4445
const DEFAULT_HEAD_REF = "HEAD";
45-
const DEFAULT_MAX_STALENESS_DAYS = 7;
46+
const DEFAULT_MAX_STALENESS_DAYS = 7; // Fallback if map older than this
4647

4748
interface Options {
4849
mapPath: string;
@@ -312,18 +313,27 @@ function selectAffectedTests(
312313
coverageMap.allTests.includes(f)
313314
);
314315

315-
// Non-source changes that we can ignore (docs, configs we don't care about, etc.)
316+
// Non-source changes that we can safely ignore
316317
const ignoredPatterns = [
318+
// Documentation
317319
"docs/**",
318320
"*.md",
319321
"*.mdx",
322+
// Editor/repo config
320323
".gitignore",
321324
".editorconfig",
322-
"LICENSE",
323325
".vscode/**",
326+
"LICENSE",
327+
// Storybook (has its own tests)
324328
"storybook/**",
325329
".storybook/**",
326330
"*.stories.tsx",
331+
// CI workflows (changes here don't affect test results)
332+
".github/**",
333+
// E2E tests (separate from integration tests)
334+
"tests/e2e/**",
335+
// Build artifacts
336+
"electron-builder.yml",
327337
];
328338

329339
const ignoredChanges = changedFiles.filter((f) =>

scripts/selective-tests/types.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@ export interface AffectedTestsResult {
3535
unmappedFiles: string[];
3636
}
3737

38-
/** Exit codes for scripts */
38+
/** Exit codes for scripts (2 = fallback so CI can distinguish from errors) */
3939
export const EXIT_CODES = {
4040
SUCCESS: 0,
41-
FALLBACK_TRIGGERED: 2,
4241
ERROR: 1,
42+
FALLBACK_TRIGGERED: 2,
4343
} as const;
4444

4545
/** Infrastructure files that should trigger all tests when changed */
@@ -66,11 +66,6 @@ export const INFRASTRUCTURE_PATTERNS = [
6666

6767
// Build configuration
6868
"vite.*.ts",
69-
"electron-builder.yml",
70-
71-
// CI configuration
72-
".github/workflows/**",
73-
".github/actions/**",
7469

7570
// This selective test system itself
7671
"scripts/selective-tests/**",

0 commit comments

Comments
 (0)