GitHub Webhook Server and Event Simulator
502
Loadrunner is a multi-purpose utility for working with GitHub webhooks and statuses.
It provides these features:
$ gem install loadrunner
hooks parent directory):
loadrunner serverloadrunner event localhost:3000 myrepo push masterThe server should respond with a detailed JSON response, specifying what
hooks were executed (executed_hooks) and what hooks could have
been executed, if they were defined in the hooks folder
(matching_hooks).
For more options, see the documentation or run
$ loadrunner --help
When running the server, it will look for hooks (executable scripts) in
the ./hooks directory, using one of these format:
hooks/global
hooks/<repo name>/global
hooks/<repo name>/<event type>
hooks/<repo name>/<event type>@branch=<branch name>
hooks/<repo name>/<event type>@tag=<tag name>
hooks/<repo name>/<event type>@tag
For example:
hooks/global
hooks/myrepo/global
hooks/myrepo/push
hooks/myrepo/push@branch=master
hooks/myrepo/push@tag=release
hooks/myrepo/push@tag
When none of the hooks are found, Loadrunner will respond with a list of hooks it was looking for, so you can use this response to figure out what it needs.
The hooks can be written in any language, and should simply be executable.
These environment variables are available to your hooks:
LOADRUNNER_REPOLOADRUNNER_OWNERLOADRUNNER_EVENTLOADRUNNER_BRANCHLOADRUNNER_COMMITLOADRUNNER_REFLOADRUNNER_TAGIf you wish to mount the Loadrunner server under another Rack or Sinatra
application, use the Loadrunner::Server as the handler.
# config.ru
require "loadrunner/server"
map "/github" do
run Loadrunner::Server
end
run YourOwnApp
You may use the Loadrunner::Status class to update the status of a
GitHub pull request.
First, make sure that your GitHub API access token is set in the environment
variable GITHUB_ACCESS_TOKEN.
require 'loadrunner/status'
response = Loadrunner::Status.update repo: 'user/repo',
sha: 'commit sha string',
state: :pending, # :pending :success :failure :error
context: "My Hooks Server",
description: "Jobs have not started yet",
url: "http://example.com"
Only repo, sha and state are required, the rest arguments are optional.
You can run both the server and the client using Docker.
# Server
$ docker run -p3000:3000 dannyben/loadrunner server
# Client
$ docker run dannyben/loadrunner event http://webhook.server.com repo push
If you wish to connect the client to the server you are running through Docker, you can do something like this:
$ docker run --network host dannyben/loadrunner event http://localhost:3000 repo push
See also: The docker-compose file.
Content type
Image
Digest
Size
83.5 MB
Last updated
over 5 years ago
docker pull dannyben/loadrunner