Skip to content

Commit b79c3e7

Browse files
Merge pull request #96 from FRRouting/master
Release 2.3.8
2 parents 02ddd8e + 102b07f commit b79c3e7

File tree

3 files changed

+52
-17
lines changed

3 files changed

+52
-17
lines changed

lib/github/update_status.rb

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def initialize(payload)
2323
@reference = payload['bamboo_ref'] || 'invalid_reference'
2424
@job = CiJob.find_by(job_ref: payload['bamboo_ref'])
2525
@check_suite = @job&.check_suite
26-
@failures = payload['failures']
26+
@failures = payload['failures'] || []
2727

2828
logger_initializer
2929
end
@@ -121,24 +121,11 @@ def current_execution?
121121
def failure
122122
@job.failure(@github_check)
123123

124-
retrieve_stats
125-
end
126-
127-
def retrieve_stats
128124
return failures_stats if @failures.is_a? Array and !@failures.empty?
129125

130-
retrieve_errors
131-
end
132-
133-
def retrieve_errors
134-
@retrieve_error = Github::TopotestFailures::RetrieveError.new(@job)
135-
@retrieve_error.retrieve
136-
137-
return if @retrieve_error.failures.empty?
138-
139-
@failures = @retrieve_error.failures
140-
141-
failures_stats
126+
CiJobFetchTopotestFailures
127+
.delay(run_at: 5.minutes.from_now, queue: 'fetch_topotest_failures')
128+
.update(@job.id, 1)
142129
end
143130

144131
def slack_notify_success

lib/github_ci_app.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@
3838
require_relative 'helpers/sinatra_payload'
3939
require_relative 'helpers/telemetry'
4040

41+
# Workers
4142
require_relative '../workers/ci_job_status'
43+
require_relative '../workers/ci_job_fetch_topotest_failures'
4244

4345
# Slack libs
4446
require_relative 'slack/slack'
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# SPDX-License-Identifier: BSD-2-Clause
2+
#
3+
# ci_job_fetch_topotest_failures.rb
4+
# Part of NetDEF CI System
5+
#
6+
# Copyright (c) 2024 by
7+
# Network Device Education Foundation, Inc. ("NetDEF")
8+
#
9+
# frozen_string_literal: true
10+
11+
class CiJobFetchTopotestFailures
12+
def self.update(ci_job_id, count)
13+
@job = CiJob.find(ci_job_id)
14+
15+
@retrieve_error = Github::TopotestFailures::RetrieveError.new(@job)
16+
@retrieve_error.retrieve
17+
18+
return if rescheduling(count)
19+
20+
@failures = @retrieve_error.failures
21+
22+
@failures.each do |failure|
23+
TopotestFailure.create(ci_job: @job,
24+
test_suite: failure['suite'],
25+
test_case: failure['case'],
26+
message: failure['message'],
27+
execution_time: failure['execution_time'])
28+
end
29+
end
30+
31+
def self.rescheduling(count)
32+
return true if count > 3
33+
34+
if @retrieve_error.failures.empty?
35+
count += 1
36+
37+
CiJobFetchTopotestFailures
38+
.delay(run_at: (5 * count).minutes.from_now, queue: 'fetch_topotest_failures')
39+
.update(@job.id, count)
40+
41+
return true
42+
end
43+
44+
false
45+
end
46+
end

0 commit comments

Comments
 (0)