Files
mermaid/scripts/run-e2e-scoped.ts
Ashish Jain bea2aeb552 chore: skip e2e tests for docs-only and ignorable-file PRs
Add IGNORABLE_PREFIXES and IGNORABLE_SUFFIXES to the e2e scope detection
script so that PRs touching only documentation, changesets, AI config, or
other non-rendering files skip e2e entirely instead of triggering the full
5-container Cypress suite.

Changes:
- Add SKIP sentinel return value to detectScope() for ignorable-only PRs
- Add ignorable file detection (docs, changesets, .claude/, assistant/, etc.)
- Update e2e.yml workflow to skip the e2e job when SKIP is returned
- Update local runner (run-e2e-scoped.ts) to handle SKIP
- Upgrade @argos-ci/cypress to ^6.3.3 for ARGOS_SUBSET support
- Add 9 new test cases covering docs-only, mixed, and skip scenarios
2026-05-04 12:28:26 +02:00

49 lines
1.6 KiB
TypeScript

/**
* Local development runner for scoped e2e tests.
*
* Detects which diagrams changed (comparing HEAD against a base ref) and
* invokes Cypress with only the matching spec files. Falls back to the full
* suite when shared code is touched.
*
* The dev server must already be running (started by start-server-and-test).
*
* Usage via pnpm:
* pnpm e2e:scope # base ref defaults to 'develop'
* E2E_BASE_REF=main pnpm e2e:scope # override base ref
*/
import { execSync, spawn } from 'child_process';
import { detectScope, SKIP } from './e2e-diagram-scope.mjs';
const base = process.argv[2] ?? process.env.E2E_BASE_REF ?? 'develop';
let changedFiles: string[] = [];
try {
const output = execSync(`git diff --name-only ${base} HEAD`, { encoding: 'utf8' });
changedFiles = output.split('\n').filter(Boolean);
} catch {
/* eslint-disable no-console */
console.warn(`[e2e:scope] Could not diff against "${base}" — running full suite.`);
}
const spec = detectScope(changedFiles);
if (spec === SKIP) {
/* eslint-disable no-console */
console.log('[e2e:scope] Only docs/ignorable files changed — nothing to test.');
process.exit(0);
}
const cypressArgs = ['run'];
if (spec) {
/* eslint-disable no-console */
console.log(`[e2e:scope] Scoped run:\n ${spec.split(',').join('\n ')}`);
cypressArgs.push('--spec', spec);
} else {
/* eslint-disable no-console */
console.log('[e2e:scope] Running full e2e suite (shared code changed or scope undetermined).');
}
const child = spawn('cypress', cypressArgs, { stdio: 'inherit' });
child.on('exit', (code) => process.exit(code ?? 0));