@@ -14,16 +14,58 @@ function print_reactor_summary() {
1414 cat " $BUILD_LOG " | sed -n " ${start} ,${end} p" | sed ' s/\[INFO\] //'
1515}
1616
17+ gha_escape () {
18+ sed -e ' s/%/%25/g' -e ' s/\r/%0D/g' -e ' s/\n/%0A/g'
19+ }
20+
21+ emit_markdownlint_annotations () {
22+ [[ -f " $BUILD_LOG " ]] || return 0
23+
24+ while IFS= read -r l; do
25+ file=$( echo " $l " | sed -E ' s/^([^:]+\.md):.*/\1/' )
26+ line=$( echo " $l " | sed -E ' s/^[^:]+\.md:([0-9]+).*/\1/' )
27+
28+ # Repair path so GitHub can link it (repo-root relative)
29+ if [[ ! -f " $file " ]]; then
30+ if [[ -f " bundles/$file " ]]; then
31+ file=" bundles/$file "
32+ elif [[ -f " itests/$file " ]]; then
33+ file=" itests/$file "
34+ fi
35+ fi
36+
37+ if echo " $l " | grep -qE ' ^[^:]+\.md:[0-9]+:[0-9]+ error MD' ; then
38+ col=$( echo " $l " | sed -E ' s/^[^:]+\.md:[0-9]+:([0-9]+) error .*/\1/' )
39+ rule=$( echo " $l " | sed -E ' s/^[^:]+\.md:[0-9]+:[0-9]+ error (MD[^ ]+) .*/\1/' )
40+ rest=$( echo " $l " | sed -E ' s/^[^:]+\.md:[0-9]+:[0-9]+ error MD[^ ]+ (.*)$/\1/' )
41+ rest_esc=$( printf ' %s' " $rest " | gha_escape)
42+ echo " ::error file=$file ,line=$line ,col=$col ,title=$rule ::$rest_esc "
43+ else
44+ rule=$( echo " $l " | sed -E ' s/^[^:]+\.md:[0-9]+ error (MD[^ ]+) .*/\1/' )
45+ rest=$( echo " $l " | sed -E ' s/^[^:]+\.md:[0-9]+ error MD[^ ]+ (.*)$/\1/' )
46+ rest_esc=$( printf ' %s' " $rest " | gha_escape)
47+ echo " ::error file=$file ,line=$line ,title=$rule ::$rest_esc "
48+ fi
49+ done < <(
50+ grep -aE ' \[INFO\] .*\.md:[0-9]+(:[0-9]+)? error MD' " $BUILD_LOG " \
51+ | sed -E ' s/^.*\[INFO\] //'
52+ )
53+ }
54+
1755function mvnp() {
18- set -o pipefail # exit build with error when pipes fail
19- local reactor_size=$( find -name " pom.xml" | grep -vE ' /src/|/target/' | wc -l)
20- local padding=$( bc -l <<< " scale=0;2*(l($reactor_size)/l(10)+1)" )
21- local command=(./mvnw $@ )
22- exec " ${command[@]} " 2>&1 | # execute, redirect stderr to stdout
23- tee " $BUILD_LOG " | # write output to log
24- stdbuf -oL grep -aE ' ^\[INFO\] Building .+ \[.+\]$' | # filter progress
25- stdbuf -o0 sed -uE ' s/^\[INFO\] Building (.*[^ ])[ ]+\[([0-9]+\/[0-9]+)\]$/\2| \1/' | # prefix project name with progress
26- stdbuf -o0 sed -e :a -e " s/^.\{1,${padding} \}|/ &/;ta" # right align progress with padding
56+ set -o pipefail # exit build with error when pipes fail
57+ local reactor_size=$( find -name " pom.xml" | grep -vE ' /src/|/target/' | wc -l)
58+ local padding=$( bc -l <<< " scale=0;2*(l($reactor_size)/l(10)+1)" )
59+ local command=(bash ./mvnw " $@ " )
60+
61+ " ${command[@]} " 2>&1 | \ # execute, redirect stderr to stdout
62+ tee " $BUILD_LOG " | \ # write output to log
63+ stdbuf -oL grep -aE ' ^\[INFO\] Building .+ \[.+\]$' | \ # filter progress
64+ stdbuf -o0 sed -uE ' s/^\[INFO\] Building (.*[^ ])[ ]+\[([0-9]+\/[0-9]+)\]$/\2| \1/' | \ # prefix project name with progress
65+ stdbuf -o0 sed -e :a -e " s/^.\{1,${padding} \}|/ &/;ta" # right align progress with padding
66+
67+ # Exit code of Maven is the first command in the pipeline
68+ return " ${PIPESTATUS[0]} "
2769}
2870
2971function build_all() {
@@ -38,6 +80,8 @@ function build_all() {
3880 status=$?
3981 echo
4082
83+ emit_markdownlint_annotations
84+
4185 if [ $status -eq 0 ]; then
4286 print_reactor_summary
4387 else
@@ -104,5 +148,5 @@ function build_based_on_changes() {
104148 fi
105149}
106150
107- ./mvnw -v
151+ bash ./mvnw -v
108152build_based_on_changes
0 commit comments