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

Feature request: group logs when running just in GitHub actions #2480

Open
GauBen opened this issue Nov 26, 2024 · 4 comments
Open

Feature request: group logs when running just in GitHub actions #2480

GauBen opened this issue Nov 26, 2024 · 4 comments

Comments

@GauBen
Copy link

GauBen commented Nov 26, 2024

Hey!

GitHub supports slightly interactive action output logs: https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/workflow-commands-for-github-actions#grouping-log-lines

It would be cool if just output had these markers when running in GitHub actions, it can be guessed by reading the env var GITHUB_ACTIONS, which is expected to be true (doc)

Would it be a useful addition to just?

I'd love to contribute this feature but I'm not very familiar with rust, I would need a few hints

@casey
Copy link
Owner

casey commented Nov 26, 2024

Very cool idea!

I think we should add it first behind a flag, and then later think about turning it on automatically if GITHUB_ACTIONS, depending on whether grouped logs are always useful, or if they have drawbacks or are too noisy.

Log groups have a start and an end, so I guess we would print out:

::group::RECIPE_NAME

Before running a recipe, and:

::endgroup::

When the recipe was finished.

One thing I'm curious about is what happens if you start a group within another group, which might happen if you recursively invoke just:

foo:
  just bar

You'd get something like:

::group::foo
::group::bar
::endgroup::
::endgroup::

Which I'm not sure would display correctly.

Here's how I would start with this feature:

  • Open a draft PR which prints out the group markers unconditionally, without worrying about a flag. You can do this in Recipe::run. I think you'll only need to add eprintln!("::group::{}", self.name) and eprintln!("::endgroup::").
  • We'll also need to see how it looks, so in the same PR, add a new step to .github/workflows/ci.yaml which invokes just on some recipes in order to see what they look like. You can add some dummy recipes to the justfile.
  • Then we can see what it actually looks like, what happens if you invoke just recursively, etc.
  • Assuming it looks good, I can then help you with adding a flag. (Which shiouldn't be too hard, it's in config.rs.)

@GauBen
Copy link
Author

GauBen commented Nov 26, 2024

I was thinking about more granular groups: each recipe line would get its group. Let's try something! Thanks for your quick reply

@casey
Copy link
Owner

casey commented Nov 26, 2024

Sounds good. We should do whatever is most usable. I don't really know what grouped logs look like, so if giving each recipe line its own group looks good, then that's fine. I suppose it might depend on the commands being run. If a single command generates a bunch of output, then putting it into a group is probably best. However, if there are a bunch of commands run which don't produce much output, then adding each one to a group might not be totally usable. We should probably experiment with both cases to see what works.

@GauBen
Copy link
Author

GauBen commented Nov 26, 2024

Starting #2482 here!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants