GhEx.Checks (gh_ex v0.3.4)

Copy Markdown View Source

Convenience functions for the GitHub Checks REST API.

Thin wrappers over GhEx.REST that return the same {:ok, body, meta} / {:error, reason} shape; opts pass through to Req.

Summary

Functions

Finds a GitHub App's check run with check_name on a git ref.

Lists the annotations attached to a check run.

Lists check runs for a git ref.

Rerequests a check run without pushing new code.

Auto-paginates a check run's annotations into a lazy Stream.

Auto-paginates the check runs for a git ref into a lazy Stream, unwrapping the "check_runs" array on each page (see GhEx.REST.stream/3).

Types

id()

@type id() :: integer() | String.t()

Functions

create_run(client, owner, repo, attrs, opts \\ [])

@spec create_run(GhEx.Client.t(), String.t(), String.t(), map(), keyword()) ::
  GhEx.REST.result()

Creates a check run.

find_run_for_ref(client, owner, repo, ref, check_name, app_id, opts \\ [])

@spec find_run_for_ref(
  GhEx.Client.t(),
  String.t(),
  String.t(),
  String.t(),
  String.t(),
  integer() | String.t(),
  keyword()
) :: GhEx.REST.result()

Finds a GitHub App's check run with check_name on a git ref.

Returns {:ok, run, meta} for the first run GitHub returns, or {:ok, nil, meta} when none matches. GitHub defaults the endpoint to its latest filter. This function only performs the lookup; the caller decides whether to call create_run/5 or update_run/6 next.

app_id is the numeric GitHub App ID, not an installation ID or OAuth client ID. Reuse the numeric ID passed when building the app client described by GhEx.App, or authenticate as the app and read it from:

{:ok, %{"id" => app_id}, _meta} = GhEx.REST.get(app_client, "/app")

Caller-supplied query parameters are preserved, but check_name and app_id are always set from their explicit arguments.

get_run(client, owner, repo, check_run_id, opts \\ [])

@spec get_run(GhEx.Client.t(), String.t(), String.t(), id(), keyword()) ::
  GhEx.REST.result()

Gets a check run by id.

list_annotations(client, owner, repo, check_run_id, opts \\ [])

@spec list_annotations(GhEx.Client.t(), String.t(), String.t(), id(), keyword()) ::
  GhEx.REST.result()

Lists the annotations attached to a check run.

list_for_ref(client, owner, repo, ref, opts \\ [])

@spec list_for_ref(GhEx.Client.t(), String.t(), String.t(), String.t(), keyword()) ::
  GhEx.REST.result()

Lists check runs for a git ref.

rerequest_run(client, owner, repo, check_run_id, opts \\ [])

@spec rerequest_run(GhEx.Client.t(), String.t(), String.t(), id(), keyword()) ::
  GhEx.REST.result()

Rerequests a check run without pushing new code.

GitHub resets the containing check suite and emits a check_run webhook with the rerequested action. The app that owns the run must handle that webhook and update the check run as needed. This is separate from rerunning a GitHub Actions workflow through GhEx.Actions and requires Checks write permission.

stream_annotations(client, owner, repo, check_run_id, opts \\ [])

@spec stream_annotations(GhEx.Client.t(), String.t(), String.t(), id(), keyword()) ::
  Enumerable.t()

Auto-paginates a check run's annotations into a lazy Stream.

stream_for_ref(client, owner, repo, ref, opts \\ [])

@spec stream_for_ref(GhEx.Client.t(), String.t(), String.t(), String.t(), keyword()) ::
  Enumerable.t()

Auto-paginates the check runs for a git ref into a lazy Stream, unwrapping the "check_runs" array on each page (see GhEx.REST.stream/3).

update_run(client, owner, repo, check_run_id, attrs, opts \\ [])

@spec update_run(GhEx.Client.t(), String.t(), String.t(), id(), map(), keyword()) ::
  GhEx.REST.result()

Updates a check run.