mirror of
https://github.com/MacosPorters/betterxen.git
synced 2026-11-26 03:39:52 +00:00
Merge pull request #380 from MacosPorters/remove-agent-pr-checks
Remove the agent-pr-checks workflow
This commit is contained in:
5 files changed
+4
-151
No files matched your search
@@ -1,102 +0,0 @@
|
||||
name: Agent PR checks
|
||||
|
||||
# Checks pull requests against the task queue: linked claimed task, file
|
||||
# ownership, overlap with other open pull requests, and independent
|
||||
# verification. Runs on the base branch only: pull request code is never checked
|
||||
# out or executed; changed files come from the API. Not yet run on GitHub.
|
||||
#
|
||||
# Advisory: problems are reported as a warning and in the run summary, but the
|
||||
# check does not fail until a live smoke test and the migration of existing
|
||||
# issues are done (docs/coordination/agent-tasks.md). Only a comment starting
|
||||
# with /verified starts the verify job; ordinary comments start nothing.
|
||||
|
||||
on:
|
||||
pull_request_target:
|
||||
types: [opened, synchronize, reopened, edited]
|
||||
issue_comment:
|
||||
types: [created]
|
||||
|
||||
permissions: {}
|
||||
|
||||
jobs:
|
||||
check:
|
||||
if: github.event_name == 'pull_request_target'
|
||||
runs-on: ubuntu-24.04-arm
|
||||
permissions:
|
||||
contents: read
|
||||
issues: read
|
||||
pull-requests: read
|
||||
steps:
|
||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
with:
|
||||
persist-credentials: false
|
||||
- name: Check pull request
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
GH_REPO: ${{ github.repository }}
|
||||
PYTHONPATH: scripts
|
||||
run: |
|
||||
set -eu
|
||||
python3 -m agent_queue event --path "$GITHUB_EVENT_PATH" > "$RUNNER_TEMP/event.json"
|
||||
number=$(python3 -c 'import json,sys; print(json.load(open(sys.argv[1]))["number"])' "$RUNNER_TEMP/event.json")
|
||||
python3 -m agent_queue gather --repo "$GH_REPO" --pr "$number" > "$RUNNER_TEMP/state.json"
|
||||
status=0
|
||||
python3 -m agent_queue pr-check --state "$RUNNER_TEMP/state.json" > "$RUNNER_TEMP/result.json" || status=$?
|
||||
{
|
||||
echo '## Agent PR check'
|
||||
echo '```json'
|
||||
cat "$RUNNER_TEMP/result.json"
|
||||
echo '```'
|
||||
} >> "$GITHUB_STEP_SUMMARY"
|
||||
# 1 means problems were found: advisory for now. Anything else is a failure of the check itself.
|
||||
if [ "$status" -eq 1 ]; then
|
||||
echo "::warning title=Agent PR check (advisory)::problems found; see the run summary"
|
||||
elif [ "$status" -ne 0 ]; then
|
||||
exit "$status"
|
||||
fi
|
||||
|
||||
verify:
|
||||
if: github.event_name == 'issue_comment' && github.event.issue.pull_request && startsWith(github.event.comment.body, '/verified')
|
||||
runs-on: ubuntu-24.04-arm
|
||||
# issues: write posts the reply.
|
||||
permissions:
|
||||
contents: read
|
||||
issues: write
|
||||
pull-requests: read
|
||||
concurrency:
|
||||
group: agent-verify-${{ github.event.issue.number }}
|
||||
cancel-in-progress: false
|
||||
steps:
|
||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
with:
|
||||
persist-credentials: false
|
||||
- name: Record verification and check again
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
GH_REPO: ${{ github.repository }}
|
||||
PYTHONPATH: scripts
|
||||
run: |
|
||||
set -eu
|
||||
python3 -m agent_queue event --path "$GITHUB_EVENT_PATH" > "$RUNNER_TEMP/event.json"
|
||||
number=$(python3 -c 'import json,sys; print(json.load(open(sys.argv[1]))["number"])' "$RUNNER_TEMP/event.json")
|
||||
python3 -m agent_queue gather --repo "$GH_REPO" --pr "$number" > "$RUNNER_TEMP/state.json"
|
||||
python3 -m agent_queue decide --event "$RUNNER_TEMP/event.json" --state "$RUNNER_TEMP/state.json" > "$RUNNER_TEMP/actions.json"
|
||||
python3 -m agent_queue apply --repo "$GH_REPO" --actions "$RUNNER_TEMP/actions.json"
|
||||
# Check again only after an accepted verification of the current head: refused, stale,
|
||||
# malformed or unauthorized /verified comments get a reply and nothing else.
|
||||
if ! python3 -m agent_queue should-rerun --actions "$RUNNER_TEMP/actions.json"; then exit 0; fi
|
||||
# pull_request_target runs are recorded against the base branch, not the pull request
|
||||
# head, so the earlier check run cannot be found by head SHA. Evaluate the same check here.
|
||||
status=0
|
||||
python3 -m agent_queue pr-check --state "$RUNNER_TEMP/state.json" > "$RUNNER_TEMP/result.json" || status=$?
|
||||
{
|
||||
echo '## Agent PR check after verification'
|
||||
echo '```json'
|
||||
cat "$RUNNER_TEMP/result.json"
|
||||
echo '```'
|
||||
} >> "$GITHUB_STEP_SUMMARY"
|
||||
if [ "$status" -eq 1 ]; then
|
||||
echo "::warning title=Agent PR check (advisory)::problems found; see the run summary"
|
||||
elif [ "$status" -ne 0 ]; then
|
||||
exit "$status"
|
||||
fi
|
||||
@@ -19,6 +19,7 @@ remains unsupported.
|
||||
- Documented the proposed guest AVX/AVX2 state and decoding contract and specified an original integer fixture with known results and fault controls (#299).
|
||||
|
||||
### Removed
|
||||
- Removed the "Agent PR checks" workflow (`.github/workflows/agent-pr-checks.yml`), its section in `docs/coordination/agent-tasks.md` and the four workflow tests in `tests/agent_queue/test_workflows_cli.py` that only exercised it. Pull requests are no longer checked for `Closes #N`, task file patterns or `/verified` comments; the claims workflow and its tests are unchanged. The agent queue Python tests pass locally (85 tests).
|
||||
- Removed the "PR template" check (`.github/workflows/pr-template.yml`, `scripts/pr_template_check.py` and its tests) and its CI test step. Also removed `.github/PULL_REQUEST_TEMPLATE.md`. Pull request descriptions are no longer validated or pre-filled; CONTRIBUTING.md still asks for the same information and the claim-first rule still applies.
|
||||
|
||||
### Changed
|
||||
|
||||
@@ -36,10 +36,9 @@ pending-run replay and exact head-SHA verification against a real repository.
|
||||
|
||||
## Production follow-ups
|
||||
|
||||
1. Keep `agent-pr-checks` advisory until this evidence is reviewed.
|
||||
2. Coordinate adding `pull-requests: read` to the production audit job permissions
|
||||
1. Coordinate adding `pull-requests: read` to the production audit job permissions
|
||||
(same defect as the smoke audit failure).
|
||||
3. Add a second QA-eligible verifier before treating `/verified` as smoke-complete.
|
||||
2. Add a second QA-eligible verifier before treating `/verified` as smoke-complete.
|
||||
|
||||
## Local unit suite
|
||||
|
||||
|
||||
@@ -90,22 +90,6 @@ cycles `agent:invalid` (and restores them when fixed), flags overlapping claims
|
||||
writes a JSON summary to the run summary. `scripts/agent-queue.sh status --json` prints the same
|
||||
machine-readable summary (counts and lists per area, priority and state).
|
||||
|
||||
## Pull request checks
|
||||
|
||||
`agent-pr-checks` fails a pull request when: it has no `Closes #N` for a claimed task; the task is held
|
||||
by someone else; it changes files outside the task's patterns; it changes a file that another open
|
||||
pull request also changes; the claim has lapsed without a push; or no eligible `/verified <current
|
||||
head sha>` exists. The SHA must be the full 40 characters and the only argument: a commit with the
|
||||
same short prefix is cheap to make. After an accepted `/verified` (an eligible verifier, the current
|
||||
head) the verify job evaluates the same check again and writes it to its run summary; the earlier
|
||||
check run is not re-run, since `pull_request_target` runs are recorded against the base branch and
|
||||
cannot be found by the pull request head. Refused, stale, malformed or unauthorized `/verified`
|
||||
comments get a reply and nothing else, and other pull request comments start no job.
|
||||
|
||||
The check is advisory for now: a failure is shown as a warning and in the run summary, and the job
|
||||
still succeeds. It becomes blocking (fail on problems, then a required check) only after a live smoke
|
||||
test on GitHub and the migration of existing issues into the queue.
|
||||
|
||||
## Forks and upstream sync
|
||||
|
||||
Work from a fork, but synchronise against the real upstream (`ranveersoni98/Xenora` in the
|
||||
|
||||
@@ -15,7 +15,7 @@ def dump(obj, path):
|
||||
|
||||
|
||||
WF = os.path.join(ROOT, ".github", "workflows")
|
||||
QUEUE_WORKFLOWS = ["agent-claims.yml", "agent-pr-checks.yml"]
|
||||
QUEUE_WORKFLOWS = ["agent-claims.yml"]
|
||||
USER_TEXT = re.compile(r"\$\{\{\s*github\.event\.(comment|issue|pull_request)\.(body|title)|github\.head_ref")
|
||||
|
||||
|
||||
@@ -58,11 +58,6 @@ class Workflows(unittest.TestCase):
|
||||
bad = "jobs:\n a:\n steps:\n - run: |\n echo ${{ github.event.comment.body }}\n"
|
||||
self.assertTrue(any(re.search(r"\$\{\{", b) for b in run_blocks(bad)))
|
||||
|
||||
def test_pr_workflow_never_checks_out_pr_code(self):
|
||||
text = self.read("agent-pr-checks.yml")
|
||||
self.assertNotRegex(text, r"github\.event\.pull_request\.head|ref:\s*\$\{\{")
|
||||
self.assertIn("pull_request_target", text)
|
||||
|
||||
def job(self, name, job):
|
||||
"""Text of one job block: from ` <job>:` to the next two-space-indented key."""
|
||||
m = re.search(r"(?ms)^ %s:\n(.*?)(?=^ \S|\Z)" % re.escape(job), self.read(name))
|
||||
@@ -74,9 +69,7 @@ class Workflows(unittest.TestCase):
|
||||
|
||||
def test_only_command_comments_start_runs(self):
|
||||
# Ordinary comments must not start a claim run or a verification re-run.
|
||||
self.assertIn("startsWith(github.event.comment.body, '/verified')", self.job_if("agent-pr-checks.yml", "verify"))
|
||||
self.assertIn("startsWith(github.event.comment.body, '/')", self.job_if("agent-claims.yml", "command"))
|
||||
self.assertNotIn("issue_comment", self.job_if("agent-pr-checks.yml", "check"))
|
||||
|
||||
def test_claim_jobs_share_one_group_and_replay(self):
|
||||
for job in ("command", "audit"):
|
||||
@@ -87,15 +80,6 @@ class Workflows(unittest.TestCase):
|
||||
self.assertIn("--recent-commands", text, job)
|
||||
self.assertNotIn("agent_queue decide", self.job("agent-claims.yml", "command"))
|
||||
|
||||
def test_rerun_needs_an_accepted_verification(self):
|
||||
text = self.job("agent-pr-checks.yml", "verify")
|
||||
self.assertIn('if ! python3 -m agent_queue should-rerun --actions "$RUNNER_TEMP/actions.json"; then exit 0; fi', text)
|
||||
self.assertLess(text.index("agent_queue should-rerun"), text.index("agent_queue pr-check"))
|
||||
# The check is evaluated in this job: pull_request_target runs cannot be found by head SHA.
|
||||
self.assertNotIn("gh run", text)
|
||||
self.assertNotIn("actions: write", text)
|
||||
self.assertIn("::warning title=Agent PR check (advisory)::", text)
|
||||
|
||||
def test_should_rerun_exit_codes(self):
|
||||
with tempfile.TemporaryDirectory() as d:
|
||||
p = os.path.join(d, "a.json")
|
||||
@@ -104,19 +88,6 @@ class Workflows(unittest.TestCase):
|
||||
dump(actions, p)
|
||||
self.assertEqual(Cli.run_cli(self, "should-rerun", "--actions", p).returncode, code, actions)
|
||||
|
||||
def test_verify_runs_one_at_a_time_per_pull_request(self):
|
||||
text = self.job("agent-pr-checks.yml", "verify")
|
||||
self.assertRegex(text, r"group: agent-verify-\$\{\{ github\.event\.issue\.number \}\}\n\s+cancel-in-progress: false")
|
||||
|
||||
def test_pr_check_is_advisory(self):
|
||||
# Exit status 1 (problems found) only warns until the live smoke test and issue migration.
|
||||
text = self.job("agent-pr-checks.yml", "check")
|
||||
found = re.search(r'if \[ "\$status" -eq 1 \]; then\n(.*?)\n\s+elif \[ "\$status" -ne 0 \]; then\n\s+exit "\$status"', text, re.S)
|
||||
self.assertIsNotNone(found, text)
|
||||
self.assertIn("::warning title=Agent PR check (advisory)::", found.group(1))
|
||||
self.assertNotIn("exit", found.group(1))
|
||||
self.assertEqual(text.count("exit "), 1)
|
||||
|
||||
def test_actions_pinned_by_sha(self):
|
||||
for name in QUEUE_WORKFLOWS:
|
||||
for use in re.findall(r"uses:\s*(\S+)", self.read(name)):
|
||||
|
||||
Reference in new issue
Block a user