diff --git a/.github/.markdownlint.yaml b/.github/.markdownlint.yaml new file mode 100644 index 0000000000000..f545d833f91ab --- /dev/null +++ b/.github/.markdownlint.yaml @@ -0,0 +1,40 @@ +# 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 + \ No newline at end of file diff --git a/.github/scripts/maven-build b/.github/scripts/maven-build index f6cac0dd899e5..9c4e4b6a50301 100755 --- a/.github/scripts/maven-build +++ b/.github/scripts/maven-build @@ -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 | \ + tee "$BUILD_LOG" | \ + stdbuf -oL grep -aE '^\[INFO\] Building .+ \[.+\]$' | \ + stdbuf -o0 sed -uE 's/^\[INFO\] Building (.*[^ ])[ ]+\[([0-9]+\/[0-9]+)\]$/\2| \1/' | \ + stdbuf -o0 sed -e :a -e "s/^.\{1,${padding}\}|/ &/;ta" + + # 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 diff --git a/.github/workflows/ci-build.yml b/.github/workflows/ci-build.yml index 648bc7da44036..e64bce0a9d439 100644 --- a/.github/workflows/ci-build.yml +++ b/.github/workflows/ci-build.yml @@ -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: >- diff --git a/bundles/org.openhab.automation.jsscripting/pom.xml b/bundles/org.openhab.automation.jsscripting/pom.xml index 61384f7b9907c..193acf124fc73 100644 --- a/bundles/org.openhab.automation.jsscripting/pom.xml +++ b/bundles/org.openhab.automation.jsscripting/pom.xml @@ -47,6 +47,7 @@ frontend-maven-plugin 2.0.0 + target/js ${node.version} target/js diff --git a/bundles/org.openhab.binding.matter/pom.xml b/bundles/org.openhab.binding.matter/pom.xml index 91cf45d5dcef0..3223dc5c90774 100644 --- a/bundles/org.openhab.binding.matter/pom.xml +++ b/bundles/org.openhab.binding.matter/pom.xml @@ -25,6 +25,7 @@ frontend-maven-plugin 2.0.0 + matter-server v20.12.2 10.5.0 @@ -101,6 +102,7 @@ frontend-maven-plugin 2.0.0 + matter-server v20.12.2 10.5.0 diff --git a/bundles/pom.xml b/bundles/pom.xml index 87a88909a34fd..db4c86e22afdd 100644 --- a/bundles/pom.xml +++ b/bundles/pom.xml @@ -523,6 +523,7 @@ target/dependency + false @@ -781,6 +782,44 @@ + + com.github.eirslett + frontend-maven-plugin + 2.0.0 + + + ${markdownlint.skip} + + + ${maven.multiModuleProjectDirectory}/target/.mvn/node-markdownlint + v24.12.0 + + + 11.6.2 + + + + + install-node-and-npm + + install-node-and-npm + + validate + + + + markdownlint + + npm + + validate + + ${project.basedir} + exec --yes markdownlint-cli2 -- **/*.md !**/target/** !**/node_modules/** --config ${maven.multiModuleProjectDirectory}/.github/.markdownlint.yaml + + + +