Automattic / a8c-ci-toolkit-buildkite-plugin

A caching plugin that can be invoked from your build script.
22 stars 5 forks source link

`annotate_test_failures`: Fix case of special characters in step label / annotation context #65

Closed AliSoftware closed 1 year ago

AliSoftware commented 1 year ago

Why?

This fixes an issue with the annotate_test_failures utility when the BUILDKITE_LABEL happens to contains special characters, like is the case for example in Tumblr-Android with steps named E2E tests #1 and E2E tests #2.

Those # in the label means that the string we derive from it to use as the annotation context end up messing things up, because that # is not escaped, and when we try to buildkite-agent annotation remove --context 'E2E tests #1', this fails to find the annotation and to remove it, because of that special character confusing the Buildkite agent API(†).

(†) That hypothesis (about why those "E2E tests #1" / "E2E tests #2" annotations were never removed on step retry in Tumblr because of that # character messing things up) was confirmed via this commit and this CI build, by creating two annotations, one with a regular context string and one with a tricky one, and showing that the regular one was removed as expected but the tricky one failed to be removed due to its # character in the context string.

How?


cc @adimoldovan FYI as to why the Buildkite annotations were never removed like they were expected to after a successful retry of the "E2E tests #N" steps on Tumblr-Android.