Add CI environment detection to disable interactivity#42
Merged
lukidoescode merged 2 commits intomainfrom Feb 23, 2026
Merged
Conversation
When running in CI environments, interactive prompts can hang indefinitely because some CI systems allocate pseudo-TTYs. This change adds automatic CI detection that disables interactive mode and provides helpful error messages guiding users to use non-interactive flags. - Add centralized `environment` module with `is_interactive()` and `non_interactive_reason()` functions - Detect CI via environment variables: CI, GITHUB_ACTIONS, GITLAB_CI, CIRCLECI, TRAVIS, JENKINS_URL, BUILDKITE, TF_BUILD - Add CARGO_CHANGESET_NO_TTY to explicitly disable interactive mode - CI detection takes priority over CARGO_CHANGESET_FORCE_TTY - Consolidate duplicate `is_interactive()` functions from interaction.rs, commands/add.rs, and commands/manage.rs - Enhance error messages to show which CI env var was detected and provide guidance on required flags - Add integration tests for CI detection behavior - Document CI usage in README with examples
FORCE_TTY is an explicit override that allows interactive mode even in CI, so it must take precedence over CI env var detection. This fixes interactive tests running in GitHub Actions where CI=true caused the binary to exit non-interactively despite FORCE_TTY=1 being set. Also fixes add_in_non_tty_multi_crate_workspace_fails to clear all CI env vars so it reliably tests the NoTerminal code path rather than CI detection.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When running in CI environments, interactive prompts can hang indefinitely because some CI systems allocate pseudo-TTYs. This change adds automatic CI detection that disables interactive mode and provides helpful error messages guiding users to use non-interactive flags.
environmentmodule withis_interactive()andnon_interactive_reason()functionsis_interactive()functions from interaction.rs, commands/add.rs, and commands/manage.rs