Authored-By: Codex (GPT-5) <noreply@openai.com>
This commit is contained in:
Executable
+56
@@ -0,0 +1,56 @@
|
||||
#!/usr/bin/env bash
|
||||
# Deterministic Gitea Markdown renderer stub for check.sh contract tests.
|
||||
set -euo pipefail
|
||||
|
||||
if printf '%s\n' "${PR_BODY}" | grep -Fq '<!--'; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
printf '%s\n' "${PR_BODY}" | awk '
|
||||
{
|
||||
line=$0
|
||||
lower=tolower(line)
|
||||
pos=1
|
||||
while (pos <= 4 && substr(line, pos, 1) == " ") pos++
|
||||
char=substr(line, pos, 1)
|
||||
run=0
|
||||
if (char == "`" || char == "~") while (substr(line, pos + run, 1) == char) run++
|
||||
rest=substr(line, pos + run)
|
||||
if (in_fence) {
|
||||
if (pos <= 4 && char == fence_char && run >= fence_run && rest ~ /^[[:blank:]]*$/) in_fence=0
|
||||
next
|
||||
}
|
||||
if (in_script) {
|
||||
if (lower ~ /<\/script[[:blank:]]*>/) in_script=0
|
||||
next
|
||||
}
|
||||
if (pos <= 4 && run >= 3 && (char == "~" || index(rest, "`") == 0)) {
|
||||
in_fence=1
|
||||
fence_char=char
|
||||
fence_run=run
|
||||
next
|
||||
}
|
||||
if (lower ~ /^[ ]{0,3}<script([[:blank:]>])/) {
|
||||
in_script=1
|
||||
next
|
||||
}
|
||||
if (lower ~ /^[ ]{0,3}<details([[:blank:]>])/) {
|
||||
print "<details>"
|
||||
next
|
||||
}
|
||||
if (line ~ /^## Tracking[[:space:]]*$/) print "<h2>Tracking</h2>"
|
||||
else if (line ~ /^## Attribution[[:space:]]*$/) print "<h2>Attribution</h2>"
|
||||
else if (line ~ /Authored-By:.*<noreply@[[:alnum:].-]+>/) {
|
||||
email=line
|
||||
sub(/^.*</, "", email)
|
||||
sub(/>.*/, "", email)
|
||||
sub(/ <noreply@[[:alnum:].-]+>.*/, "", line)
|
||||
print line " <a href=\"mailto:" email "\">" email "</a>"
|
||||
}
|
||||
else {
|
||||
gsub(/</, "\\<", line)
|
||||
gsub(/>/, "\\>", line)
|
||||
print line
|
||||
}
|
||||
}
|
||||
'
|
||||
@@ -3,6 +3,7 @@
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT="$(cd "$(dirname "$0")/.." && pwd)/check.sh"
|
||||
TEST_BIN="$(cd "$(dirname "$0")" && pwd)/bin"
|
||||
PASS=0
|
||||
FAIL=0
|
||||
FIXTURES=$(mktemp -d)
|
||||
@@ -28,7 +29,8 @@ check() {
|
||||
body=$(canonical_body "${bug:-bug-test}")
|
||||
local out rc=0
|
||||
out=$(cd "${FIXTURES}" && HEAD_BRANCH="$branch" PR_TITLE="$title" PR_AUTHOR="$author" \
|
||||
PR_BODY="$body" BASE_SHA="$BASE" HEAD_SHA="$GOOD_HEAD" bash "$SCRIPT" 2>&1) || rc=$?
|
||||
PR_BODY="$body" GITEA_SERVER_URL="https://code.test" GITEA_TOKEN="test-token" PATH="${TEST_BIN}:$PATH" \
|
||||
BASE_SHA="$BASE" HEAD_SHA="$GOOD_HEAD" bash "$SCRIPT" 2>&1) || rc=$?
|
||||
local got_lines=0
|
||||
echo "$out" | grep -qE "^FAIL" && got_lines=1 || true
|
||||
if [ "$rc" -eq "$want_fail" ] && [ "$got_lines" -eq "$want_fail" ]; then
|
||||
@@ -46,7 +48,8 @@ check_contract() {
|
||||
local out rc=0
|
||||
out=$(cd "${FIXTURES}" && HEAD_BRANCH="architect/bug-x7k2m9/contract" \
|
||||
PR_TITLE="[bug-x7k2m9] Enforce contract" PR_AUTHOR="architect" \
|
||||
PR_BODY="$body" BASE_SHA="$base" HEAD_SHA="$head" bash "$SCRIPT" 2>&1) || rc=$?
|
||||
PR_BODY="$body" GITEA_SERVER_URL="https://code.test" GITEA_TOKEN="test-token" PATH="${TEST_BIN}:$PATH" \
|
||||
BASE_SHA="$base" HEAD_SHA="$head" bash "$SCRIPT" 2>&1) || rc=$?
|
||||
if [ "$rc" -eq 1 ] && printf '%s\n' "$out" | grep -Fq "$diagnostic"; then
|
||||
echo "PASS [$desc]"
|
||||
PASS=$((PASS + 1))
|
||||
@@ -62,7 +65,8 @@ check_contract_pass() {
|
||||
local out rc=0
|
||||
out=$(cd "${FIXTURES}" && HEAD_BRANCH="architect/bug-x7k2m9/contract" \
|
||||
PR_TITLE="[bug-x7k2m9] Enforce contract" PR_AUTHOR="architect" \
|
||||
PR_BODY="$body" BASE_SHA="$base" HEAD_SHA="$head" bash "$SCRIPT" 2>&1) || rc=$?
|
||||
PR_BODY="$body" GITEA_SERVER_URL="https://code.test" GITEA_TOKEN="test-token" PATH="${TEST_BIN}:$PATH" \
|
||||
BASE_SHA="$base" HEAD_SHA="$head" bash "$SCRIPT" 2>&1) || rc=$?
|
||||
if [ "$rc" -eq 0 ] && printf '%s\n' "$out" | grep -Fq "check-naming: ok"; then
|
||||
echo "PASS [$desc]"
|
||||
PASS=$((PASS + 1))
|
||||
@@ -78,7 +82,8 @@ check_chore_contract() {
|
||||
local out rc=0
|
||||
out=$(cd "${FIXTURES}" && HEAD_BRANCH="chore/contract" \
|
||||
PR_TITLE="Improve delivery contract" PR_AUTHOR="dev" \
|
||||
PR_BODY="$body" BASE_SHA="$base" HEAD_SHA="$head" bash "$SCRIPT" 2>&1) || rc=$?
|
||||
PR_BODY="$body" GITEA_SERVER_URL="https://code.test" GITEA_TOKEN="test-token" PATH="${TEST_BIN}:$PATH" \
|
||||
BASE_SHA="$base" HEAD_SHA="$head" bash "$SCRIPT" 2>&1) || rc=$?
|
||||
if [ "$rc" -eq 1 ] && printf '%s\n' "$out" | grep -Fq "$diagnostic"; then
|
||||
echo "PASS [$desc]"
|
||||
PASS=$((PASS + 1))
|
||||
@@ -140,34 +145,43 @@ check_contract "attribution must be in its own section" \
|
||||
"$BASE" "$GOOD_HEAD" "## Attribution must contain"
|
||||
check_contract "hidden provenance does not satisfy the visible contract" \
|
||||
$'<!--\n## Tracking\n- Fixes bug-x7k2m9 — https://agenthub.fritzlab.net/bug-x7k2m9\n\n## Attribution\n- Authored-By: Codex (GPT-5) <noreply@openai.com>\n-->' \
|
||||
"$BASE" "$GOOD_HEAD" "PR body must not contain HTML comment delimiters"
|
||||
"$BASE" "$GOOD_HEAD" "PR body must contain a non-empty ## Tracking section"
|
||||
check_contract "comment removal cannot synthesize section headings" \
|
||||
$'<!-- hidden -->## Tracking\n- Fixes bug-x7k2m9 — https://agenthub.fritzlab.net/bug-x7k2m9\n\n<!-- hidden -->## Attribution\n- Authored-By: Codex (GPT-5) <noreply@openai.com>' \
|
||||
"$BASE" "$GOOD_HEAD" "PR body must not contain HTML comment delimiters"
|
||||
"$BASE" "$GOOD_HEAD" "PR body must contain a non-empty ## Tracking section"
|
||||
check_contract "four-space indented backticks do not expose comments" \
|
||||
$' ````\n<!--\n## Tracking\n- Fixes bug-x7k2m9 — https://agenthub.fritzlab.net/bug-x7k2m9\n\n## Attribution\n- Authored-By: Codex (GPT-5) <noreply@openai.com>\n-->' \
|
||||
"$BASE" "$GOOD_HEAD" "PR body must not contain HTML comment delimiters"
|
||||
"$BASE" "$GOOD_HEAD" "PR body must contain a non-empty ## Tracking section"
|
||||
check_contract "unequal backtick runs do not expose comments" \
|
||||
$'`<!--``\n## Tracking\n- Fixes bug-x7k2m9 — https://agenthub.fritzlab.net/bug-x7k2m9\n\n## Attribution\n- Authored-By: Codex (GPT-5) <noreply@openai.com>\n-->' \
|
||||
"$BASE" "$GOOD_HEAD" "PR body must not contain HTML comment delimiters"
|
||||
"$BASE" "$GOOD_HEAD" "PR body must contain a non-empty ## Tracking section"
|
||||
check_contract "invalid backtick fence info does not expose comments" \
|
||||
$'```html`oops\n<!--\n## Tracking\n- Fixes bug-x7k2m9 — https://agenthub.fritzlab.net/bug-x7k2m9\n\n## Attribution\n- Authored-By: Codex (GPT-5) <noreply@openai.com>\n-->' \
|
||||
"$BASE" "$GOOD_HEAD" "PR body must not contain HTML comment delimiters"
|
||||
"$BASE" "$GOOD_HEAD" "PR body must contain a non-empty ## Tracking section"
|
||||
check_contract "invalid fence closer does not expose comments" \
|
||||
$'```html\n```oops\n```\n<!--\n## Tracking\n- Fixes bug-x7k2m9 — https://agenthub.fritzlab.net/bug-x7k2m9\n\n## Attribution\n- Authored-By: Codex (GPT-5) <noreply@openai.com>\n-->' \
|
||||
"$BASE" "$GOOD_HEAD" "PR body must not contain HTML comment delimiters"
|
||||
"$BASE" "$GOOD_HEAD" "PR body must contain a non-empty ## Tracking section"
|
||||
check_contract "fences inside comments do not expose provenance" \
|
||||
$'<!--\n```html\n## Tracking\n- Fixes bug-x7k2m9 — https://agenthub.fritzlab.net/bug-x7k2m9\n\n## Attribution\n- Authored-By: Codex (GPT-5) <noreply@openai.com>\n-->' \
|
||||
"$BASE" "$GOOD_HEAD" "PR body must not contain HTML comment delimiters"
|
||||
"$BASE" "$GOOD_HEAD" "PR body must contain a non-empty ## Tracking section"
|
||||
check_contract "escaped backticks do not hide a comment opener" \
|
||||
$'\\`<!--\\`\n## Tracking\n- Fixes bug-x7k2m9 — https://agenthub.fritzlab.net/bug-x7k2m9\n\n## Attribution\n- Authored-By: Codex (GPT-5) <noreply@openai.com>\n-->' \
|
||||
"$BASE" "$GOOD_HEAD" "PR body must not contain HTML comment delimiters"
|
||||
"$BASE" "$GOOD_HEAD" "PR body must contain a non-empty ## Tracking section"
|
||||
check_contract "fenced provenance does not satisfy the visible contract" \
|
||||
$'```\n```oops\n## Tracking\n- Fixes bug-x7k2m9 — https://agenthub.fritzlab.net/bug-x7k2m9\n\n## Attribution\n- Authored-By: Codex (GPT-5) <noreply@openai.com>' \
|
||||
"$BASE" "$GOOD_HEAD" "PR body must not contain fenced code delimiters"
|
||||
check_contract "fenced code delimiters are rejected" \
|
||||
$'```text\nvisible example\n```\n\n## Tracking\n- Fixes bug-x7k2m9 — https://agenthub.fritzlab.net/bug-x7k2m9\n\n## Attribution\n- Authored-By: Codex (GPT-5) <noreply@openai.com>' \
|
||||
"$BASE" "$GOOD_HEAD" "PR body must not contain fenced code delimiters"
|
||||
"$BASE" "$GOOD_HEAD" "PR body must contain a non-empty ## Tracking section"
|
||||
check_contract "indented fence closer does not expose provenance" \
|
||||
$'```\n ```\n## Tracking\n- Fixes bug-x7k2m9 — https://agenthub.fritzlab.net/bug-x7k2m9\n\n## Attribution\n- Authored-By: Codex (GPT-5) <noreply@openai.com>\n```' \
|
||||
"$BASE" "$GOOD_HEAD" "PR body must contain a non-empty ## Tracking section"
|
||||
check_contract_pass "fenced code examples remain available" \
|
||||
$'```html\n<script>example only</script>\n```\n\n## Tracking\n- Fixes bug-x7k2m9 — https://agenthub.fritzlab.net/bug-x7k2m9\n\n## Attribution\n- Authored-By: Codex (GPT-5) <noreply@openai.com>' \
|
||||
"$BASE" "$GOOD_HEAD"
|
||||
check_contract "details cannot collapse provenance" \
|
||||
$'<details><summary>Release notes</summary>\n\n## Tracking\n- Fixes bug-x7k2m9 — https://agenthub.fritzlab.net/bug-x7k2m9\n\n## Attribution\n- Authored-By: Codex (GPT-5) <noreply@openai.com>\n</details>' \
|
||||
"$BASE" "$GOOD_HEAD" "rendered PR body must not contain collapsed details"
|
||||
check_contract "script cannot suppress provenance" \
|
||||
$'<script>\n## Tracking\n- Fixes bug-x7k2m9 — https://agenthub.fritzlab.net/bug-x7k2m9\n\n## Attribution\n- Authored-By: Codex (GPT-5) <noreply@openai.com>\n</script>' \
|
||||
"$BASE" "$GOOD_HEAD" "PR body must contain a non-empty ## Tracking section"
|
||||
|
||||
git -C "${FIXTURES}" commit --allow-empty -q -m "unwatermarked change"
|
||||
BAD_HEAD=$(git -C "${FIXTURES}" rev-parse HEAD)
|
||||
|
||||
Reference in New Issue
Block a user