-
Notifications
You must be signed in to change notification settings - Fork 964
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
Not a tty #241
Comments
Thank you @1138-4eb, but we'd like to keep issues related to code in this repository.
|
@andymckay, this issue is related to almost, if not all, the code in this repository. For example: |
I too am interested in this. |
@ioquatix, note that the messages in lines 4 and 5 are warnings. I don't know if those are related to the error in line 6. See for example https://github.com/ghdl/ghdl/runs/298621638#step:5:14 |
Ahh, interesting. So maybe it can work? Why does it get permission denied when trying to run that script? Presumably it's |
The execution might continue after those warning, although not providing a tty. Anyway, I have not been able to achieve using both |
Yeah, I've come to the same conclusion, no matter what I do I can't figure out how to get it to allocate a TTY/PTY that actually works. |
@1138-4eb did you find any solution at all? |
No. TBH, I was quite surprised about how this issue was handled. Alternatives so far are to manually force each tool (if options are provided) or to use docker containers (thus, making GitHub environments and actions irrelevant). |
I've emailed github support.. but that's a black hole... let's see if anything comes of it. |
What are you trying to do with this? Is it just color codes? (Im sure there are other implications of being a tty) As far as Im aware, the web console will render ANSI color codes correctly, however there is of course the issue of: how is a tool, in general, supposed to know that? I dont really know enough to say for sure, but it seems like allocating a tty is not 100% correct- does that assume it is a 2 way input/output? Obviously you cant type into the web console, so I dont know how close we can get to saying the web console is a true tty, and thus implying we support the features of a tty (input, maybe more?) I hesitate to say we should force downstream tools (anything the runner runs during job execution, ie your workflow) to think they have a tty. I recall this impacting things like installers which may throw a prompt up and wait for input, and similar issues. I do know: We set $TERM=dumb so that tools ran here dont try to do anything fancy. After all, all we are doing is buffering the stdout of the programs you run, and streaming them line by line to the web browser. That being said, I did mention the web console will render ansi colors. How can we configure the environment to indicate that to downstream processes? Ive played around with setting TERM differently, read about terminfo, etc, but honestly havent fully wrapped my head around it yet I guess in general, my stance is that the web console is not a terminal and shouldnt pretend to be, although we do in a sense, because we render ansi colors. And my question to that is, is there a granular way we can surface that capability (ansi colors, only) to downstream tools? Via environment or other? @ioquatix To answer something you brought up, in the |
@dakale An example use case of TTY environment variable is gpg-agent, which is used to sign files on GitHub Actions. If TTY is broken, GPG2, installed by default, can't communicate with gpg-agent well. To resolve this, we needed to force using GPG1, which doesn't depend on TTY by default. @olafurpg created a GitHub action task to do so: Signing files with GPG is required for uploading artifacts to the Maven central repository. Hopefully, we can use gpg2 (installed by default) in GH action without such a complex setup. |
Hi @dakale! Thanks a lot for giving this a thought!
Yes, the main issue I found is a difference between executing "test runners" locally or on GHA. Some of these tools are pytest, tox, colorama, yarn, grunt, (rich)go... The point it that each of those uses a different mechanism to force colors when a tty is not available. Therefore, although possible, it is a maintenance nightmare. I'm afraid that there is no resource to tell all of them at once, except providing a good enough tty.
IMHO, you are mixing concepts here. On the one hand, TTY stands for TeleTYpewriter, which in modern days, is interpreted as a text-only terminal, as opposed to a GUI. On the other hand, a terminal, be it text-only or a GUI, can be input-only, output-only, or both of them. The normal approach is for it to be input/output locally and output-only on CI environments. I don't think it is harmful at all to let downstream tools know/think that they are using a tty for output only, because a proper terminal is used almost always (all suggested cmd, powershell and bash terminals are proper tty tools). Furthermore, most of the jobs that are executed on CI should be in "batch mode", even if an input terminal was shown. This is true for local execution too.
Most installers allow to run them in batch mode. If they don't, and they need the environment to be forced, that's an issue to be solved by the maintainers of the installers. Please, note that any limitation you might think about with this regard is applicable almost directly to docker containers. I mean that this has already being addressed and solved. Precisely, if the same tasks are executed in containers running on GHA, a proper tty (output-only) is provided. This is to say that any user can potentially replace
I think that any solution which makes it optional, such as providing a (limited) tty and using TERM to tell that it is not a regular "xterm", is better than forcing a solution. If a tty is provided, users can disable it. However, now it is not available, so it's not possible to enable it. EDIT @xerial, precisely, this issue is related to actions/starter-workflows#96, because GPG seems to be required for using a docker credential helper. |
I'm trying to use
It should be attached to a TTY
No, if you want you can close
Well, aside from the fact you CAN type into a web console if it's set up for it, for the automated background testing, you can either close One additional note here, is travis allows you to log into a build to debug it, and it's already a TTY so easy to do so. If you ever adopt this functionality in the future, you'll probably desire to have a TTY allocated.
Whatever choice you are forcing tools into some specific situation. That being said, most tools are designed to be run within a TTY.
If you use a pipe for STDOUT, it will potentially buffer a large amount, but if you use a TTY the buffering strategy is different and typically more fine grained.
Typically you need to allocate a TTY and ensure
As stated by @1138-4eb a "web console"/"terminal" and a "TTY" are entirely different things.
To be honest, I don't really care about colours, but that I need a TTY allocated so I can test process management functionality, including |
@1138-4eb @ioquatix If you need to spawn processes with PTYs, you can check out https://www.pyinvoke.org/. I've been using it for a couple months on GitLab CI/CD (which behaves very similarly to GitHub Actions in this case). Here's a little sample (the |
@claudeleveille, it seems that you are running all the steps inside docker containers ( Summarizing:
This issue is requesting support for the last use case. Using pyinvoke in the workflow file might be a suitable workaround, should it be installed by default. If users need to execute action Nevertheless, I will try pyinvoke. Should it work as expected on the three platforms, it might be worth requesting to have it installed by default in the environments. @dakale, wdyt? |
@claudeleveille, I run some further tests: https://github.com/1138-4EB/actions/tree/color
Should |
(Thanks @joshmgross) This issue is better suited to live here Ill reopen since we havent made a decision on if its something we want to implement or not |
This is certainly worth digging into and figuring out. |
FYI as a workaround you can use |
@dalehamel, that sounds interesting. Can you please elaborate? Is it possible to use it as a steps:
- uses: actions/checkout@v1
- shell: script -e -c {0}
run: |
pip3 install tox --progress-bar off
tox -e py38-test |
From the manpage:
So seems like some OG Unix command lol at the "students" part... I'd never heard of it until I tried porting some tests that need a TTY to github actions. I don't care about actually saving the typescript file, but it seems to be able to fake(?) there being a TTY well enough for things that expect stdout to be a TTY to actually work.
I did a test with
IDK why, haven't debugged further. I was just wrapping my other commands in it and those worked fine. |
See console-rs#631 and actions/runner#241. Color support (or more precisely, whether the Actions runner advertises itself as a proper tty) seems flaky in GitHub.
See #631 and actions/runner#241. Color support (or more precisely, whether the Actions runner advertises itself as a proper tty) seems flaky in GitHub.
Details about this is from actions/runner#241 (comment) and actions/runner#241 (comment).
…rts of the engine (#198) This PR: * Updates `ie test` to use bubbletea for rendering it's output, similar to `ie interactive` and soon `ie execute`. * Refactors `ie interactive` and `ie test` implementations to exist in their own folders inside of `engine` (Which will be renamed to `ie` in the future). * Refactors code commonly used across execute, interactive, and test modes into a new package found in `internal/engine/common`. * Decoupled models from requiring a pointer to `Engine` as a parameter in preparation for when it will be deprecated in the future. * Reimplements `shells.ExecuteCodeBlock` to be a variable alias of `shells.executeCodeBlockImpl`. This allows for us to easily mock the the `ExecuteCodeBlock` implementation easily in tests. This allows us to do things like track calls to commands, record what commands were failed, mimic failures from executing commands, etc without having to actually execute commands. This is particularly useful in cases where we want to test the behavior of executing an Azure CLI command without actually executing the command itself. * Fixed an issue with the regex used to locate resource groups inside of command outputs and added tests to ensure that it works. * Adds a new environment `github-action`, specifically for running `ie test` inside of github actions runners. If this flag is not supplied, `ie test` will crash due to bubbletea attempting to open tty when there are no ttys available. (See actions/runner#241 for more information on GH actions not providing a TTY). *
This is convenient for CI/CD tools that may not run jobs in a tty. See actions/runner#241
This works around a lack of TTY in github actions. See actions/runner#241 (comment) Signed-off-by: Nick Mitchell <[email protected]>
This works around a lack of TTY in github actions. See actions/runner#241 (comment) Signed-off-by: Nick Mitchell <[email protected]>
This works around a lack of TTY in github actions. See actions/runner#241 (comment) Signed-off-by: Nick Mitchell <[email protected]>
This works around a lack of TTY in github actions. See actions/runner#241 (comment) Signed-off-by: Nick Mitchell <[email protected]>
This works around a lack of TTY in github actions. See actions/runner#241 (comment) Signed-off-by: Nick Mitchell <[email protected]>
Default shells seem to be limited. For example, the following step:
produces:
As a result, multiple tools that can provide pretty coloured logs do not work as expected. This is the case of e.g. colorama or pytest in the Python ecosystem.
A possible workaround is to use
docker run --rm -t ...
. However, this involves installing in the container multiple resources/tools that are already available on the host. Furthermore, I don't know if windows containers are supported onwindows-latest
jobs.I tried setting
shell: bash -i -l {0}
, but I get:I tried
python -c 'import pty; pty.spawn("/bin/sh")'
too, but the job wil run for more than 10min with no output.Which is the appropriate syntax to get a TTY?
The text was updated successfully, but these errors were encountered: