Add markdown action (#19010)

Signed-off-by: Leo Siepel <leosiepel@gmail.com>
This commit is contained in:
lsiepel
2026-03-30 15:57:40 +02:00
committed by GitHub
parent cc07d55d51
commit 5891fe1d3f
6 changed files with 136 additions and 12 deletions
+39
View File
@@ -0,0 +1,39 @@
# From: https://github.com/openhab/openhab-docs/blob/main/.github/.markdownlint.yaml
default: true
# Expect dash usage for unordered lists
MD004:
style: dash
# Allow long line lengths
MD013: false
# Allow duplicate headers for different nesting
MD024:
siblings_only: true
# Allow Multiple top level headers in the same document
MD025: false
# Allow trailing punctuation in headers
MD026: false
MD029:
style: one
# Allow inline HTML
MD033: false
# Code block style
MD046:
style: fenced
# Emphasis in underscore
MD049:
style: underscore
# Strong in asterisk
MD050:
style: asterisk
MD060: false
+54 -10
View File
@@ -14,16 +14,58 @@ function print_reactor_summary() {
cat "$BUILD_LOG" | sed -n "${start},${end}p" | sed 's/\[INFO\] //'
}
gha_escape() {
sed -e 's/%/%25/g' -e 's/\r/%0D/g' -e 's/\n/%0A/g'
}
emit_markdownlint_annotations() {
[[ -f "$BUILD_LOG" ]] || return 0
while IFS= read -r l; do
file=$(echo "$l" | sed -E 's/^([^:]+\.md):.*/\1/')
line=$(echo "$l" | sed -E 's/^[^:]+\.md:([0-9]+).*/\1/')
# Repair path so GitHub can link it (repo-root relative)
if [[ ! -f "$file" ]]; then
if [[ -f "bundles/$file" ]]; then
file="bundles/$file"
elif [[ -f "itests/$file" ]]; then
file="itests/$file"
fi
fi
if echo "$l" | grep -qE '^[^:]+\.md:[0-9]+:[0-9]+ error MD'; then
col=$(echo "$l" | sed -E 's/^[^:]+\.md:[0-9]+:([0-9]+) error .*/\1/')
rule=$(echo "$l" | sed -E 's/^[^:]+\.md:[0-9]+:[0-9]+ error (MD[^ ]+) .*/\1/')
rest=$(echo "$l" | sed -E 's/^[^:]+\.md:[0-9]+:[0-9]+ error MD[^ ]+ (.*)$/\1/')
rest_esc=$(printf '%s' "$rest" | gha_escape)
echo "::error file=$file,line=$line,col=$col,title=$rule::$rest_esc"
else
rule=$(echo "$l" | sed -E 's/^[^:]+\.md:[0-9]+ error (MD[^ ]+) .*/\1/')
rest=$(echo "$l" | sed -E 's/^[^:]+\.md:[0-9]+ error MD[^ ]+ (.*)$/\1/')
rest_esc=$(printf '%s' "$rest" | gha_escape)
echo "::error file=$file,line=$line,title=$rule::$rest_esc"
fi
done < <(
grep -aE '\[INFO\] .*\.md:[0-9]+(:[0-9]+)? error MD' "$BUILD_LOG" \
| sed -E 's/^.*\[INFO\] //'
)
}
function mvnp() {
set -o pipefail # exit build with error when pipes fail
local reactor_size=$(find -name "pom.xml" | grep -vE '/src/|/target/' | wc -l)
local padding=$(bc -l <<< "scale=0;2*(l($reactor_size)/l(10)+1)")
local command=(./mvnw $@)
exec "${command[@]}" 2>&1 | # execute, redirect stderr to stdout
tee "$BUILD_LOG" | # write output to log
stdbuf -oL grep -aE '^\[INFO\] Building .+ \[.+\]$' | # filter progress
stdbuf -o0 sed -uE 's/^\[INFO\] Building (.*[^ ])[ ]+\[([0-9]+\/[0-9]+)\]$/\2| \1/' | # prefix project name with progress
stdbuf -o0 sed -e :a -e "s/^.\{1,${padding}\}|/ &/;ta" # right align progress with padding
set -o pipefail # exit build with error when pipes fail
local reactor_size=$(find -name "pom.xml" | grep -vE '/src/|/target/' | wc -l)
local padding=$(bc -l <<< "scale=0;2*(l($reactor_size)/l(10)+1)")
local command=(bash ./mvnw "$@")
"${command[@]}" 2>&1 | \ # execute, redirect stderr to stdout
tee "$BUILD_LOG" | \ # write output to log
stdbuf -oL grep -aE '^\[INFO\] Building .+ \[.+\]$' | \ # filter progress
stdbuf -o0 sed -uE 's/^\[INFO\] Building (.*[^ ])[ ]+\[([0-9]+\/[0-9]+)\]$/\2| \1/' | \ # prefix project name with progress
stdbuf -o0 sed -e :a -e "s/^.\{1,${padding}\}|/ &/;ta" # right align progress with padding
# Exit code of Maven is the first command in the pipeline
return "${PIPESTATUS[0]}"
}
function build_all() {
@@ -38,6 +80,8 @@ function build_all() {
status=$?
echo
emit_markdownlint_annotations
if [ $status -eq 0 ]; then
print_reactor_summary
else
@@ -104,5 +148,5 @@ function build_based_on_changes() {
fi
}
./mvnw -v
bash ./mvnw -v
build_based_on_changes
+1 -1
View File
@@ -67,7 +67,7 @@ jobs:
- name: Build
id: build
run: './.github/scripts/maven-build'
run: bash './.github/scripts/maven-build'
env:
CHANGED_FILES: ${{ steps.files.outputs.all }}
MAVEN_OPTS: >-