-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #60 from RodrigoMNardi/feature/github/cancelled_info
Detailed execution info
- Loading branch information
Showing
17 changed files
with
330 additions
and
25 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
db/migrate/20240408141736_add_check_suite_cancelled_ref.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# SPDX-License-Identifier: BSD-2-Clause | ||
# | ||
# 20240408141736_add_check_suite_cancelled_ref.rb | ||
# Part of NetDEF CI System | ||
# | ||
# Copyright (c) 2024 by | ||
# Network Device Education Foundation, Inc. ("NetDEF") | ||
# | ||
# frozen_string_literal: true | ||
|
||
class AddCheckSuiteCancelledRef < ActiveRecord::Migration[6.0] | ||
def change | ||
add_column :check_suites, :cancelled_by_id, :bigint | ||
add_index :check_suites, :cancelled_by_id | ||
add_foreign_key :check_suites, :stages, column: :cancelled_by_id | ||
end | ||
end |
15 changes: 15 additions & 0 deletions
15
db/migrate/20240408164410_add_check_suite_cancelled_in_stage.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# SPDX-License-Identifier: BSD-2-Clause | ||
# | ||
# 20240408152636_add_check_suite_cancelled_in_stage.rb | ||
# Part of NetDEF CI System | ||
# | ||
# Copyright (c) 2024 by | ||
# Network Device Education Foundation, Inc. ("NetDEF") | ||
# | ||
# frozen_string_literal: true | ||
|
||
class AddCheckSuiteCancelledInStage < ActiveRecord::Migration[6.0] | ||
def change | ||
add_reference :stages, :cancelled_at_stage, foreign_key: { to_table: :check_suites } | ||
end | ||
end |
17 changes: 17 additions & 0 deletions
17
db/migrate/20240417094603_change_check_suite_cancelled_by_id.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# SPDX-License-Identifier: BSD-2-Clause | ||
# | ||
# 20240417094603_change_check_suite_cancelled_by_id.rb | ||
# Part of NetDEF CI System | ||
# | ||
# Copyright (c) 2024 by | ||
# Network Device Education Foundation, Inc. ("NetDEF") | ||
# | ||
# frozen_string_literal: true | ||
|
||
class ChangeCheckSuiteCancelledById < ActiveRecord::Migration[6.0] | ||
def change | ||
change_table :check_suites do |t| | ||
t.references :cancelled_previous_check_suite, foreign_key: { to_table: :check_suites } | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# SPDX-License-Identifier: BSD-2-Clause | ||
# | ||
# 20240417102854_remove_check_suite_columns.rb | ||
# Part of NetDEF CI System | ||
# | ||
# Copyright (c) 2024 by | ||
# Network Device Education Foundation, Inc. ("NetDEF") | ||
# | ||
# frozen_string_literal: true | ||
|
||
class RemoveCheckSuiteColumns < ActiveRecord::Migration[6.0] | ||
def change | ||
if ActiveRecord::Base.connection.column_exists?(:check_suites, :cancelled_by_id) | ||
remove_column :check_suites, :cancelled_by_id | ||
end | ||
|
||
remove_column :check_suites, :id_id if ActiveRecord::Base.connection.column_exists?(:check_suites, :id_id) | ||
end | ||
end |
30 changes: 30 additions & 0 deletions
30
db/migrate/20240417130601_change_check_suite_stopped_in_stage.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# SPDX-License-Identifier: BSD-2-Clause | ||
# | ||
# 202404130601_change_check_suite_stopped_in_stage.rb | ||
# Part of NetDEF CI System | ||
# | ||
# Copyright (c) 2024 by | ||
# Network Device Education Foundation, Inc. ("NetDEF") | ||
# | ||
# frozen_string_literal: true | ||
|
||
class ChangeCheckSuiteStoppedInStage < ActiveRecord::Migration[6.0] | ||
def change | ||
if ActiveRecord::Base.connection.column_exists?(:stages, :cancelled_at_stage_id) | ||
remove_column :stages, :cancelled_at_stage_id | ||
end | ||
|
||
if ActiveRecord::Base.connection.column_exists?(:check_suites, :cancelled_in_stage_id) | ||
remove_column :check_suites, :cancelled_in_stage_id | ||
end | ||
|
||
if ActiveRecord::Base.connection.column_exists?(:check_suites, :cancelled_previous_check_suite_id) | ||
remove_column :check_suites, :cancelled_previous_check_suite_id | ||
end | ||
|
||
change_table :check_suites do |t| | ||
t.references :stopped_in_stage, foreign_key: { to_table: :stages } | ||
t.references :cancelled_previous_check_suite, foreign_key: { to_table: :check_suites } | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# SPDX-License-Identifier: BSD-2-Clause | ||
# | ||
# build_stage_failed.rb | ||
# Part of NetDEF CI System | ||
# | ||
# Copyright (c) 2024 by | ||
# Network Device Education Foundation, Inc. ("NetDEF") | ||
# | ||
# frozen_string_literal: true | ||
|
||
require_relative '../database_loader' | ||
require_relative '../lib/helpers/configuration' | ||
|
||
begin_date = ARGV[0] | ||
end_date = ARGV[1] | ||
author = ARGV[2] | ||
|
||
check_suites = [] | ||
|
||
Stage | ||
.joins(:jobs, :check_suite) | ||
.where(stages: { name: 'Build' }) | ||
.where(jobs: { created_at: [begin_date..end_date], status: %i[failure skipped] }) | ||
.where(check_suites: { author: author }) | ||
.each do |stage| | ||
message = "Check Suite ID: https://ci1.netdef.org/browse/#{stage.check_suite.bamboo_ci_ref}" | ||
check_suites << message unless check_suites.include? message | ||
end | ||
|
||
check_suites.each do |line| | ||
puts line | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
# SPDX-License-Identifier: BSD-2-Clause | ||
# | ||
# rerun_report.rb | ||
# Part of NetDEF CI System | ||
# | ||
# Copyright (c) 2024 by | ||
# Network Device Education Foundation, Inc. ("NetDEF") | ||
# | ||
# frozen_string_literal: true | ||
|
||
require 'json' | ||
require 'csv' | ||
require_relative '../database_loader' | ||
|
||
module Reports | ||
class ChainedRerun | ||
def report(begin_date, end_date) | ||
@result = {} | ||
@offenders = [] | ||
|
||
CheckSuite | ||
.left_joins(:audit_retries) | ||
.where.not(check_suites: { cancelled_previous_check_suite_id: nil }) | ||
.where(created_at: [begin_date..end_date]) | ||
.order(:created_at) | ||
.group_by(&:pull_request_id) | ||
.each_pair do |pull_request_id, chained_check_suites| | ||
generate_result(pull_request_id, chained_check_suites) | ||
end | ||
end | ||
|
||
private | ||
|
||
def generate_result(pull_request_id, chained_check_suites) | ||
@local_chained = {} | ||
@chain = 1 | ||
|
||
create_paths(chained_check_suites) | ||
|
||
puts "Pull Request ID: #{pull_request_id}" | ||
@local_chained.each_pair do |_c, path| | ||
puts path.reverse.join(' -> ') | ||
end | ||
end | ||
|
||
def create_paths(chained_check_suites) | ||
chained_check_suites.reverse_each do |check_suite| | ||
initialize_or_add(check_suite) | ||
|
||
if chained_check_suites.map(&:id).include?(check_suite.cancelled_previous_check_suite_id) | ||
@local_chained[@chain] << check_suite.cancelled_previous_check_suite_id | ||
else | ||
@local_chained[@chain] << CheckSuite.find(check_suite.cancelled_previous_check_suite_id).id | ||
@chain += 1 | ||
end | ||
end | ||
end | ||
|
||
def initialize_or_add(check_suite) | ||
@local_chained[@chain] ||= [] | ||
@local_chained[@chain] << check_suite.id unless @local_chained[@chain].include? check_suite.id | ||
end | ||
end | ||
end | ||
|
||
return unless __FILE__ == $PROGRAM_NAME | ||
|
||
ActiveRecord::Base.logger = Logger.new('/dev/null') | ||
|
||
begin_date = ARGV[0] | ||
end_date = ARGV[1] | ||
|
||
Reports::ChainedRerun.new.report(begin_date, end_date) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# SPDX-License-Identifier: BSD-2-Clause | ||
# | ||
# github_user_usage.rb | ||
# Part of NetDEF CI System | ||
# | ||
# Copyright (c) 2024 by | ||
# Network Device Education Foundation, Inc. ("NetDEF") | ||
# | ||
# frozen_string_literal: true | ||
|
||
require_relative '../database_loader' | ||
|
||
ActiveRecord::Base.logger = Logger.new('/dev/null') | ||
|
||
user = GithubUser.find_by_github_login(ARGV[0]) | ||
|
||
if user.pull_requests.empty? | ||
puts "No pull requests found for user: #{user.github_login}" | ||
else | ||
puts "Pull Requests for user: #{user.github_login}" | ||
user.pull_requests.each do |pr| | ||
puts "Pull Request: https://github.com/FRRouting/frr/pull/#{pr.github_pr_id}" | ||
end | ||
end | ||
|
||
if user.check_suites.empty? | ||
puts "No check suites found for user: #{user.github_login}" | ||
else | ||
puts "Check Suites for user: #{user.github_login}" | ||
user.check_suites.each do |cs| | ||
puts "Check Suite: https://ci1.netdef.org/browse/#{cs.bamboo_ci_ref}" | ||
end | ||
end | ||
|
||
if user.audit_retries.empty? | ||
puts "No audit retries found for user: #{user.github_login}" | ||
else | ||
puts "Audit Retries for user: #{user.github_login}" | ||
user.audit_retries.each do |ar| | ||
puts "Audit Retry: #{ar.retry_type} at #{ar.created_at}" | ||
end | ||
end |
Oops, something went wrong.