Affected Tests in CI
codegraph affected traces import dependencies transitively to find which test files are affected by a set of changed source files — so CI can run only the relevant tests.
codegraph affected src/utils.ts src/api.ts # pass files as argumentsgit diff --name-only | codegraph affected --stdin # pipe from git diffcodegraph affected src/auth.ts --filter "e2e/*" # custom test-file patternOptions
Section titled “Options”| Option | Description | Default |
|---|---|---|
--stdin | Read the file list from stdin | false |
-d, --depth <n> | Max dependency traversal depth | 5 |
-f, --filter <glob> | Custom glob to identify test files | auto-detect |
-j, --json | Output as JSON | false |
-q, --quiet | Output file paths only | false |
CI / hook example
Section titled “CI / hook example”#!/usr/bin/env bashAFFECTED=$(git diff --name-only HEAD | codegraph affected --stdin --quiet)if [ -n "$AFFECTED" ]; then npx vitest run $AFFECTEDfi