palantir / policy-bot

A GitHub App that enforces approval policies on pull requests
Apache License 2.0
727 stars 104 forks source link

Adding Simulation API #725

Closed atatkin closed 3 months ago

atatkin commented 4 months ago

This pr adds a new POST route api/simulate/:owner/:repo/:number. This route requires a GitHub bearer token with access to read the the underlying pull request.

When called, policy-bot will re-evaluate the policy of the referenced pr and return a simulated result back to the caller. The result does NOT get written back to the pull request as a STATUS.

A request body can be included specifying a number of options which can modify how the simulation runs. These should be relatively easy to extend with additional options in the future.

Today this supports:

The route can also be used without any options to trigger policy-bot to re-evaluate the pull request as is.

The returned simulated result does not currently contain all of the fields of the base result but it should be easy to extend as needed.