Skip to content

fix: exit nonzero when a circuit fails to build correctly - #4718

Closed
billythompsons wants to merge 8 commits into
tscircuit:mainfrom
billythompsons:fix-4707-build-exit-code
Closed

fix: exit nonzero when a circuit fails to build correctly#4718
billythompsons wants to merge 8 commits into
tscircuit:mainfrom
billythompsons:fix-4707-build-exit-code

Conversation

@billythompsons

@billythompsons billythompsons commented Sep 11, 2026

Copy link
Copy Markdown

Fixes #4707.

Problem

tsci build printed "Build completed with errors" yet exited 0 and counted the circuit as passed when the circuit itself failed to build - e.g. a trace targeting a nonexistent component (source_trace_not_connected_error). CI cannot detect the invalid design from the process status.

Fix

The build now distinguishes an invalid circuit from DRC violations on an otherwise valid one:

  • circuit-json-diagnostics gains isCircuitFailureError, currently matching source_trace_not_connected_error: a trace endpoint that resolves to no existing port is an invalid design, never a legitimate partial build.
  • buildFile (and the build worker) report hasCircuitErrors when such an error is present (respecting --ignore-errors, after DRC ignore-category filtering).
  • tsci build exits 1 when any circuit has a circuit failure (fatal errors still always exit 1), and failed circuits are no longer counted as passed in the summary.

Deliberately scoped narrow: routing failures like pcb_trace_missing_error stay exit 0 because valid simulation/partial circuits can legitimately leave traces unrouted (covered by the existing build-output-flags simulation tests, which pass unchanged). DRC violations (e.g. pcb_component_outside_board_error) also stay exit 0, as do warnings. Happy to extend the failure set in a follow-up if you want routing failures included.

Tests

  • New build-exit-code-circuit-errors.test.ts: the issue's exact repro (trace to a nonexistent component) exits 1 with "0 passed / 1 failed"; with --ignore-errors exits 0.
  • Existing exit-code/DRC/simulation contract tests pass unchanged: build-with-drc-error, build-with-ignore-error, build-ignore-drc-categories, build-ignore-placement-drc-routes, build-output-flags.

@billythompsons

Copy link
Copy Markdown
Author

Closing - #4715 landed just before this and covers the same ground (exit 1 on circuit errors, artifacts retained, failed circuits not counted as passed). Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tsci build exits 0 and counts a circuit as passed when a trace targets a nonexistent component

1 participant