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

Add support for begin/end messages with grouped output #651

Merged
merged 1 commit into from
Feb 19, 2022

Conversation

janslow
Copy link
Contributor

@janslow janslow commented Jan 14, 2022

Fixes #647

This allows CI systems that support grouping (such as with GitHub Actions's ::group:: command and Azure Devops) to collapse all of the logs for a single task, to improve readability of log

Example

The following Taskfile

# Taskfile.yml
version: 3
output:
  group:
    begin: "::group::{{ .TASK }}"
    end: "::endgroup::"
tasks:
  default:
    cmds:
      - "echo 'Hello, World!'"

Results in the following output

$ task
task: [default] echo 'Hello, World!'
::group::default
Hello, World!
::endgroup::

See this GitHub Actions job for a full example:

image

image

Fixes go-task#647

This allows CI systems that support grouping (such as with [GitHub Actions's `::group::` command](https://docs.github.com/en/actions/learn-github-actions/workflow-commands-for-github-actions#grouping-log-lines) and [Azure Devops](https://docs.microsoft.com/en-us/azure/devops/pipelines/scripts/logging-commands?view=azure-devops&tabs=bash#formatting-commands)) to collapse all of the logs for a single task, to improve readability of logs

## Example

The following Taskfile

```
# Taskfile.yml
version: 3
output:
  group:
    begin: "::group::{{ .TASK }}"
    end: "::endgroup::"
tasks:
  default:
    cmds:
      - "echo 'Hello, World!'"
```

Results in the following output
```bash
$ task
task: [default] echo 'Hello, World!'
::group::default
Hello, World!
::endgroup::
```

See [this GitHub Actions job](https://github.com/janslow/task/runs/4811059609?check_suite_focus=true) for a full example

<img width="771" alt="image" src="https://user-images.githubusercontent.com/1253367/149429832-6cb0c1b5-0758-442e-9375-c4daa65771bc.png">
<img width="394" alt="image" src="https://user-images.githubusercontent.com/1253367/149429851-1d5d2ab5-9095-4795-9b57-f91750720d40.png">
@@ -6,6 +6,6 @@ import (

type Interleaved struct{}
Copy link
Contributor Author

@janslow janslow Jan 14, 2022

Choose a reason for hiding this comment

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

Note, the Interleaved/Prefixed/Group types are no longer used outside of the output package (they're now only created via output.Style.Build() and only consumed as the output.Output interface), so they could be unexported (I'm happy to do this refactor if you want).

@janslow janslow marked this pull request as ready for review January 14, 2022 00:29
andreynering added a commit that referenced this pull request Feb 19, 2022
@andreynering andreynering merged commit cfb6653 into go-task:master Feb 19, 2022
@andreynering
Copy link
Member

Hi @janslow,

You did an awesome job here, thanks a lot!

I did some small improvements at b323531, mostly moving some files around where they better fit.

@janslow janslow deleted the group-begin-message branch February 24, 2022 12:48
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

Successfully merging this pull request may close these issues.

Grouped output with GitHub Actions friendly begin/end markers
2 participants