Skip to content

Commit 9b0be93

Browse files
committed
Tests and debug for blank annotations
1 parent 40a7021 commit 9b0be93

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

hooks/command

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ docker \
3535

3636
cat "$annotation_path"
3737

38+
buildkite-agent artifact upload "$annotation_path"
39+
3840
if ! grep -q "There were no failures" "$annotation_path"; then
3941
echo "--- :buildkite: Creating annotation"
4042
# shellcheck disable=SC2002

tests/command.bats

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,31 @@ load "$BATS_PATH/load.bash"
2828

2929
assert_output --partial "Annotation added"
3030

31+
unstub mktemp
32+
unstub buildkite-agent
33+
unstub docker
34+
}
35+
36+
@test "doesn't create annotation unless there's failures" {
37+
export BUILDKITE_PLUGIN_JUNIT_ANNOTATE_ARTIFACTS="junits/*.xml"
38+
39+
artifacts_tmp="tests/tmp/$PWD/junit-artifacts"
40+
annotation_tmp="tests/tmp/$PWD/junit-annotation"
41+
42+
stub mktemp \
43+
"-d junit-annotate-plugin-artifacts-tmp.XXXXXXXXXX : mkdir -p $artifacts_tmp; echo $artifacts_tmp" \
44+
"-d junit-annotate-plugin-annotation-tmp.XXXXXXXXXX : mkdir -p $annotation_tmp; echo $annotation_tmp"
45+
46+
stub buildkite-agent "artifact download junits/*.xml /plugin/tests/tmp//plugin/junit-artifacts : echo Downloaded artifacts"
47+
48+
stub docker "--log-level error run --rm --volume /plugin/tests/tmp//plugin/junit-artifacts:/junits --volume /plugin/hooks/../ruby:/src --env BUILDKITE_PLUGIN_JUNIT_ANNOTATE_JOB_UUID_FILE_PATTERN= ruby:2.5-alpine /src/bin/annotate /junits : echo There were no failures"
49+
50+
run "$PWD/hooks/command"
51+
52+
assert_success
53+
54+
assert_output --partial "There were no failures"
55+
3156
unstub mktemp
3257
unstub buildkite-agent
3358
unstub docker

0 commit comments

Comments
 (0)