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

The GitHub action for Darker doesn't use syntax highlighting #263

Closed
mayk0gan opened this issue Jan 26, 2022 · 3 comments · Fixed by #353
Closed

The GitHub action for Darker doesn't use syntax highlighting #263

mayk0gan opened this issue Jan 26, 2022 · 3 comments · Fixed by #353
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@mayk0gan
Copy link
Collaborator

Currently, you run:
proc = subprocess.run([sys.executable, str(MAIN_SCRIPT)]);
in the github action.

It doesn't output any colors, which makes it harder to understand darker's output.
You could use something like written here: https://stackoverflow.com/questions/58307157/subprocess-call-output-in-color printing the output with colors.

@akaihola
Copy link
Owner

akaihola commented Feb 2, 2022

Thanks @mayk0gan, I will consider that and return to this suggestion a bit later.

@akaihola akaihola self-assigned this Feb 2, 2022
@akaihola akaihola added the enhancement New feature or request label Feb 2, 2022
@akaihola akaihola added this to the 1.5.0 milestone Feb 2, 2022
@akaihola
Copy link
Owner

akaihola commented Feb 24, 2022

@mayk0gan, as far as I understand, the solution for subprocess.call output in color on Stack Overflow captures all output and prints it all in one color.

I would assume you'd prefer to have Darker's original output colors intact in the GitHub Action output instead? Do you have an idea of how to achieve that?

Jeff Geerling's blog post Getting colorized output from Molecule and Ansible on GitHub Actions for CI suggests to me that GitHub Actions actually will convert TTY ANSI color codes to HTML colors, and the problem here is only that Darker assumes the output is not to a TTY and will thus disable colors.

So maybe a command line option or environment variable to force color output would suffice?
Black has:

  --color / --no-color            Show colored diff. Only applies when
                                  `--diff` is given.

On the other hand, Jeff writes:

  • PY_COLORS: This is a somewhat standard way to tell Python-based tools to force color output, even without TTY.

The two places in Darker code which decide between color and raw output are

@akaihola akaihola added the good first issue Good for newcomers label Feb 24, 2022
@akaihola akaihola added the help wanted Extra attention is needed label Mar 14, 2022
@akaihola
Copy link
Owner

@mayk0gan I can include Darker color output in the GitHub Action in release 1.5.0 if you think that would make sense and if you can lend your hand a bit by testing and discussing the design choices mentioned above.

@akaihola akaihola removed help wanted Extra attention is needed good first issue Good for newcomers labels Apr 3, 2022
@akaihola akaihola changed the title Show colorful output in github action The GitHub action for Darker doesn't use syntax highlighting Apr 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
2 participants