Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions scripts/check-affected/run.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,10 @@ test('runChecks skips CI checks, runs every local check of a fail-open plan, and
}
const related = executed.filter((command) => command.includes('related'));
assert.equal(related.length, 1);
assert.ok(
!related[0]?.some((arg) => arg.startsWith('--project')),
'a fail-open related run keeps every Vitest project',
// check:unit runs in this plan too, so the related run leaves the unit projects to it.
assert.deepEqual(
related[0]?.filter((arg) => arg.startsWith('--project')),
['--project=!unit-core', '--project=!fuzz-worker'],
);
assert.ok(
!related[0]?.includes('--coverage'),
Expand Down Expand Up @@ -251,6 +252,17 @@ test('runChecks skips CI checks, runs every local check of a fail-open plan, and
);
});

// The related run leaves the unit projects out, so only check:unit can see their failures.
test('a fail-open plan fails on a unit-suite failure', async () => {
const plan = selectChecks({ changedFiles: ['unknown/path.xyz'], packageEntryFiles: [] });
assert.equal(plan.failOpen, true);
const code = await runChecks(plan, { scripts: ALL_SCRIPTS }, ARGS, {
execute: async (command) => (command.includes('check:unit') ? 23 : 0),
cwd: '.',
});
assert.equal(code, 23);
});

async function runFailingOn(script: string, changedFiles: string[]): Promise<number> {
const plan = selectChecks({ changedFiles, packageEntryFiles: [] });
assert.equal(plan.failOpen, false, changedFiles.join(', '));
Expand Down
10 changes: 5 additions & 5 deletions scripts/check-affected/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,13 +213,13 @@ export async function runChecks(
const skipped = plan.checks.map(getCheckSpec).filter((spec: CheckSpec) => !spec.localRunnable);
// A fail-open plan could not narrow the change, so no check may stand in for another.
const relatedSelected = !plan.failOpen && plan.checks.includes('vitest-related');
// Leaving the unit projects to `unit` stands in for nothing, so fail-open plans do it too.
// The run stops at the first failure, so no pass skips the `unit` run.
const related = {
changedFiles: options.changedFiles ?? [],
unitSuiteRuns:
!plan.failOpen &&
runnable.some(
(spec) => spec.id === 'unit' && !isCoveredByRelatedTests(spec, relatedSelected),
),
unitSuiteRuns: runnable.some(
(spec) => spec.id === 'unit' && !isCoveredByRelatedTests(spec, relatedSelected),
),
};
const ciJobs = skipped.length > 0 ? ciJobsByCheck() : new Map<CheckId, string[]>();
for (const spec of skipped) {
Expand Down
Loading