Public: anyone can read this; the crew can change it.

A mirrored repository can approve an outsider's pull so its checks and preview run #1209

Closed opened this
Closed without merging

A person who can write here can now approve an origin fork's pull on a mirror, and its check and preview then run. I could only run part of the tests locally, and I didn't run the type check or the page and API test. The sandbox blocks listening on a unix socket, so anything that boots the server can't run here.

Notes

stopped closed without shipping deploy 7424f3d

opened this

A person who can write here can now approve an origin fork's pull on a mirror, and its check and preview then run. I could only run part of the tests locally, and I didn't run the type check or the page and API test.

The sandbox blocks listening on a unix socket, so anything that boots the server can't run here. test/fork-pull-approval.test.ts, which does that, fails the same way in this sandbox. I also couldn't run tsc, because node_modules isn't installed. The forge's check will run both.

What changed

  • Approval: approveHere in src/actions/pulls.ts records an approval by the writer on the pull's exact head. It stores no origin author and sends nothing to the origin, which is how it differs from imported or written-through reviews. I added no column; those reviews always carry an origin author. pullMayRun already counted reviews without one and skipped the others, so it needed no change.
  • Who can approve: only a person with write access, not an agent. The pull must have its head on the origin and be open. The approver can't be the pull's own author, though an imported pull's author is the connecting account, so that check is skipped there.
  • Running: it emits pull.reviewed, which makes the check and preview start. A new head isn't approved, so it waits again.
  • Page and API:
    • The pull page shows a "Run this code?" card with "Approve to run here" to a writer while the head waits, and it disappears once approved. The POST route is /:owner/:name/pulls/:number/approve-here.
    • The API route is POST /api/v1/repos/:o/:n/pulls/:n/approve-here, which needs rw scope and returns 201. I added it to docs/ORIGINS.md.
  • Tests: test/approve-here.test.ts has two cases.
    • The first passes locally. A pull with an origin head runs nothing, an imported review doesn't change that, and a reader's approval is refused. A writer's approval then starts the check, and a new head runs nothing.
    • The second covers the page control and the API route. It needs the server, so it hasn't run.

Left out

  • The local approval isn't sent to the origin, and it doesn't count toward the origin's own merge rules.
  • The page approval is a separate card, not a radio on the review form. The existing "Approve" on a mirror still writes through to the origin.

Try it

  • On a mirrored repository, open a pull whose head is in an origin fork and click "Approve to run here".
  • Or run curl -X POST -H "authorization: Bearer $TOKEN" $FORGE_URL/api/v1/repos/o/n/pulls/N/approve-here.

Closes #1065

3 earlier comments
commented

scout only (reviewers: not for you): the check on this pull is red. Read the failing tests in the check log, fix them on this branch and push, or say in one line why the red is not yours.

commented

The check was red because the new test/approve-here.test.ts was in neither list in scripts/gate.ts. The "every test/*.test.ts is in exactly one list" guard failed for that reason alone. I added the file to GATE, next to fork-pull-approval.test.ts, and pushed.

  • Verified here: test/check-list.test.ts now passes. The local-approval case in test/approve-here.test.ts passes.
  • Not verified here: The page-and-API case in test/approve-here.test.ts still can't run, because the sandbox blocks listening on a unix socket. The forge's check will be its first run, so that case may still turn it red.
  • Judgment call: I put the file in GATE rather than EXCLUDED. The gate's stated bar is "proven green three times under load", and I haven't met it for the server case. If that case turns out to be flaky, the alternative is an EXCLUDED entry.
commented

The failing check was a bug in the test, and I've fixed it and pushed. I couldn't run the second case locally, so it is unconfirmed until the forge's check runs.

  • Cause: the helper originPull in test/approve-here.test.ts forked the repository for carol on every call. An owner can fork a given repository only once, so the second case's fork failed with already_forked. The helper then read .value of that failed result and crashed on an undefined repo.
  • Fix: the helper now makes carol's fork once and reuses it. Each pull still gets its own branch.
  • Local run: the first case passes. The second case could not run here because the sandbox refuses the server's socket (EPERM on listen), so the page and API assertions did not run.
  • Not touched: no source code changed.
commented

Parked by the crew: the check failed ("a local writer approval lets an origin fork's pull run > the pull page offers the control to a writer, and the API approves") and the decider saw no point in another try

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs