test: expose missing Forgejo workflow names
Some checks failed
CI / test (pull_request) Failing after 3m48s
CI / release-exercise (pull_request) Successful in 25s
CI / self-guards (pull_request) Successful in 21s
CI / action-exercise (pull_request) Successful in 20s
CI / docs-sync-exercise (pull_request) Successful in 20s
labels / labels (pull_request) Successful in 22s
Refs guard / refs-not-closing (pull_request) Successful in 20s

This commit is contained in:
codex-bot-andresmgsl 2026-08-25 08:41:27 +00:00
parent 6dc8bf6558
commit 9f54eb98bf
2 changed files with 55 additions and 2 deletions

View file

@ -693,8 +693,9 @@ pr_view_stub() {
} }
# The FAILURE is older but listed second — array order would pick it. # The FAILURE is older but listed second — array order would pick it.
FAKE_STATUS='{"state":"failure","statuses":[ FAKE_STATUS='{"state":"failure","statuses":[
{"context":"ci / check","status":"success","created_at":"2026-08-02T10:00:00Z","updated_at":"2026-08-02T10:00:00Z"}, {"context":"labels / labels (pull_request)","status":"success","created_at":"2026-08-02T10:00:00Z","updated_at":"2026-08-02T10:00:00Z"},
{"context":"ci / check","status":"failure","created_at":"2026-08-02T09:00:00Z","updated_at":"2026-08-02T09:00:00Z"}]}' {"context":"labels / labels (pull_request)","status":"failure","created_at":"2026-08-02T09:00:00Z","updated_at":"2026-08-02T09:00:00Z"},
{"context":"codecov","status":"success","created_at":"2026-08-02T10:00:00Z","updated_at":"2026-08-02T10:00:00Z"}]}'
FAKE_PR='{"head":{"sha":"abc"},"base":{"sha":"base"},"merge_base":"ancestor","draft":false,"mergeable":true}' FAKE_PR='{"head":{"sha":"abc"},"base":{"sha":"base"},"merge_base":"ancestor","draft":false,"mergeable":true}'
pr_view_stub pr_view_stub
view_json="$(REPO=o/r forge_pr_view 5)" view_json="$(REPO=o/r forge_pr_view 5)"
@ -702,6 +703,13 @@ check "pr_view maps createdAt" 0 "" \
grep -q '"createdAt": "2026-08-02T10:00:00Z"' <<<"$view_json" grep -q '"createdAt": "2026-08-02T10:00:00Z"' <<<"$view_json"
check "pr_view maps completedAt" 0 "" \ check "pr_view maps completedAt" 0 "" \
grep -q '"completedAt":' <<<"$view_json" grep -q '"completedAt":' <<<"$view_json"
check "pr_view derives workflowName from the first context separator" 0 "" \
jq -e 'any(.statusCheckRollup[];
.context == "labels / labels (pull_request)" and .workflowName == "labels")' \
>/dev/null <<<"$view_json"
check "pr_view leaves workflowName empty when the context has no separator" 0 "" \
jq -e 'any(.statusCheckRollup[];
.context == "codecov" and .workflowName == "")' >/dev/null <<<"$view_json"
check "pr_view maps mergeable to the UI string" 0 "" \ check "pr_view maps mergeable to the UI string" 0 "" \
grep -q '"mergeable": "MERGEABLE"' <<<"$view_json" grep -q '"mergeable": "MERGEABLE"' <<<"$view_json"

View file

@ -589,6 +589,51 @@ expect "a rollup of ONLY self entries is honestly NONE, never SUCCESS" NONE \
expect "a genuine foreign FAILURE still blocks beside a cancelled self entry" FAILURE \ expect "a genuine foreign FAILURE still blocks beside a cancelled self entry" FAILURE \
"$(rollup "[$(run_ a FAILURE),\ "$(rollup "[$(run_ a FAILURE),\
$(rec_ CANCELLED 2026-08-01T15:17:56Z 2026-08-01T15:17:59Z)]" | checks_state)" $(rec_ CANCELLED 2026-08-01T15:17:56Z 2026-08-01T15:17:59Z)]" | checks_state)"
# Forgejo exposes Actions checks only as commit statuses. Drive the real
# backend mapper here: fixtures that hand-write workflowName repeat the field
# omission that hid #243 instead of proving the adapter supplies it.
forgejo_rollup() {
local statuses="$1"
(
# shellcheck source=lib/forge-forgejo.sh
. lib/forge-forgejo.sh
forge_api() {
case "$1" in
repos/o/r/pulls/5)
printf '%s\n' '{"head":{"sha":"abc"},"base":{"sha":"base"},"merge_base":"ancestor","draft":false,"mergeable":true}'
;;
repos/o/r/commits/abc/status)
printf '%s\n' "$statuses"
;;
*) return 1 ;;
esac
}
REPO=o/r forge_pr_view 5
)
}
forgejo_self_red='{"state":"failure","statuses":[
{"context":"labels / labels (pull_request)","status":"failure","created_at":"2026-08-23T18:32:00Z","updated_at":"2026-08-23T18:32:00Z"},
{"context":"CI / test (pull_request)","status":"pending","created_at":"2026-08-23T18:32:00Z","updated_at":"2026-08-23T18:32:00Z"}]}'
expect "Forgejo StatusContexts exclude a self FAILURE and retain pending work" PENDING \
"$(forgejo_rollup "$forgejo_self_red" | checks_state)"
forgejo_self_only='{"state":"failure","statuses":[
{"context":"labels / labels (pull_request)","status":"failure","created_at":"2026-08-23T18:32:00Z","updated_at":"2026-08-23T18:32:00Z"}]}'
expect "Forgejo StatusContexts containing only the self workflow are NONE" NONE \
"$(forgejo_rollup "$forgejo_self_only" | checks_state)"
forgejo_foreign_red='{"state":"failure","statuses":[
{"context":"labels / labels (pull_request)","status":"failure","created_at":"2026-08-23T18:32:00Z","updated_at":"2026-08-23T18:32:00Z"},
{"context":"CI / test (pull_request)","status":"failure","created_at":"2026-08-23T18:32:00Z","updated_at":"2026-08-23T18:32:00Z"}]}'
expect "Forgejo StatusContexts retain a genuine foreign FAILURE" FAILURE \
"$(forgejo_rollup "$forgejo_foreign_red" | checks_state)"
forgejo_bare_red='{"state":"failure","statuses":[
{"context":"codecov","status":"failure","created_at":"2026-08-23T18:32:00Z","updated_at":"2026-08-23T18:32:00Z"}]}'
expect "a bare Forgejo context is never guessed to be the self workflow" FAILURE \
"$(forgejo_rollup "$forgejo_bare_red" | checks_state)"
# ...and an empty self filters NOTHING: outside Actions no workflow name is # ...and an empty self filters NOTHING: outside Actions no workflow name is
# ambient, and the exclusion must never drop entries on a guess — the same # ambient, and the exclusion must never drop entries on a guess — the same
# displaced-self rollup keeps blocking there, all-cancelled context intact. # displaced-self rollup keeps blocking there, all-cancelled context intact.