Merge remote-tracking branch 'parent/main' into upstream-20240517

This commit is contained in:
KMY 2024-05-17 08:53:59 +09:00
commit 094ff9d2ee
153 changed files with 1412 additions and 631 deletions

View file

@ -38,42 +38,25 @@ Warden::Manager.before_logout do |_, warden|
end
module Devise
mattr_accessor :pam_authentication
@@pam_authentication = false
mattr_accessor :pam_controlled_service
@@pam_controlled_service = nil
mattr_accessor :pam_authentication, default: false
mattr_accessor :pam_controlled_service, default: nil
mattr_accessor :check_at_sign
@@check_at_sign = false
mattr_accessor :check_at_sign, default: false
mattr_accessor :ldap_authentication
@@ldap_authentication = false
mattr_accessor :ldap_host
@@ldap_host = nil
mattr_accessor :ldap_port
@@ldap_port = nil
mattr_accessor :ldap_method
@@ldap_method = nil
mattr_accessor :ldap_base
@@ldap_base = nil
mattr_accessor :ldap_uid
@@ldap_uid = nil
mattr_accessor :ldap_mail
@@ldap_mail = nil
mattr_accessor :ldap_bind_dn
@@ldap_bind_dn = nil
mattr_accessor :ldap_password
@@ldap_password = nil
mattr_accessor :ldap_tls_no_verify
@@ldap_tls_no_verify = false
mattr_accessor :ldap_search_filter
@@ldap_search_filter = nil
mattr_accessor :ldap_uid_conversion_enabled
@@ldap_uid_conversion_enabled = false
mattr_accessor :ldap_uid_conversion_search
@@ldap_uid_conversion_search = nil
mattr_accessor :ldap_uid_conversion_replace
@@ldap_uid_conversion_replace = nil
mattr_accessor :ldap_authentication, default: false
mattr_accessor :ldap_host, default: nil
mattr_accessor :ldap_port, default: nil
mattr_accessor :ldap_method, default: nil
mattr_accessor :ldap_base, default: nil
mattr_accessor :ldap_uid, default: nil
mattr_accessor :ldap_mail, default: nil
mattr_accessor :ldap_bind_dn, default: nil
mattr_accessor :ldap_password, default: nil
mattr_accessor :ldap_tls_no_verify, default: false
mattr_accessor :ldap_search_filter, default: nil
mattr_accessor :ldap_uid_conversion_enabled, default: false
mattr_accessor :ldap_uid_conversion_search, default: nil
mattr_accessor :ldap_uid_conversion_replace, default: nil
module Strategies
class PamAuthenticatable
@ -96,9 +79,7 @@ module Devise
return pass
end
if validate(resource)
success!(resource)
end
success!(resource) if validate(resource)
end
private

View file

@ -0,0 +1,13 @@
# frozen_string_literal: true
# Automatically enable YJIT as of Ruby 3.3, as it brings very
# sizeable performance improvements.
# If you are deploying to a memory constrained environment
# you may want to delete this file, but otherwise it's free
# performance.
if defined?(RubyVM::YJIT.enable)
Rails.application.config.after_initialize do
RubyVM::YJIT.enable
end
end

View file

@ -0,0 +1,65 @@
# frozen_string_literal: true
# Set OTEL_* environment variables according to OTel docs:
# https://opentelemetry.io/docs/concepts/sdk-configuration/
if ENV.keys.any? { |name| name.match?(/OTEL_.*_ENDPOINT/) }
require 'opentelemetry/sdk'
require 'opentelemetry/exporter/otlp'
require 'opentelemetry/instrumentation/active_job'
require 'opentelemetry/instrumentation/active_model_serializers'
require 'opentelemetry/instrumentation/concurrent_ruby'
require 'opentelemetry/instrumentation/excon'
require 'opentelemetry/instrumentation/faraday'
require 'opentelemetry/instrumentation/http'
require 'opentelemetry/instrumentation/http_client'
require 'opentelemetry/instrumentation/net/http'
require 'opentelemetry/instrumentation/pg'
require 'opentelemetry/instrumentation/rack'
require 'opentelemetry/instrumentation/rails'
require 'opentelemetry/instrumentation/redis'
require 'opentelemetry/instrumentation/sidekiq'
OpenTelemetry::SDK.configure do |c|
# use_all() attempts to load ALL the auto-instrumentations
# currently loaded by Ruby requires.
#
# Load attempts will emit an INFO or WARN to the console
# about the success/failure to wire up an auto-instrumentation.
# "WARN -- : Instrumentation: <X> failed to install" is most
# likely caused by <X> not being a Ruby library loaded by
# the application or the instrumentation has been explicitly
# disabled.
#
# To disable an instrumentation, set an environment variable
# along this pattern:
#
# OTEL_RUBY_INSTRUMENTATION_<X>_ENABLED=false
#
# For example, PostgreSQL and Redis produce a lot of child spans
# in the course of this application doing its business. To turn
# them off, set the env vars below, but recognize that you will
# be missing details about what particular calls to the
# datastores are slow.
#
# OTEL_RUBY_INSTRUMENTATION_PG_ENABLED=false
# OTEL_RUBY_INSTRUMENTATION_REDIS_ENABLED=false
c.use_all({
'OpenTelemetry::Instrumentation::Rack' => {
use_rack_events: false, # instead of events, use middleware; allows for untraced_endpoints to ignore child spans
untraced_endpoints: ['/health'],
},
})
prefix = ENV.fetch('OTEL_SERVICE_NAME_PREFIX', 'mastodon')
c.service_name = case $PROGRAM_NAME
when /puma/ then "#{prefix}/web"
else
"#{prefix}/#{$PROGRAM_NAME.split('/').last}"
end
c.service_version = Mastodon::Version.to_s
end
end

View file

@ -0,0 +1,19 @@
# frozen_string_literal: true
# TODO: https://github.com/simplecov-ruby/simplecov/pull/1084
# Patches this missing condition, monitor for upstream fix
module SimpleCov
module SourceFileExtensions
def build_branches
coverage_branch_data = coverage_data.fetch('branches', {}) || {} # Add the final empty hash in case where 'branches' is present, but returns nil
branches = coverage_branch_data.flat_map do |condition, coverage_branches|
build_branches_from(condition, coverage_branches)
end
process_skipped_branches(branches)
end
end
end
SimpleCov::SourceFile.prepend(SimpleCov::SourceFileExtensions) if defined?(SimpleCov::SourceFile)