feat: branch/PR naming standard CI check
test / test (push) Successful in 5s

Composite action that validates head branch and PR title against the
fritzlab naming standard (role/bug-id/kebab + [bug-id] titles).
Always exits 0 (warn-only) until the Bugs system is live.

- check.sh: validation logic (branch form, title form, bug-id cross-check)
- action.yaml: composite action wrapping check.sh
- tests/run: 20-case test matrix (valid/invalid/chore/mismatch/dfritz)
- .gitea/workflows/test.yaml: CI that runs the test suite

Closes fritzlab/agenthub#559
This commit is contained in:
dev
2026-07-25 19:01:08 +00:00
commit 5b5d16c46f
5 changed files with 243 additions and 0 deletions
Executable
+58
View File
@@ -0,0 +1,58 @@
#!/usr/bin/env bash
# Branch and PR title naming-standard checker.
# Always exits 0 — warn-only until the Bugs system is live and STRICT=1 is set.
set -euo pipefail
BRANCH="${HEAD_BRANCH:-}"
TITLE="${PR_TITLE:-}"
AUTHOR="${PR_AUTHOR:-}"
# Break-glass: dfritz is exempt from all naming checks.
if [ "${AUTHOR}" = "dfritz" ]; then
echo "check-naming: dfritz break-glass — exempt"
exit 0
fi
WARN=0
BRANCH_KIND="invalid"
BRANCH_BUG=""
# ---- branch form ----
# <role>/bug-<id>/<kebab>
if echo "${BRANCH}" | grep -qE "^(dev|ux|ops|security|perf|architect|support)/bug-[a-z0-9]+/[a-z0-9][a-z0-9-]*$"; then
BRANCH_KIND="role-bug"
BRANCH_BUG=$(echo "${BRANCH}" | sed -E 's|^[^/]+/(bug-[a-z0-9]+)/.*|\1|')
# chore/<kebab>
elif echo "${BRANCH}" | grep -qE "^chore/[a-z0-9][a-z0-9-]*$"; then
BRANCH_KIND="chore"
else
echo "WARN[check-naming]: branch '${BRANCH}' does not match convention"
echo " expected: <role>/bug-<id>/<kebab> (role: dev|ux|ops|security|perf|architect|support)"
echo " or: chore/<kebab>"
WARN=1
fi
# ---- title form ----
TITLE_BUG=""
if echo "${TITLE}" | grep -qE "^\[bug-[a-z0-9]+\] ."; then
TITLE_BUG=$(echo "${TITLE}" | sed -E 's|^\[(bug-[a-z0-9]+)\].*|\1|')
fi
if [ "${BRANCH_KIND}" = "role-bug" ]; then
if [ -z "${TITLE_BUG}" ]; then
echo "WARN[check-naming]: title missing [${BRANCH_BUG}] prefix for branch '${BRANCH}'"
WARN=1
elif [ "${TITLE_BUG}" != "${BRANCH_BUG}" ]; then
echo "WARN[check-naming]: bug-id mismatch — branch carries '${BRANCH_BUG}' but title carries '${TITLE_BUG}'"
WARN=1
fi
elif [ "${BRANCH_KIND}" = "chore" ] && [ -n "${TITLE_BUG}" ]; then
echo "WARN[check-naming]: chore branch should not carry a [bug-id] title prefix"
WARN=1
fi
if [ "${WARN}" -eq 0 ]; then
echo "check-naming: ok"
fi
exit 0