Skip to content

add teardown handling for CLI execution success and failure scenarios#11

Merged
OlegZee merged 6 commits intodevfrom
feature/cli-teardown-rules
Mar 16, 2026
Merged

add teardown handling for CLI execution success and failure scenarios#11
OlegZee merged 6 commits intodevfrom
feature/cli-teardown-rules

Conversation

@OlegZee
Copy link
Owner

@OlegZee OlegZee commented Mar 16, 2026

Adds consistent teardown execution for CLI script runs so teardown targets run after both successful builds and build failures (including when ThrowOnError is enabled), aligning CLI behavior with the long-lived engine teardown flow.

Changes:

Introduces ScriptRunner.runTeardownAsync and uses it from both CLI execution and XakeEngine.StopAsync.
Updates CLI runScript to always run teardown after build completion/failure, and to preserve the original build error when teardown also fails.
Adds CLI-focused tests covering teardown on success, failure, teardown-failure reporting, and skipping teardown for --dryrun/--dump.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds consistent teardown execution for CLI script runs, ensuring teardown targets run after both successful builds and build failures (including when ThrowOnError is enabled), while still skipping teardown for --dryrun and --dump modes.

Changes:

  • Introduces CLI tests validating teardown behavior on success, failure (with ThrowOnError), and non-executing modes (--dryrun/--dump).
  • Centralizes teardown execution into ScriptRunner.runTeardownAsync.
  • Updates CLI execution (runScript) and long-lived engine shutdown (XakeEngine.StopAsync) to use the shared teardown runner.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/tests/CommandLineTests.fs Adds regression tests covering teardown execution behavior for CLI runs.
src/core/XakeScriptBuilder.fs Uses the shared teardown runner during XakeEngine.StopAsync.
src/core/ScriptRunner.fs Adds runTeardownAsync and invokes teardown after run-mode execution completes (success or failure).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

…ion failures, add teardown invokation on Ctrl-C keypress
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds consistent teardown execution for CLI-driven runs, aligning CLI behavior more closely with the long-lived engine shutdown path and validating the behavior with new command-line tests.

Changes:

  • Add ScriptRunner.runTeardownAsync and invoke it after CLI builds complete (success or failure).
  • Invoke teardown on Ctrl+C via Console.CancelKeyPress handler.
  • Add CLI tests covering teardown on success, teardown on failure (with ThrowOnError), and skipping teardown in --dryrun/--dump.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.

File Description
src/tests/CommandLineTests.fs Adds tests for teardown execution/skip behavior and a temp-root helper for isolation.
src/core/XakeScriptBuilder.fs Reuses centralized teardown runner during XakeEngine.StopAsync.
src/core/ScriptRunner.fs Introduces runTeardownAsync and runs teardown after CLI execution and on cancellation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

OlegZee and others added 2 commits March 16, 2026 14:50
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
…xecution, new tests to verify correct error handling in case of teardown exception
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR makes teardown execution consistent for CLI script runs by ensuring teardown targets are executed after both successful builds and build failures (including when ThrowOnError is enabled), aligning CLI behavior with long-lived engine shutdown behavior.

Changes:

  • Adds a shared ScriptRunner.runTeardownAsync helper and uses it from both CLI execution and XakeEngine.StopAsync.
  • Updates CLI Ctrl+C handling to cancel the running build workflow (rather than immediately exiting) so teardown can still run.
  • Adds CLI-focused tests covering teardown on success, teardown on failure with ThrowOnError, skipped teardown for --dryrun/--dump, and teardown failure reporting.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
src/tests/CommandLineTests.fs Adds new tests validating teardown behavior across CLI success/failure and non-run modes.
src/core/XakeScriptBuilder.fs Switches engine shutdown teardown to reuse the shared teardown helper.
src/core/ScriptRunner.fs Introduces shared teardown helper and ensures teardown runs after CLI builds (including when errors are reraised).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

OlegZee and others added 2 commits March 16, 2026 18:53
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds consistent teardown execution for CLI script runs so teardown targets run after both successful builds and build failures (including when ThrowOnError is enabled), aligning CLI behavior with the long-lived engine teardown flow.

Changes:

  • Introduces ScriptRunner.runTeardownAsync and uses it from both CLI execution and XakeEngine.StopAsync.
  • Updates CLI runScript to always run teardown after build completion/failure, and to preserve the original build error when teardown also fails.
  • Adds CLI-focused tests covering teardown on success, failure, teardown-failure reporting, and skipping teardown for --dryrun/--dump.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
src/tests/CommandLineTests.fs Adds coverage for teardown execution across CLI success/failure modes and non-execution modes.
src/core/XakeScriptBuilder.fs Switches engine stop teardown execution to the shared ScriptRunner.runTeardownAsync.
src/core/ScriptRunner.fs Implements shared teardown runner and ensures CLI runScript runs teardown after build completion/failure (with Ctrl+C cancellation support).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

@OlegZee OlegZee merged commit 33df8fe into dev Mar 16, 2026
5 checks passed
@OlegZee OlegZee deleted the feature/cli-teardown-rules branch March 16, 2026 18:50
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.

2 participants