updateCheckRun method

Future<CheckRun> updateCheckRun(
  1. RepositorySlug slug,
  2. CheckRun checkRunToUpdate, {
  3. String? name,
  4. String? detailsUrl,
  5. String? externalId,
  6. DateTime? startedAt,
  7. CheckRunStatus status = CheckRunStatus.queued,
  8. CheckRunConclusion? conclusion,
  9. DateTime? completedAt,
  10. CheckRunOutput? output,
  11. List<CheckRunAction>? actions,
})

Updates a check run for a specific commit in a repository. Your GitHub App must have the checks:write permission to edit check runs.

  • name: The name of the check. For example, "code-coverage".
  • detailsUrl: The URL of the integrator's site that has the full details of the check.
  • externalId: A reference for the run on the integrator's system.
  • status: The current status. Can be one of queued, in_progress, or completed. Default: queued.
  • startedAt: The time that the check run began.
  • conclusion: Required if you provide completed_at or a status of completed. The final conclusion of the check. When the conclusion is action_required, additional details should be provided on the site specified by details_url. Note: Providing conclusion will automatically set the status parameter to completed.
  • completedAt: The time the check completed.
  • output: Check runs can accept a variety of data in the output object, including a title and summary and can optionally provide descriptive details about the run.
  • actions: Possible further actions the integrator can perform, which a user may trigger. Each action includes a label, identifier and description. A maximum of three actions are accepted.

API docs: https://developer.github.com/v3/checks/runs/#update-a-check-run

Implementation

Future<CheckRun> updateCheckRun(
  RepositorySlug slug,
  CheckRun checkRunToUpdate, {
  String? name,
  String? detailsUrl,
  String? externalId,
  DateTime? startedAt,
  CheckRunStatus status = CheckRunStatus.queued,
  CheckRunConclusion? conclusion,
  DateTime? completedAt,
  CheckRunOutput? output,
  List<CheckRunAction>? actions,
}) async {
  assert(conclusion != null ||
      (completedAt == null && status != CheckRunStatus.completed));
  assert(actions == null || actions.length <= 3);
  return github.requestJson<Map<String, dynamic>, CheckRun>(
    'PATCH',
    '/repos/${slug.fullName}/check-runs/${checkRunToUpdate.id}',
    statusCode: StatusCodes.OK,
    preview: _previewHeader,
    body: jsonEncode(createNonNullMap(<String, dynamic>{
      'name': name,
      'details_url': detailsUrl,
      'external_id': externalId,
      'started_at': dateToGitHubIso8601(startedAt),
      'status': status,
      'conclusion': conclusion,
      'completed_at': dateToGitHubIso8601(completedAt),
      'output': output,
      'actions': actions,
    })),
    convert: CheckRun.fromJson,
  );
}