Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ruby 3 support #1

Closed
wants to merge 28 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
dfe70e8
Refs #36846 - change descriptionFormat to snake case (#10846)
jeremylenz Jan 17, 2024
3ac7cdd
Refs #35713 - correctly call methods with kwargs (#10845)
jeremylenz Jan 17, 2024
57ab3c9
Fixes #37028 - Set up sp-reference for content source
adamruzicka Jan 4, 2024
e2cb74f
Fixes #36994 - remove spaces from Ansible template (#10849)
jeremylenz Jan 18, 2024
8591b4c
Fixes #35974 - Extra index to check for installed package id (#10842)
parthaa Jan 18, 2024
8b17663
Fixes #37005 - Allow to set the the default name of template change c…
Et7f3 Jan 19, 2024
ced0ed0
Fixes #36946 - cache if tracer/host_tools is installed (#10811)
sbernhard Jan 22, 2024
acbe320
Fixes #37080 - content counts index goes over max size
ianballou Jan 22, 2024
799b4c0
Fixes #37058 - Optimize query to identify orphaned content units
jpasqualetto Jan 17, 2024
f281fc5
use NodeJS 14 and Ruby 2.7 in React tests
evgeni Jan 22, 2024
4f236c7
Fixes #37051 - Add job templates for Ansible 'by search query' (#10850)
jeremylenz Jan 23, 2024
7e7d6d3
Refs #36846 - use descriptionFormat for updatePackages (#10858)
jeremylenz Jan 23, 2024
9915be7
Fixes #37074 - drop users.disabled field
evgeni Jan 2, 2024
2e084c9
Fixes #36998 - declare development dependency on theforeman-rubocop
evgeni Nov 28, 2023
7f99691
Refs #36998 - Fix Rails/Pick and Rails/IndexWith cops
evgeni Jan 23, 2024
98c9fee
Refs #36998 - disable Rails/ContentTag cop
evgeni Jan 23, 2024
98a9b4d
Fixes #37075 - make RemoveKatelloFromNotificationName a noop
evgeni Jan 2, 2024
3773276
Fixes #37073 - only rename Katello settings if category column exists
evgeni Jan 2, 2024
edd5341
Fixes #37050 - restrict module copying to source repository
ianballou Jan 12, 2024
2ab734f
Fixes #37084 - Drop simplecov dependency (#10837)
ekohl Jan 24, 2024
477009b
Fixes #37032 - Drop minitest-tags development dependency
ekohl Jan 5, 2024
6af370d
Fixes #37094 - Drop uglifier development dependency
evgeni Jan 24, 2024
08dbe77
Fixes #37083 - Remove unused pulp_export_destination setting
ekohl Jun 15, 2023
cc1b7cc
Fixes #37100 - Update VCR to 6.1+
evgeni Jan 25, 2024
e3bf6db
Fixes #37095 - Use shared GitHub workflow to run tests
evgeni Oct 27, 2023
d4c9455
Refs #37095 - move test dependencies into an own group
evgeni Nov 28, 2023
aef65aa
Run CI on Ruby 3
ofedoren Jan 25, 2024
c090281
Ruby 3 support
ofedoren Jan 18, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/react_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ jobs:
- name: Use Node.js
uses: actions/setup-node@v1
with:
node-version: '12.x'
node-version: '14'
# We could update the postinstall action for foreman to look for an environment variable for plugin webpack dirs
# before kicking off the ruby script to find them, this would eliminate the ruby dep and running `npm i` in Katello.
- uses: ruby/setup-ruby@v1
with:
ruby-version: 2.6
ruby-version: '2.7'
- name: Checkout Foreman repo
uses: actions/checkout@v2
with:
Expand Down
28 changes: 28 additions & 0 deletions .github/workflows/ruby.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
name: CI

on:
pull_request:
push:
branches:
- 'master'
- 'KATELLO-*'

concurrency:
group: ${{ github.ref_name }}-${{ github.workflow }}
cancel-in-progress: true

jobs:
rubocop:
name: Rubocop
uses: theforeman/actions/.github/workflows/rubocop.yml@v0

test:
name: Ruby
uses: theforeman/actions/.github/workflows/foreman_plugin.yml@v0
with:
plugin: katello
postgresql_container: ghcr.io/theforeman/postgresql-evr
test_existing_database: false
foreman_repository: ofedoren/foreman
foreman_version: foreman-on-ruby-3-letsgooo
4 changes: 4 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ inherit_from:
Rails:
Enabled: true

Rails/ContentTag:
Enabled: false

AllCops:
Exclude:
- db/migrate/20131014135042_katello_tables.rb
Expand All @@ -23,6 +26,7 @@ AllCops:
- Gemfile
- locale/action_names.rb
- lib/monkeys/remove_hidden_distribution.rb
- vendor/**/*
Include:
- '**/*.rb'
- app/views/**/*.rabl
Expand Down
4 changes: 4 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
source 'https://rubygems.org'

gemspec

Dir[File.join(__dir__, 'gemfile.d', '*.rb')].each do |bundle|
eval_gemfile(bundle)
end
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def change_content_source_data
.distinct

if Katello.with_remote_execution?
template_id = JobTemplate.find_by(name: 'Configure host for new content source')&.id
template_id = RemoteExecutionFeature.feature!(:katello_change_content_source).job_template_id
job_invocation_path = new_job_invocation_path(template_id: template_id, host_ids: content_hosts.map { |h| h[:id] }) if template_id
end

Expand Down
2 changes: 1 addition & 1 deletion app/lib/actions/katello/capsule_content/sync.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def plan(smart_proxy, options = {})
if smart_proxy.has_feature?(SmartProxy::PULP3_FEATURE)
plan_action(Actions::Pulp3::ContentGuard::Refresh, smart_proxy)
end
plan_action(SyncCapsule, smart_proxy, refresh_options)
plan_action(SyncCapsule, smart_proxy, **refresh_options)
end
plan_self(smart_proxy_id: smart_proxy.id)
end
Expand Down
2 changes: 1 addition & 1 deletion app/lib/actions/katello/capsule_content/sync_capsule.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def plan(smart_proxy, options = {})
options[:repository_ids_list] = repos.pluck(:id)
end
if smart_proxy.has_feature?(SmartProxy::PULP3_FEATURE)
plan_action(Actions::Pulp3::Orchestration::Repository::RefreshRepos, smart_proxy, options)
plan_action(Actions::Pulp3::Orchestration::Repository::RefreshRepos, smart_proxy, **options)
end

repos.in_groups_of(Setting[:foreman_proxy_content_batch_size], false) do |repo_batch|
Expand Down
4 changes: 2 additions & 2 deletions app/lib/actions/katello/content_view/publish.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Publish < Actions::EntryAction
def plan(content_view, description = "", options = {importing: false, syncable: false}) # rubocop:disable Metrics/PerceivedComplexity
action_subject(content_view)

content_view.check_ready_to_publish!(options.slice(:importing, :syncable))
content_view.check_ready_to_publish!(**options.slice(:importing, :syncable))
unless options[:importing] || options[:syncable]
::Katello::Util::CandlepinRepositoryChecker.check_repositories_for_publish!(content_view)
end
Expand Down Expand Up @@ -57,7 +57,7 @@ def plan(content_view, description = "", options = {importing: false, syncable:
separated_repo_map = separated_repo_mapping(repository_mapping, content_view.solve_dependencies)

if options[:importing]
handle_import(version, options.slice(:path, :metadata))
handle_import(version, **options.slice(:path, :metadata))
elsif separated_repo_map[:pulp3_yum_multicopy].keys.flatten.present?
plan_action(Repository::MultiCloneToVersion, separated_repo_map[:pulp3_yum_multicopy], version)
end
Expand Down
2 changes: 1 addition & 1 deletion app/lib/actions/katello/content_view/remove.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def plan(content_view, options)
concurrence do
all_cv_envs.each do |cv_env|
if cv_env.hosts.any? || cv_env.activation_keys.any?
plan_action(ContentViewEnvironment::ReassignObjects, cv_env, options)
plan_action(ContentViewEnvironment::ReassignObjects, cv_env, **options)
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/lib/actions/katello/content_view_version/destroy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def plan(version, options = {})
repos.each do |repo|
repo_options = options.clone
repo_options[:docker_cleanup] = false
plan_action(Repository::Destroy, repo, repo_options)
plan_action(Repository::Destroy, repo, **repo_options)
docker_cleanup ||= repo.docker?
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/lib/actions/katello/content_view_version/export.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def plan(options)
action_subject(options.fetch(:content_view_version))

sequence do
export_output = plan_action(::Actions::Pulp3::Orchestration::ContentViewVersion::Export, options).output
export_output = plan_action(::Actions::Pulp3::Orchestration::ContentViewVersion::Export, **options).output

plan_self(export_history_id: export_output[:export_history_id],
exported_file_checksum: export_output[:exported_file_checksum],
Expand Down
2 changes: 1 addition & 1 deletion app/lib/actions/katello/product/destroy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def plan_content_destruction(product, skip_environment_update)
def plan_repo_destruction(product, options)
product.repositories.in_default_view.each do |repo|
repo_options = options.clone
plan_action(Katello::Repository::Destroy, repo, repo_options.merge(destroy_content: false))
plan_action(Katello::Repository::Destroy, repo, **repo_options.merge(destroy_content: false))
end
end

Expand Down
6 changes: 3 additions & 3 deletions app/lib/actions/katello/repository/bulk_metadata_generate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ module Repository
class BulkMetadataGenerate < Actions::Base
def plan(repos, options = {})
sequence do
plan_action(::Actions::BulkAction, ::Actions::Katello::Repository::MetadataGenerate, repos.in_default_view, options) if repos.in_default_view.any?
plan_action(::Actions::BulkAction, ::Actions::Katello::Repository::MetadataGenerate, repos.archived, options) if repos.archived.any?
plan_action(::Actions::BulkAction, ::Actions::Katello::Repository::MetadataGenerate, repos.in_published_environments, options) if repos.in_published_environments.any?
plan_action(::Actions::BulkAction, ::Actions::Katello::Repository::MetadataGenerate, repos.in_default_view, **options) if repos.in_default_view.any?
plan_action(::Actions::BulkAction, ::Actions::Katello::Repository::MetadataGenerate, repos.archived, **options) if repos.archived.any?
plan_action(::Actions::BulkAction, ::Actions::Katello::Repository::MetadataGenerate, repos.in_published_environments, **options) if repos.in_published_environments.any?
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions app/lib/actions/katello/repository/clone_contents.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def plan(source_repositories, new_repository, options)

index_options = {id: new_repository.id, force_index: true}
index_options[:source_repository_id] = source_repositories.first.id if source_repositories.count == 1 && filters.empty? && rpm_filenames.nil?
plan_action(Katello::Repository::IndexContent, index_options)
plan_action(Katello::Repository::IndexContent, **index_options)
end
end

Expand All @@ -38,7 +38,7 @@ def metadata_generate(source_repositories, new_repository, filters, rpm_filename
metadata_options[:source_repository] = source_repositories.first
end

plan_action(Katello::Repository::MetadataGenerate, new_repository, metadata_options)
plan_action(Katello::Repository::MetadataGenerate, new_repository, **metadata_options)
unless source_repositories.first.saved_checksum_type == new_repository.saved_checksum_type
plan_self(:source_checksum_type => source_repositories.first.saved_checksum_type,
:target_repo_id => new_repository.id)
Expand Down
2 changes: 1 addition & 1 deletion app/lib/actions/katello/repository/import_upload.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def plan(repository, uploads, options = {})
action_class = ::Actions::Pulp3::Orchestration::Repository::ImportUpload
end

import_upload = plan_action(action_class, repository, SmartProxy.pulp_primary, import_upload_args)
import_upload = plan_action(action_class, repository, SmartProxy.pulp_primary, **import_upload_args)
plan_action(FinishUpload, repository, :import_upload_task => import_upload.output,
generate_metadata: false, content_type: options[:content_type])
import_upload.output
Expand Down
2 changes: 1 addition & 1 deletion app/lib/actions/katello/repository/multi_clone_contents.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def metadata_generate(source_repositories, new_repository, filters, matching_con
metadata_options[:source_repository] = source_repositories.first
end

plan_action(Katello::Repository::MetadataGenerate, new_repository, metadata_options)
plan_action(Katello::Repository::MetadataGenerate, new_repository, **metadata_options)
unless source_repositories.first.saved_checksum_type == new_repository.saved_checksum_type
plan_self(:source_checksum_type => source_repositories.first.saved_checksum_type,
:target_repo_id => new_repository.id)
Expand Down
2 changes: 1 addition & 1 deletion app/lib/actions/katello/repository/remove_content.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def plan(repository, content_units, options = {})
repository.clear_smart_proxy_sync_histories
pulp_action = plan_action(
Pulp3::Orchestration::Repository::RemoveUnits,
repository, SmartProxy.pulp_primary, remove_content_args)
repository, SmartProxy.pulp_primary, **remove_content_args)
return if pulp_action.error
plan_self(:content_unit_class => content_units.first.class.name, :content_unit_ids => content_unit_ids)
plan_action(CapsuleSync, repository) if sync_capsule
Expand Down
2 changes: 1 addition & 1 deletion app/lib/actions/katello/repository/sync.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def plan(repo, options = {})
sync_action = plan_action(Actions::Pulp3::Orchestration::Repository::Sync,
repo,
SmartProxy.pulp_primary,
pulp_sync_options)
**pulp_sync_options)
output = sync_action.output

plan_action(Katello::Repository::IndexContent, :id => repo.id, :force_index => skip_metadata_check)
Expand Down
11 changes: 6 additions & 5 deletions app/lib/actions/middleware/backend_services_check.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module Actions
module Middleware
class BackendServicesCheck < Dynflow::Middleware
def plan(*args)
def plan(*args, **kwargs)
if Setting[:check_services_before_actions]
#To prevent the ping from happening multiple times, keep track on the initial entry action
#If capsule_id is passed as in args from an action, Katello::Ping checks the pulp server on the capsule
Expand All @@ -10,7 +10,7 @@ def plan(*args)
to_check = services - parent.input[:services_checked]

if to_check.any?
result = User.as_anonymous_admin { ::Katello::Ping.ping(services: to_check, capsule_id: capsule_id(args))[:services] }
result = User.as_anonymous_admin { ::Katello::Ping.ping(services: to_check, capsule_id: capsule_id(args, kwargs))[:services] }

to_check.each do |service|
if result[service][:status] != ::Katello::Ping::OK_RETURN_CODE
Expand All @@ -20,13 +20,14 @@ def plan(*args)
parent.input[:services_checked].concat(to_check)
end
end
pass(*args)
pass(*args, **kwargs)
end

protected

def capsule_id(args)
capsule_id = nil
def capsule_id(args, kwargs)
capsule_id = kwargs[:capsule_id] || kwargs[:smart_proxy_id]
return capsule_id if capsule_id
args.each do |arg|
if arg.is_a? SmartProxy
capsule_id = arg.id
Expand Down
4 changes: 2 additions & 2 deletions app/lib/actions/middleware/remote_action.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ module Middleware
# wraps the plan/run/finalize methods to include the info about the user
# that triggered the action.
class RemoteAction < Dynflow::Middleware
def plan(*args)
def plan(*args, **kwargs)
fail "No current user is set. Please set User.current to perform a remote action" if User.current.nil?
pass(*args).tap do
pass(*args, **kwargs).tap do
action.input[:remote_user] = User.remote_user
action.input[:remote_cp_user] = User.remote_user
end
Expand Down
2 changes: 1 addition & 1 deletion app/lib/actions/pulp3/capsule_content/sync.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def plan(repository, smart_proxy, options = {})
sequence do
sync_task = plan_self(:repository_id => repository.id, :smart_proxy_id => smart_proxy.id, :options => options)
options[:sync_task_output] = sync_task.output[:pulp_tasks]
plan_action(GenerateMetadata, repository, smart_proxy, options)
plan_action(GenerateMetadata, repository, smart_proxy, **options)
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class Delete < Pulp3::Abstract
def plan(smart_proxy_acs, options = {})
sequence do
plan_action(Actions::Pulp3::AlternateContentSource::Delete, smart_proxy_acs)
plan_action(Actions::Pulp3::AlternateContentSource::DeleteRemote, smart_proxy_acs, options)
plan_action(Actions::Pulp3::AlternateContentSource::DeleteRemote, smart_proxy_acs, **options)
plan_self(smart_proxy_id: smart_proxy_acs.smart_proxy_id, smart_proxy_acs_id: smart_proxy_acs.id)
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def plan(repository, smart_proxy, options = {})
if options[:source_repository] && publication_content_type
plan_self(source_repository_id: options[:source_repository].id, target_repository_id: repository.id, smart_proxy_id: smart_proxy.id)
elsif publication_content_type && (force_publication || repository.publication_href.nil? || !repository.using_mirrored_metadata?)
plan_action(Actions::Pulp3::Repository::CreatePublication, repository, smart_proxy, options)
plan_action(Actions::Pulp3::Repository::CreatePublication, repository, smart_proxy, **options)
elsif !publication_content_type
plan_self(target_repository_id: repository.id, contents_changed: options[:contents_changed], skip_publication: true)
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def plan(repository, smart_proxy, args)
smart_proxy,
args).output
plan_self(:commit_output => tag_manifest_output[:pulp_tasks])
plan_action(Pulp3::Repository::SaveVersion, repository, {force_fetch_version: true, tasks: tag_manifest_output[:pulp_tasks]})
plan_action(Pulp3::Repository::SaveVersion, repository, force_fetch_version: true, tasks: tag_manifest_output[:pulp_tasks])
else
if content_unit_href
artifact_output = { :content_unit_href => content_unit_href }
Expand All @@ -33,7 +33,7 @@ def plan(repository, smart_proxy, args)
repository,
smart_proxy,
commit_output[:pulp_tasks],
args.dig(:unit_type_id), args).output
args.dig(:unit_type_id), **args).output
end

plan_self(:commit_output => commit_output[:pulp_tasks], :artifact_output => artifact_output)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class RemoveUnits < Pulp3::Abstract

def plan(repository, smart_proxy, options)
sequence do
action_output = plan_action(Actions::Pulp3::Repository::RemoveUnits, repository, smart_proxy, options).output
action_output = plan_action(Actions::Pulp3::Repository::RemoveUnits, repository, smart_proxy, **options).output
plan_action(Pulp3::Repository::SaveVersion, repository, tasks: action_output[:pulp_tasks])
end
end
Expand Down
4 changes: 2 additions & 2 deletions app/lib/actions/pulp3/orchestration/repository/sync.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ module Orchestration
module Repository
class Sync < Pulp3::Abstract
include Actions::Helpers::OutputPropagator
def plan(repository, smart_proxy, options)
def plan(repository, smart_proxy, **options)
sequence do
plan_action(Actions::Pulp3::Repository::RefreshRemote, repository, smart_proxy)
action_output = plan_action(Actions::Pulp3::Repository::Sync, repository, smart_proxy, options).output
action_output = plan_action(Actions::Pulp3::Repository::Sync, repository, smart_proxy, **options).output

force_fetch_version = true if options[:optimize] == false
version_output = plan_action(Pulp3::Repository::SaveVersion, repository, tasks: action_output[:pulp_tasks], :force_fetch_version => force_fetch_version).output
Expand Down
12 changes: 6 additions & 6 deletions app/lib/katello/lazy_accessor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,21 +56,21 @@ def changed_remote_attributes=(val)
@changed_remote_attributes = val
end

def save(*)
if (status = super)
def save(...)
if (status = super(...))
changed_remote_attributes.clear
end
status
end

def save!(*)
super.tap do
def save!(...)
super(...).tap do
changed_remote_attributes.clear
end
end

def reload(*)
super.tap do
def reload(...)
super(...).tap do
changed_remote_attributes.clear
end
end
Expand Down
6 changes: 3 additions & 3 deletions app/mailers/katello/errata_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ def promote_errata(options)

def errata_counts(errata)
counts = {:total => errata.count}
counts.merge(Hash[[:security, :bugfix, :enhancement].collect do |errata_type|
[errata_type, errata.send(errata_type).count]
end])
counts.merge([:security, :bugfix, :enhancement].index_with do |errata_type|
errata.send(errata_type).count
end)
end
end
end
6 changes: 4 additions & 2 deletions app/models/katello/concerns/host_managed_extensions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,8 @@ def remote_execution_proxies(provider, *_rest)

scoped_search relation: :pools, on: :pools_expiring_in_days, ext_method: :find_with_expiring_pools, only_explicit: true

smart_proxy_reference :content_facet => [:content_source_id]

def add_back_cve_errors
if @pending_cve_attrs&.[](:content_view_id).present? || @pending_cve_attrs&.[](:lifecycle_environment_id).present?
check_cve_attributes({ content_facet_attributes: @pending_cve_attrs })
Expand Down Expand Up @@ -542,9 +544,9 @@ def rhel_eos_schedule_index

def package_names_for_job_template(action:, search:, versions: nil)
if self.operatingsystem.family == 'Debian'
deb_names_for_job_template(action, search)
deb_names_for_job_template(action: action, search: search)
else
yum_names_for_job_template(action, search, versions)
yum_names_for_job_template(action: action, search: search, versions: versions)
end
end

Expand Down
Loading
Loading