Something went wrong while fetching comments. Please try again.
Created by: bobheadxi
bk.AnnotatedCmd
is the generator-based pull-oriented annotations API to replace sporadic calls to annotate.sh
and buildkite-angent annotate
, splitting out annotation creation concerns out of check scripts and into the pipeline generator in a style similar to how ArtifactPaths
works, but cooler and with way more bad bash from an engineer desperately copy-pasta-ing from Stackoverflow late at night (myself).
This achieves all of the goals laid out by @jhchabran in https://github.com/sourcegraph/sourcegraph/issues/26071#issuecomment-952680939:
./annotations
. Potential sg check
integration maybe? bk.AnnotatedCmd
as the main touch point for users, I've included a big docstring there including this information which should make it easy to discover for users of bk.AnnotatedCmd
Closes https://github.com/sourcegraph/sourcegraph/issues/26071
In your script, leave a file in ./annotations
:
if [ $EXIT_CODE -ne 0 ]; then
echo -e "$OUT" >./annotations/docsite
fi
In your pipeline operation, replace bk.Cmd
with bk.AnnotatedCmd
:
pipeline.AddStep(":memo: Check and build docsite",
bk.AnnotatedCmd("./dev/check/docsite.sh", bk.AnnotatedCmdOpts{
Type: bk.AnnotationTypeError,
}))
That's it!
See https://buildkite.com/sourcegraph/sourcegraph/builds/130786:
Rules of the game:
MultiJobContext
, or all annotations from a job go into a single annotation block.MultiJobContext
and default per-job annotations, annotations of different levels go into separate annotation blocks.md
files in annotations
are treated as markdown content, otherwise we format them as terminal contentannotated-command.sh
, aliased as ./an
, turns pipeline options into arguments and runs the given command./annotations
directory for filesannotate.sh
with the generated arguments and some other parameters based on the name of the file, e.g. if it has a .md
extension or if we should include the file name.Benefits:
$BUILDKITE
or buildkite-agent
This PR is on a main-dry-run
that runs everything. https://github.com/sourcegraph/sourcegraph/commit/7dafb63f601e39e025b181a829969a2abaa95af1 triggers intentional linter errors that will generate annotations. Security scanning annotations are always around, so we verify if that works.