Skip to content

feat(tools-formatting): Support github and azure output formatting for annotations and groups#4153

Open
JasonVMo wants to merge 8 commits into
mainfrom
user/jasonvmo/output-grouping
Open

feat(tools-formatting): Support github and azure output formatting for annotations and groups#4153
JasonVMo wants to merge 8 commits into
mainfrom
user/jasonvmo/output-grouping

Conversation

@JasonVMo
Copy link
Copy Markdown
Collaborator

Description

This adds functionality in tools-formatting to support github actions and azure pipelines console output.

Reporters

It does this by introducing the concept of reporters, similar to many other tools (like testing frameworks), which controls how certain types of output is formatted.

  • four built-in reporter types are supported: azure, github, console, and file
  • console and file are identical for now, except that file disables color formatting
  • ReporterRegistry is a singleton class which can be overridden if additional reporter types need to be supported.
  • reporters handle annotations, file annotations, and groups
  • for console/file: annotations just provide standard error message formatting, groups utilize tree-views for output

Core functions

The library exposes formatMessage, formatFileMessage, and formatGroup which can have the reporter specified, or will default to whatever is appropriate for the current environment.

To-dos

  • Integrate the table formatting. This will involve handling writing MD tables to github summary files, and support for MD as a format in general.
  • Consume the library in tools that produce grouped output (like align-deps)

Comment thread incubator/tools-formatting/README.md Outdated
Comment thread incubator/tools-formatting/README.md Outdated
Comment thread incubator/tools-formatting/README.md Outdated
@Saadnajmi
Copy link
Copy Markdown
Contributor

Any chance this could be shared with Lage?

@JasonVMo
Copy link
Copy Markdown
Collaborator Author

Any chance this could be shared with Lage?

Yes, totally. This package is a zero-dependency formatting package that can be used anywhere for structured formatting.

@Saadnajmi
Copy link
Copy Markdown
Contributor

Is there an example of output? Hard to judge otherwise

Comment thread incubator/tools-formatting/src/paths.ts Outdated
Comment thread incubator/tools-formatting/src/reporters.ts Outdated
Comment thread incubator/tools-formatting/src/index.ts
Comment thread incubator/tools-formatting/src/github.ts Outdated
Comment thread incubator/tools-formatting/src/github.ts Outdated
Comment thread incubator/tools-formatting/src/azure.ts Outdated
*/
export function formatGroup(
header: string,
children: string[],
Copy link
Copy Markdown
Member

@tido64 tido64 May 18, 2026

Choose a reason for hiding this comment

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

This function feels unnatural to use. In an app, you want to be able to add the begin/end markers somewhere and everything in-between should be able to call a reporter freely.

In #4156, I've sort of solved this with a withGroupReporter(header, (reporter) => { ... }) and passing the reporter down. The wrapper just ensures that begin/end markers are printed as necessary.

I'm also not sure any of the CI specifics belong in a formatting package. They are much closer to reporting than formatting. It's a red flag that the code refers to "reporter" more than formatting.

Comment on lines +259 to +261
function formatGroup(header: string, children: string[]): string {
return formatAsTree(header, children, base);
}
Copy link
Copy Markdown
Member

@tido64 tido64 May 18, 2026

Choose a reason for hiding this comment

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

This seems wrong. Log lines can belong to a group, but not all of them need to be displayed as a tree.

Comment thread incubator/tools-formatting/src/reporters.ts Outdated
Comment thread incubator/tools-formatting/src/reporters.ts Outdated
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.

3 participants