Bors-NG v0.1.0 BorsNG.WebhookController View Source

The webhook controller responds to HTTP requests that are initiated from other services (currently, just GitHub).

For example, I can run iex -S mix phx.server and do this:

iex> # Push state to "GitHub"
iex> alias BorsNG.GitHub
iex> alias BorsNG.GitHub.ServerMock
iex> alias BorsNG.Database
iex> ServerMock.put_state(%{
...>   {:installation, 91} => %{ repos: [
...>     %GitHub.Repo{
...>       id: 14,
...>       name: "test/repo",
...>       owner: %{
...>         id: 6,
...>         login: "bors-fanboi",
...>         avatar_url: "data:image/svg+xml,<svg></svg>",
...>         type: :user
...>       }}
...>   ] },
...>   {{:installation, 91}, 14} => %{
...>     branches: %{},
...>     comments: %{1 => []},
...>     pulls: %{
...>       1 => %GitHub.Pr{
...>         number: 1,
...>         title: "Test",
...>         body: "Mess",
...>         state: :open,
...>         base_ref: "master",
...>         head_sha: "00000001",
...>         user: %GitHub.User{
...>           id: 6,
...>           login: "bors-fanboi",
...>           avatar_url: "data:image/svg+xml,<svg></svg>"}}},
...>     statuses: %{},
...>     files: %{}}})
iex> # The installation now exists; notify bors about it.
iex> BorsNG.WebhookController.do_webhook(%{
...>   body_params: %{
...>     "installation" => %{ "id" => 91 },
...>     "sender" => %{
...>       "id" => 6,
...>       "login" => "bors-fanboi",
...>       "avatar_url" => "" },
...>     "action" => "created" }}, "github", "installation")
iex> # This starts a background sync process with the installation.
iex> # Watch it happen in the user interface.
iex> BorsNG.Worker.SyncerInstallation.wait_hot_spin_xref(91)
iex> proj = Database.Repo.get_by!(Database.Project, repo_xref: 14)
iex> proj.name
"test/repo"
iex> patch = Database.Repo.get_by!(Database.Patch, pr_xref: 1)
iex> patch.title
"Test"

Link to this section Summary

Link to this section Functions

Link to this function

do_webhook(conn, binary1, binary2)

View Source
Link to this function

do_webhook_installation_sync(conn)

View Source
Link to this function

do_webhook_pr(conn, map)

View Source

This action is reached via /webhook/:provider