Skip to content

Conversation

@alekstorm
Copy link
Contributor

Buildkite annotations, which this plugin creates, are limited to 100KB, and this plugin has a sophisticated algorithm for truncating the annotation to only the number of failures that would generate a Markdown-formatted annotation of less than that size. With stacktraces, that number can be as low as 15 failures: a small fraction of what a change to a large monorepo can cause.

This change causes the plugin to also upload an artifact containing the HTML-ified non-truncated Markdown output, and link to that artifact from the annotation if the annotation has been truncated.

This requires a refactor: Truncater now knows nothing about Formatter or Markdown; it only handles the truncation algorithm on the strings returned by a block. Much of the logic to wire Truncater and Formatters together has been moved to a new Processor class (this name was too similar to "Runner", so I renamed that to "Main"). This makes each class a bit more cohesive: Truncater only handles string truncation, Processor hands off the result of Formatter to Truncater, and Main writes the result of Processor to annotations and artifacts.

Also:

  • I repurposed the test_layout template to also wrap the artifact, making the appearance similar to the annotation within Buildkite's UI.
  • There's now a mixin for classes that want to reraise-or-log, depending on the result of a fail_on_error method, and any error can now be accompanied by a "diagnostics" JSON object.
  • We now have a runtime dependency on a Markdown-to-HTML converter, so I switched to Kramdown, which is pure Ruby. The current minimal Dockerfile doesn't have the tools to compile C extensions.

@alekstorm alekstorm force-pushed the output-artifact branch 3 times, most recently from a552d48 to dbd002a Compare April 1, 2021 21:48
Buildkite annotations, which this plugin creates, are limited to 100KB, and this plugin has a
sophisticated algorithm for truncating the annotation to only the number of failures that would generate a
Markdown-formatted annotation of less than that size. With stacktraces, that number can be as low
as 15 failures: a small fraction of what a change to a large monorepo can cause.

This change causes the plugin to also upload an artifact containing the HTML-ified non-truncated Markdown
output, and link to that artifact from the annotation if the annotation has been truncated.

This requires a refactor: Truncater now knows nothing about Formatter or Markdown; it only handles
the truncation algorithm on the strings returned by a block. Much of the logic to wire Truncater and
Formatters together has been moved to a new Processor class (this name was too similar to "Runner", so I
renamed that to "Main"). This makes each class a bit more cohesive: Truncater only handles string truncation,
Processor hands off the result of Formatter to Truncater, and Main writes the result of Processor to
annotations and artifacts.

Also:
- I repurposed the `test_layout` template to also wrap the artifact, making the appearance similar to the
  annotation within Buildkite's UI.
- There's now a mixin for classes that want to reraise-or-log, depending on the result of a `fail_on_error`
  method, and any error can now be accompanied by a "diagnostics" JSON object.
- We now have a runtime dependency on a Markdown-to-HTML converter, so I switched to Kramdown, which
  is pure Ruby. The current minimal Dockerfile doesn't have the tools to compile C extensions.
@alekstorm
Copy link
Contributor Author

Bump. Is there any update on this?

@maschwenk
Copy link
Contributor

@liath want to take a look?

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.

2 participants