Skip to Content
screw bugs docs

GitHub bot

How to have screw-bugs Cloud test a pull request's preview from a PR comment.

Comment /screw-bugs on a pull request. The bot finds the PR's preview, runs a Cloud run planned from the diff, and comments the report.

Not open yet

Only the screw-bugs team can start Cloud runs for now, and the GitHub App installs only on uxstudioteam's repositories.

Before you start

WhoDoes what, once
Someone who can install GitHub AppsInstalls screw-bugs-cloud on the repository
YouSign in with GitHub on screwbugs.dev
YouHave push access to the repository

Can't install apps? Send this to your developer: "Please install the screw-bugs-cloud GitHub App on our repo."

Without a sign-in, the bot asks you to sign in, then comment again. The run is the commenter's: their test accounts, their cost.

The command

Start a comment with /screw-bugs, or tag @screw-bugs-cloud the same way. A tag further into a line, or one in code or a quote, doesn't count.

CommentWhat it does
/screw-bugsTest the preview, with cases planned from the change
/screw-bugs check that sign-up still worksSay what to test, in your own words
/screw-bugs --url https://โ€ฆTest that address instead of the preview found
/screw-bugs --account trial-userTest signed in as one of your Cloud test accounts
/screw-bugs helpShow these options on the PR

Everything after the command, including the following lines, is the instructions (at most 4,000 characters). Put --url and --account on the /screw-bugs line, at most once each: on a later line they're read as instructions.

--account takes a label from your accounts on screwbugs.dev/accounts, not local screw-bugs ones. With a label you don't have there, the run starts, then fails, saying so.

Example

/screw-bugs --account trial-user check that the upgrade banner links to checkout

The bot reacts ๐Ÿ‘€ to your comment and replies:

๐Ÿ”Ž screw-bugs is testing https://arlo-git-upgrade-banner-team.vercel.app/, signed in as trial-user. The report will be here. ยท Stop this run

When the run ends, the same comment changes to:

๐Ÿ› screw-bugs tested https://arlo-git-upgrade-banner-team.vercel.app/: the report.

Your comment's ๐Ÿ‘€ becomes ๐ŸŽ‰ when every test passed, or ๐Ÿ‘Ž otherwise. ๐Ÿ‘Ž doesn't always mean a bug: a test may not have finished, and the report's verdict says which.

How it finds the preview

  1. GitHub deployments of the PR's head commit (never production).
  2. Otherwise, the previews in Vercel's PR comment.
  3. Otherwise, the address saved for this repository from an earlier answer.

When there are none, several, or the one found doesn't load, the bot tries the saved address; if that doesn't load either, it asks on the PR, listing what it found. Reply:

/screw-bugs --url https://arlo-git-upgrade-banner-team.vercel.app

An address that follows the branch (as Vercel's branch previews do) is saved for the repository's next PRs. The run waits, blocked, until someone who can push answers.

Named sites

Instructions can name another site: /screw-bugs check the pricing page of copyfol.io. A small model then chooses between it and the preview; when unsure, the bot asks as above.

With --account, named sites are ignored and the preview is tested. A named site never gets the repository's preview headers. It signs in, if needed, with your own test accounts for it.

Stopping and limits

  • The ๐Ÿ”Ž comment links to Stop this run (/runs/<slug>/stop). Anyone who can push, or an admin, can stop it; the comment then says who did (or, if a report already exists, links it).
  • A PR has one run at a time. A new /screw-bugs while one waits gets a pointer to what it waits for.
  • While a run waits for an address, a comment with --url answers it, with no ๐Ÿ‘€: its instructions and --account are ignored.
  • When a run stops at a cap, the final comment says so (for example "It stopped at its time limit, so some cases may not have run").

How it works

  • The App sends comment events to /api/github/webhook, which checks GitHub's signature, then the commenter's push access and Cloud sign-in.
  • Runs start on a comment only, never on every push: each one costs a model and a browser.
  • The run's status is one bot comment, edited in place from start to report.
  • Protected previews get the repository's preview headers.

Code: apps/web/src/server/github (Cloud), comment texts in packages/shares/src/github.ts (Cloud).

For agents

  • Cloud runs are team-only for now: ask the user whether they're on the screw-bugs team. If not, the bot refuses.
  • Post as the user: gh pr comment <number> --body "/screw-bugs check that sign-up still works". It runs as their GitHub account, so they need push access and a sign-in.
  • You can't list Cloud test accounts: ask the user for the label.
  • Follow it with gh pr view <number> --comments, about once a minute, reading the comments from screw-bugs-cloud[bot]:
    • Only comments posted after yours count: earlier runs on the PR left their own ๐Ÿ› comments. gh pr view <number> --json comments gives each comment's author and createdAt.
    • The result is in this run's status comment: the first bot comment after yours that starts with ๐Ÿ”Ž, ๐Ÿ›, ๐Ÿ›‘ or "couldn't finish". A ๐Ÿ”Ž comment is edited in place (keeping its place and createdAt) when the run ends; a run that ends before testing posts its result as a new comment. Only a ๐Ÿ› comment has a report link.
    • Everything else (questions, sign-ins, refusals) comes as new comments, and they stay after they're answered.
  • gh pr comment prints your comment's URL, ending #issuecomment-<id>; its reactions are at gh api repos/<owner>/<repo>/issues/comments/<id>/reactions.
  • No ๐Ÿ‘€ on your comment within a minute or two, and no reply? (A --url answer to a waiting run never gets either: wait for the ๐Ÿ”Ž comment instead.) The commenter can't push, the App isn't installed, or the run couldn't be created (ask the user to try again). ๐Ÿ‘€ but no reply after 5 minutes? Tell the user.
  • A question or sign-in can wait a day: hand it to the user. Once they've answered or signed in, follow again.
  • Give up about 25 minutes (for a run with the default limit) after the ๐Ÿ”Ž comment appears (or after the user tells you they've answered or signed in), and tell the user.
  • The report link opens without a sign-in; its page carries the verdict and issues as text.
The bot's comment starts withMeansDo
๐Ÿ”Ž screw-bugs is testing โ€ฆRunningKeep reading
๐Ÿ› screw-bugs tested โ€ฆ: the reportDoneTake the report link; read the report
screw-bugs couldn't finish this run โ€ฆFailed, no reportTell the user why
๐Ÿ›‘ screw-bugs stopped testing โ€ฆSomeone stopped it, no reportTell the user
@user, โ€ฆ Which address should screw-bugs test?Waiting for a preview addressAsk the user, or reply /screw-bugs --url โ€ฆ
That /screw-bugs command can't run: โ€ฆMalformed command (--url, --account, a repeated flag, instructions too long), no runFix it and comment again
@user, this run signs in as your test account โ€ฆWaiting for the user's sign-in (up to 1 day)Give the user the link: only they can sign in
@user, what this run was asked to test needs a signed-in user โ€ฆWaiting for the user to add an account and sign in (up to 1 day)Give the user the link
@user, a run on this pull request is waiting โ€ฆAnother run is already waitingTell the user what it waits for
@user, sign in to โ€ฆNot signed in, no runAsk the user to sign in on screwbugs.dev
screw-bugs tests this pull request's preview โ€ฆThe help textNothing to wait for
@user, โ€ฆ (any other reply)Refused (not open yet, cap reached, a run already going), or an answer that did not reach the runTell the user what it says
NextSlack bot (coming soon)

On this page