-
Notifications
You must be signed in to change notification settings - Fork 315
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
[hab,studio] Add noninteractive & no coloring modes via environment variables. #1682
Conversation
adc0548
to
33a2221
Compare
VERBOSE Prints more verbose output (\`-v' flag overrides) | ||
http_proxy Sets an http_proxy environment variable inside the Studio | ||
https_proxy Sets an https_proxy environment variable inside the Studio | ||
no_proxy Sets a no_proxy environment variable inside the Studio |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great to see complete env var docs! We should update https://github.com/habitat-sh/habitat/blob/master/www/source/docs/reference/environment-vars.html.md as well.
This is super great. I'd merge but think its important not to forget about the web docs. |
…ariables. The primary use case driving this feature is running builds in a CI environment. Some logging streams do not cope well with progress bar style output which behave by using carriage returns to the terminal to set its cursor back to the start of the line and "redraw" the current line. These logging streams frequently start outputting each progress tick/redraw as a full new line and very quickly consume a large amount of output. In systems such as Travis there is a upper bound to the number of log lines provided back to the user. As we care about the build output not spinners of doom, we needed a way to turn these off. This change adds a way for users of Habitat tooling (such as `hab`, `hab pkg build`, `hab studio`, etc.) to explicitly drop single-line progress bar indicators or to disable text coloring by setting 2 new environment variables. As this feature is targeted for CI environments, environment variables were used so that the command issued in CI is virtually identical to the command issued on a developer's workstation. Additionally, running a `hab pkg build` will invoke a `hab` process which invokes a `hab-studio` process which may contain further `hab` subprocess before completing. The amount of work required to only support explicit flags on all the related tools would have made this feature much more complex and error prone. The choice of prefixing these environment variables with `HAB_` ensures that there's almost no chance these variables would affect the build of any software and so can be safely passed over the Studio's barrier of isolation. Currently, `hab`'s UI system will check 2 things to determine its behavior: * Coloring is determined by checking the `TERM` environment variable to check the local terminfo database. If the `TERM` supports color, then `hab` will add ansi coloring. * Progress bars is determined by checking if the input and output streams (i.e. stdin, stdout, stderr) have a TTY assigned (using `libc::isatty()` or equivalent depending in platform). This change checks an environment variable `HAB_NONINTERACTIVE` which if set to `"true"`, will override the default detection logic and tell the UI that it does *not* have a TTY assigned. As a consequence, downloading and uploading progress bars will be disabled. Additionally, another environment variable `HAB_NOCOLORING` is checked, and if set to `"true"` will disable all coloring from `hab`, `hab-studio`, `hab-plan-build`, etc. tl;dr ----- To skip spinners in CI either: env HAB_NONINTERACTIVE=true hab pkg build ... or export HAB_NONINTERACTIVE=true hab pkg build ... References #1280 Signed-off-by: Fletcher Nichol <[email protected]>
33a2221
to
1c1a0e6
Compare
@mwrock Good call--I updated the docs and rebased. In all honesty it was a fluke that I found our |
@thesentinels approve |
🤘 I am testing your branch against master before merging it. We do this to ensure that the master branch is never failing tests. |
|
💖 Travis CI reports this PR passed. It always makes me feel nice when humans approve of one anothers work. I'm merging this PR now. I just want you and the contributor to answer me one question: |
@fnichol / @eeyun, I think this is still broken-feeling. When I set Also a personal preference: I feel fairly strongly that a low-level tool like Habitat should have color turned OFF by default and only be toggled on by a user config/env var. Colored output has been a constant source of annoyance for me and my colleagues (for various reasons) since we adopted Habitat. |
The primary use case driving this feature is running builds in a CI environment. Some logging streams do not cope well with progress bar style output which behave by using carriage returns to the terminal to set its cursor back to the start of the line and "redraw" the current line. These logging streams frequently start outputting each progress tick/redraw as a full new line and very quickly consume a large amount of output. In systems such as Travis there is a upper bound to the number of log lines provided back to the user. As we care about the build output not spinners of doom, we needed a way to turn these off.
This change adds a way for users of Habitat tooling (such as
hab
,hab pkg build
,hab studio
, etc.) to explicitly drop single-line progress bar indicators or to disable text coloring by setting 2 new environment variables. As this feature is targeted for CI environments, environment variables were used so that the command issued in CI is virtually identical to the command issued on a developer's workstation. Additionally, running ahab pkg build
will invoke ahab
process which invokes ahab-studio
process which may contain furtherhab
subprocess before completing. The amount of work required to only support explicit flags on all the related tools would have made this feature much more complex and error prone. The choice of prefixing these environment variables withHAB_
ensures that there's almost no chance these variables would affect the build of any software and so can be safely passed over the Studio's barrier of isolation.Currently,
hab
's UI system will check 2 things to determine its behavior:TERM
environment variable to check the local terminfo database. If theTERM
supports color, thenhab
will add ansi coloring.libc::isatty()
or equivalent depending in platform).This change checks an environment variable
HAB_NONINTERACTIVE
which if set to"true"
, will override the default detection logic and tell the UI that it does not have a TTY assigned. As a consequence, downloading and uploading progress bars will be disabled.Additionally, another environment variable
HAB_NOCOLORING
is checked, and if set to"true"
will disable all coloring fromhab
,hab-studio
,hab-plan-build
, etc.tl;dr
To skip spinners in CI either:
or
References #1280