#!/usr/bin/env bats # Contract for the two label-writing workflows: pr-labeler.yaml (which labels # it may apply and from what input) and stale.yaml (which labels drive the # auto-close policy and who is exempt). Every label name either workflow can # write or match must resolve against .github/labels.yml — a mistyped name is # not an error at runtime, it is a rule that silently stops matching. # # These tests intentionally pin executable/structural lines, not prose: a # mapping demoted to a YAML `#` or JavaScript `//` comment must never satisfy # the contract. See hack/promote-gate-contract.bats for the pattern. load test_helper REPO_ROOT="$(cd "$(dirname "${BATS_TEST_FILENAME:-$0}")/.." && pwd)" PR_LABELER="$REPO_ROOT/.github/workflows/pr-labeler.yaml" STALE="$REPO_ROOT/.github/workflows/stale.yaml" LABELS="$REPO_ROOT/.github/labels.yml" DOCS="$REPO_ROOT/docs/agents/contributing.md" # Comment-stripping filters, one per language in these files. grep exits 1 on # an empty selection (legitimate for an empty block) and 2 on a real error, so # only the latter propagates. code_lines() { local rc=0 grep -v '^[[:space:]]*#' || rc=$? [ "$rc" -le 1 ] } script_lines() { local rc=0 grep -v '^[[:space:]]*//' || rc=$? [ "$rc" -le 1 ] } # Body of a `const = {` ... `};` object literal inside the # github-script block. Comments are stripped BEFORE block detection so a # commented-out `// const typeToKind = {` can never open the block. js_object_block() { script_lines < "$2" | awk -v name="const $1 = {" ' index($0, name) { inside = 1; next } inside && /^[[:space:]]*};[[:space:]]*$/ { exit } inside' } # The type -> kind/* table under "Type → `kind/*`" in docs/agents/contributing.md, # as "