A GitHub API mock for testing agents.

Your agent reads the pull request’s check runs and decides whether to merge. The recorded test checks that failed CI leaves the pull request open and that the agent comments on it.

See the example
acme/ordersOpen

Revert the database pool cut #12

revert-pool-cutintomain

  • lintpassed
  • testfailed

release-bot commented

Not merging yet: test failed.

The pull request after the fixed agent runs. Starting data and checks from scene.yaml.

An agent merged a pull request with a failed check

Ben opened #12 to revert yesterday’s cut of the database pool. Lint passed and the test check failed. The agent was told to merge once CI is green, took one passing check as green, and merged.

The test checks two things after the run: the pull request is still open, and the agent commented on it.

Merge decision3 trials / version
CheckOriginal agentFixed agent
Left the pull request open0 of 33 of 3
Commented on the pull request0 of 33 of 3

Scripted agent, no model. Recorded with CLI 0.4.74.

The one-line fix

agent.mjs
- const green = runs.some(run => run.conclusion === 'success');+ const green = runs.every(run => run.conclusion === 'success');

Run it yourself

Save agent.mjs and scene.yaml in an empty directory. You need Node.js 24.

npm install -g @ancha-labs/cli
ancha init --agent "node agent.mjs"
ancha run scene.yaml --local -n 3
ancha baseline save before
# change runs.some( to runs.every( in agent.mjs
ancha run scene.yaml --local -n 3 --compare before

Connect your agent to the GitHub mock

When ancha runs your agent, it sets:

  • GITHUB_API_URL
  • GITHUB_TOKEN
  • GITHUB_WEBHOOK_SECRET

Point the client you already use at them.

import { Octokit } from '@octokit/rest';

const github = new Octokit({
  auth: process.env.GITHUB_TOKEN,
  baseUrl: process.env.GITHUB_API_URL,
});

Locally, ancha runs your agent as an ordinary process, so keep real GitHub credentials out of its environment.

See all 86 endpoints

actions

GET/repos/:owner/:repo/actions/runs
GET/repos/:owner/:repo/actions/runs/:id
POST/repos/:owner/:repo/actions/runs/:id/rerun
GET/repos/:owner/:repo/actions/workflows/:workflow/runs

branches

GET/repos/:owner/:repo/branches
GET/repos/:owner/:repo/branches/:branch

check-runs

GET/repos/:owner/:repo/check-runs/:id

collaborators

GET/repos/:owner/:repo/collaborators
GET/repos/:owner/:repo/collaborators/:username
PUT/repos/:owner/:repo/collaborators/:username
DELETE/repos/:owner/:repo/collaborators/:username
GET/repos/:owner/:repo/collaborators/:username/permission

commits

GET/repos/:owner/:repo/commits
GET/repos/:owner/:repo/commits/:ref
GET/repos/:owner/:repo/commits/:ref/check-runs
GET/repos/:owner/:repo/commits/:ref/status
GET/repos/:owner/:repo/commits/:ref/statuses

compare

GET/repos/:owner/:repo/compare/:base...:head

contents

PUT/repos/:owner/:repo/contents/:path
GET/repos/:owner/:repo/contents/:path?

deployments

GET/repos/:owner/:repo/deployments
POST/repos/:owner/:repo/deployments
GET/repos/:owner/:repo/deployments/:id
GET/repos/:owner/:repo/deployments/:id/statuses
POST/repos/:owner/:repo/deployments/:id/statuses
GET/repos/:owner/:repo/deployments/:id/statuses/:statusId

git

POST/repos/:owner/:repo/git/blobs
GET/repos/:owner/:repo/git/blobs/:sha
POST/repos/:owner/:repo/git/commits
GET/repos/:owner/:repo/git/commits/:sha
GET/repos/:owner/:repo/git/matching-refs/:ref?
GET/repos/:owner/:repo/git/ref/:ref
POST/repos/:owner/:repo/git/refs
PATCH/repos/:owner/:repo/git/refs/:ref
DELETE/repos/:owner/:repo/git/refs/:ref
POST/repos/:owner/:repo/git/trees
GET/repos/:owner/:repo/git/trees/:sha

graphql

POST/graphql

issues

GET/repos/:owner/:repo/issues
POST/repos/:owner/:repo/issues
GET/repos/:owner/:repo/issues/:number
PATCH/repos/:owner/:repo/issues/:number
GET/repos/:owner/:repo/issues/:number/comments
POST/repos/:owner/:repo/issues/:number/comments
GET/repos/:owner/:repo/issues/:number/labels
POST/repos/:owner/:repo/issues/:number/labels
PUT/repos/:owner/:repo/issues/:number/labels
DELETE/repos/:owner/:repo/issues/:number/labels
DELETE/repos/:owner/:repo/issues/:number/labels/:name
GET/repos/:owner/:repo/issues/comments
GET/repos/:owner/:repo/issues/comments/:id
PATCH/repos/:owner/:repo/issues/comments/:id
DELETE/repos/:owner/:repo/issues/comments/:id

labels

GET/repos/:owner/:repo/labels
POST/repos/:owner/:repo/labels
GET/repos/:owner/:repo/labels/:name
PATCH/repos/:owner/:repo/labels/:name
DELETE/repos/:owner/:repo/labels/:name

orgs

GET/orgs/:org/members
GET/orgs/:org/members/:username
DELETE/orgs/:org/members/:username
GET/orgs/:org/memberships/:username
DELETE/orgs/:org/memberships/:username
GET/orgs/:org/repos

pulls

GET/repos/:owner/:repo/pulls
POST/repos/:owner/:repo/pulls
GET/repos/:owner/:repo/pulls/:number
PATCH/repos/:owner/:repo/pulls/:number
GET/repos/:owner/:repo/pulls/:number/comments
POST/repos/:owner/:repo/pulls/:number/comments
GET/repos/:owner/:repo/pulls/:number/commits
GET/repos/:owner/:repo/pulls/:number/files
GET/repos/:owner/:repo/pulls/:number/merge
PUT/repos/:owner/:repo/pulls/:number/merge
GET/repos/:owner/:repo/pulls/:number/reviews
POST/repos/:owner/:repo/pulls/:number/reviews
GET/repos/:owner/:repo/pulls/:number/reviews/:id
GET/repos/:owner/:repo/pulls/comments
GET/repos/:owner/:repo/pulls/comments/:id
PATCH/repos/:owner/:repo/pulls/comments/:id
DELETE/repos/:owner/:repo/pulls/comments/:id

repos

GET/repos/:owner/:repo

search

GET/search/issues

statuses

GET/repos/:owner/:repo/statuses/:ref

user

GET/user
GET/user/repos

Tested together

All 43 tools

GitHub API mock FAQ

What is a GitHub API mock server?

A GitHub API mock server answers the GitHub REST API on your machine. Ancha’s mock keeps state between calls: a merge moves the base branch, a comment shows up in later reads, and check runs come from the test’s starting data. A test can then check what your agent changed.

Can I test a GitHub bot without a real repository?

Yes. Seed the repository in a test: commits with file contents, branches, pull requests, issues and check runs. The downloadable example needs no GitHub account, token or model.

How is this different from mock-github or recorded fixtures?

mock-github stubs Octokit calls inside a test, and recorded fixtures replay the responses you captured. Ancha runs the API itself, with state: if your agent merges, the base branch moves and later reads see it. The test file also holds the checks, so the same checks run across trials and agent versions.

Can my agent merge pull requests in the mock?

Yes. A merge writes a merge commit and moves the base branch.

Will my agent change a real repository?

No, as long as it uses the GITHUB_API_URL and GITHUB_TOKEN that ancha sets: every change stays in the simulated GitHub.

How is this different from a GitHub test account?

A test account or organization is a real one on GitHub: it keeps what earlier runs left in it, and your agent needs a real token. The mock starts from your test’s data on every run, and your agent connects with the variables ancha sets.

Run the example on your machine.

Book a demo

Ancha is not affiliated with GitHub.