Skip to content

Commit

Permalink
Merge pull request #72 from FRRouting/master
Browse files Browse the repository at this point in the history
Release 2.3.2
  • Loading branch information
RodrigoMNardi authored Jun 15, 2024
2 parents 8cf6662 + 4de789d commit da9cc12
Show file tree
Hide file tree
Showing 8 changed files with 68 additions and 13 deletions.
6 changes: 6 additions & 0 deletions app/github_app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ def sinatra_logger_level
attr_writer :sinatra_logger_level
end

get '/telemetry' do
content_type :json

Telemetry.instance.stats
end

get '/ping' do
halt 200, 'Pong'
end
Expand Down
18 changes: 14 additions & 4 deletions config/puma.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

# SPDX-License-Identifier: BSD-2-Clause
#
# puma.rb
Expand All @@ -8,16 +6,28 @@
# Copyright (c) 2023 by
# Network Device Education Foundation, Inc. ("NetDEF")
#
# frozen_string_literal: true

require_relative '../config/setup'
require 'puma'

workers 10

threads_count = (ENV['RAILS_MAX_THREADS'] || 5).to_i
threads 1, threads_count
threads 1, (ENV['RAILS_MAX_THREADS'] || 5).to_i

port GitHubApp::Configuration.instance.config['port'] || 4667

activate_control_app

preload_app!

pidfile 'puma.pid'

before_fork do
Thread.new do
loop do
Telemetry.instance.update_stats Puma.stats
sleep 30
end
end
end
6 changes: 5 additions & 1 deletion lib/github/build/retry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def enqueued_stages

def enqueued_failure_tests
@check_suite.ci_jobs.where.not(status: :success).each do |ci_job|
next unless ci_job.stage.configuration.can_retry?
next if must_skip_retry?(ci_job)

logger(Logger::WARN, "Enqueue CiJob: #{ci_job.inspect}")
ci_job.enqueue(@github)
Expand All @@ -57,6 +57,10 @@ def enqueued_failure_tests

private

def must_skip_retry?(ci_job)
ci_job.stage.nil? || !ci_job.stage.configuration.can_retry?
end

def logger(severity, message)
@loggers.each do |logger_object|
logger_object.add(severity, message)
Expand Down
14 changes: 10 additions & 4 deletions lib/github/check.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def create(name)
@check_suite.pull_request.repository,
name,
@check_suite.commit_sha_ref,
accept: 'application/vnd.github+json'
accept: 'application/vnd.github.antiope-preview+json'
)
end

Expand Down Expand Up @@ -92,14 +92,20 @@ def skipped(check_ref, output = {})
end

def get_check_run(check_ref)
@app.check_run(@check_suite.pull_request.repository, check_ref).to_h
@app.check_run(@check_suite.pull_request.repository,
check_ref,
accept: 'application/vnd.github.antiope-preview+json').to_h
end

def fetch_check_runs
return [] if @check_suite.nil?

@app
.check_runs_for_ref(@check_suite.pull_request.repository, @check_suite.pull_request.branch_name)
.check_runs_for_ref(
@check_suite.pull_request.repository,
@check_suite.pull_request.branch_name,
accept: 'application/vnd.github.antiope-preview+json'
)
.to_h[:check_runs]
.map do |check_run|
check_run[:id]
Expand Down Expand Up @@ -129,7 +135,7 @@ def fetch_username(username)
def basic_status(check_ref, status, output)
opts = {
status: status,
accept: 'application/vnd.github+json'
accept: 'application/vnd.github.antiope-preview+json'
}

opts[:output] = output unless output.empty?
Expand Down
1 change: 1 addition & 0 deletions lib/github_ci_app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
require_relative 'helpers/github_logger'
require_relative 'helpers/request'
require_relative 'helpers/sinatra_payload'
require_relative 'helpers/telemetry'

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

require 'singleton'
require 'json'

class Telemetry
include Singleton

# :nocov:
def update_stats(stats)
File.write('telemetry.json', stats.to_json)
end

def stats
JSON.parse(File.read('telemetry.json'))
end
# :nocov:
end
2 changes: 2 additions & 0 deletions reports/re_run_report.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ def create_csv(filename)

def raw_output(result, file_descriptor: nil)
result.each_pair do |pull_request, info|
next if info[:total] <= OFFENDER_LIMIT

print("\nPull Request: ##{pull_request} - Reruns: #{info[:total]}", file_descriptor)

info[:check_suites].each do |cs|
Expand Down
8 changes: 4 additions & 4 deletions spec/lib/github/check_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
before do
allow(fake_client).to receive(:create_check_run)
.with(check_suite.pull_request.repository, name,
check_suite.commit_sha_ref, accept: 'application/vnd.github+json')
check_suite.commit_sha_ref, accept: 'application/vnd.github.antiope-preview+json')
.and_return(pr_info)
end

Expand All @@ -110,7 +110,7 @@
id,
{
status: status,
accept: 'application/vnd.github+json'
accept: 'application/vnd.github.antiope-preview+json'
})
.and_return(pr_info)
end
Expand All @@ -133,7 +133,7 @@
{
status: status,
output: output,
accept: 'application/vnd.github+json'
accept: 'application/vnd.github.antiope-preview+json'
})
.and_return(pr_info)
end
Expand Down Expand Up @@ -199,7 +199,7 @@
{
status: status,
conclusion: conclusion,
accept: 'application/vnd.github+json'
accept: 'application/vnd.github.antiope-preview+json'
})
.and_return(true)
end
Expand Down

0 comments on commit da9cc12

Please sign in to comment.