mirror of
https://github.com/n8n-io/n8n.git
synced 2026-05-31 16:57:08 +02:00
Some checks failed
CI: Master (Build, Test, Lint) / Build for Github Cache (push) Waiting to run
CI: Master (Build, Test, Lint) / Unit tests (22.22.3) (push) Waiting to run
CI: Master (Build, Test, Lint) / Unit tests (24.15.0) (push) Waiting to run
CI: Master (Build, Test, Lint) / Lint (push) Waiting to run
CI: Master (Build, Test, Lint) / Performance (push) Waiting to run
CI: Master (Build, Test, Lint) / Notify Slack on failure (push) Blocked by required conditions
Util: Update Node Popularity / update-popularity (push) Has been cancelled
Test: E2E Coverage Weekly / Prepare Docker (coverage) (push) Has been cancelled
Util: Update Node Popularity / approve-and-automerge (push) Has been cancelled
Test: E2E Coverage Weekly / E2E (coverage) (push) Has been cancelled
Test: E2E Coverage Weekly / Aggregate Coverage (push) Has been cancelled
Release: Schedule Patch Release PRs / Create patch release PR (${{ matrix.track }}) (beta) (push) Has been cancelled
Release: Schedule Patch Release PRs / Create patch release PR (${{ matrix.track }}) (stable) (push) Has been cancelled
Release: Schedule Patch Release PRs / Create patch release PR (${{ matrix.track }}) (v1) (push) Has been cancelled
Co-authored-by: n8n-cat-bot[bot] <n8n-cat-bot[bot]@users.noreply.github.com> Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com> Co-authored-by: Declan Carroll <declan@n8n.io>
41 lines
1.4 KiB
JavaScript
41 lines
1.4 KiB
JavaScript
#!/usr/bin/env node
|
|
import { execSync, spawnSync } from 'node:child_process';
|
|
|
|
const mergeBase = process.env.MERGE_BASE;
|
|
const cwd = execSync('git rev-parse --show-toplevel', { encoding: 'utf-8' }).trim();
|
|
const log = (m) => console.log(`[test-changed] ${m}`);
|
|
const diff = (range, paths = '') =>
|
|
execSync(`git diff --name-only ${range} ${paths}`.trim(), { cwd, encoding: 'utf-8' }).trim();
|
|
const runJest = (extra = []) => {
|
|
const r = spawnSync('jest', [...extra, ...process.argv.slice(2)], { stdio: 'inherit' });
|
|
process.exit(r.status ?? 1);
|
|
};
|
|
|
|
if (!mergeBase) {
|
|
log('MERGE_BASE unset → full');
|
|
runJest();
|
|
}
|
|
|
|
// Turbo --affected can invoke us when only an upstream package changed, in
|
|
// which case jest --changedSince would walk an empty in-package diff and run
|
|
// zero tests — the one direction we must never take.
|
|
const inPackage = diff(`${mergeBase}...HEAD`, '-- packages/nodes-base/');
|
|
if (!inPackage) {
|
|
log('upstream-only change → full');
|
|
runJest();
|
|
}
|
|
|
|
if (/\/(jest\.config\.js|test\/(setup|globalSetup)\.ts|package\.json)$/m.test(inPackage)) {
|
|
log('in-package config change → full');
|
|
runJest();
|
|
}
|
|
|
|
const all = diff(`${mergeBase}...HEAD`);
|
|
if (/^(pnpm-lock\.yaml|package\.json|packages\/cli\/src\/public-api\/v1\/)/m.test(all)) {
|
|
log('cross-cutting change → full');
|
|
runJest();
|
|
}
|
|
|
|
log(`scoping via jest --changedSince=${mergeBase}`);
|
|
runJest([`--changedSince=${mergeBase}`]);
|