Skip to content
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

feat: modified spinner code to disable when running in CI or Github a… #215

Merged
merged 4 commits into from
Oct 16, 2024

Conversation

Bharadwajshivam28
Copy link
Member

@Bharadwajshivam28 Bharadwajshivam28 commented Sep 30, 2024

…ctions

fixes: #210

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Sep 30, 2024
@k8s-ci-robot k8s-ci-robot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Sep 30, 2024
@Bharadwajshivam28
Copy link
Member Author

Bharadwajshivam28 commented Sep 30, 2024

@rjsadow I have added functionality to disable spinner when running in CI or Github actions environment.

Here this CLI I do same disable stuff when running in CI or Github actions

@@ -55,7 +56,16 @@ func NewSpinner(w io.Writer) *Spinner {
}
}

func isCIEnvironment() bool {
return os.Getenv("CI") != "" || os.Getenv("GITHUB_ACTIONS") != ""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is "CI" a standard environment variable?

if not, we should be using some sort of project specific prefix, to avoid conflicting with some unrelated meaning.

there are standard environment variables about the capability of the terminal, see the linked code in #210

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

commented also on #210

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is "CI" a standard environment variable?

if not, we should be using some sort of project specific prefix, to avoid conflicting with some unrelated meaning.

there are standard environment variables about the capability of the terminal, see the linked code in #210

The thing is that the CI also detects the ci environment as I linked one tool in which I use the same way there and it works totally good

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should invent our own unprefixed environment variables, this is a global namespace.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should invent our own unprefixed environment variables, this is a global namespace.

Can you just tell me where I can find environment variables to identify ci in Hydrophone?

Copy link
Collaborator

@rjsadow rjsadow Oct 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a more universal approach would be to identify if we're running in a terminal or not. If not, lets disable the spinner. x/term has a IsTerminal method that we may be able to make use of. I've never used it directly but this example code seems to be promising from a few minutes of testing. https://go.dev/play/p/dCeTgh5teta. If we return from Spinner.Start if IsTerminal is false that may be a good enough stop gap.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, we check for tty in https://github.com/kubernetes-sigs/kind/blob/main/pkg/internal/env/term.go

there is not a universal environment variable for "is CI" and we shouldn't attempt to invent it here

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some CI use a fake tty, and there are other user signals that they would like to disable this, each check is commented above.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @rjsadow @BenTheElder I have modified the spinner function and used x/term and IsTerminal to check if running in non terminal environment the spinner function should not start

@rjsadow
Copy link
Collaborator

rjsadow commented Oct 16, 2024

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 16, 2024
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Bharadwajshivam28, rjsadow

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 16, 2024
@k8s-ci-robot k8s-ci-robot merged commit e0f797c into kubernetes-sigs:main Oct 16, 2024
8 checks passed
@Bharadwajshivam28 Bharadwajshivam28 deleted the feat/spinner_ci branch October 18, 2024 20:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Automatic detection of CI environments to disable the spinner
4 participants