datreeio / datree

Prevent Kubernetes misconfigurations from reaching production (again 😤 )! From code to cloud, Datree provides an E2E policy enforcement solution to run automatic checks for rule violations. See our docs: https://hub.datree.io
https://datree.io
Apache License 2.0
6.39k stars 363 forks source link

Disable spinner when detecting runs in CI to avoid messing up logs with spinner etc #620

Closed HariSekhon closed 2 years ago

HariSekhon commented 2 years ago

Following on from this ticket:

https://github.com/datreeio/action-datree/issues/5

I think it would be good for datree to detect when it is running within a CI system and default to using simpler output to prevent generating huge logs or messing up the screen.

I am looking at adding --output simple to the CI myself for now, but I believe other tools already detect when running in CI and tone their output down automatically so this isn't a new idea.

I even do this myself for my own code by checking for all the common environment variables for CI builds, eg:

https://github.com/HariSekhon/DevOps-Bash-tools/blob/master/lib/ci.sh

eyarz commented 2 years ago

Generally, I agree, but the --output simple will disable the spinner and also the emoji. I think the emoji should be kept because it's not their fault that the spinner is spamming the log 😅

Maybe we can change the behavior so that when Datree recognizes it's running in a CI, it will not show (just) the spinner. @HariSekhon @shmuelsa WDYT?

HariSekhon commented 2 years ago

Hey I've got nothing against emojis, down with the spinner in CI though.

This should probably also happen if datree recognizes that it's in a pipeline and stdout has been redirected, although I guess --output simple could be used in that case.

shmuelsa commented 2 years ago

Hey! Our app context has an internal package that detects very early if we're running in a CI ('CiContext'). we can rely on it in the initialization of the spinner base. @adifay maybe one of the community can help us with that

eyarz commented 2 years ago

✅ To keep everyone in sync, the task definition is to detect when Datree is running in CI and disable the spinner.

⚠️ This task is NOT about detecting when Datree is running in CI and running Datree in simple mode (--output simple)