feat(tools-formatting): Support github and azure output formatting for annotations and groups#4153
feat(tools-formatting): Support github and azure output formatting for annotations and groups#4153JasonVMo wants to merge 8 commits into
Conversation
…crosoft/rnx-kit into user/jasonvmo/output-grouping
|
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. |
|
Is there an example of output? Hard to judge otherwise |
| */ | ||
| export function formatGroup( | ||
| header: string, | ||
| children: string[], |
There was a problem hiding this comment.
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.
| function formatGroup(header: string, children: string[]): string { | ||
| return formatAsTree(header, children, base); | ||
| } |
There was a problem hiding this comment.
This seems wrong. Log lines can belong to a group, but not all of them need to be displayed as a tree.
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.
ReporterRegistryis a singleton class which can be overridden if additional reporter types need to be supported.Core functions
The library exposes
formatMessage,formatFileMessage, andformatGroupwhich can have the reporter specified, or will default to whatever is appropriate for the current environment.To-dos