-
Notifications
You must be signed in to change notification settings - Fork 0
/
buildstats
executable file
·736 lines (619 loc) · 20.8 KB
/
buildstats
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
#!/bin/bash
cd "$(dirname "$0")" ; here="$(pwd)"
source "$here/common"
[ "$here/console.css" -nt "$logs/console.css" ] && cp "$here/console.css" "$logs/console.css"
build_query() {
local name="$1"
local type="$2"
local query=''
local args
eval "args=( \"\${!${type}[@]}\" )"
for i in "${args[@]}" ; do
if [[ "$i" =~ ^[0-9]+$ ]] || [[ "$name" == $i ]] ; then
local value
eval "value=\"\${${type}['$i']}\""
if [ "$query" == '' ]
then query="($value)"
else query="$query|($value)"
fi
fi
done
echo "$query"
}
build_filter() {
local name="$1"
local type="$2"
local query=''
local args
eval "args=( \"\${!${type}[@]}\" )"
for i in "${args[@]}" ; do
if [[ "$i" =~ ^[0-9]+$ ]] || [[ "$name" == $i ]] ; then
local value
eval "value=\"\${${type}['$i']}\""
if [ "$query" == '' ]
then query="$value"
else query="$query;$value"
fi
fi
done
echo "$query"
}
warning_group_file() {
if [ "$1" = '(ungrouped warnings)' ]
then echo 'other'
else printf '%s' "$1" | sed 's:[^a-zA-Z0-9_]:-:g;s:--*:-:g;s:^-*::;s:-*$::'
fi
}
filter_log() {
local file="$1"
local name="$2"
local type="$3"
local query="$(build_query "$name" "count_$type")"
local ignore="$(build_query "$name" "ignore_$type")"
if [ "$query" == '' ] ; then
return
fi
if [ -z "$ignore" ]
then grep -P "$query" "$file" | sort --human-numeric-sort | uniq
else grep -P "$query" "$file" | grep -vP "$ignore" | sort --human-numeric-sort | uniq
fi
}
format_html() {
html_header "$project_name: $3 build" "../.." > "$2"
echo "<pre>" >> "$2"
"$here/console2html.cpp" --format html < "$1" >> "$2"
echo "</pre>" >> "$2"
html_footer >> "$2"
}
format_plain() {
"$here/console2html.cpp" --format plain < "$1" > "$2"
}
format() {
if [ "$2" -nt "$3" ] || [ "$here/console2html.cpp" -nt "$3" ] ; then
format_$1 "${@:2}"
fi
}
is_cache_valid() {
local cache="$1"
local input="$2"
[ ! "$force" = 1 ] \
&& [ -f "$cache" ] \
&& [ ! "$input" -nt "$cache" ] \
&& [ ! "$here/buildstats" -nt "$cache" ] \
&& [ ! "$here/common" -nt "$cache" ] \
&& [ ! "$here/config" -nt "$cache" ] \
&& [ ! "$here/config.local" -nt "$cache" ] \
&& [ ! "$here/projects/$project" -nt "$cache" ] \
&& [ ! "$here/projects/$project.local" -nt "$cache" ] \
&& true
}
get_config_change() {
local prefix="$1"
local old="$2"
local new="$3"
declare -A oldlines
while IFS='' read -r line || [[ -n "$line" ]] ; do
[ -z "$line" ] && continue
oldlines["$line"]=1
done < "$old"
while IFS='' read -r line || [[ -n "$line" ]] ; do\
[ -z "$line" ] && continue
[ "${oldlines["$line"]:-0}" = 1 ] && continue
local feature=''
for suffix in "${config_unavailable[@]}" ; do
if [[ "$line" == *"$suffix" ]] ; then
feature="${line%"$suffix"}"
fi
done
[ -z "$feature" ] && continue
[ "${oldlines["$feature"]:-0}" = 1 ] && printf "%s%s\n" "$prefix" "${line#--}"
done < "$new"
}
handle_build() {
local file="$1"
local path="${file%.ref}"
local name="${path##*/}"
local has_false_positives=0
if in_wildcard_array "$name" "${false_positives[@]}" ; then
has_false_positives=1
fi
local commit="$(cat "$file")"
commits+="$commit
"
local old_file="$path.old"
local old_commit=''
local old_prefix=''
if [ -f "$old_file" ] ; then
old_commit="$(cat "$old_file")"
old_commits+="$old_commit
"
old_prefix="$logs/commits/$old_commit/$name"
fi
local prefix="$logs/commits/$commit/$name"
if [ ! -e "$prefix-raw.txt" ] ; then
echo "Skipping missing/incomplete '${esc}[33m$name${esc}[0m' at commit ${esc}[34m$commit${esc}[0m"
return
fi
local cache="$path-cache.html"
if is_cache_valid "$cache" "$prefix-raw.txt" ; then
local html="$(cat "$cache")
"
if [ $has_false_positives = 0 ]
then builds_legit+="$html"
else builds_bogus+="$html"
fi
return
fi
# Produce a nice colorful html log.
format html "$prefix-raw.txt" "$prefix.html" "$name"
# Produce a plain text log without shell color codes.
format plain "$prefix-raw.txt" "$prefix.txt" "$name"
local config_warnings_file="$prefix-config-warnings.txt"
local config_errors_file="$prefix-config-errors.txt"
if ! is_cache_valid "$config_warnings_file" "$prefix-config.txt" ; then
filter_log "$prefix-config.txt" "$name" config_warnings > "$config_warnings_file"
fi
if ! is_cache_valid "$config_errors_file" "$prefix-config.txt" ; then
filter_log "$prefix-config.txt" "$name" config_errors > "$config_errors_file"
fi
local config_warnings="$(wc -l < "$config_warnings_file")"
local config_errors="$(wc -l < "$config_errors_file")"
local warnings_file="$prefix-warnings.txt"
local errors_file="$prefix-errors.txt"
if ! is_cache_valid "$warnings_file" "$prefix.txt" ; then
filter_log "$prefix.txt" "$name" warnings > "$warnings_file"
fi
if ! is_cache_valid "$errors_file" "$prefix.txt" ; then
filter_log "$prefix.txt" "$name" errors > "$errors_file"
fi
local warnings="$(wc -l < "$warnings_file")"
local errors="$(wc -l < "$errors_file")"
local time="$(grep real "$prefix-time.txt" 2> /dev/null)"
local time="${time##* }"
local minutes="$(echo "$time" | sed -r 's/^real\t(.*)m(.*)s$/\1/g')"
local seconds="$(echo "$time" | sed -r 's/^real\t(.*)m(.*)s$/\2/g')"
local dir="${file%/*}"
local wprefix="$(relative_path "$dir" "$prefix")"
local warnings_l='warnings'
[ "$warnings" = 1 ] && warnings_l='warning '
local errors_l='errors'
[ "$errors" = 1 ] && errors_l='error '
local config_class=''
[ $config_warnings = 0 ] || config_class=" class='w w$config_warnings'"
[ $config_errors = 0 ] || config_class=" class='e e$config_errors'"
if ! in_array "$name" "${build_types[@]}" ; then
disabled='obsolete'
else
local args
local disabled=''
parse_build_type "$name" 'args'
for arg in "${args[@]}" ; do
if in_array "$arg" "${disabled_configs[@]}" ; then
[ -z "$disabled" ] || disabled="$disabled, "
disabled="$disabled$arg"
fi
done
[ -z "$disabled" ] || disabled="$disabled disabled"
fi
local dclass=''
if [ ! -z "$disabled" ] ; then
dclass=" class=\"disabled\" title=\"$disabled\""
fi
local details=''
if [ -d "$prefix-results/" ] ; then
details+=" <span class=\"details\">[<a href=\"$wprefix-results/\">details</a>]</span>"
fi
if [ ! $has_false_positives = 0 ] && [ $warnings -gt 19 ] ; then
local warnings_dir="$prefix-warnings"
local old_warnings_dir="$old_prefix-warnings"
local warnings_index="$warnings_dir/index.txt"
local old_warnings_index="$old_warnings_dir/index.txt"
local windex_dir="$path-warnings"
local windex="$windex_dir/index.html"
if ! is_cache_valid "$windex_dir" "$warnings_file" ; then
mkdir -p "$windex_dir"
rm -f "$windex_dir"/*
# Split warnings into groups
if [ "$windex_dir" = "$warnings_dir" ] ; then
local query="$(build_query "$name" 'group_warnings')"
local filter="$(build_filter "$name" 'group_filter')"
declare -A groups
while IFS='' read -r line || [[ -n "$line" ]] ; do
local group="$(
printf '%s' "$line" | grep -Pom1 "$query" | sed "$filter;s:^ *::;s: *$::" | head -n1
)"
[ -z "$group" ] && group='(ungrouped warnings)'
groups["$group"]+="$line"$'\n'
done < "$warnings_file"
for group in "${!groups[@]}" ; do
local group_file="$warnings_dir/$(warning_group_file "$group").txt"
printf '%s' "${groups[$group]}" >> "$group_file";
printf '%s\n' "$group"
done | sort -u > "$warnings_index"
fi
local warning_indices=( "$warnings_index" )
[ -f "$old_warnings_index" ] && warning_indices+=( "$old_warnings_index" )
# Create index page for groups
if [ $(cat "${warning_indices[@]}" | sort -u | wc -l) -gt 1 ] ; then
local documentation="$(build_filter "$name" 'group_documentation')"
local warnings_title="$name warnings for $project_name in $type $context"
printf '%s\n<h1>%s</h1>\n<ul>\n' \
"$(html_header "$warnings_title" "../../..")" \
"$warnings_title" \
> "$windex"
cat "${warning_indices[@]}" | sort -u | \
while IFS='' read -r group || [[ -n "$group" ]] ; do
[ -z "$group" ] && continue
local group_file="$warnings_dir/$(warning_group_file "$group").txt"
local group_size="0"
[ -f "$group_file" ] && group_size="$(wc -l < "$group_file")"
printf "%d %s\n" "$group_size" "$group"
done \
| sort -h | sed 's:^[0-9]* *::' | \
while IFS='' read -r group || [[ -n "$group" ]] ; do
[ -z "$group" ] && continue
local group_file="$warnings_dir/$(warning_group_file "$group").txt"
local group_size="0"
[ -f "$group_file" ] && group_size="$(wc -l < "$group_file")"
local link="<s>$group</s>"
local wgroup_file="$(relative_path "$windex_dir" "$group_file" | sed 's: :%20:g')"
[ -f "$group_file" ] && link="<a href=\"$wgroup_file\">$group</a>"
local changes=''
if [ ! -z "$old_prefix" ] ; then
local old_group_file="$old_warnings_dir/$(warning_group_file "$group").txt"
[ -f "$group_file" ] || group_file='/dev/null'
[ -f "$old_group_file" ] || old_group_file='/dev/null'
local change_file="$windex_dir/$(warning_group_file "$group")-change.txt"
if ! is_cache_valid "$change_file" "$here/warningdiff.cpp" \
|| [ "$warnings_file" -nt "$change_file" ] || [ "$old_warnings_file" -nt "$change_file" ]
then
"$here/warningdiff.cpp" "$project_name/" "$repo/.git" \
"$old_commit" "$old_group_file" "$commit" "$group_file" \
> "$change_file"
fi
local broken="$(cat "$change_file" | grep -P '^\+' | wc -l)"
local fixed="$(cat "$change_file" | grep -P '^\-' | wc -l)"
[ $broken = 0 ] || changes+="<span class=\"bad\">+$broken</span>"
[ ! $broken = 0 ] && [ ! $fixed = 0 ] && changes+=' '
[ $fixed = 0 ] || changes+="<span class=\"good\">-$fixed</span>"
local wchange_file="$(relative_path "$windex_dir" "$change_file" | sed 's: :%20:g')"
if [ -z "$changes" ]
then changes=' | ='
else changes=" | <a href=\"$wchange_file\"><b>$changes</b></a>"
fi
fi
local docs=''
if [ ! -z "$documentation" ] ; then
local docs_url="$(printf '%s' "$group" | sed -e "$documentation")"
if [ ! -z "$docs_url" ] && [ ! "$docs_url" = "$group" ] ; then
docs=" [<a href="$docs_url">docs</a>]"
fi
fi
printf '<li>%s%s (%d%s)\n' \
"$link" \
"$docs" \
"$group_size" \
"$changes" \
>> "$windex"
done
printf '</ul>\n%s\n' "$(html_footer)" >> "$windex"
fi
touch "$windex_dir"
fi
if [ -f "$windex" ] ; then
details+=" <span class=\"grouped\">[<a href=\"$name-warnings/\">grouped</a>]</span>"
fi
fi
local primary_id=''
local extra_ids=''
local id="$name"
while [ ! -z "$id" ] && [ -z "${html_ids["$id"]}" ] ; do
if [ -z "$primary_id" ]
then primary_id="id=\"$id\" "
else extra_ids="<a id=\"$id\"></a>$extra_ids"
fi
html_ids["$id"]=1
if [[ "$id" == *_* ]] ; then
local part="${id##*_}"
if [ $has_false_positives = 0 ] && [ -z "${html_ids["$part"]}" ] ; then
extra_ids="<a id=\"$part\"></a>$extra_ids"
html_ids["$part"]=1
fi
id="${id%_*}"
elif [ $has_false_positives = 0 ] && [[ "$id" == *-* ]] ; then
id="${id%-*}"
else
break
fi
done
local html="<tr$dclass>
<td class='n'>${extra_ids}<a ${primary_id}href=\"$wprefix.html\">$name</a>$details</td>
<td align=right class='w w$warnings'>"
[ $warnings -gt 0 ] && html+="<a href=\"$wprefix-warnings.txt\">"
html+="<b>$warnings</b> $warnings_l"
[ $warnings -gt 0 ] && html+="</a>"
html+="</td>
<td align=right class='e e$errors'>"
[ $errors -gt 0 ] && html+="<a href=\"$wprefix-errors.txt\">"
html+="<b>$errors</b> $errors_l"
[ $errors -gt 0 ] && html+="</a>"
html+="</td>
<td align=right class='tm'>$minutes min</td><td align=right class='ts'>$seconds s</td>
<td><a href=\"$wprefix.txt\">[txt]</a></td>
<td><a href=\"$wprefix-raw.txt\">[raw]</a></td>
<td><a href=\"$wprefix-options.txt\">[opt]</a></td>
<td$config_class><a href=\"$wprefix-config.txt\">[cfg]</a>"
[ $config_warnings -gt 0 ] && html+="<a href=\"$wprefix-config-warnings.txt\">[w]</a>"
[ $config_errors -gt 0 ] && html+="<a href=\"$wprefix-config-errors.txt\">[e]</a>"
if [ ! -z "$old_prefix" ] ; then
local config_change_file="$path-config-change.txt"
local config_file="$prefix-config.txt"
local old_config_file="$old_prefix-config.txt"
if ! is_cache_valid "$config_change_file" "$config_file" \
|| [ "$old_config_file" -nt "$config_change_file" ] ; then
local change="$(
get_config_change '+' "$old_config_file" "$config_file"
get_config_change '-' "$config_file" "$old_config_file"
)"
printf '%s\n' "$change" > "$config_change_file"
fi
local changes=''
local broken="$(cat "$config_change_file" | grep -P '^\+' | wc -l)"
local fixed="$(cat "$config_change_file" | grep -P '^\-' | wc -l)"
[ $broken = 0 ] || changes+="<span class=\"bad\">+$broken</span>"
[ ! $broken = 0 ] && [ ! $fixed = 0 ] && changes+=' '
[ $fixed = 0 ] || changes+="<span class=\"good\">-$fixed</span>"
local wconfig_change_file="$(relative_path "$dir" "$config_change_file")"
[ -z "$changes" ] || html+=" <a href=\"$wconfig_change_file\"><b>$changes</b></a>"
fi
html+="</td>"
if [ ! $has_false_positives = 0 ] && [ ! -z "$old_prefix" ] ; then
local change_file="$path-change.txt"
local old_warnings_file="$old_prefix-warnings.txt"
local old_errors_file="$old_prefix-errors.txt"
if ! is_cache_valid "$change_file" "$here/warningdiff.cpp" \
|| [ "$warnings_file" -nt "$change_file" ] || [ "$old_warnings_file" -nt "$change_file" ] \
|| [ "$errors_file" -nt "$change_file" ] || [ "$old_errors_file" -nt "$change_file" ]
then
local change="$(
"$here/warningdiff.cpp" "$project_name/" "$repo/.git" "$old_commit" "$old_warnings_file" "$commit" "$warnings_file"
"$here/warningdiff.cpp" "$project_name/" "$repo/.git" "$old_commit" "$old_errors_file" "$commit" "$errors_file"
)"
printf '%s\n' "$change" > "$change_file"
fi
local changes=''
local broken="$(cat "$change_file" | grep -P '^\+' | wc -l)"
local fixed="$(cat "$change_file" | grep -P '^\-' | wc -l)"
[ $broken = 0 ] || changes+="<span class=\"bad\">+$broken</span>"
[ ! $broken = 0 ] && [ ! $fixed = 0 ] && changes+=' '
[ $fixed = 0 ] || changes+="<span class=\"good\">-$fixed</span>"
local wchange_file="$(relative_path "$dir" "$change_file")"
if [ -z "$changes" ]
then changes='='
else changes="<a href=\"$wchange_file\"><b>$changes</b></a>"
fi
html+="
<td align=center>$changes</td>"
elif [ ! $has_false_positives = 0 ] ; then
html+="
<td></td>"
fi
html+='
</tr>
'
printf '%s' "$html" > "$cache"
if [ $has_false_positives = 0 ]
then builds_legit+="$html"
else builds_bogus+="$html"
fi
echo "${esc}[34m$name${esc}[0m: $warnings warnings, $errors errors, $minutes min $seconds s"
}
link_builds() {
local name="$1"
local dir="$2"
local commits="$(printf '%s' "$3" | sort | uniq)"
[ -z "$commits" ] && return
printf '%s' "<b>$name"
local comma=0
for commit in $commits ; do
if [ $comma = 1 ]
then printf '%s' ", "
else comma=1
fi
url="$(relative_path "$dir" "$logs/commits/$commit/")"
timestamp="$(git --git-dir="$repo/.git" show -s --format='%ct' "$commit")"
datetime="$(date --utc --iso-8601=seconds --date="@$timestamp")"
time="$(date --utc --rfc-3339=seconds --date="@$timestamp")"
time="${time%+00:00}"
text="$(
git --git-dir="$repo/.git" describe --exact-match --tags "$commit" 2> /dev/null \
|| printf '%s' "${commit:0:6}"
)"
printf '%s' "<a href="$url">$text</a> (<time datetime=\"$datetime\">$time</time>)"
done
printf '%s\n' '</b><br>'
}
handle_context() {
local type="$1"
local dir="$2"
[ -d "$dir" ] || return
local context="${dir##*/}"
local timefile="$dir/index.time"
if ! is_cache_valid "$timefile" "$dir"
then echo "Updating '${esc}[36m$context${esc}[0m'..."
else return
fi
local -A html_ids
html_ids['analyzers']=1
html_ids['external']=1
local commits=''
local old_commits=''
local builds_legit=''
local builds_bogus=''
for f in $(dir -d $dir/*.ref 2> /dev/null | sort -V) ; do
handle_build "$f"
done
local html="$(html_header "$project_name build logs for $type $context" "../.." "
<script type=\"text/javascript\">
function nextElementSibling(e) {
do {
e = e.nextSibling;
} while(e && e.nodeType != 1);
return e;
}
function startsWith(str, needle) {
return str.substring(0, needle.length) == needle;
}
function endsWith(str, needle) {
return str.indexOf(needle, str.length - needle.length) !== -1;
}
function contains(str, needle) {
return str.indexOf(needle) !== -1;
}
function isInCategory(e, id) {
if(!e || !e.id) {
return 0;
}
if(startsWith(e.id, id + '_')) {
return 1;
}
if(!contains(id, '_')) {
if(startsWith(e.id, id + '-')) {
return 1;
}
if(contains(e.id, '_' + id + '_')) {
return 2;
}
if(endsWith(e.id, '_' + id)) {
return 2;
}
}
return isInCategory(nextElementSibling(e), id);
}
function setCategoryClass(id, className) {
var e = document.getElementById(id);
if(!e || !e.parentElement || !e.parentElement.parentElement) {
return;
}
var tr = e.parentElement.parentElement;
tr.className = className;
var contiguous = contains(id, '_') || isInCategory(nextElementSibling(e), id) != 2;
while(tr = nextElementSibling(tr)) {
var a = tr.firstElementChild ? tr.firstElementChild.firstElementChild : null;
if(isInCategory(a, id)) {
tr.className = className;
} else if(contiguous) {
break;
}
}
}
var oldid = null;
window.onload = function () {
var newid = window.location.hash.substr(1);
if(newid == '') {
newid = null;
}
if(newid != oldid) {
if(oldid) {
setCategoryClass(oldid, null);
}
if(newid) {
setCategoryClass(newid, 'selected');
}
oldid = newid;
}
}
if('onhashchange' in window) {
window.onhashchange = window.onload;
}
</script>")
<h1>Build logs for $type "
if [ ! -z "$commit_url" ]
then html+="<a href="$commit_url$context">$context</a>"
else html+="$context"
fi
html+="</h1>
<a href=\"../\">Other Logs</a><br>
<br>
"
if [ ! "$type" = 'commit' ] ; then
html+="$(link_builds 'Current build: ' "$dir" "$commits" | sed 's:^:\t:')"
html+="$(link_builds 'Previous build: ' "$dir" "$old_commits" | sed 's:^:\t:')"
fi
if [ ! -z "$builds_legit" ] ; then
html+="
<br>
<table cellspacing=1 cellpadding=2 class='legit stats'>
$(printf '%s' "$builds_legit" | sed 's:^:\t\t:')
</table>"
fi
if [ ! -z "$builds_bogus" ] ; then
html+="
<h2 id=\"analyzers\">Static analyzers and other build logs that are likely to contain false positives:</h2>
<table cellspacing=1 cellpadding=2 class='bogus stats'>
$(printf '%s' "$builds_bogus" | sed 's:^:\t\t:')
</table>"
fi
if [ ! -z "$covertiy_scan_project$github_project$appveyor_project" ] ; then
html+="
<h2 id=\"external\">External tools:</h2>
<ul>"
if [ ! -z "$covertiy_scan_project" ] ; then
html+="
<li><b><a href=\"https://scan.coverity.com/projects/$covertiy_scan_project\">Coverity Scan</a></b>"
fi
if [ ! -z "$github_project" ] ; then
html+="
<li><b><a href=\"https://github.com/$github_project/actions\">GitHub CI</a></b>
<li><b><a href=\"https://github.com/$github_project/security/code-scanning\">GitHub Code Scanning</a></b>"
fi
if [ ! -z "$appveyor_project" ] ; then
html+="
<li><b><a href=\"https://ci.appveyor.com/project/$appveyor_project\">AppVeyor</a></b>"
fi
html+="
</ul>"
fi
html+="
$(html_footer)"
local index="$dir/index.html"
if [ ! -e "$index" ] || [ "$(cat "$index")" != "$html" ]
then printf '%s\n' "$html" > "$index"
else echo "${esc}[32m(no changes)${esc}[0m"
fi
if [ ! -z "$project_buildlogs_url" ] && [ "$type" = 'branch' ] ; then
local _commits="$(printf '%s' "$commits" | sort | uniq)"
local _buildlogs_url="${project_buildlogs_url}branches/${context}/"
local _buildlogs_feed="$dir/feed.rss"
echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>
<rss version=\"2.0\" xmlns:atom=\"http://www.w3.org/2005/Atom\">
<channel>
<title>${project_name} build logs for branch ${context}</title>
<link>${_buildlogs_url}</link>
<description>Errors, warnings and notices for ${project_name} built with different compilers.</description>
<language>en-us</language>
<atom:link href=\"${_buildlogs_url}feed.rss\" rel=\"self\" type=\"application/rss+xml\" />" \
> "$_buildlogs_feed"
for commit in $_commits ; do
local _time="$(git --git-dir="$repo/.git" show -s --format='%ct' "$commit")"
echo "<item>
<title>${project_name} build logs for branch ${context} updated to ${commit}</title>
<link>${_buildlogs_url}</link>
<pubDate>$(date --rfc-2822 --utc --date="@${_time}")</pubDate>
<guid>${project_buildlogs_url}commits/${commit}/</guid>
</item>" >> "$_buildlogs_feed"
done
echo '</channel>
</rss>' >> "$_buildlogs_feed"
touch --reference="$index" "$_buildlogs_feed"
fi
touch "$timefile"
}
echo "Updating indices..."
for f in $(dir -d $logs/commits/* 2> /dev/null) ; do
handle_context 'commit' "$f"
done
for f in $(dir -d $logs/branches/* 2> /dev/null) ; do
handle_context 'branch' "$f"
done
echo "Done."