Skip to content

fix: errors from tns doctor are not visible in CI environment #4404

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 27, 2019

Conversation

rosen-vladimirov
Copy link
Contributor

When tns doctor detects errors in the configuration, it should print them to stdout and prompt the user to select how to resolve them.
In non-interactive terminal, it should just print the errors and fails as the prompter are not meaningful in non-interactive terminal - there's noone to answer them.

The logic works fine when you pipe the output of tns doctor to file for example (tns doctor > out.txt). CLI correctly detects the terminal as non-interactive, prints the errors and exits.
However, most of the CI environments are determined as interactive terminals by CLI. That's because CLI checks if the stdout and stdin of the current process are text terminal (TTY). CI environments set required flags, so the process seems like running in such text terminal.
When CLI thinks the process is running in text terminal, it uses some external package (ora) to print pretty lines. However, ora package also checks if the process is running in text terminal (which both CLI and ora think is true), but it also checks if the environment variable CI is set.
When it is set, ora package decides that it cannot print colored messages and just doesn't print anything.

To resolve this, improve the check if interactive terminal in CLI to respect the known environment variables that define the process as running in CI:

  • for Travis the environment varible CI is set.
  • for CircleCI the environment variable CI is set
  • for Jenkins the environment variable JENKINS_HOME is set

Whenever one of those environment variables is set, CLI will decide it is running in non-interactive terminal and will not use ora (for tns doctor). It will also not show any prompters in this case.

NOTE: Deleted duplicate test from other service

PR Checklist

What is the current behavior?

Errors from tns doctor are not shown in Travis/CircleCI. Instead the CI build just hangs as CLI had shown prompter.

What is the new behavior?

Errors from tns doctor are shown in Travis/CircleCI and the CI Build fails directly instead of hanging.

Fixes issue #4383

@rosen-vladimirov rosen-vladimirov added this to the 5.2.1 milestone Feb 27, 2019
@rosen-vladimirov rosen-vladimirov self-assigned this Feb 27, 2019
@cla-bot cla-bot bot added the cla: yes label Feb 27, 2019
@ghost ghost added the new PR label Feb 27, 2019
When `tns doctor` detects errors in the configuration, it should print them to stdout and prompt the user to select how to resolve them.
In non-interactive terminal, it should just print the errors and fails as the prompter are not meaningful in non-interactive terminal - there's noone to answer them.

The logic works fine when you pipe the output of `tns doctor` to file for example (`tns doctor > out.txt`). CLI correctly detects the terminal as non-interactive, prints the errors and exits.
However, most of the CI environments are determined as interactive terminals by CLI. That's because CLI checks if the stdout and stdin of the current process are text terminal (TTY). CI environments set required flags, so the process seems like running in such text terminal.
When CLI thinks the process is running in text terminal, it uses some external package (ora) to print pretty lines. However, `ora` package also checks if the process is running in text terminal (which both CLI and `ora` think is true), but it also checks if the environment variable `CI` is set.
When it is set, `ora` package decides that it cannot print colored messages and just doesn't print anything.

To resolve this, improve the check if interactive terminal in CLI to respect the known environment variables that define the process as running in CI:
- for Travis the environment varible `CI` is set.
- for CircleCI the environment variable `CI` is set
- for Jenkins the environment variable `JENKINS_HOME` is set

Whenever one of those environment variables is set, CLI will decide it is running in non-interactive terminal and will not use `ora` (for `tns doctor`). It will also not show any prompters in this case.
@yagey
Copy link

yagey commented Feb 27, 2019

thank you!

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

Successfully merging this pull request may close these issues.

3 participants