返回 CodeWhale
agent-task-metadata.test.sh
根目录 / .github / scripts / agent-task-metadata.test.sh
1 #!/usr/bin/env bash
2 set -euo pipefail
3
4 repo="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
5 cd "${repo}"
6
7 template=".github/ISSUE_TEMPLATE/agent-task.yml"
8 workflow=".github/workflows/agent-task-labels.yml"
9 retired_workflow=".github/workflows/v0868-milestone-sync.yml"
10
11 fail() {
12 echo "agent-task metadata contract failed: $*" >&2
13 exit 1
14 }
15
16 [[ -f "${template}" ]] || fail "missing ${template}"
17 [[ -f "${workflow}" ]] || fail "missing ${workflow}"
18 [[ ! -e "${retired_workflow}" ]] || fail "retired milestone sync still exists"
19
20 if grep -nE '^(title|labels):.*v[0-9]+\.[0-9]+\.[0-9]+' "${template}"; then
21 fail "agent-task defaults must not pin a release version"
22 fi
23
24 grep -qF 'labels: ["agent-ready"]' "${template}" \
25 || fail "agent-task template must opt into agent-ready without a version label"
26 grep -qF 'types: [opened]' "${workflow}" \
27 || fail "agent-task labeling must run only when an issue is opened"
28 grep -qF "labels.has('agent-ready')" "${workflow}" \
29 || fail "agent-task labeling must be gated by the explicit agent-ready label"
30
31 if grep -nE 'listMilestones|issues\.update|^[[:space:]]*milestone:' "${workflow}"; then
32 fail "agent-task automation must never read or assign milestones"
33 fi
34
35 if grep -nE 'types:.*(labeled|milestoned)' "${workflow}"; then
36 fail "agent-task automation must not react to later label or milestone edits"
37 fi
38
39 echo "Agent-task metadata is release-neutral and milestone-safe."
40
40 lines BASH