File tree 2 files changed +35
-7
lines changed
2 files changed +35
-7
lines changed Original file line number Diff line number Diff line change @@ -46,15 +46,14 @@ cat "$annotation_path"
46
46
if grep -q " <details>" " $annotation_path " ; then
47
47
48
48
if ! check_size; then
49
- echo " --- :warning: Failures too large to annotate"
50
- echo " The failures are too large to create a build annotation. Please inspect the failed JUnit artifacts manually."
51
- exit 0
49
+ echo " --- :warning: Failures too large to annotate"
50
+ echo " The failures are too large to create a build annotation. Please inspect the failed JUnit artifacts manually."
51
+ else
52
+ echo " --- :buildkite: Creating annotation"
53
+ # shellcheck disable=SC2002
54
+ cat " $annotation_path " | buildkite-agent annotate --context " ${BUILDKITE_PLUGIN_JUNIT_ANNOTATE_CONTEXT:- junit} " --style error
52
55
fi
53
56
54
- echo " --- :buildkite: Creating annotation"
55
- # shellcheck disable=SC2002
56
- cat " $annotation_path " | buildkite-agent annotate --context " ${BUILDKITE_PLUGIN_JUNIT_ANNOTATE_CONTEXT:- junit} " --style error
57
-
58
57
if [[ " ${BUILDKITE_PLUGIN_JUNIT_ANNOTATE_FAIL_BUILD_ON_ERROR:- false} " =~ (true| on| 1) ]]
59
58
then
60
59
echo " --- :boom: Failing build due to error"
Original file line number Diff line number Diff line change @@ -148,4 +148,33 @@ load "$BATS_PATH/load.bash"
148
148
unstub buildkite-agent
149
149
unstub du
150
150
unstub mktemp
151
+ }
152
+
153
+ @test " returns an error if fail-build-on-error is true and annotation is too large" {
154
+ export BUILDKITE_PLUGIN_JUNIT_ANNOTATE_ARTIFACTS=" junits/*.xml"
155
+ export BUILDKITE_PLUGIN_JUNIT_ANNOTATE_FAIL_BUILD_ON_ERROR=true
156
+
157
+ artifacts_tmp=" tests/tmp/$PWD /junit-artifacts"
158
+ annotation_tmp=" tests/tmp/$PWD /junit-annotation"
159
+
160
+ stub mktemp \
161
+ " -d junit-annotate-plugin-artifacts-tmp.XXXXXXXXXX : mkdir -p $artifacts_tmp ; echo $artifacts_tmp " \
162
+ " -d junit-annotate-plugin-annotation-tmp.XXXXXXXXXX : mkdir -p $annotation_tmp ; echo $annotation_tmp "
163
+
164
+ # 1KB over the 1MB size limit of annotations
165
+ stub du " -k /plugin/tests/tmp//plugin/junit-annotation/annotation.md : echo 1025 /plugin/tests/tmp//plugin/junit-annotation/annotation.md"
166
+
167
+ stub buildkite-agent " artifact download junits/*.xml /plugin/tests/tmp//plugin/junit-artifacts : echo Downloaded artifacts"
168
+
169
+ 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= --env BUILDKITE_PLUGIN_JUNIT_ANNOTATE_FAILURE_FORMAT= ruby:2.7-alpine ruby /src/bin/annotate /junits : echo '<details>Failure</details>'"
170
+
171
+ run " $PWD /hooks/command"
172
+
173
+ assert_failure
174
+
175
+ assert_output --partial " Failures too large to annotate"
176
+
177
+ unstub mktemp
178
+ unstub buildkite-agent
179
+ unstub docker
151
180
}
You can’t perform that action at this time.
0 commit comments