Skip to content

Commit

Permalink
Merge pull request #96 from FRRouting/master
Browse files Browse the repository at this point in the history
Release 2.3.8
  • Loading branch information
RodrigoMNardi authored Aug 31, 2024
2 parents 02ddd8e + 102b07f commit b79c3e7
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 17 deletions.
21 changes: 4 additions & 17 deletions lib/github/update_status.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def initialize(payload)
@reference = payload['bamboo_ref'] || 'invalid_reference'
@job = CiJob.find_by(job_ref: payload['bamboo_ref'])
@check_suite = @job&.check_suite
@failures = payload['failures']
@failures = payload['failures'] || []

logger_initializer
end
Expand Down Expand Up @@ -121,24 +121,11 @@ def current_execution?
def failure
@job.failure(@github_check)

retrieve_stats
end

def retrieve_stats
return failures_stats if @failures.is_a? Array and !@failures.empty?

retrieve_errors
end

def retrieve_errors
@retrieve_error = Github::TopotestFailures::RetrieveError.new(@job)
@retrieve_error.retrieve

return if @retrieve_error.failures.empty?

@failures = @retrieve_error.failures

failures_stats
CiJobFetchTopotestFailures
.delay(run_at: 5.minutes.from_now, queue: 'fetch_topotest_failures')
.update(@job.id, 1)
end

def slack_notify_success
Expand Down
2 changes: 2 additions & 0 deletions lib/github_ci_app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@
require_relative 'helpers/sinatra_payload'
require_relative 'helpers/telemetry'

# Workers
require_relative '../workers/ci_job_status'
require_relative '../workers/ci_job_fetch_topotest_failures'

# Slack libs
require_relative 'slack/slack'
Expand Down
46 changes: 46 additions & 0 deletions workers/ci_job_fetch_topotest_failures.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# SPDX-License-Identifier: BSD-2-Clause
#
# ci_job_fetch_topotest_failures.rb
# Part of NetDEF CI System
#
# Copyright (c) 2024 by
# Network Device Education Foundation, Inc. ("NetDEF")
#
# frozen_string_literal: true

class CiJobFetchTopotestFailures
def self.update(ci_job_id, count)
@job = CiJob.find(ci_job_id)

@retrieve_error = Github::TopotestFailures::RetrieveError.new(@job)
@retrieve_error.retrieve

return if rescheduling(count)

@failures = @retrieve_error.failures

@failures.each do |failure|
TopotestFailure.create(ci_job: @job,
test_suite: failure['suite'],
test_case: failure['case'],
message: failure['message'],
execution_time: failure['execution_time'])
end
end

def self.rescheduling(count)
return true if count > 3

if @retrieve_error.failures.empty?
count += 1

CiJobFetchTopotestFailures
.delay(run_at: (5 * count).minutes.from_now, queue: 'fetch_topotest_failures')
.update(@job.id, count)

return true
end

false
end
end

0 comments on commit b79c3e7

Please sign in to comment.