File tree 3 files changed +51
-0
lines changed
3 files changed +51
-0
lines changed Original file line number Diff line number Diff line change @@ -80,6 +80,11 @@ if [ $has_errors -eq 0 ]; then
80
80
create_annotation=1
81
81
fi
82
82
83
+ if [[ -n " ${BUILDKITE_PLUGIN_JUNIT_ANNOTATE_REPORT_SLOWEST:- } " ]]; then
84
+ echo " Create annotation with slowest tests"
85
+ create_annotation=1
86
+ fi
87
+
83
88
if [[ -e " ${annotation_path} " ]]; then
84
89
TOTAL_TESTS=$( head -5 " ${annotation_path} " | grep ' Total tests' | cut -d\ -f3)
85
90
else
Original file line number Diff line number Diff line change
1
+ Failures: 0
2
+ Errors: 0
3
+ Skipped: 0
4
+ Total tests: 8
5
+
6
+ <details>
7
+ <summary>5 slowest tests</summary>
8
+ <table>
9
+ <thead><tr><th>Unit</th><th>Test</th><th>Time</th></tr></thead>
10
+ <tbody>
11
+ <tr><td>spec.models.account_spec</td><td>Account#maximum_jobs_added_by_pipeline_changer returns 250 by default</td><td>0.977127</td></tr>
12
+ <tr><td>spec.models.account_spec</td><td>Account#maximum_jobs_added_by_pipeline_changer returns 250 by default</td><td>0.967127</td></tr>
13
+ <tr><td>spec.models.account_spec</td><td>Account#maximum_jobs_added_by_pipeline_changer returns 500 if the account is ABC</td><td>0.620013</td></tr>
14
+ <tr><td>spec.models.account_spec</td><td>Account#maximum_jobs_added_by_pipeline_changer returns 900 if the account is F00</td><td>0.520013</td></tr>
15
+ <tr><td>spec.models.account_spec</td><td>Account#maximum_jobs_added_by_pipeline_changer returns 700 if the account is XYZ</td><td>0.420013</td></tr>
16
+ </tbody>
17
+ </table>
18
+ </details>
Original file line number Diff line number Diff line change @@ -500,3 +500,31 @@ DOCKER_STUB_DEFAULT_OPTIONS='--log-level error run --rm --volume \* --volume \*
500
500
unstub docker
501
501
rm " ${annotation_input} "
502
502
}
503
+
504
+ @test " creates annotation with no failures but with slowest tests trigger" {
505
+ export BUILDKITE_PLUGIN_JUNIT_ANNOTATE_ARTIFACTS=" junits/*.xml"
506
+ export BUILDKITE_PLUGIN_JUNIT_ANNOTATE_REPORT_SLOWEST=5
507
+
508
+ stub mktemp \
509
+ " -d \* : mkdir -p '$artifacts_tmp '; echo '$artifacts_tmp '" \
510
+ " -d \* : mkdir -p '$annotation_tmp '; echo '$annotation_tmp '"
511
+
512
+ stub buildkite-agent \
513
+ " artifact download \* \* : echo Downloaded artifact \$ 3 to \$ 4" \
514
+ " annotate --context \* --style \* : cat >'${annotation_input} '; echo Annotation added with context \$ 3 and style \$ 5, content saved"
515
+
516
+ stub docker \
517
+ " --log-level error run --rm --volume \* --volume \* --env \* --env \* --env BUILDKITE_PLUGIN_JUNIT_ANNOTATE_REPORT_SLOWEST=5 --env \* \* ruby /src/bin/annotate /junits : cat tests/2-slowest-tests.output"
518
+
519
+ run " $PWD /hooks/command"
520
+
521
+ assert_success
522
+
523
+ assert_output --partial " Create annotation with slowest tests"
524
+ assert_output --partial " <summary>5 slowest tests</summary>"
525
+
526
+ unstub mktemp
527
+ unstub buildkite-agent
528
+ unstub docker
529
+ rm " ${annotation_input} "
530
+ }
You can’t perform that action at this time.
0 commit comments