Skip to content

Commit 52df870

Browse files
author
Julian Simpson
committed
Don't publish annotations larger than 100KB
The API won't process annotations larger than 100KB, so it's better to reply with an error message earlier.
1 parent 5eedd9f commit 52df870

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

hooks/command

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
set -euo pipefail
44

55
PLUGIN_DIR="$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd)/.."
6+
MAX_SIZE=100 # in KB
67

78
echo "--- :junit: Download the junits"
89

@@ -15,6 +16,12 @@ function cleanup {
1516
rm -rf "${annotation_dir}"
1617
}
1718

19+
function check_size {
20+
local size_in_kb
21+
size_in_kb=$(du -k "${annotation_path}" | cut -f 1)
22+
[ "${size_in_kb}" -lt "${MAX_SIZE}" ]
23+
}
24+
1825
trap cleanup EXIT
1926

2027
buildkite-agent artifact download \
@@ -37,6 +44,12 @@ docker \
3744
cat "$annotation_path"
3845

3946
if grep -q "<details>" "$annotation_path"; then
47+
48+
if ! check_size; then
49+
echo "--- :hurtrealbad: Sorry, annotation is too big to publish"
50+
exit 1
51+
fi
52+
4053
echo "--- :buildkite: Creating annotation"
4154
# shellcheck disable=SC2002
4255
cat "$annotation_path" | buildkite-agent annotate --context junit --style error

0 commit comments

Comments
 (0)