Skip to content

feat: Add support for grouping all of a task's output - #2985

Open
jonathanio wants to merge 2 commits into
go-task:mainfrom
jonathanio:enable-task-cmds-grouping-output
Open

feat: Add support for grouping all of a task's output#2985
jonathanio wants to merge 2 commits into
go-task:mainfrom
jonathanio:enable-task-cmds-grouping-output

Conversation

@jonathanio

Copy link
Copy Markdown

Description

Add support for extending the grouping in tasks from just the grouping of each individual cmd output to a single grouping across the entire task output for all cmds. This nonetheless only applies to all cmd entries called within a task. If a task calls another task, that task's output will be grouped under that task's grouping.

This should make the output much easier to read under tools such as GitHub Workflows and GitLab pipelines.

Closes #2941

Note

I noticed that #2979 splits the site into next and latest folders, but CONTRIBUTING.md doesn't say which version to update; therefore, I updated both folders to keep them in sync. Please let me know if this is incorrect.

AI Declaration

Much of the code and documentation was written using Kiro through ChatGPT 5.6 Luna and reviewed with Qwen3 Coder Next. I fully reviewed all code and documentation changes and made any final necessary updates as needed before committing.

Checklist

  • I have read and followed the Contribution Guide.
  • I have disclosed the use of any AI-generated content in this pull request per the AI Usage Policy.
  • I fully understand the changes and have hand-written the description (No AI) of this pull request.

Copilot AI lite review requested due to automatic review settings August 18, 2026 13:50

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds an opt-in “group by task” mode for output: group, so a task’s multiple cmds can be emitted as a single grouped block (improving readability in CI logs like GitHub Actions/GitLab).

Changes:

  • Add group.by_task (Taskfile) and --output-group-by-task / TASK_OUTPUT_GROUP_BY_TASK (CLI/env) to enable task-level grouping.
  • Implement task-level output buffering/flushing in the executor, with accompanying tests and testdata fixtures.
  • Update JSON schema, docs (next/latest), shell completions, and changelog to document the new option.

Reviewed changes

Copilot reviewed 23 out of 23 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
website/src/public/schema.json Adds group.by_task to the published schema and updates output description text.
website/src/public/next-schema.json Adds group.by_task to the next schema and updates output description text.
website/src/next/docs/reference/schema.md Updates schema example to include by_task.
website/src/next/docs/reference/environment.md Documents TASK_OUTPUT_GROUP_BY_TASK.
website/src/next/docs/reference/cli.md Documents --output-group-by-task.
website/src/next/docs/guide.md Adds guide section explaining task-level grouping behavior/constraints.
website/src/latest/docs/reference/schema.md Updates schema example to include by_task.
website/src/latest/docs/reference/environment.md Documents TASK_OUTPUT_GROUP_BY_TASK.
website/src/latest/docs/reference/cli.md Documents --output-group-by-task.
website/src/latest/docs/guide.md Adds guide section explaining task-level grouping behavior/constraints.
testdata/output_group/Taskfile.yml Adds a multi-command task fixture for default per-command grouping behavior.
testdata/output_group_by_task/Taskfile.yml New fixture covering by-task grouping scenarios (deferred, nested, deps).
testdata/output_group_by_task_error_only/Taskfile.yml New fixture covering by-task grouping with error_only.
taskfile/ast/output.go Adds ByTask field to OutputGroup YAML parsing.
taskfile/ast/output_test.go Adds tests for output parsing including by_task.
task.go Implements task-level output buffering/closing and threads it through command execution.
task_test.go Adds executor integration tests for default grouping vs by-task grouping (incl. deps/error-only).
internal/flags/flags.go Adds --output-group-by-task flag and validates it only with --output=group.
completion/zsh/_task Adds completion entry for --output-group-by-task.
completion/ps/task.ps1 Adds completion entry for --output-group-by-task.
completion/nu/task-completions.nu Adds completion entry for --output-group-by-task.
completion/fish/task.fish Adds completion entry for --output-group-by-task.
CHANGELOG.md Notes the new opt-in task-level grouping feature.
Suppressed comments (1)

task.go:514

  • For task-level grouping, taskOut.failed is set immediately after RunCommand returns, before timeout normalization and before the cmd.IgnoreError early-return below. This means --output-group-error-only may treat a command as “failed” for grouping even if it’s later ignored. If the intent is to suppress grouped output when all failures are ignored, move the taskOut.failed assignment to after the IgnoreError check (and after timeout normalization).
		if taskOut == nil {
			if closeErr := closer(err); closeErr != nil {
				e.Logger.Errf(logger.Red, "task: unable to close writer: %v\n", closeErr)
			}
		} else if err != nil {
			taskOut.failed = true
		}

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread website/src/latest/docs/reference/cli.md
Comment thread task.go Outdated
Add support for extending the grouping in tasks from just the grouping
of each individual cmd output to a single grouping across the entire
task output for all cmds. This nonetheless only applies to all cmd
entries called within a task. If a task calls another task, that task's
output will be grouped under that task's grouping.

This should make the output much easier to read under tools such as
GitHub Workflows and GitLab pipelines.
Fix the handling of grouped outputs where a child task failing may
result in the output of the commands of a parent task when that parent
task itself didn't fail. Therefore when running with error_only output,
task should not accidentally output more than a single task's output.
@jonathanio
jonathanio force-pushed the enable-task-cmds-grouping-output branch from 05dcd1d to d9522a8 Compare August 18, 2026 15:25
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.

Add support for a "group-by-task" output format

2 participants