From 04ab01f9f71a71c5ca7822f13105528da7e51f69 Mon Sep 17 00:00:00 2001 From: Rodrigo Nardi Date: Sat, 24 Aug 2024 19:23:44 -0300 Subject: [PATCH 1/3] Update Status Apparently, address sanitize errors take a long time to be made available in the Bamboo API, so we will use the Delayed Job to retrieve the execution results after 1 minute. Signed-off-by: Rodrigo Nardi --- lib/github/update_status.rb | 19 ++---------- workers/ci_job_fetch_topotest_failures.rb | 36 +++++++++++++++++++++++ 2 files changed, 39 insertions(+), 16 deletions(-) create mode 100644 workers/ci_job_fetch_topotest_failures.rb diff --git a/lib/github/update_status.rb b/lib/github/update_status.rb index 0f314c1..e8f838c 100644 --- a/lib/github/update_status.rb +++ b/lib/github/update_status.rb @@ -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: 60.seconds.from_now, queue: 'fetch_topotest_failures') + .update(@job.id) end def slack_notify_success diff --git a/workers/ci_job_fetch_topotest_failures.rb b/workers/ci_job_fetch_topotest_failures.rb new file mode 100644 index 0000000..f416680 --- /dev/null +++ b/workers/ci_job_fetch_topotest_failures.rb @@ -0,0 +1,36 @@ +# 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) + @job = CiJob.find(ci_job_id) + + @retrieve_error = Github::TopotestFailures::RetrieveError.new(@job) + @retrieve_error.retrieve + + return if @retrieve_error.failures.empty? + + @failures = @retrieve_error.failures + + failures_stats + end + + private + + def failures_stats + @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 +end From 72f058885324cbed708527545c7f464bd7fa3f2b Mon Sep 17 00:00:00 2001 From: Rodrigo Nardi Date: Sat, 24 Aug 2024 19:58:49 -0300 Subject: [PATCH 2/3] Update Status Adding missing lib load Signed-off-by: Rodrigo Nardi --- lib/github_ci_app.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/github_ci_app.rb b/lib/github_ci_app.rb index 631a07f..9474c85 100644 --- a/lib/github_ci_app.rb +++ b/lib/github_ci_app.rb @@ -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' From 599b6d2b99c15b483f1839a93958fe3d7f59804e Mon Sep 17 00:00:00 2001 From: Rodrigo Nardi Date: Sat, 24 Aug 2024 20:05:29 -0300 Subject: [PATCH 3/3] CiJobFetchTopotestFailures Removing extra method Signed-off-by: Rodrigo Nardi --- workers/ci_job_fetch_topotest_failures.rb | 6 ------ 1 file changed, 6 deletions(-) diff --git a/workers/ci_job_fetch_topotest_failures.rb b/workers/ci_job_fetch_topotest_failures.rb index f416680..5ccc67f 100644 --- a/workers/ci_job_fetch_topotest_failures.rb +++ b/workers/ci_job_fetch_topotest_failures.rb @@ -19,12 +19,6 @@ def self.update(ci_job_id) @failures = @retrieve_error.failures - failures_stats - end - - private - - def failures_stats @failures.each do |failure| TopotestFailure.create(ci_job: @job, test_suite: failure['suite'],