Skip to content

Add CI environment detection to disable interactivity#42

Merged
lukidoescode merged 2 commits intomainfrom
lwagner/37-non-interactivity-in-ci
Feb 23, 2026
Merged

Add CI environment detection to disable interactivity#42
lukidoescode merged 2 commits intomainfrom
lwagner/37-non-interactivity-in-ci

Conversation

@lukidoescode
Copy link
Copy Markdown
Owner

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

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.
@lukidoescode lukidoescode merged commit 1b6080c into main Feb 23, 2026
7 checks passed
@lukidoescode lukidoescode deleted the lwagner/37-non-interactivity-in-ci branch February 23, 2026 20:37
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.

Do not allow interactivity in CI

1 participant