From a2edc2f56f1ff510c43b680ee5455ea5eeeceb93 Mon Sep 17 00:00:00 2001 From: abiba Date: Sat, 12 Sep 2026 17:13:54 +0000 Subject: [PATCH] ci(pr-pipeline): fix flaky frontmatter check (grep -q SIGPIPE under pipefail) The validate job runs with bash -e -o pipefail. `echo "$FM" | grep -q '^name:'` lets grep exit on first match, which can SIGPIPE the echo; pipefail then reports the pipeline non-zero and the || branch raises a false "Missing name/description". The flagged file set varied run to run (and included files untouched by the PR) while a fresh clone of the same commit passes the identical check. Reproduced: the old form failed 3 of 5 local runs under the same shell flags, the herestring form passed 5 of 5. Use herestrings so no pipe can be broken. --- .gitea/workflows/pr-pipeline.yaml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.gitea/workflows/pr-pipeline.yaml b/.gitea/workflows/pr-pipeline.yaml index 7525b10..9ffe552 100644 --- a/.gitea/workflows/pr-pipeline.yaml +++ b/.gitea/workflows/pr-pipeline.yaml @@ -43,17 +43,21 @@ jobs: echo "=== Prose Contract Frontmatter Validation ===" FAILED=0 for f in $(find . -name "*.prose.md" -not -path "./.git/*" -not -path "./runs/*"); do + # NOTE: use herestrings, not `echo "$FM" | grep ...`. Under the runner's + # `-e -o pipefail`, `grep -q` exits on first match and can SIGPIPE the + # producer, making the pipeline report non-zero and raising a false + # "Missing name/description" whose file set varies run to run. FM=$(sed -n '/^---$/,/^---$/p' "$f" | sed '1d;$d') [ -z "$FM" ] && { echo " ❌ $f: No YAML frontmatter"; FAILED=$((FAILED+1)); continue; } - KIND=$(echo "$FM" | grep '^kind:' | awk '{print $2}') + KIND=$(grep '^kind:' <<< "$FM" | awk '{print $2}') case "$KIND" in function|responsibility|gateway|pattern|test|template|architecture|enforcement) echo " ✅ $f: kind=$KIND" ;; *) echo " ❌ $f: Invalid kind='$KIND'"; FAILED=$((FAILED+1)) ;; esac - echo "$FM" | grep -q '^name:' || { echo " ❌ $f: Missing name"; FAILED=$((FAILED+1)); } - echo "$FM" | grep -q '^description:' || { echo " ❌ $f: Missing description"; FAILED=$((FAILED+1)); } + grep -q '^name:' <<< "$FM" || { echo " ❌ $f: Missing name"; FAILED=$((FAILED+1)); } + grep -q '^description:' <<< "$FM" || { echo " ❌ $f: Missing description"; FAILED=$((FAILED+1)); } done [ $FAILED -gt 0 ] && { echo "❌ FRONTMATTER FAILED ($FAILED error(s))"; exit 1; } echo "✅ Frontmatter validation passed"