Skip to content

Commit

Permalink
Github::Check
Browse files Browse the repository at this point in the history
Removing unnecessary command

Signed-off-by: Rodrigo Nardi <[email protected]>
  • Loading branch information
RodrigoMNardi committed Jun 22, 2024
1 parent 954a613 commit 704c375
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 39 deletions.
18 changes: 1 addition & 17 deletions lib/github/build/summary.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def initialize(job, logger_level: Logger::INFO, agent: 'Github')
def build_summary
current_stage = @job.stage
current_stage = fetch_parent_stage if current_stage.nil?
check_and_update_github_ref(current_stage)
current_stage.refresh_reference(@github)

logger(Logger::INFO, "build_summary: #{current_stage.inspect}")
msg = "Github::Build::Summary - #{@job.inspect}, #{current_stage.inspect}, bamboo info: #{bamboo_info}"
Expand All @@ -60,22 +60,6 @@ def bamboo_info
finish.fetch_build_status
end

def check_and_update_github_ref(current_stage)
current_refs = @github.fetch_check_runs

logger(Logger::INFO,
'check_and_update_github_ref - current_stage: ' \
"#{current_stage.inspect} current_refs: #{current_refs.inspect}")

return if current_refs.include? current_stage.check_ref.to_i

logger(Logger::INFO,
'check_and_update_github_ref - current_stage: ' \
"#{current_stage.inspect} current_refs: #{current_refs.inspect} - Refreshing reference.")

current_stage.refresh_reference(@github)
end

def must_update_previous_stage(current_stage)
previous_stage = current_stage.previous_stage

Expand Down
22 changes: 0 additions & 22 deletions lib/github/check.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,28 +99,6 @@ def get_check_run(check_ref)
accept: Octokit::Preview::PREVIEW_TYPES[:checks]).to_h
end

def fetch_check_runs
return [] if @check_suite.nil?

check_runs =
@app
.check_runs_for_ref(
@check_suite.pull_request.repository,
@check_suite.pull_request.branch_name,
accept: Octokit::Preview::PREVIEW_TYPES[:checks]
).to_h[:check_runs]

return [] if check_runs.nil?

check_runs.map do |check_run|
check_run[:id]
end
rescue Octokit::UnprocessableEntity => e
@logger.error "fetch_check_runs: #{e.class} #{e.message}"

[]
end

def installation_id
@authenticate_app.find_app_installations(accept: 'application/vnd.github.v3+json').first['id'].to_i
end
Expand Down
17 changes: 17 additions & 0 deletions spec/lib/github/check_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,23 @@
end
end

context 'when call comment_reaction_thumb_down' do
let(:pr_id) { 1 }
let(:repo) { 'test' }
let(:comment_id) { 1 }
let(:pr_info) { { comment_id: comment_id } }

before do
allow(fake_client).to receive(:create_issue_comment_reaction)
.with(repo, comment_id, '-1', accept: Octokit::Preview::PREVIEW_TYPES[:reactions])

Check warning on line 95 in spec/lib/github/check_spec.rb

View workflow job for this annotation

GitHub Actions / Rubocop

[rubocop] reported by reviewdog 🐶 Use 2 (not 24) spaces for indenting an expression spanning multiple lines. Raw Output: spec/lib/github/check_spec.rb:95:31: C: Layout/MultilineMethodCallIndentation: Use 2 (not 24) spaces for indenting an expression spanning multiple lines.
.and_return(pr_info)

Check warning on line 96 in spec/lib/github/check_spec.rb

View workflow job for this annotation

GitHub Actions / Rubocop

[rubocop] reported by reviewdog 🐶 Use 2 (not 24) spaces for indenting an expression spanning multiple lines. Raw Output: spec/lib/github/check_spec.rb:96:31: C: Layout/MultilineMethodCallIndentation: Use 2 (not 24) spaces for indenting an expression spanning multiple lines.
end

it 'must returns pull request info' do
expect(check.comment_reaction_thumb_down(repo, comment_id)).to eq(pr_info)
end
end

context 'when call create' do
let(:pr_id) { 1 }
let(:name) { 'test' }
Expand Down

0 comments on commit 704c375

Please sign in to comment.