Class: CleoQualityReview::StickyCommentPublisher

Inherits:
Object
  • Object
show all
Defined in:
lib/cleo_quality_review/sticky_comment_publisher.rb

Overview

Publishes quality review findings as a single sticky pull request comment, editing it in place on every run rather than posting a new one

Constant Summary collapse

COMMENTS_PER_PAGE =
100
MAX_COMMENT_PAGES =
20

Instance Method Summary collapse

Constructor Details

#initialize(run:, rendered_review:, env: ENV, client: nil) ⇒ StickyCommentPublisher

Returns a new instance of StickyCommentPublisher.

Parameters:

  • run (Run) —

    completed quality review run

  • rendered_review (String) —

    JSON produced by the pr_review formatter

  • env (Hash{String => String}) (defaults to: ENV) —

    process environment

  • client (GitHubClient, nil) (defaults to: nil) —

    GitHub API client (built from env when omitted)



22
23
24
25
26
27
# File 'lib/cleo_quality_review/sticky_comment_publisher.rb', line 22

def initialize(run:, rendered_review:, env: ENV, client: nil)
  @run = run
  @env = env
  @client = client
  @builder = StickyCommentBuilder.new(rendered_review: rendered_review)
end

Instance Method Details

#publish ⇒ String

Publish the sticky comment, or skip when there is no PR context/findings

Returns:

  • (String) —

    status message



32
33
34
35
36
37
# File 'lib/cleo_quality_review/sticky_comment_publisher.rb', line 32

def publish
  skip_reason = publication_skip_reason
  return skip_reason if skip_reason

  existing_comment_id ? update_comment : create_comment
end